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

@ -3,7 +3,6 @@
package docker
import (
"encoding/json"
"fmt"
"os"
"os/exec"
@ -52,11 +51,6 @@ func GetDockerStat() ([]CgroupDockerStat, error) {
return ret, nil
}
func (c CgroupDockerStat) String() string {
s, _ := json.Marshal(c)
return string(s)
}
// GetDockerIDList returnes a list of DockerID.
// This requires certain permission.
func GetDockerIDList() ([]string, error) {
@ -220,11 +214,6 @@ func CgroupMemDocker(containerID string) (*CgroupMemStat, error) {
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.
func getCgroupFilePath(containerID, base, target, file string) string {
if len(base) == 0 {

Loading…
Cancel
Save