From 605835795181840f6fd63265611de5f143189f8d Mon Sep 17 00:00:00 2001 From: Eason <291028775@qq.com> Date: Sun, 8 Jan 2023 21:55:50 +0800 Subject: [PATCH] doc: update json format --- src/entity/process.go | 92 +++++++++++++++++++++---------------------- src/entity/system.go | 48 +++++++++++----------- 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/entity/process.go b/src/entity/process.go index 2a1e243..20522f9 100644 --- a/src/entity/process.go +++ b/src/entity/process.go @@ -27,9 +27,9 @@ type ProcessIO struct { Wchar int `json:"wchar"` Syscr int `json:"syscr"` Syscw int `json:"syscw"` - ReadBytes int `json:"read_bytes"` - WriteBytes int `json:"write_bytes"` - CancelledWriteBytes int `json:"cancelled_write_bytes"` + ReadBytes int `json:"readBytes"` + WriteBytes int `json:"writeBytes"` + CancelledWriteBytes int `json:"cancelledWriteBytes"` } type ProcessStat struct { @@ -61,49 +61,49 @@ type ProcessStat struct { } type ProcessStatus struct { - Name string `json:"Name"` - Umask string `json:"Umask"` - State string `json:"State"` - Tgid string `json:"Tgid"` - Ngid string `json:"Ngid"` - Pid string `json:"Pid"` - PPid string `json:"PPid"` - TracerPid string `json:"TracerPid"` - Uid string `json:"Uid"` - Gid string `json:"Gid"` - FDSize string `json:"FDSize"` - Groups string `json:"Groups"` - VmPeak string `json:"VmPeak"` - VmSize string `json:"VmSize"` - VmLck string `json:"VmLck"` - VmPin string `json:"VmPin"` - VmHWM string `json:"VmHWM"` - VmRSS string `json:"VmRSS"` - RssAnon string `json:"RssAnon"` - RssFile string `json:"RssFile"` - RssShmem string `json:"RssShmem"` - VmData string `json:"VmData"` - VmStk string `json:"VmStk"` - VmExe string `json:"VmExe"` - VmLib string `json:"VmLib"` - VmPTE string `json:"VmPTE"` - VmSwap string `json:"VmSwap"` - Threads string `json:"Threads"` - SigQ string `json:"SigQ"` - SigPnd string `json:"SigPnd"` - ShdPnd string `json:"ShdPnd"` - SigBlk string `json:"SigBlk"` - SigIgn string `json:"SigIgn"` - SigCgt string `json:"SigCgt"` - CapInh string `json:"CapInh"` - CapPrm string `json:"CapPrm"` - CapEff string `json:"CapEff"` - CapBnd string `json:"CapBnd"` - CapAmb string `json:"CapAmb"` - CpusAllowed string `json:"Cpus_allowed"` - CpusAllowedList string `json:"Cpus_allowed_list"` - VoluntaryCtxtSwitches string `json:"voluntary_ctxt_switches"` - NonVoluntaryCtxtSwitches string `json:"nonvoluntary_ctxt_switches"` + Name string `json:"name"` + Umask string `json:"umask"` + State string `json:"state"` + Tgid string `json:"tgid"` + Ngid string `json:"ngid"` + Pid string `json:"pid"` + PPid string `json:"pPid"` + TracerPid string `json:"tracerPid"` + Uid string `json:"uid"` + Gid string `json:"gid"` + FDSize string `json:"fdSize"` + Groups string `json:"groups"` + VmPeak string `json:"vmPeak"` + VmSize string `json:"vmSize"` + VmLck string `json:"vmLck"` + VmPin string `json:"vmPin"` + VmHWM string `json:"vmHWM"` + VmRSS string `json:"vmRSS"` + RssAnon string `json:"rssAnon"` + RssFile string `json:"rssFile"` + RssShmem string `json:"rssShmem"` + VmData string `json:"vmData"` + VmStk string `json:"vmStk"` + VmExe string `json:"vmExe"` + VmLib string `json:"vmLib"` + VmPTE string `json:"vmPTE"` + VmSwap string `json:"vmSwap"` + Threads string `json:"threads"` + SigQ string `json:"sigQ"` + SigPnd string `json:"sigPnd"` + ShdPnd string `json:"shdPnd"` + SigBlk string `json:"sigBlk"` + SigIgn string `json:"sigIgn"` + SigCgt string `json:"sigCgt"` + CapInh string `json:"capInh"` + CapPrm string `json:"capPrm"` + CapEff string `json:"capEff"` + CapBnd string `json:"capBnd"` + CapAmb string `json:"capAmb"` + CpusAllowed string `json:"cpusAllowed"` + CpusAllowedList string `json:"cpusAllowedList"` + VoluntaryCtxtSwitches string `json:"voluntaryCtxtSwitches"` + NonVoluntaryCtxtSwitches string `json:"nonVoluntaryCtxtSwitches"` } type ProcessInfo struct { diff --git a/src/entity/system.go b/src/entity/system.go index e326912..c756e14 100644 --- a/src/entity/system.go +++ b/src/entity/system.go @@ -31,10 +31,10 @@ type SystemFSInfo struct { } type SystemNetworkInfo struct { - IPv4 string - IPv6 string - Rx uint64 - Tx uint64 + IPv4 string `json:"ipv4"` + IPv6 string `json:"ipv6"` + Rx uint64 `json:"rx"` + Tx uint64 `json:"tx"` } type SystemCpuRaw struct { @@ -51,29 +51,29 @@ type SystemCpuRaw struct { } type SystemCPUInfo struct { - User float32 - Nice float32 - System float32 - Idle float32 - Iowait float32 - Irq float32 - SoftIrq float32 - Steal float32 - Guest float32 + User float32 `json:"user"` + Nice float32 `json:"nice"` + System float32 `json:"system"` + Idle float32 `json:"idle"` + Iowait float32 `json:"iowait"` + Irq float32 `json:"irq"` + SoftIrq float32 `json:"softIrq"` + Steal float32 `json:"steal"` + Guest float32 `json:"guest"` } type SystemStats struct { - Uptime time.Duration - Hostname string - MemTotal uint64 - MemFree uint64 - MemBuffers uint64 - MemCached uint64 - SwapTotal uint64 - SwapFree uint64 - NetworkInfo map[string]*SystemNetworkInfo - CPU map[string]*SystemCPUInfo // or []SystemCPUInfo to get all the cpu-core's stats? - TimeStamp int64 + Uptime time.Duration `json:"uptime"` + Hostname string `json:"hostname"` + MemTotal uint64 `json:"memTotal"` + MemFree uint64 `json:"memFree"` + MemBuffers uint64 `json:"memBuffers"` + MemCached uint64 `json:"memCached"` + SwapTotal uint64 `json:"swapTotal"` + SwapFree uint64 `json:"swapFree"` + NetworkInfo map[string]*SystemNetworkInfo `json:"networkInfo"` + CPU map[string]*SystemCPUInfo `json:"cpu"` + TimeStamp int64 `json:"timeStamp"` } func (stats *SystemStats) ToString() string {