godep update: gopsutil
This commit is contained in:
parent
63e9a4ae68
commit
b4e8a23da4
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/influxdb/telegraf",
|
"ImportPath": "github.com/influxdb/telegraf",
|
||||||
"GoVersion": "go1.5",
|
"GoVersion": "go1.5.1",
|
||||||
"Packages": [
|
"Packages": [
|
||||||
"./..."
|
"./..."
|
||||||
],
|
],
|
||||||
|
@ -177,38 +177,38 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/shirou/gopsutil/common",
|
"ImportPath": "github.com/shirou/gopsutil/common",
|
||||||
"Comment": "1.0.0-158-g0fd612e",
|
"Comment": "1.0.0-153-gc1313e7",
|
||||||
"Rev": "0fd612ec7b9079dc624ae4815acadf1903d82011"
|
"Rev": "c1313e76341b18456212c5645d1daa7f132ac50e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/shirou/gopsutil/cpu",
|
"ImportPath": "github.com/shirou/gopsutil/cpu",
|
||||||
"Comment": "1.0.0-158-g0fd612e",
|
"Comment": "1.0.0-153-gc1313e7",
|
||||||
"Rev": "0fd612ec7b9079dc624ae4815acadf1903d82011"
|
"Rev": "c1313e76341b18456212c5645d1daa7f132ac50e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/shirou/gopsutil/disk",
|
"ImportPath": "github.com/shirou/gopsutil/disk",
|
||||||
"Comment": "1.0.0-158-g0fd612e",
|
"Comment": "1.0.0-153-gc1313e7",
|
||||||
"Rev": "0fd612ec7b9079dc624ae4815acadf1903d82011"
|
"Rev": "c1313e76341b18456212c5645d1daa7f132ac50e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/shirou/gopsutil/docker",
|
"ImportPath": "github.com/shirou/gopsutil/docker",
|
||||||
"Comment": "1.0.0-158-g0fd612e",
|
"Comment": "1.0.0-153-gc1313e7",
|
||||||
"Rev": "0fd612ec7b9079dc624ae4815acadf1903d82011"
|
"Rev": "c1313e76341b18456212c5645d1daa7f132ac50e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/shirou/gopsutil/load",
|
"ImportPath": "github.com/shirou/gopsutil/load",
|
||||||
"Comment": "1.0.0-158-g0fd612e",
|
"Comment": "1.0.0-153-gc1313e7",
|
||||||
"Rev": "0fd612ec7b9079dc624ae4815acadf1903d82011"
|
"Rev": "c1313e76341b18456212c5645d1daa7f132ac50e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/shirou/gopsutil/mem",
|
"ImportPath": "github.com/shirou/gopsutil/mem",
|
||||||
"Comment": "1.0.0-158-g0fd612e",
|
"Comment": "1.0.0-153-gc1313e7",
|
||||||
"Rev": "0fd612ec7b9079dc624ae4815acadf1903d82011"
|
"Rev": "c1313e76341b18456212c5645d1daa7f132ac50e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/shirou/gopsutil/net",
|
"ImportPath": "github.com/shirou/gopsutil/net",
|
||||||
"Comment": "1.0.0-158-g0fd612e",
|
"Comment": "1.0.0-153-gc1313e7",
|
||||||
"Rev": "0fd612ec7b9079dc624ae4815acadf1903d82011"
|
"Rev": "c1313e76341b18456212c5645d1daa7f132ac50e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/streadway/amqp",
|
"ImportPath": "github.com/streadway/amqp",
|
||||||
|
|
|
@ -4,7 +4,6 @@ package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -47,13 +46,9 @@ func CgroupCPU(containerid string, base string) (*cpu.CPUTimesStat, error) {
|
||||||
if len(base) == 0 {
|
if len(base) == 0 {
|
||||||
base = "/sys/fs/cgroup/cpuacct/docker"
|
base = "/sys/fs/cgroup/cpuacct/docker"
|
||||||
}
|
}
|
||||||
statfile := path.Join(base, containerid, "cpuacct.stat")
|
path := path.Join(base, containerid, "cpuacct.stat")
|
||||||
|
|
||||||
if _, err := os.Stat(statfile); os.IsNotExist(err) {
|
lines, err := common.ReadLines(path)
|
||||||
statfile = path.Join("/sys/fs/cgroup/cpuacct/system.slice", "docker-" + containerid + ".scope", "cpuacct.stat")
|
|
||||||
}
|
|
||||||
|
|
||||||
lines, err := common.ReadLines(statfile)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -89,17 +84,12 @@ func CgroupMem(containerid string, base string) (*CgroupMemStat, error) {
|
||||||
if len(base) == 0 {
|
if len(base) == 0 {
|
||||||
base = "/sys/fs/cgroup/memory/docker"
|
base = "/sys/fs/cgroup/memory/docker"
|
||||||
}
|
}
|
||||||
statfile := path.Join(base, containerid, "memory.stat")
|
path := path.Join(base, containerid, "memory.stat")
|
||||||
|
|
||||||
if _, err := os.Stat(statfile); os.IsNotExist(err) {
|
|
||||||
statfile = path.Join("/sys/fs/cgroup/memory/system.slice", "docker-" + containerid + ".scope", "memory.stat")
|
|
||||||
}
|
|
||||||
|
|
||||||
// empty containerid means all cgroup
|
// empty containerid means all cgroup
|
||||||
if len(containerid) == 0 {
|
if len(containerid) == 0 {
|
||||||
containerid = "all"
|
containerid = "all"
|
||||||
}
|
}
|
||||||
lines, err := common.ReadLines(statfile)
|
lines, err := common.ReadLines(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,6 @@ import (
|
||||||
func VirtualMemory() (*VirtualMemoryStat, error) {
|
func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||||
filename := "/proc/meminfo"
|
filename := "/proc/meminfo"
|
||||||
lines, _ := common.ReadLines(filename)
|
lines, _ := common.ReadLines(filename)
|
||||||
// flag if MemAvailable is in /proc/meminfo (kernel 3.14+)
|
|
||||||
memavail := false
|
|
||||||
|
|
||||||
ret := &VirtualMemoryStat{}
|
ret := &VirtualMemoryStat{}
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
|
@ -35,9 +33,6 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||||
ret.Total = t * 1024
|
ret.Total = t * 1024
|
||||||
case "MemFree":
|
case "MemFree":
|
||||||
ret.Free = t * 1024
|
ret.Free = t * 1024
|
||||||
case "MemAvailable":
|
|
||||||
memavail = true
|
|
||||||
ret.Available = t * 1024
|
|
||||||
case "Buffers":
|
case "Buffers":
|
||||||
ret.Buffers = t * 1024
|
ret.Buffers = t * 1024
|
||||||
case "Cached":
|
case "Cached":
|
||||||
|
@ -48,9 +43,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||||
ret.Inactive = t * 1024
|
ret.Inactive = t * 1024
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !memavail {
|
ret.Available = ret.Free + ret.Buffers + ret.Cached
|
||||||
ret.Available = ret.Free + ret.Buffers + ret.Cached
|
|
||||||
}
|
|
||||||
ret.Used = ret.Total - ret.Free
|
ret.Used = ret.Total - ret.Free
|
||||||
ret.UsedPercent = float64(ret.Total-ret.Available) / float64(ret.Total) * 100.0
|
ret.UsedPercent = float64(ret.Total-ret.Available) / float64(ret.Total) * 100.0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue