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