Merge pull request #29 from jamescun/master
Unify JSON tags to snake_case
This commit is contained in:
commit
512ba09921
10
cpu.go
10
cpu.go
|
@ -23,16 +23,16 @@ type CPUTimesStat struct {
|
|||
|
||||
type CPUInfoStat struct {
|
||||
CPU int32 `json:"cpu"`
|
||||
VendorID string `json:"vendorId"`
|
||||
VendorID string `json:"vendor_id"`
|
||||
Family string `json:"family"`
|
||||
Model string `json:"model"`
|
||||
Stepping int32 `json:"stepping"`
|
||||
PhysicalID string `json:"physicalId"`
|
||||
CoreID string `json:"coreId"`
|
||||
PhysicalID string `json:"physical_id"`
|
||||
CoreID string `json:"core_id"`
|
||||
Cores int32 `json:"cores"`
|
||||
ModelName string `json:"modelName"`
|
||||
ModelName string `json:"model_name"`
|
||||
Mhz float64 `json:"mhz"`
|
||||
CacheSize int32 `json:"cacheSize"`
|
||||
CacheSize int32 `json:"cache_size"`
|
||||
Flags []string `json:"flags"`
|
||||
}
|
||||
|
||||
|
|
26
disk.go
26
disk.go
|
@ -9,11 +9,11 @@ type DiskUsageStat struct {
|
|||
Total uint64 `json:"total"`
|
||||
Free uint64 `json:"free"`
|
||||
Used uint64 `json:"used"`
|
||||
UsedPercent float64 `json:"usedPercent"`
|
||||
InodesTotal uint64 `json:"inodesTotal"`
|
||||
InodesUsed uint64 `json:"inodesUsed"`
|
||||
InodesFree uint64 `json:"inodesFree"`
|
||||
InodesUsedPercent float64 `json:"inodesUsedPercent"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type DiskPartitionStat struct {
|
||||
|
@ -24,15 +24,15 @@ type DiskPartitionStat struct {
|
|||
}
|
||||
|
||||
type DiskIOCountersStat struct {
|
||||
ReadCount uint64 `json:"readCount"`
|
||||
WriteCount uint64 `json:"writeCount"`
|
||||
ReadBytes uint64 `json:"readBytes"`
|
||||
WriteBytes uint64 `json:"writeBytes"`
|
||||
ReadTime uint64 `json:"readTime"`
|
||||
WriteTime uint64 `json:"writeTime"`
|
||||
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"`
|
||||
Name string `json:"name"`
|
||||
IoTime uint64 `json:"ioTime"`
|
||||
SerialNumber string `json:"serialNumber"`
|
||||
IoTime uint64 `json:"io_time"`
|
||||
SerialNumber string `json:"serial_number"`
|
||||
}
|
||||
|
||||
func (d DiskUsageStat) String() string {
|
||||
|
|
|
@ -58,7 +58,7 @@ func TestDiskUsageStat_String(t *testing.T) {
|
|||
InodesFree: 6000,
|
||||
InodesUsedPercent: 49.1,
|
||||
}
|
||||
e := `{"path":"/","total":1000,"free":2000,"used":3000,"usedPercent":50.1,"inodesTotal":4000,"inodesUsed":5000,"inodesFree":6000,"inodesUsedPercent":49.1}`
|
||||
e := `{"path":"/","total":1000,"free":2000,"used":3000,"used_percent":50.1,"inodes_total":4000,"inodes_used":5000,"inodes_free":6000,"inodes_used_percent":49.1}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("DiskUsageStat string is invalid: %v", v)
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ func TestDiskIOCountersStat_String(t *testing.T) {
|
|||
WriteBytes: 400,
|
||||
SerialNumber: "SERIAL",
|
||||
}
|
||||
e := `{"readCount":100,"writeCount":200,"readBytes":300,"writeBytes":400,"readTime":0,"writeTime":0,"name":"sd01","ioTime":0,"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"}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("DiskUsageStat string is invalid: %v", v)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
type CgroupMemStat struct {
|
||||
ContainerID string `json:"containerid"`
|
||||
ContainerID string `json:"container_id"`
|
||||
Cache uint64 `json:"cache"`
|
||||
RSS uint64 `json:"rss"`
|
||||
RSSHuge uint64 `json:"rss_huge"`
|
||||
|
|
14
host.go
14
host.go
|
@ -9,13 +9,13 @@ import (
|
|||
type HostInfoStat struct {
|
||||
Hostname string `json:"hostname"`
|
||||
Uptime uint64 `json:"uptime"`
|
||||
Procs uint64 `json:"procs"` // number of processes
|
||||
OS string `json:"os"` // ex: freebsd, linux
|
||||
Platform string `json:"platform"` // ex: ubuntu, linuxmint
|
||||
PlatformFamily string `json:"platformFamily"` // ex: debian, rhel
|
||||
PlatformVersion string `json:"platformVersion"`
|
||||
VirtualizationSystem string `json:"virtualizationSystem"`
|
||||
VirtualizationRole string `json:"virtualizationRole"` // guest or host
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ func TestHostInfoStat_String(t *testing.T) {
|
|||
OS: "linux",
|
||||
Platform: "ubuntu",
|
||||
}
|
||||
e := `{"hostname":"test","uptime":3000,"procs":100,"os":"linux","platform":"ubuntu","platformFamily":"","platformVersion":"","virtualizationSystem":"","virtualizationRole":""}`
|
||||
e := `{"hostname":"test","uptime":3000,"procs":100,"os":"linux","platform":"ubuntu","platform_family":"","platform_version":"","virtualization_system":"","virtualization_role":""}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("HostInfoStat string is invalid: %v", v)
|
||||
}
|
||||
|
|
4
mem.go
4
mem.go
|
@ -8,7 +8,7 @@ type VirtualMemoryStat struct {
|
|||
Total uint64 `json:"total"`
|
||||
Available uint64 `json:"available"`
|
||||
Used uint64 `json:"used"`
|
||||
UsedPercent float64 `json:"usedPercent"`
|
||||
UsedPercent float64 `json:"used_percent"`
|
||||
Free uint64 `json:"free"`
|
||||
Active uint64 `json:"active"`
|
||||
Inactive uint64 `json:"inactive"`
|
||||
|
@ -22,7 +22,7 @@ type SwapMemoryStat struct {
|
|||
Total uint64 `json:"total"`
|
||||
Used uint64 `json:"used"`
|
||||
Free uint64 `json:"free"`
|
||||
UsedPercent float64 `json:"usedPercent"`
|
||||
UsedPercent float64 `json:"used_percent"`
|
||||
Sin uint64 `json:"sin"`
|
||||
Sout uint64 `json:"sout"`
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func TestVirtualMemoryStat_String(t *testing.T) {
|
|||
UsedPercent: 30.1,
|
||||
Free: 40,
|
||||
}
|
||||
e := `{"total":10,"available":20,"used":30,"usedPercent":30.1,"free":40,"active":0,"inactive":0,"buffers":0,"cached":0,"wired":0,"shared":0}`
|
||||
e := `{"total":10,"available":20,"used":30,"used_percent":30.1,"free":40,"active":0,"inactive":0,"buffers":0,"cached":0,"wired":0,"shared":0}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("VirtualMemoryStat string is invalid: %v", v)
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func TestSwapMemoryStat_String(t *testing.T) {
|
|||
Free: 40,
|
||||
UsedPercent: 30.1,
|
||||
}
|
||||
e := `{"total":10,"used":30,"free":40,"usedPercent":30.1,"sin":0,"sout":0}`
|
||||
e := `{"total":10,"used":30,"free":40,"used_percent":30.1,"sin":0,"sout":0}`
|
||||
if e != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("SwapMemoryStat string is invalid: %v", v)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue