added sum
This commit is contained in:
parent
acce66b50f
commit
660a31ca7c
|
@ -20,7 +20,10 @@
|
|||
"container": "go_proxy"
|
||||
},
|
||||
"items": [{
|
||||
"keys": [
|
||||
"keys": [{
|
||||
"metric": "cpu.usage.sum",
|
||||
"key": "sum"
|
||||
},
|
||||
{
|
||||
"metric": "cpu.usage.user",
|
||||
"key": "user"
|
||||
|
|
35
stat/cpu.go
35
stat/cpu.go
|
@ -5,8 +5,8 @@ import (
|
|||
"io"
|
||||
"strings"
|
||||
|
||||
|
||||
|
||||
"strconv"
|
||||
"git.loafle.net/overflow/ssh_crawler/util"
|
||||
)
|
||||
//
|
||||
type CPUStat struct {
|
||||
|
@ -49,27 +49,28 @@ func (cpu CPUStat) Read(r io.Reader) (map[string]string, error) {
|
|||
//if len(parts) > 9 {
|
||||
// guest = util.StringToInt64(parts[9])
|
||||
//}
|
||||
//if len(parts) > 10 {
|
||||
// guestNice = util.StringToInt64(parts[10])
|
||||
//}
|
||||
if len(parts) <= 10 {
|
||||
//guestNice = util.StringToInt64(parts[10])
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
//stats = append(stats, CPUStat{
|
||||
//Device := util.StringToInt64(parts[0])
|
||||
//User := util.StringToInt64(parts[1])
|
||||
//Nice := util.StringToInt64(parts[2])
|
||||
//System := util.StringToInt64(parts[3])
|
||||
//Idle := util.StringToInt64(parts[4])
|
||||
//Iowait := util.StringToInt64(parts[5])
|
||||
//Irq := util.StringToInt64(parts[6])
|
||||
//SoftIrq := util.StringToInt64(parts[7])
|
||||
//Steal := steal
|
||||
//Guest := guest
|
||||
//GuestNice := guestNice
|
||||
User := util.StringToInt64(parts[1])
|
||||
Nice := util.StringToInt64(parts[2])
|
||||
System := util.StringToInt64(parts[3])
|
||||
Idle := util.StringToInt64(parts[4])
|
||||
Iowait := util.StringToInt64(parts[5])
|
||||
Irq := util.StringToInt64(parts[6])
|
||||
SoftIrq := util.StringToInt64(parts[7])
|
||||
Steal := util.StringToInt64(parts[8])
|
||||
Guest := util.StringToInt64(parts[9])
|
||||
GuestNice := util.StringToInt64(parts[10])
|
||||
//})
|
||||
|
||||
//sum := User + Nice + System + Idle + Iowait + Irq + SoftIrq + Steal + Guest + GuestNice
|
||||
//resMap["sum"] = strconv.FormatInt(sum, 10)
|
||||
sum := User + Nice + System + Idle + Iowait + Irq + SoftIrq + Steal + Guest + GuestNice
|
||||
resMap["sum"] = strconv.FormatInt(sum, 10)
|
||||
resMap["user"] = parts[1]
|
||||
resMap["nice"] = parts[2]
|
||||
resMap["system"] = parts[3]
|
||||
|
|
Loading…
Reference in New Issue
Block a user