mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-24 13:48:56 +08:00
JSON representation is renamed to fit Google JSON style, camelCase.
This commit is contained in:
parent
46ddd57c72
commit
4bb84648bf
@ -19,6 +19,12 @@ psutil functions on some architectures...
|
||||
We introduced versioning by using gopkgin. And breaking changes will be introduced at v2. See `issue 174 <https://github.com/shirou/gopsutil/issues/174>`_ .
|
||||
|
||||
|
||||
Migrating to v2
|
||||
-------------------------
|
||||
|
||||
On gopsutil itself, `v2migration.sh <https://github.com/shirou/gopsutil/blob/v2/v2migration.sh>`_ is used for migration. It can not be commly used, but it may help to your migration.
|
||||
|
||||
|
||||
Available Architectures
|
||||
------------------------------------
|
||||
|
||||
|
14
cpu/cpu.go
14
cpu/cpu.go
@ -18,22 +18,22 @@ type TimesStat struct {
|
||||
Softirq float64 `json:"softirq"`
|
||||
Steal float64 `json:"steal"`
|
||||
Guest float64 `json:"guest"`
|
||||
GuestNice float64 `json:"guest_nice"`
|
||||
GuestNice float64 `json:"guestNice"`
|
||||
Stolen float64 `json:"stolen"`
|
||||
}
|
||||
|
||||
type InfoStat struct {
|
||||
CPU int32 `json:"cpu"`
|
||||
VendorID string `json:"vendor_id"`
|
||||
VendorID string `json:"vendorId"`
|
||||
Family string `json:"family"`
|
||||
Model string `json:"model"`
|
||||
Stepping int32 `json:"stepping"`
|
||||
PhysicalID string `json:"physical_id"`
|
||||
CoreID string `json:"core_id"`
|
||||
PhysicalID string `json:"physicalId"`
|
||||
CoreID string `json:"coreId"`
|
||||
Cores int32 `json:"cores"`
|
||||
ModelName string `json:"model_name"`
|
||||
ModelName string `json:"modelName"`
|
||||
Mhz float64 `json:"mhz"`
|
||||
CacheSize int32 `json:"cache_size"`
|
||||
CacheSize int32 `json:"cacheSize"`
|
||||
Flags []string `json:"flags"`
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ func (c TimesStat) String() string {
|
||||
`"softirq":` + strconv.FormatFloat(c.Softirq, 'f', 1, 64),
|
||||
`"steal":` + strconv.FormatFloat(c.Steal, 'f', 1, 64),
|
||||
`"guest":` + strconv.FormatFloat(c.Guest, 'f', 1, 64),
|
||||
`"guest_nice":` + strconv.FormatFloat(c.GuestNice, 'f', 1, 64),
|
||||
`"guestNice":` + strconv.FormatFloat(c.GuestNice, 'f', 1, 64),
|
||||
`"stolen":` + strconv.FormatFloat(c.Stolen, 'f', 1, 64),
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ func finishCPUInfo(c *InfoStat) error {
|
||||
}
|
||||
}
|
||||
if len(c.CoreID) == 0 {
|
||||
lines, err := common.ReadLines(sysCpuPath(c.CPU, "topology/core_id"))
|
||||
lines, err := common.ReadLines(sysCpuPath(c.CPU, "topology/coreId"))
|
||||
if err == nil {
|
||||
c.CoreID = lines[0]
|
||||
}
|
||||
@ -117,7 +117,7 @@ func Info() ([]InfoStat, error) {
|
||||
return ret, err
|
||||
}
|
||||
c.CPU = int32(t)
|
||||
case "vendor_id":
|
||||
case "vendorId":
|
||||
c.VendorID = value
|
||||
case "cpu family":
|
||||
c.Family = value
|
||||
|
@ -41,7 +41,7 @@ func TestCPUTimeStat_String(t *testing.T) {
|
||||
System: 200.1,
|
||||
Idle: 300.1,
|
||||
}
|
||||
e := `{"cpu":"cpu0","user":100.1,"system":200.1,"idle":300.1,"nice":0.0,"iowait":0.0,"irq":0.0,"softirq":0.0,"steal":0.0,"guest":0.0,"guest_nice":0.0,"stolen":0.0}`
|
||||
e := `{"cpu":"cpu0","user":100.1,"system":200.1,"idle":300.1,"nice":0.0,"iowait":0.0,"irq":0.0,"softirq":0.0,"steal":0.0,"guest":0.0,"guestNice":0.0,"stolen":0.0}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("CPUTimesStat string is invalid: %v", v)
|
||||
}
|
||||
|
26
disk/disk.go
26
disk/disk.go
@ -10,11 +10,11 @@ type UsageStat struct {
|
||||
Total uint64 `json:"total"`
|
||||
Free uint64 `json:"free"`
|
||||
Used uint64 `json:"used"`
|
||||
UsedPercent float64 `json:"used_percent"`
|
||||
InodesTotal uint64 `json:"inodes_total"`
|
||||
InodesUsed uint64 `json:"inodes_used"`
|
||||
InodesFree uint64 `json:"inodes_free"`
|
||||
InodesUsedPercent float64 `json:"inodes_used_percent"`
|
||||
UsedPercent float64 `json:"usedPercent"`
|
||||
InodesTotal uint64 `json:"inodesTotal"`
|
||||
InodesUsed uint64 `json:"inodesUsed"`
|
||||
InodesFree uint64 `json:"inodesFree"`
|
||||
InodesUsedPercent float64 `json:"inodesUsedPercent"`
|
||||
}
|
||||
|
||||
type PartitionStat struct {
|
||||
@ -25,15 +25,15 @@ type PartitionStat struct {
|
||||
}
|
||||
|
||||
type IOCountersStat struct {
|
||||
ReadCount uint64 `json:"read_count"`
|
||||
WriteCount uint64 `json:"write_count"`
|
||||
ReadBytes uint64 `json:"read_bytes"`
|
||||
WriteBytes uint64 `json:"write_bytes"`
|
||||
ReadTime uint64 `json:"read_time"`
|
||||
WriteTime uint64 `json:"write_time"`
|
||||
ReadCount uint64 `json:"readCount"`
|
||||
WriteCount uint64 `json:"writeCount"`
|
||||
ReadBytes uint64 `json:"readBytes"`
|
||||
WriteBytes uint64 `json:"writeBytes"`
|
||||
ReadTime uint64 `json:"readTime"`
|
||||
WriteTime uint64 `json:"writeTime"`
|
||||
Name string `json:"name"`
|
||||
IoTime uint64 `json:"io_time"`
|
||||
SerialNumber string `json:"serial_number"`
|
||||
IoTime uint64 `json:"ioTime"`
|
||||
SerialNumber string `json:"serialNumber"`
|
||||
}
|
||||
|
||||
func (d UsageStat) String() string {
|
||||
|
@ -62,7 +62,7 @@ func TestDiskUsageStat_String(t *testing.T) {
|
||||
InodesUsedPercent: 49.1,
|
||||
Fstype: "ext4",
|
||||
}
|
||||
e := `{"path":"/","fstype":"ext4","total":1000,"free":2000,"used":3000,"used_percent":50.1,"inodes_total":4000,"inodes_used":5000,"inodes_free":6000,"inodes_used_percent":49.1}`
|
||||
e := `{"path":"/","fstype":"ext4","total":1000,"free":2000,"used":3000,"usedPercent":50.1,"inodesTotal":4000,"inodesUsed":5000,"inodesFree":6000,"inodesUsedPercent":49.1}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("DiskUsageStat string is invalid: %v", v)
|
||||
}
|
||||
@ -90,7 +90,7 @@ func TestDiskIOCountersStat_String(t *testing.T) {
|
||||
WriteBytes: 400,
|
||||
SerialNumber: "SERIAL",
|
||||
}
|
||||
e := `{"read_count":100,"write_count":200,"read_bytes":300,"write_bytes":400,"read_time":0,"write_time":0,"name":"sd01","io_time":0,"serial_number":"SERIAL"}`
|
||||
e := `{"readCount":100,"writeCount":200,"readBytes":300,"writeBytes":400,"readTime":0,"writeTime":0,"name":"sd01","ioTime":0,"serialNumber":"SERIAL"}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("DiskUsageStat string is invalid: %v", v)
|
||||
}
|
||||
|
@ -6,36 +6,36 @@ var ErrDockerNotAvailable = errors.New("docker not available")
|
||||
var ErrCgroupNotAvailable = errors.New("cgroup not available")
|
||||
|
||||
type CgroupMemStat struct {
|
||||
ContainerID string `json:"container_id"`
|
||||
ContainerID string `json:"containerID"`
|
||||
Cache uint64 `json:"cache"`
|
||||
RSS uint64 `json:"rss"`
|
||||
RSSHuge uint64 `json:"rss_huge"`
|
||||
MappedFile uint64 `json:"mapped_file"`
|
||||
RSSHuge uint64 `json:"rssHuge"`
|
||||
MappedFile uint64 `json:"mappedFile"`
|
||||
Pgpgin uint64 `json:"pgpgin"`
|
||||
Pgpgout uint64 `json:"pgpgout"`
|
||||
Pgfault uint64 `json:"pgfault"`
|
||||
Pgmajfault uint64 `json:"pgmajfault"`
|
||||
InactiveAnon uint64 `json:"inactive_anon"`
|
||||
ActiveAnon uint64 `json:"active_anon"`
|
||||
InactiveFile uint64 `json:"inactive_file"`
|
||||
ActiveFile uint64 `json:"active_file"`
|
||||
InactiveAnon uint64 `json:"inactiveAnon"`
|
||||
ActiveAnon uint64 `json:"activeAnon"`
|
||||
InactiveFile uint64 `json:"inactiveFile"`
|
||||
ActiveFile uint64 `json:"activeFile"`
|
||||
Unevictable uint64 `json:"unevictable"`
|
||||
HierarchicalMemoryLimit uint64 `json:"hierarchical_memory_limit"`
|
||||
TotalCache uint64 `json:"total_cache"`
|
||||
TotalRSS uint64 `json:"total_rss"`
|
||||
TotalRSSHuge uint64 `json:"total_rss_huge"`
|
||||
TotalMappedFile uint64 `json:"total_mapped_file"`
|
||||
TotalPgpgIn uint64 `json:"total_pgpgin"`
|
||||
TotalPgpgOut uint64 `json:"total_pgpgout"`
|
||||
TotalPgFault uint64 `json:"total_pgfault"`
|
||||
TotalPgMajFault uint64 `json:"total_pgmajfault"`
|
||||
TotalInactiveAnon uint64 `json:"total_inactive_anon"`
|
||||
TotalActiveAnon uint64 `json:"total_active_anon"`
|
||||
TotalInactiveFile uint64 `json:"total_inactive_file"`
|
||||
TotalActiveFile uint64 `json:"total_active_file"`
|
||||
TotalUnevictable uint64 `json:"total_unevictable"`
|
||||
MemUsageInBytes uint64 `json:"mem_usage_in_bytes"`
|
||||
MemMaxUsageInBytes uint64 `json:"mem_max_usage_in_bytes"`
|
||||
MemLimitInBytes uint64 `json:"memory.limit_in_bytes"`
|
||||
MemFailCnt uint64 `json:"memory.failcnt"`
|
||||
HierarchicalMemoryLimit uint64 `json:"hierarchicalMemoryLimit"`
|
||||
TotalCache uint64 `json:"totalCache"`
|
||||
TotalRSS uint64 `json:"totalRss"`
|
||||
TotalRSSHuge uint64 `json:"totalRssHuge"`
|
||||
TotalMappedFile uint64 `json:"totalMappedFile"`
|
||||
TotalPgpgIn uint64 `json:"totalPgpgin"`
|
||||
TotalPgpgOut uint64 `json:"totalPgpgout"`
|
||||
TotalPgFault uint64 `json:"totalPgfault"`
|
||||
TotalPgMajFault uint64 `json:"totalPgmajfault"`
|
||||
TotalInactiveAnon uint64 `json:"totalInactiveAnon"`
|
||||
TotalActiveAnon uint64 `json:"totalActiveAnon"`
|
||||
TotalInactiveFile uint64 `json:"totalInactiveFile"`
|
||||
TotalActiveFile uint64 `json:"totalActiveFile"`
|
||||
TotalUnevictable uint64 `json:"totalUnevictable"`
|
||||
MemUsageInBytes uint64 `json:"memUsageInBytes"`
|
||||
MemMaxUsageInBytes uint64 `json:"memMaxUsageInBytes"`
|
||||
MemLimitInBytes uint64 `json:"memoryLimitInBbytes"`
|
||||
MemFailCnt uint64 `json:"memoryFailcnt"`
|
||||
}
|
||||
|
@ -101,9 +101,9 @@ func CgroupMem(containerId string, base string) (*CgroupMemStat, error) {
|
||||
ret.Cache = v
|
||||
case "rss":
|
||||
ret.RSS = v
|
||||
case "rss_huge":
|
||||
case "rssHuge":
|
||||
ret.RSSHuge = v
|
||||
case "mapped_file":
|
||||
case "mappedFile":
|
||||
ret.MappedFile = v
|
||||
case "pgpgin":
|
||||
ret.Pgpgin = v
|
||||
@ -113,43 +113,43 @@ func CgroupMem(containerId string, base string) (*CgroupMemStat, error) {
|
||||
ret.Pgfault = v
|
||||
case "pgmajfault":
|
||||
ret.Pgmajfault = v
|
||||
case "inactive_anon":
|
||||
case "inactiveAnon":
|
||||
ret.InactiveAnon = v
|
||||
case "active_anon":
|
||||
case "activeAnon":
|
||||
ret.ActiveAnon = v
|
||||
case "inactive_file":
|
||||
case "inactiveFile":
|
||||
ret.InactiveFile = v
|
||||
case "active_file":
|
||||
case "activeFile":
|
||||
ret.ActiveFile = v
|
||||
case "unevictable":
|
||||
ret.Unevictable = v
|
||||
case "hierarchical_memory_limit":
|
||||
case "hierarchicalMemoryLimit":
|
||||
ret.HierarchicalMemoryLimit = v
|
||||
case "total_cache":
|
||||
case "totalCache":
|
||||
ret.TotalCache = v
|
||||
case "total_rss":
|
||||
case "totalRss":
|
||||
ret.TotalRSS = v
|
||||
case "total_rss_huge":
|
||||
case "totalRssHuge":
|
||||
ret.TotalRSSHuge = v
|
||||
case "total_mapped_file":
|
||||
case "totalMappedFile":
|
||||
ret.TotalMappedFile = v
|
||||
case "total_pgpgin":
|
||||
case "totalPgpgin":
|
||||
ret.TotalPgpgIn = v
|
||||
case "total_pgpgout":
|
||||
case "totalPgpgout":
|
||||
ret.TotalPgpgOut = v
|
||||
case "total_pgfault":
|
||||
case "totalPgfault":
|
||||
ret.TotalPgFault = v
|
||||
case "total_pgmajfault":
|
||||
case "totalPgmajfault":
|
||||
ret.TotalPgMajFault = v
|
||||
case "total_inactive_anon":
|
||||
case "totalInactiveAnon":
|
||||
ret.TotalInactiveAnon = v
|
||||
case "total_active_anon":
|
||||
case "totalActiveAnon":
|
||||
ret.TotalActiveAnon = v
|
||||
case "total_inactive_file":
|
||||
case "totalInactiveFile":
|
||||
ret.TotalInactiveFile = v
|
||||
case "total_active_file":
|
||||
case "totalActiveFile":
|
||||
ret.TotalActiveFile = v
|
||||
case "total_unevictable":
|
||||
case "totalUnevictable":
|
||||
ret.TotalUnevictable = v
|
||||
}
|
||||
}
|
||||
@ -162,11 +162,11 @@ func CgroupMem(containerId string, base string) (*CgroupMemStat, error) {
|
||||
if err == nil {
|
||||
ret.MemMaxUsageInBytes = r
|
||||
}
|
||||
r, err = getCgroupMemFile(containerId, base, "memory.limit_in_bytes")
|
||||
r, err = getCgroupMemFile(containerId, base, "memoryLimitInBbytes")
|
||||
if err == nil {
|
||||
ret.MemLimitInBytes = r
|
||||
}
|
||||
r, err = getCgroupMemFile(containerId, base, "memory.failcnt")
|
||||
r, err = getCgroupMemFile(containerId, base, "memoryFailcnt")
|
||||
if err == nil {
|
||||
ret.MemFailCnt = r
|
||||
}
|
||||
|
10
host/host.go
10
host/host.go
@ -9,14 +9,14 @@ import (
|
||||
type InfoStat struct {
|
||||
Hostname string `json:"hostname"`
|
||||
Uptime uint64 `json:"uptime"`
|
||||
BootTime uint64 `json:"boot_time"`
|
||||
BootTime uint64 `json:"bootTime"`
|
||||
Procs uint64 `json:"procs"` // number of processes
|
||||
OS string `json:"os"` // ex: freebsd, linux
|
||||
Platform string `json:"platform"` // ex: ubuntu, linuxmint
|
||||
PlatformFamily string `json:"platform_family"` // ex: debian, rhel
|
||||
PlatformVersion string `json:"platform_version"`
|
||||
VirtualizationSystem string `json:"virtualization_system"`
|
||||
VirtualizationRole string `json:"virtualization_role"` // guest or host
|
||||
PlatformFamily string `json:"platformFamily"` // ex: debian, rhel
|
||||
PlatformVersion string `json:"platformVersion"`
|
||||
VirtualizationSystem string `json:"virtualizationSystem"`
|
||||
VirtualizationRole string `json:"virtualizationRole"` // guest or host
|
||||
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ func TestHostInfoStat_String(t *testing.T) {
|
||||
Platform: "ubuntu",
|
||||
BootTime: 1447040000,
|
||||
}
|
||||
e := `{"hostname":"test","uptime":3000,"boot_time":1447040000,"procs":100,"os":"linux","platform":"ubuntu","platform_family":"","platform_version":"","virtualization_system":"","virtualization_role":""}`
|
||||
e := `{"hostname":"test","uptime":3000,"bootTime":1447040000,"procs":100,"os":"linux","platform":"ubuntu","platformFamily":"","platformVersion":"","virtualizationSystem":"","virtualizationRole":""}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("HostInfoStat string is invalid: %v", v)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ type VirtualMemoryStat struct {
|
||||
// Percentage of RAM used by programs
|
||||
//
|
||||
// This value is computed from the kernel specific values.
|
||||
UsedPercent float64 `json:"used_percent"`
|
||||
UsedPercent float64 `json:"usedPercent"`
|
||||
|
||||
// This is the kernel's notion of free memory; RAM chips whose bits nobody
|
||||
// cares about the value of right now. For a human consumable number,
|
||||
@ -48,7 +48,7 @@ type SwapMemoryStat struct {
|
||||
Total uint64 `json:"total"`
|
||||
Used uint64 `json:"used"`
|
||||
Free uint64 `json:"free"`
|
||||
UsedPercent float64 `json:"used_percent"`
|
||||
UsedPercent float64 `json:"usedPercent"`
|
||||
Sin uint64 `json:"sin"`
|
||||
Sout uint64 `json:"sout"`
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ func TestVirtualMemoryStat_String(t *testing.T) {
|
||||
UsedPercent: 30.1,
|
||||
Free: 40,
|
||||
}
|
||||
e := `{"total":10,"available":20,"used":30,"used_percent":30.1,"free":40,"active":0,"inactive":0,"wired":0,"buffers":0,"cached":0}`
|
||||
e := `{"total":10,"available":20,"used":30,"usedPercent":30.1,"free":40,"active":0,"inactive":0,"wired":0,"buffers":0,"cached":0}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("VirtualMemoryStat string is invalid: %v", v)
|
||||
}
|
||||
@ -65,7 +65,7 @@ func TestSwapMemoryStat_String(t *testing.T) {
|
||||
Free: 40,
|
||||
UsedPercent: 30.1,
|
||||
}
|
||||
e := `{"total":10,"used":30,"free":40,"used_percent":30.1,"sin":0,"sout":0}`
|
||||
e := `{"total":10,"used":30,"free":40,"usedPercent":30.1,"sin":0,"sout":0}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("SwapMemoryStat string is invalid: %v", v)
|
||||
}
|
||||
|
12
net/net.go
12
net/net.go
@ -19,10 +19,10 @@ func init() {
|
||||
|
||||
type IOCountersStat struct {
|
||||
Name string `json:"name"` // interface name
|
||||
BytesSent uint64 `json:"bytes_sent"` // number of bytes sent
|
||||
BytesRecv uint64 `json:"bytes_recv"` // number of bytes received
|
||||
PacketsSent uint64 `json:"packets_sent"` // number of packets sent
|
||||
PacketsRecv uint64 `json:"packets_recv"` // number of packets received
|
||||
BytesSent uint64 `json:"bytesSent"` // number of bytes sent
|
||||
BytesRecv uint64 `json:"bytesRecv"` // number of bytes received
|
||||
PacketsSent uint64 `json:"packetsSent"` // number of packets sent
|
||||
PacketsRecv uint64 `json:"packetsRecv"` // number of packets received
|
||||
Errin uint64 `json:"errin"` // total number of errors while receiving
|
||||
Errout uint64 `json:"errout"` // total number of errors while sending
|
||||
Dropin uint64 `json:"dropin"` // total number of incoming packets which were dropped
|
||||
@ -65,8 +65,8 @@ type InterfaceStat struct {
|
||||
}
|
||||
|
||||
type FilterStat struct {
|
||||
ConnTrackCount int64 `json:"conntrack_count"`
|
||||
ConnTrackMax int64 `json:"conntrack_max"`
|
||||
ConnTrackCount int64 `json:"conntrackCount"`
|
||||
ConnTrackMax int64 `json:"conntrackMax"`
|
||||
}
|
||||
|
||||
var constMap = map[string]int{
|
||||
|
@ -175,8 +175,8 @@ func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
|
||||
// the currently in use conntrack count and the max.
|
||||
// If the file does not exist or is invalid it will return nil.
|
||||
func FilterCounters() ([]FilterStat, error) {
|
||||
countfile := common.HostProc("sys/net/netfilter/nf_conntrack_count")
|
||||
maxfile := common.HostProc("sys/net/netfilter/nf_conntrack_max")
|
||||
countfile := common.HostProc("sys/net/netfilter/nf_conntrackCount")
|
||||
maxfile := common.HostProc("sys/net/netfilter/nf_conntrackMax")
|
||||
|
||||
count, err := common.ReadInts(countfile)
|
||||
|
||||
|
@ -23,7 +23,7 @@ func TestNetIOCountersStatString(t *testing.T) {
|
||||
Name: "test",
|
||||
BytesSent: 100,
|
||||
}
|
||||
e := `{"name":"test","bytes_sent":100,"bytes_recv":0,"packets_sent":0,"packets_recv":0,"errin":0,"errout":0,"dropin":0,"dropout":0}`
|
||||
e := `{"name":"test","bytesSent":100,"bytesRecv":0,"packetsSent":0,"packetsRecv":0,"errin":0,"errout":0,"dropin":0,"dropout":0}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("NetIOCountersStat string is invalid: %v", v)
|
||||
}
|
||||
@ -207,7 +207,7 @@ func TestNetFilterCounters(t *testing.T) {
|
||||
|
||||
if runtime.GOOS == "linux" {
|
||||
// some test environment has not the path.
|
||||
if !common.PathExists("/proc/sys/net/netfilter/nf_conntrack_count") {
|
||||
if !common.PathExists("/proc/sys/net/netfilter/nf_conntrackCount") {
|
||||
t.SkipNow()
|
||||
}
|
||||
}
|
||||
@ -221,7 +221,7 @@ func TestNetFilterCounters(t *testing.T) {
|
||||
}
|
||||
for _, vv := range v {
|
||||
if vv.ConnTrackMax == 0 {
|
||||
t.Errorf("nf_conntrack_max needs to be greater than zero: %v", vv)
|
||||
t.Errorf("nf_conntrackMax needs to be greater than zero: %v", vv)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,10 +48,10 @@ type RlimitStat struct {
|
||||
}
|
||||
|
||||
type IOCountersStat struct {
|
||||
ReadCount uint64 `json:"read_count"`
|
||||
WriteCount uint64 `json:"write_count"`
|
||||
ReadBytes uint64 `json:"read_bytes"`
|
||||
WriteBytes uint64 `json:"write_bytes"`
|
||||
ReadCount uint64 `json:"readCount"`
|
||||
WriteCount uint64 `json:"writeCount"`
|
||||
ReadBytes uint64 `json:"readBytes"`
|
||||
WriteBytes uint64 `json:"writeBytes"`
|
||||
}
|
||||
|
||||
type NumCtxSwitchesStat struct {
|
||||
|
@ -48,10 +48,10 @@ type MemoryMapsStat struct {
|
||||
Rss uint64 `json:"rss"`
|
||||
Size uint64 `json:"size"`
|
||||
Pss uint64 `json:"pss"`
|
||||
SharedClean uint64 `json:"shared_clean"`
|
||||
SharedDirty uint64 `json:"shared_dirty"`
|
||||
PrivateClean uint64 `json:"private_clean"`
|
||||
PrivateDirty uint64 `json:"private_dirty"`
|
||||
SharedClean uint64 `json:"sharedClean"`
|
||||
SharedDirty uint64 `json:"sharedDirty"`
|
||||
PrivateClean uint64 `json:"privateClean"`
|
||||
PrivateDirty uint64 `json:"privateDirty"`
|
||||
Referenced uint64 `json:"referenced"`
|
||||
Anonymous uint64 `json:"anonymous"`
|
||||
Swap uint64 `json:"swap"`
|
||||
@ -473,9 +473,9 @@ func (p *Process) fillFromIO() (*IOCountersStat, error) {
|
||||
ret.ReadCount = t
|
||||
case "syscw":
|
||||
ret.WriteCount = t
|
||||
case "read_bytes":
|
||||
case "readBytes":
|
||||
ret.ReadBytes = t
|
||||
case "write_bytes":
|
||||
case "writeBytes":
|
||||
ret.WriteBytes = t
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,16 @@
|
||||
#
|
||||
# go get golang.org/x/tools/cmd/gorename
|
||||
|
||||
IFS=$'\n'
|
||||
|
||||
## Part 1. rename Functions to pass golint. ex) cpu.CPUTimesStat -> cpu.TimesStat
|
||||
|
||||
#
|
||||
# Note:
|
||||
# process has IOCounters() for file IO, and also NetIOCounters() for Net IO.
|
||||
# This scripts replace process.NetIOCounters() to IOCounters().
|
||||
# So you need hand-fixing process.
|
||||
|
||||
|
||||
TARGETS=`cat <<EOF
|
||||
CPUTimesStat -> TimesStat
|
||||
CPUInfoStat -> InfoStat
|
||||
@ -47,7 +50,6 @@ Id -> ID
|
||||
convertCpuTimes -> convertCPUTimes
|
||||
EOF`
|
||||
|
||||
IFS=$'\n'
|
||||
for T in $TARGETS
|
||||
do
|
||||
echo $T
|
||||
@ -55,3 +57,78 @@ do
|
||||
done
|
||||
|
||||
|
||||
###### Part 2 rename JSON key name
|
||||
## Google JSOn style
|
||||
## https://google.github.io/styleguide/jsoncstyleguide.xml
|
||||
|
||||
sed -i "" 's/guest_nice/guestNice/g' cpu/*.go
|
||||
sed -i "" 's/vendor_id/vendorId/g' cpu/*.go
|
||||
sed -i "" 's/physical_id/physicalId/g' cpu/*.go
|
||||
sed -i "" 's/model_name/modelName/g' cpu/*.go
|
||||
sed -i "" 's/cache_size/cacheSize/g' cpu/*.go
|
||||
sed -i "" 's/core_id/coreId/g' cpu/*.go
|
||||
|
||||
sed -i "" 's/inodes_total/inodesTotal/g' disk/*.go
|
||||
sed -i "" 's/inodes_used/inodesUsed/g' disk/*.go
|
||||
sed -i "" 's/inodes_free/inodesFree/g' disk/*.go
|
||||
sed -i "" 's/inodes_used_percent/inodesUsedPercent/g' disk/*.go
|
||||
sed -i "" 's/read_count/readCount/g' disk/*.go
|
||||
sed -i "" 's/write_count/writeCount/g' disk/*.go
|
||||
sed -i "" 's/read_bytes/readBytes/g' disk/*.go
|
||||
sed -i "" 's/write_bytes/writeBytes/g' disk/*.go
|
||||
sed -i "" 's/read_time/readTime/g' disk/*.go
|
||||
sed -i "" 's/write_time/writeTime/g' disk/*.go
|
||||
sed -i "" 's/io_time/ioTime/g' disk/*.go
|
||||
sed -i "" 's/serial_number/serialNumber/g' disk/*.go
|
||||
sed -i "" 's/used_percent/usedPercent/g' disk/*.go
|
||||
sed -i "" 's/inodesUsed_percent/inodesUsedPercent/g' disk/*.go
|
||||
|
||||
sed -i "" 's/total_cache/totalCache/g' docker/*.go
|
||||
sed -i "" 's/total_rss_huge/totalRssHuge/g' docker/*.go
|
||||
sed -i "" 's/total_rss/totalRss/g' docker/*.go
|
||||
sed -i "" 's/total_mapped_file/totalMappedFile/g' docker/*.go
|
||||
sed -i "" 's/total_pgpgin/totalPgpgin/g' docker/*.go
|
||||
sed -i "" 's/total_pgpgout/totalPgpgout/g' docker/*.go
|
||||
sed -i "" 's/total_pgfault/totalPgfault/g' docker/*.go
|
||||
sed -i "" 's/total_pgmajfault/totalPgmajfault/g' docker/*.go
|
||||
sed -i "" 's/total_inactive_anon/totalInactiveAnon/g' docker/*.go
|
||||
sed -i "" 's/total_active_anon/totalActiveAnon/g' docker/*.go
|
||||
sed -i "" 's/total_inactive_file/totalInactiveFile/g' docker/*.go
|
||||
sed -i "" 's/total_active_file/totalActiveFile/g' docker/*.go
|
||||
sed -i "" 's/total_unevictable/totalUnevictable/g' docker/*.go
|
||||
sed -i "" 's/mem_usage_in_bytes/memUsageInBytes/g' docker/*.go
|
||||
sed -i "" 's/mem_max_usage_in_bytes/memMaxUsageInBytes/g' docker/*.go
|
||||
sed -i "" 's/memory.limit_in_bytes/memoryLimitInBbytes/g' docker/*.go
|
||||
sed -i "" 's/memory.failcnt/memoryFailcnt/g' docker/*.go
|
||||
sed -i "" 's/mapped_file/mappedFile/g' docker/*.go
|
||||
sed -i "" 's/container_id/containerID/g' docker/*.go
|
||||
sed -i "" 's/rss_huge/rssHuge/g' docker/*.go
|
||||
sed -i "" 's/inactive_anon/inactiveAnon/g' docker/*.go
|
||||
sed -i "" 's/active_anon/activeAnon/g' docker/*.go
|
||||
sed -i "" 's/inactive_file/inactiveFile/g' docker/*.go
|
||||
sed -i "" 's/active_file/activeFile/g' docker/*.go
|
||||
sed -i "" 's/hierarchical_memory_limit/hierarchicalMemoryLimit/g' docker/*.go
|
||||
|
||||
sed -i "" 's/boot_time/bootTime/g' host/*.go
|
||||
sed -i "" 's/platform_family/platformFamily/g' host/*.go
|
||||
sed -i "" 's/platform_version/platformVersion/g' host/*.go
|
||||
sed -i "" 's/virtualization_system/virtualizationSystem/g' host/*.go
|
||||
sed -i "" 's/virtualization_role/virtualizationRole/g' host/*.go
|
||||
|
||||
sed -i "" 's/used_percent/usedPercent/g' mem/*.go
|
||||
|
||||
sed -i "" 's/bytes_sent/bytesSent/g' net/*.go
|
||||
sed -i "" 's/bytes_recv/bytesRecv/g' net/*.go
|
||||
sed -i "" 's/packets_sent/packetsSent/g' net/*.go
|
||||
sed -i "" 's/packets_recv/packetsRecv/g' net/*.go
|
||||
sed -i "" 's/conntrack_count/conntrackCount/g' net/*.go
|
||||
sed -i "" 's/conntrack_max/conntrackMax/g' net/*.go
|
||||
|
||||
sed -i "" 's/read_count/readCount/g' process/*.go
|
||||
sed -i "" 's/write_count/writeCount/g' process/*.go
|
||||
sed -i "" 's/read_bytes/readBytes/g' process/*.go
|
||||
sed -i "" 's/write_bytes/writeBytes/g' process/*.go
|
||||
sed -i "" 's/shared_clean/sharedClean/g' process/*.go
|
||||
sed -i "" 's/shared_dirty/sharedDirty/g' process/*.go
|
||||
sed -i "" 's/private_clean/privateClean/g' process/*.go
|
||||
sed -i "" 's/private_dirty/privateDirty/g' process/*.go
|
||||
|
Loading…
x
Reference in New Issue
Block a user