[docker]: move String() to docker.go for all platforms.

tags/v2.18.01
shirou 7 years ago
parent 49e4d328f8
commit 231815dfea

@ -1,6 +1,7 @@
package docker package docker
import ( import (
"encoding/json"
"errors" "errors"
"github.com/shirou/gopsutil/internal/common" "github.com/shirou/gopsutil/internal/common"
@ -50,6 +51,11 @@ type CgroupMemStat struct {
MemFailCnt uint64 `json:"memoryFailcnt"` MemFailCnt uint64 `json:"memoryFailcnt"`
} }
func (m CgroupMemStat) String() string {
s, _ := json.Marshal(m)
return string(s)
}
type CgroupDockerStat struct { type CgroupDockerStat struct {
ContainerID string `json:"containerID"` ContainerID string `json:"containerID"`
Name string `json:"name"` Name string `json:"name"`
@ -57,3 +63,8 @@ type CgroupDockerStat struct {
Status string `json:"status"` Status string `json:"status"`
Running bool `json:"running"` Running bool `json:"running"`
} }
func (c CgroupDockerStat) String() string {
s, _ := json.Marshal(c)
return string(s)
}

@ -3,7 +3,6 @@
package docker package docker
import ( import (
"encoding/json"
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
@ -52,11 +51,6 @@ func GetDockerStat() ([]CgroupDockerStat, error) {
return ret, nil return ret, nil
} }
func (c CgroupDockerStat) String() string {
s, _ := json.Marshal(c)
return string(s)
}
// GetDockerIDList returnes a list of DockerID. // GetDockerIDList returnes a list of DockerID.
// This requires certain permission. // This requires certain permission.
func GetDockerIDList() ([]string, error) { func GetDockerIDList() ([]string, error) {
@ -220,11 +214,6 @@ func CgroupMemDocker(containerID string) (*CgroupMemStat, error) {
return CgroupMem(containerID, common.HostSys("fs/cgroup/memory/docker")) return CgroupMem(containerID, common.HostSys("fs/cgroup/memory/docker"))
} }
func (m CgroupMemStat) String() string {
s, _ := json.Marshal(m)
return string(s)
}
// getCgroupFilePath constructs file path to get targetted stats file. // getCgroupFilePath constructs file path to get targetted stats file.
func getCgroupFilePath(containerID, base, target, file string) string { func getCgroupFilePath(containerID, base, target, file string) string {
if len(base) == 0 { if len(base) == 0 {

Loading…
Cancel
Save