refactor collect push , sys -> core (#271)
Co-authored-by: wangzhiguo04 <wangzhiguo04@meicai.cn>
This commit is contained in:
parent
4b2f6a2c27
commit
66421ae557
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/modules/collector/cache"
|
"github.com/didi/nightingale/src/modules/collector/cache"
|
||||||
"github.com/didi/nightingale/src/modules/collector/config"
|
"github.com/didi/nightingale/src/modules/collector/config"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
"github.com/didi/nightingale/src/modules/collector/http/routes"
|
"github.com/didi/nightingale/src/modules/collector/http/routes"
|
||||||
"github.com/didi/nightingale/src/modules/collector/log/worker"
|
"github.com/didi/nightingale/src/modules/collector/log/worker"
|
||||||
"github.com/didi/nightingale/src/modules/collector/stra"
|
"github.com/didi/nightingale/src/modules/collector/stra"
|
||||||
|
@ -75,7 +76,7 @@ func main() {
|
||||||
sys.Init(cfg.Sys)
|
sys.Init(cfg.Sys)
|
||||||
stra.Init(cfg.Stra)
|
stra.Init(cfg.Stra)
|
||||||
|
|
||||||
funcs.InitRpcClients()
|
core.InitRpcClients()
|
||||||
funcs.BuildMappers()
|
funcs.BuildMappers()
|
||||||
funcs.Collect()
|
funcs.Collect()
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package funcs
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/rpc"
|
"net/rpc"
|
|
@ -1,4 +1,4 @@
|
||||||
package funcs
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
|
@ -1,4 +1,4 @@
|
||||||
package funcs
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
"github.com/didi/nightingale/src/modules/collector/log/strategy"
|
"github.com/didi/nightingale/src/modules/collector/log/strategy"
|
||||||
"github.com/didi/nightingale/src/modules/collector/log/worker"
|
"github.com/didi/nightingale/src/modules/collector/log/worker"
|
||||||
"github.com/didi/nightingale/src/modules/collector/stra"
|
"github.com/didi/nightingale/src/modules/collector/stra"
|
||||||
"github.com/didi/nightingale/src/modules/collector/sys/funcs"
|
|
||||||
"github.com/didi/nightingale/src/toolkits/http/render"
|
"github.com/didi/nightingale/src/toolkits/http/render"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -36,7 +36,7 @@ func pushData(c *gin.Context) {
|
||||||
var recvMetricValues []*dataobj.MetricValue
|
var recvMetricValues []*dataobj.MetricValue
|
||||||
errors.Dangerous(c.ShouldBindJSON(&recvMetricValues))
|
errors.Dangerous(c.ShouldBindJSON(&recvMetricValues))
|
||||||
|
|
||||||
err := funcs.Push(recvMetricValues)
|
err := core.Push(recvMetricValues)
|
||||||
render.Message(c, err)
|
render.Message(c, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
"github.com/didi/nightingale/src/modules/collector/stra"
|
"github.com/didi/nightingale/src/modules/collector/stra"
|
||||||
"github.com/didi/nightingale/src/modules/collector/sys/funcs"
|
|
||||||
"github.com/didi/nightingale/src/toolkits/identity"
|
"github.com/didi/nightingale/src/toolkits/identity"
|
||||||
|
|
||||||
"github.com/toolkits/pkg/logger"
|
"github.com/toolkits/pkg/logger"
|
||||||
|
@ -208,7 +208,7 @@ func postToCollector(paramPoints []*dataobj.MetricValue) {
|
||||||
sort.Sort(tsps)
|
sort.Sort(tsps)
|
||||||
|
|
||||||
for _, ps := range tsps {
|
for _, ps := range tsps {
|
||||||
funcs.Push(ps.ps)
|
core.Push(ps.ps)
|
||||||
|
|
||||||
// 1000ms是经验值
|
// 1000ms是经验值
|
||||||
// 对于10G/小时的数据量+异步落盘的场景, 产生的结果友好一些
|
// 对于10G/小时的数据量+异步落盘的场景, 产生的结果友好一些
|
||||||
|
|
|
@ -2,10 +2,11 @@ package funcs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CollectorMetrics() []*dataobj.MetricValue {
|
func CollectorMetrics() []*dataobj.MetricValue {
|
||||||
return []*dataobj.MetricValue{
|
return []*dataobj.MetricValue{
|
||||||
GaugeValue("proc.agent.alive", 1),
|
core.GaugeValue("proc.agent.alive", 1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/toolkits/pkg/nux"
|
"github.com/toolkits/pkg/nux"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -222,32 +223,32 @@ func CpuMetrics() []*dataobj.MetricValue {
|
||||||
var ret []*dataobj.MetricValue
|
var ret []*dataobj.MetricValue
|
||||||
|
|
||||||
cpuIdleVal := CpuIdle()
|
cpuIdleVal := CpuIdle()
|
||||||
idle := GaugeValue("cpu.idle", cpuIdleVal)
|
idle := core.GaugeValue("cpu.idle", cpuIdleVal)
|
||||||
util := GaugeValue("cpu.util", 100.0-cpuIdleVal)
|
util := core.GaugeValue("cpu.util", 100.0-cpuIdleVal)
|
||||||
user := GaugeValue("cpu.user", CpuUser())
|
user := core.GaugeValue("cpu.user", CpuUser())
|
||||||
system := GaugeValue("cpu.sys", CpuSystem())
|
system := core.GaugeValue("cpu.sys", CpuSystem())
|
||||||
nice := GaugeValue("cpu.nice", CpuNice())
|
nice := core.GaugeValue("cpu.nice", CpuNice())
|
||||||
iowait := GaugeValue("cpu.iowait", CpuIowait())
|
iowait := core.GaugeValue("cpu.iowait", CpuIowait())
|
||||||
irq := GaugeValue("cpu.irq", CpuIrq())
|
irq := core.GaugeValue("cpu.irq", CpuIrq())
|
||||||
softirq := GaugeValue("cpu.softirq", CpuSoftIrq())
|
softirq := core.GaugeValue("cpu.softirq", CpuSoftIrq())
|
||||||
steal := GaugeValue("cpu.steal", CpuSteal())
|
steal := core.GaugeValue("cpu.steal", CpuSteal())
|
||||||
guest := GaugeValue("cpu.guest", CpuGuest())
|
guest := core.GaugeValue("cpu.guest", CpuGuest())
|
||||||
switches := GaugeValue("cpu.switches", CpuContentSwitches())
|
switches := core.GaugeValue("cpu.switches", CpuContentSwitches())
|
||||||
ret = []*dataobj.MetricValue{idle, util, user, nice, system, iowait, irq, softirq, steal, guest, switches}
|
ret = []*dataobj.MetricValue{idle, util, user, nice, system, iowait, irq, softirq, steal, guest, switches}
|
||||||
|
|
||||||
idles := CpuIdles()
|
idles := CpuIdles()
|
||||||
for i, stats := range idles {
|
for i, stats := range idles {
|
||||||
tags := fmt.Sprintf("core=%d", i)
|
tags := fmt.Sprintf("core=%d", i)
|
||||||
ret = append(ret, GaugeValue("cpu.core.idle", stats.Idle, tags))
|
ret = append(ret, core.GaugeValue("cpu.core.idle", stats.Idle, tags))
|
||||||
ret = append(ret, GaugeValue("cpu.core.util", 100.0-stats.Idle, tags))
|
ret = append(ret, core.GaugeValue("cpu.core.util", 100.0-stats.Idle, tags))
|
||||||
ret = append(ret, GaugeValue("cpu.core.user", stats.User, tags))
|
ret = append(ret, core.GaugeValue("cpu.core.user", stats.User, tags))
|
||||||
ret = append(ret, GaugeValue("cpu.core.sys", stats.System, tags))
|
ret = append(ret, core.GaugeValue("cpu.core.sys", stats.System, tags))
|
||||||
ret = append(ret, GaugeValue("cpu.core.irq", stats.Irq, tags))
|
ret = append(ret, core.GaugeValue("cpu.core.irq", stats.Irq, tags))
|
||||||
ret = append(ret, GaugeValue("cpu.core.softirq", stats.SoftIrq, tags))
|
ret = append(ret, core.GaugeValue("cpu.core.softirq", stats.SoftIrq, tags))
|
||||||
ret = append(ret, GaugeValue("cpu.core.steal", stats.Steal, tags))
|
ret = append(ret, core.GaugeValue("cpu.core.steal", stats.Steal, tags))
|
||||||
ret = append(ret, GaugeValue("cpu.core.iowait", stats.Iowait, tags))
|
ret = append(ret, core.GaugeValue("cpu.core.iowait", stats.Iowait, tags))
|
||||||
ret = append(ret, GaugeValue("cpu.core.nice", stats.Nice, tags))
|
ret = append(ret, core.GaugeValue("cpu.core.nice", stats.Nice, tags))
|
||||||
ret = append(ret, GaugeValue("cpu.core.guest", stats.Guest, tags))
|
ret = append(ret, core.GaugeValue("cpu.core.guest", stats.Guest, tags))
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
"github.com/didi/nightingale/src/modules/collector/sys"
|
"github.com/didi/nightingale/src/modules/collector/sys"
|
||||||
"github.com/didi/nightingale/src/toolkits/identity"
|
"github.com/didi/nightingale/src/toolkits/identity"
|
||||||
)
|
)
|
||||||
|
@ -46,6 +47,6 @@ func collect(sec int64, fn func() []*dataobj.MetricValue) {
|
||||||
item.Timestamp = now
|
item.Timestamp = now
|
||||||
metricValues = append(metricValues, item)
|
metricValues = append(metricValues, item)
|
||||||
}
|
}
|
||||||
Push(metricValues)
|
core.Push(metricValues)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
"github.com/didi/nightingale/src/modules/collector/sys"
|
"github.com/didi/nightingale/src/modules/collector/sys"
|
||||||
|
|
||||||
"github.com/toolkits/pkg/logger"
|
"github.com/toolkits/pkg/logger"
|
||||||
|
@ -56,26 +57,26 @@ func DeviceMetrics() []*dataobj.MetricValue {
|
||||||
diskUsed += du.BlocksUsed
|
diskUsed += du.BlocksUsed
|
||||||
|
|
||||||
tags := fmt.Sprintf("mount=%s", du.FsFile)
|
tags := fmt.Sprintf("mount=%s", du.FsFile)
|
||||||
ret = append(ret, GaugeValue("disk.bytes.total", du.BlocksAll, tags))
|
ret = append(ret, core.GaugeValue("disk.bytes.total", du.BlocksAll, tags))
|
||||||
ret = append(ret, GaugeValue("disk.bytes.free", du.BlocksFree, tags))
|
ret = append(ret, core.GaugeValue("disk.bytes.free", du.BlocksFree, tags))
|
||||||
ret = append(ret, GaugeValue("disk.bytes.used", du.BlocksUsed, tags))
|
ret = append(ret, core.GaugeValue("disk.bytes.used", du.BlocksUsed, tags))
|
||||||
ret = append(ret, GaugeValue("disk.bytes.used.percent", du.BlocksUsedPercent, tags))
|
ret = append(ret, core.GaugeValue("disk.bytes.used.percent", du.BlocksUsedPercent, tags))
|
||||||
|
|
||||||
if du.InodesAll == 0 {
|
if du.InodesAll == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = append(ret, GaugeValue("disk.inodes.total", du.InodesAll, tags))
|
ret = append(ret, core.GaugeValue("disk.inodes.total", du.InodesAll, tags))
|
||||||
ret = append(ret, GaugeValue("disk.inodes.free", du.InodesFree, tags))
|
ret = append(ret, core.GaugeValue("disk.inodes.free", du.InodesFree, tags))
|
||||||
ret = append(ret, GaugeValue("disk.inodes.used", du.InodesUsed, tags))
|
ret = append(ret, core.GaugeValue("disk.inodes.used", du.InodesUsed, tags))
|
||||||
ret = append(ret, GaugeValue("disk.inodes.used.percent", du.InodesUsedPercent, tags))
|
ret = append(ret, core.GaugeValue("disk.inodes.used.percent", du.InodesUsedPercent, tags))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ret) > 0 && diskTotal > 0 {
|
if len(ret) > 0 && diskTotal > 0 {
|
||||||
ret = append(ret, GaugeValue("disk.cap.bytes.total", float64(diskTotal)))
|
ret = append(ret, core.GaugeValue("disk.cap.bytes.total", float64(diskTotal)))
|
||||||
ret = append(ret, GaugeValue("disk.cap.bytes.used", float64(diskUsed)))
|
ret = append(ret, core.GaugeValue("disk.cap.bytes.used", float64(diskUsed)))
|
||||||
ret = append(ret, GaugeValue("disk.cap.bytes.free", float64(diskTotal-diskUsed)))
|
ret = append(ret, core.GaugeValue("disk.cap.bytes.free", float64(diskTotal-diskUsed)))
|
||||||
ret = append(ret, GaugeValue("disk.cap.bytes.used.percent", float64(diskUsed)*100.0/float64(diskTotal)))
|
ret = append(ret, core.GaugeValue("disk.cap.bytes.used.percent", float64(diskUsed)*100.0/float64(diskTotal)))
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
|
|
||||||
"github.com/toolkits/pkg/logger"
|
"github.com/toolkits/pkg/logger"
|
||||||
"github.com/toolkits/pkg/nux"
|
"github.com/toolkits/pkg/nux"
|
||||||
|
@ -127,19 +128,19 @@ func IOStatsMetrics() []*dataobj.MetricValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
duration := IODelta(device, TS)
|
duration := IODelta(device, TS)
|
||||||
ret = append(ret, GaugeValue("disk.io.read.request", float64(rio), tags))
|
ret = append(ret, core.GaugeValue("disk.io.read.request", float64(rio), tags))
|
||||||
ret = append(ret, GaugeValue("disk.io.write.request", float64(wio), tags))
|
ret = append(ret, core.GaugeValue("disk.io.write.request", float64(wio), tags))
|
||||||
ret = append(ret, GaugeValue("disk.io.read.bytes", float64(deltaRsec)*512.0, tags))
|
ret = append(ret, core.GaugeValue("disk.io.read.bytes", float64(deltaRsec)*512.0, tags))
|
||||||
ret = append(ret, GaugeValue("disk.io.write.bytes", float64(deltaWsec)*512.0, tags))
|
ret = append(ret, core.GaugeValue("disk.io.write.bytes", float64(deltaWsec)*512.0, tags))
|
||||||
ret = append(ret, GaugeValue("disk.io.avgrq_sz", avgrqSz, tags))
|
ret = append(ret, core.GaugeValue("disk.io.avgrq_sz", avgrqSz, tags))
|
||||||
ret = append(ret, GaugeValue("disk.io.avgqu_sz", float64(IODelta(device, IOMsecWeightedTotal))/1000.0, tags))
|
ret = append(ret, core.GaugeValue("disk.io.avgqu_sz", float64(IODelta(device, IOMsecWeightedTotal))/1000.0, tags))
|
||||||
ret = append(ret, GaugeValue("disk.io.await", await, tags))
|
ret = append(ret, core.GaugeValue("disk.io.await", await, tags))
|
||||||
ret = append(ret, GaugeValue("disk.io.svctm", svctm, tags))
|
ret = append(ret, core.GaugeValue("disk.io.svctm", svctm, tags))
|
||||||
tmp := float64(use) * 100.0 / float64(duration)
|
tmp := float64(use) * 100.0 / float64(duration)
|
||||||
if tmp > 100.0 {
|
if tmp > 100.0 {
|
||||||
tmp = 100.0
|
tmp = 100.0
|
||||||
}
|
}
|
||||||
ret = append(ret, GaugeValue("disk.io.util", tmp, tags))
|
ret = append(ret, core.GaugeValue("disk.io.util", tmp, tags))
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
"github.com/didi/nightingale/src/modules/collector/sys"
|
"github.com/didi/nightingale/src/modules/collector/sys"
|
||||||
|
|
||||||
"github.com/toolkits/pkg/logger"
|
"github.com/toolkits/pkg/logger"
|
||||||
|
@ -52,14 +53,14 @@ func FsRWMetrics() []*dataobj.MetricValue {
|
||||||
f, err := os.Open(du.FsFile)
|
f, err := os.Open(du.FsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("target mount point open failed:", err)
|
logger.Error("target mount point open failed:", err)
|
||||||
ret = append(ret, GaugeValue("disk.rw.error", 1, tags))
|
ret = append(ret, core.GaugeValue("disk.rw.error", 1, tags))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
fs, err := f.Stat()
|
fs, err := f.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("get target mount point status failed:", err)
|
logger.Error("get target mount point status failed:", err)
|
||||||
ret = append(ret, GaugeValue("disk.rw.error", 2, tags))
|
ret = append(ret, core.GaugeValue("disk.rw.error", 2, tags))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,9 +73,9 @@ func FsRWMetrics() []*dataobj.MetricValue {
|
||||||
content := "FS-RW" + now
|
content := "FS-RW" + now
|
||||||
err = CheckFS(file, content)
|
err = CheckFS(file, content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ret = append(ret, GaugeValue("disk.rw.error", 3, tags))
|
ret = append(ret, core.GaugeValue("disk.rw.error", 3, tags))
|
||||||
} else {
|
} else {
|
||||||
ret = append(ret, GaugeValue("disk.rw.error", 0, tags))
|
ret = append(ret, core.GaugeValue("disk.rw.error", 0, tags))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
"github.com/didi/nightingale/src/modules/collector/sys"
|
"github.com/didi/nightingale/src/modules/collector/sys"
|
||||||
|
|
||||||
"github.com/toolkits/pkg/logger"
|
"github.com/toolkits/pkg/logger"
|
||||||
|
@ -60,50 +61,50 @@ func NetMetrics() (ret []*dataobj.MetricValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inbits := inbytes * 8
|
inbits := inbytes * 8
|
||||||
ret = append(ret, GaugeValue("net.in.bits", inbits, tags))
|
ret = append(ret, core.GaugeValue("net.in.bits", inbits, tags))
|
||||||
|
|
||||||
outbytes := float64(stat.outBytes-oldStat.outBytes) / float64(interval)
|
outbytes := float64(stat.outBytes-oldStat.outBytes) / float64(interval)
|
||||||
if outbytes < 0 {
|
if outbytes < 0 {
|
||||||
outbytes = 0
|
outbytes = 0
|
||||||
}
|
}
|
||||||
outbits := outbytes * 8
|
outbits := outbytes * 8
|
||||||
ret = append(ret, GaugeValue("net.out.bits", outbits, tags))
|
ret = append(ret, core.GaugeValue("net.out.bits", outbits, tags))
|
||||||
|
|
||||||
v := float64(stat.inDrop-oldStat.inDrop) / float64(interval)
|
v := float64(stat.inDrop-oldStat.inDrop) / float64(interval)
|
||||||
if v < 0 {
|
if v < 0 {
|
||||||
v = 0
|
v = 0
|
||||||
}
|
}
|
||||||
ret = append(ret, GaugeValue("net.in.dropped", v, tags))
|
ret = append(ret, core.GaugeValue("net.in.dropped", v, tags))
|
||||||
|
|
||||||
v = float64(stat.outDrop-oldStat.outDrop) / float64(interval)
|
v = float64(stat.outDrop-oldStat.outDrop) / float64(interval)
|
||||||
if v < 0 {
|
if v < 0 {
|
||||||
v = 0
|
v = 0
|
||||||
}
|
}
|
||||||
ret = append(ret, GaugeValue("net.out.dropped", v, tags))
|
ret = append(ret, core.GaugeValue("net.out.dropped", v, tags))
|
||||||
|
|
||||||
v = float64(stat.inPackets-oldStat.inPackets) / float64(interval)
|
v = float64(stat.inPackets-oldStat.inPackets) / float64(interval)
|
||||||
if v < 0 {
|
if v < 0 {
|
||||||
v = 0
|
v = 0
|
||||||
}
|
}
|
||||||
ret = append(ret, GaugeValue("net.in.pps", v, tags))
|
ret = append(ret, core.GaugeValue("net.in.pps", v, tags))
|
||||||
|
|
||||||
v = float64(stat.outPackets-oldStat.outPackets) / float64(interval)
|
v = float64(stat.outPackets-oldStat.outPackets) / float64(interval)
|
||||||
if v < 0 {
|
if v < 0 {
|
||||||
v = 0
|
v = 0
|
||||||
}
|
}
|
||||||
ret = append(ret, GaugeValue("net.out.pps", v, tags))
|
ret = append(ret, core.GaugeValue("net.out.pps", v, tags))
|
||||||
|
|
||||||
v = float64(stat.inErr-oldStat.inErr) / float64(interval)
|
v = float64(stat.inErr-oldStat.inErr) / float64(interval)
|
||||||
if v < 0 {
|
if v < 0 {
|
||||||
v = 0
|
v = 0
|
||||||
}
|
}
|
||||||
ret = append(ret, GaugeValue("net.in.errs", v, tags))
|
ret = append(ret, core.GaugeValue("net.in.errs", v, tags))
|
||||||
|
|
||||||
v = float64(stat.outErr-oldStat.outErr) / float64(interval)
|
v = float64(stat.outErr-oldStat.outErr) / float64(interval)
|
||||||
if v < 0 {
|
if v < 0 {
|
||||||
v = 0
|
v = 0
|
||||||
}
|
}
|
||||||
ret = append(ret, GaugeValue("net.out.errs", v, tags))
|
ret = append(ret, core.GaugeValue("net.out.errs", v, tags))
|
||||||
|
|
||||||
if strings.HasPrefix(iface, "vnet") { //vnet采集到的stat.speed不准确,不计算percent
|
if strings.HasPrefix(iface, "vnet") { //vnet采集到的stat.speed不准确,不计算percent
|
||||||
continue
|
continue
|
||||||
|
@ -114,36 +115,36 @@ func NetMetrics() (ret []*dataobj.MetricValue) {
|
||||||
inPercent := float64(inbits) * 100 / float64(stat.speed*1000000)
|
inPercent := float64(inbits) * 100 / float64(stat.speed*1000000)
|
||||||
|
|
||||||
if inPercent < 0 || stat.speed <= 0 {
|
if inPercent < 0 || stat.speed <= 0 {
|
||||||
ret = append(ret, GaugeValue("net.in.percent", 0, tags))
|
ret = append(ret, core.GaugeValue("net.in.percent", 0, tags))
|
||||||
} else {
|
} else {
|
||||||
ret = append(ret, GaugeValue("net.in.percent", inPercent, tags))
|
ret = append(ret, core.GaugeValue("net.in.percent", inPercent, tags))
|
||||||
}
|
}
|
||||||
|
|
||||||
outTotalUsed += outbits
|
outTotalUsed += outbits
|
||||||
outPercent := float64(outbits) * 100 / float64(stat.speed*1000000)
|
outPercent := float64(outbits) * 100 / float64(stat.speed*1000000)
|
||||||
if outPercent < 0 || stat.speed <= 0 {
|
if outPercent < 0 || stat.speed <= 0 {
|
||||||
ret = append(ret, GaugeValue("net.out.percent", 0, tags))
|
ret = append(ret, core.GaugeValue("net.out.percent", 0, tags))
|
||||||
} else {
|
} else {
|
||||||
ret = append(ret, GaugeValue("net.out.percent", outPercent, tags))
|
ret = append(ret, core.GaugeValue("net.out.percent", outPercent, tags))
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = append(ret, GaugeValue("net.bandwidth.mbits", stat.speed, tags))
|
ret = append(ret, core.GaugeValue("net.bandwidth.mbits", stat.speed, tags))
|
||||||
totalBandwidth += stat.speed
|
totalBandwidth += stat.speed
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = append(ret, GaugeValue("net.bandwidth.mbits.total", totalBandwidth))
|
ret = append(ret, core.GaugeValue("net.bandwidth.mbits.total", totalBandwidth))
|
||||||
ret = append(ret, GaugeValue("net.in.bits.total", inTotalUsed))
|
ret = append(ret, core.GaugeValue("net.in.bits.total", inTotalUsed))
|
||||||
ret = append(ret, GaugeValue("net.out.bits.total", outTotalUsed))
|
ret = append(ret, core.GaugeValue("net.out.bits.total", outTotalUsed))
|
||||||
|
|
||||||
if totalBandwidth <= 0 {
|
if totalBandwidth <= 0 {
|
||||||
ret = append(ret, GaugeValue("net.in.bits.total.percent", 0))
|
ret = append(ret, core.GaugeValue("net.in.bits.total.percent", 0))
|
||||||
ret = append(ret, GaugeValue("net.out.bits.total.percent", 0))
|
ret = append(ret, core.GaugeValue("net.out.bits.total.percent", 0))
|
||||||
} else {
|
} else {
|
||||||
inTotalPercent := float64(inTotalUsed) / float64(totalBandwidth*1000000) * 100
|
inTotalPercent := float64(inTotalUsed) / float64(totalBandwidth*1000000) * 100
|
||||||
ret = append(ret, GaugeValue("net.in.bits.total.percent", inTotalPercent))
|
ret = append(ret, core.GaugeValue("net.in.bits.total.percent", inTotalPercent))
|
||||||
|
|
||||||
outTotalPercent := float64(outTotalUsed) / float64(totalBandwidth*1000000) * 100
|
outTotalPercent := float64(outTotalUsed) / float64(totalBandwidth*1000000) * 100
|
||||||
ret = append(ret, GaugeValue("net.out.bits.total.percent", outTotalPercent))
|
ret = append(ret, core.GaugeValue("net.out.bits.total.percent", outTotalPercent))
|
||||||
}
|
}
|
||||||
|
|
||||||
historyIfStat = newIfStat
|
historyIfStat = newIfStat
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/toolkits/pkg/nux"
|
"github.com/toolkits/pkg/nux"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func LoadAvgMetrics() []*dataobj.MetricValue {
|
func LoadAvgMetrics() []*dataobj.MetricValue {
|
||||||
|
@ -15,8 +16,8 @@ func LoadAvgMetrics() []*dataobj.MetricValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
return []*dataobj.MetricValue{
|
return []*dataobj.MetricValue{
|
||||||
GaugeValue("cpu.loadavg.1", load.Avg1min),
|
core.GaugeValue("cpu.loadavg.1", load.Avg1min),
|
||||||
GaugeValue("cpu.loadavg.5", load.Avg5min),
|
core.GaugeValue("cpu.loadavg.5", load.Avg5min),
|
||||||
GaugeValue("cpu.loadavg.15", load.Avg15min),
|
core.GaugeValue("cpu.loadavg.15", load.Avg15min),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/toolkits/pkg/nux"
|
"github.com/toolkits/pkg/nux"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MemMetrics() []*dataobj.MetricValue {
|
func MemMetrics() []*dataobj.MetricValue {
|
||||||
|
@ -32,15 +33,15 @@ func MemMetrics() []*dataobj.MetricValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
return []*dataobj.MetricValue{
|
return []*dataobj.MetricValue{
|
||||||
GaugeValue("mem.bytes.total", m.MemTotal),
|
core.GaugeValue("mem.bytes.total", m.MemTotal),
|
||||||
GaugeValue("mem.bytes.used", memUsed),
|
core.GaugeValue("mem.bytes.used", memUsed),
|
||||||
GaugeValue("mem.bytes.free", memFree),
|
core.GaugeValue("mem.bytes.free", memFree),
|
||||||
GaugeValue("mem.bytes.used.percent", pmemUsed),
|
core.GaugeValue("mem.bytes.used.percent", pmemUsed),
|
||||||
GaugeValue("mem.bytes.buffers", m.Buffers),
|
core.GaugeValue("mem.bytes.buffers", m.Buffers),
|
||||||
GaugeValue("mem.bytes.cached", m.Cached),
|
core.GaugeValue("mem.bytes.cached", m.Cached),
|
||||||
GaugeValue("mem.swap.bytes.total", m.SwapTotal),
|
core.GaugeValue("mem.swap.bytes.total", m.SwapTotal),
|
||||||
GaugeValue("mem.swap.bytes.used", m.SwapUsed),
|
core.GaugeValue("mem.swap.bytes.used", m.SwapUsed),
|
||||||
GaugeValue("mem.swap.bytes.free", m.SwapFree),
|
core.GaugeValue("mem.swap.bytes.free", m.SwapFree),
|
||||||
GaugeValue("mem.swap.bytes.used.percent", pswapUsed),
|
core.GaugeValue("mem.swap.bytes.used.percent", pswapUsed),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/toolkits/pkg/logger"
|
"github.com/toolkits/pkg/logger"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NfMetrics() []*dataobj.MetricValue {
|
func NfMetrics() []*dataobj.MetricValue {
|
||||||
|
@ -20,19 +21,19 @@ func NfMetrics() []*dataobj.MetricValue {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("read file err:", connMaxFile, err)
|
logger.Error("read file err:", connMaxFile, err)
|
||||||
} else {
|
} else {
|
||||||
res = append(res, GaugeValue("sys.net.netfilter.nf_conntrack_max", nfConntrackMax))
|
res = append(res, core.GaugeValue("sys.net.netfilter.nf_conntrack_max", nfConntrackMax))
|
||||||
}
|
}
|
||||||
|
|
||||||
nfConntrackCount, err := file.ToInt64(connCountFile)
|
nfConntrackCount, err := file.ToInt64(connCountFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("read file err:", connMaxFile, err)
|
logger.Error("read file err:", connMaxFile, err)
|
||||||
} else {
|
} else {
|
||||||
res = append(res, GaugeValue("sys.net.netfilter.nf_conntrack_count", nfConntrackCount))
|
res = append(res, core.GaugeValue("sys.net.netfilter.nf_conntrack_count", nfConntrackCount))
|
||||||
}
|
}
|
||||||
|
|
||||||
if nfConntrackMax != 0 {
|
if nfConntrackMax != 0 {
|
||||||
percent := float64(nfConntrackCount) / float64(nfConntrackMax) * 100
|
percent := float64(nfConntrackCount) / float64(nfConntrackMax) * 100
|
||||||
res = append(res, GaugeValue("sys.net.netfilter.nf_conntrack_count.percent", percent))
|
res = append(res, core.GaugeValue("sys.net.netfilter.nf_conntrack_count.percent", percent))
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
"github.com/didi/nightingale/src/modules/collector/sys"
|
"github.com/didi/nightingale/src/modules/collector/sys"
|
||||||
|
|
||||||
"github.com/toolkits/pkg/logger"
|
"github.com/toolkits/pkg/logger"
|
||||||
|
@ -44,7 +45,7 @@ func NtpOffsetMetrics() []*dataobj.MetricValue {
|
||||||
logger.Debug("ntp: client receive time, ", dstTime)
|
logger.Debug("ntp: client receive time, ", dstTime)
|
||||||
|
|
||||||
delta := duration / 1e6 // 转换成 ms
|
delta := duration / 1e6 // 转换成 ms
|
||||||
ret = append(ret, GaugeValue("sys.ntp.offset.ms", delta))
|
ret = append(ret, core.GaugeValue("sys.ntp.offset.ms", delta))
|
||||||
|
|
||||||
//one ntp server's response is enough
|
//one ntp server's response is enough
|
||||||
break
|
break
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package funcs
|
package funcs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
"github.com/toolkits/pkg/logger"
|
"github.com/toolkits/pkg/logger"
|
||||||
"github.com/toolkits/pkg/nux"
|
"github.com/toolkits/pkg/nux"
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ func UdpMetrics() []*dataobj.MetricValue {
|
||||||
ret := make([]*dataobj.MetricValue, count)
|
ret := make([]*dataobj.MetricValue, count)
|
||||||
i := 0
|
i := 0
|
||||||
for key, val := range udp {
|
for key, val := range udp {
|
||||||
ret[i] = GaugeValue("snmp.Udp."+key,val)
|
ret[i] = core.GaugeValue("snmp.Udp."+key, val)
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ func TcpMetrics() []*dataobj.MetricValue {
|
||||||
ret := make([]*dataobj.MetricValue, count)
|
ret := make([]*dataobj.MetricValue, count)
|
||||||
i := 0
|
i := 0
|
||||||
for key, val := range tcp {
|
for key, val := range tcp {
|
||||||
ret[i] = GaugeValue("snmp.Tcp."+key,val)
|
ret[i] = core.GaugeValue("snmp.Tcp."+key, val)
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/toolkits/pkg/nux"
|
"github.com/toolkits/pkg/nux"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SocketStatSummaryMetrics() []*dataobj.MetricValue {
|
func SocketStatSummaryMetrics() []*dataobj.MetricValue {
|
||||||
|
@ -16,7 +17,7 @@ func SocketStatSummaryMetrics() []*dataobj.MetricValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range ssMap {
|
for k, v := range ssMap {
|
||||||
ret = append(ret, GaugeValue("net."+k, v))
|
ret = append(ret, core.GaugeValue("net."+k, v))
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/toolkits/pkg/nux"
|
"github.com/toolkits/pkg/nux"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FsKernelMetrics() []*dataobj.MetricValue {
|
func FsKernelMetrics() []*dataobj.MetricValue {
|
||||||
|
@ -27,10 +28,10 @@ func FsKernelMetrics() []*dataobj.MetricValue {
|
||||||
|
|
||||||
v := math.Ceil(float64(allocateFiles) * 100 / float64(maxFiles))
|
v := math.Ceil(float64(allocateFiles) * 100 / float64(maxFiles))
|
||||||
return []*dataobj.MetricValue{
|
return []*dataobj.MetricValue{
|
||||||
GaugeValue("sys.fs.files.max", maxFiles),
|
core.GaugeValue("sys.fs.files.max", maxFiles),
|
||||||
GaugeValue("sys.fs.files.free", maxFiles-allocateFiles),
|
core.GaugeValue("sys.fs.files.free", maxFiles-allocateFiles),
|
||||||
GaugeValue("sys.fs.files.used", allocateFiles),
|
core.GaugeValue("sys.fs.files.used", allocateFiles),
|
||||||
GaugeValue("sys.fs.files.used.percent", v),
|
core.GaugeValue("sys.fs.files.used.percent", v),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ func ProcsNumMetrics() []*dataobj.MetricValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
return []*dataobj.MetricValue{
|
return []*dataobj.MetricValue{
|
||||||
GaugeValue("sys.ps.process.total", num),
|
core.GaugeValue("sys.ps.process.total", num),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +88,6 @@ func EntityNumMetrics() []*dataobj.MetricValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
return []*dataobj.MetricValue{
|
return []*dataobj.MetricValue{
|
||||||
GaugeValue("sys.ps.entity.total", num),
|
core.GaugeValue("sys.ps.entity.total", num),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/toolkits/pkg/sys"
|
"github.com/toolkits/pkg/sys"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
"github.com/didi/nightingale/src/modules/collector/sys/funcs"
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PluginScheduler struct {
|
type PluginScheduler struct {
|
||||||
|
@ -140,5 +140,5 @@ func PluginRun(plugin *Plugin) {
|
||||||
items[i].Step = int64(plugin.Cycle)
|
items[i].Step = int64(plugin.Cycle)
|
||||||
}
|
}
|
||||||
|
|
||||||
funcs.Push(items)
|
core.Push(items)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
"github.com/didi/nightingale/src/model"
|
"github.com/didi/nightingale/src/model"
|
||||||
"github.com/didi/nightingale/src/modules/collector/sys/funcs"
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
"github.com/didi/nightingale/src/toolkits/identity"
|
"github.com/didi/nightingale/src/toolkits/identity"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -50,11 +50,11 @@ func PortCollect(p *model.PortCollect) {
|
||||||
value = 1
|
value = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
item := funcs.GaugeValue("proc.port.listen", value, p.Tags)
|
item := core.GaugeValue("proc.port.listen", value, p.Tags)
|
||||||
item.Step = int64(p.Step)
|
item.Step = int64(p.Step)
|
||||||
item.Timestamp = time.Now().Unix()
|
item.Timestamp = time.Now().Unix()
|
||||||
item.Endpoint = identity.Identity
|
item.Endpoint = identity.Identity
|
||||||
funcs.Push([]*dataobj.MetricValue{item})
|
core.Push([]*dataobj.MetricValue{item})
|
||||||
}
|
}
|
||||||
|
|
||||||
func isListening(port int) bool {
|
func isListening(port int) bool {
|
||||||
|
|
|
@ -4,13 +4,13 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/toolkits/pkg/logger"
|
|
||||||
process "github.com/shirou/gopsutil/process"
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
"github.com/didi/nightingale/src/model"
|
"github.com/didi/nightingale/src/model"
|
||||||
"github.com/didi/nightingale/src/modules/collector/sys/funcs"
|
|
||||||
"github.com/didi/nightingale/src/modules/collector/cache"
|
"github.com/didi/nightingale/src/modules/collector/cache"
|
||||||
|
"github.com/didi/nightingale/src/modules/collector/core"
|
||||||
"github.com/didi/nightingale/src/toolkits/identity"
|
"github.com/didi/nightingale/src/toolkits/identity"
|
||||||
|
process "github.com/shirou/gopsutil/process"
|
||||||
|
"github.com/toolkits/pkg/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProcScheduler struct {
|
type ProcScheduler struct {
|
||||||
|
@ -53,13 +53,13 @@ func ProcCollect(p *model.ProcCollect) {
|
||||||
var memUsedTotal uint64 = 0
|
var memUsedTotal uint64 = 0
|
||||||
var memUtilTotal = 0.0
|
var memUtilTotal = 0.0
|
||||||
var cpuUtilTotal = 0.0
|
var cpuUtilTotal = 0.0
|
||||||
var items [] *dataobj.MetricValue
|
var items []*dataobj.MetricValue
|
||||||
cnt := 0
|
cnt := 0
|
||||||
for _, procs := range ps {
|
for _, procs := range ps {
|
||||||
if isProc(procs, p.CollectMethod, p.Target) {
|
if isProc(procs, p.CollectMethod, p.Target) {
|
||||||
cnt++
|
cnt++
|
||||||
procCache, exists := cache.ProcsCache.Get(procs.Pid)
|
procCache, exists := cache.ProcsCache.Get(procs.Pid)
|
||||||
if !exists{
|
if !exists {
|
||||||
cache.ProcsCache.Set(procs.Pid, procs)
|
cache.ProcsCache.Set(procs.Pid, procs)
|
||||||
procCache = procs
|
procCache = procs
|
||||||
}
|
}
|
||||||
|
@ -83,22 +83,21 @@ func ProcCollect(p *model.ProcCollect) {
|
||||||
cpuUtilTotal += cpuUtil
|
cpuUtilTotal += cpuUtil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
procNumItem := funcs.GaugeValue("proc.num", cnt, p.Tags)
|
procNumItem := core.GaugeValue("proc.num", cnt, p.Tags)
|
||||||
memUsedItem := funcs.GaugeValue("proc.mem.used", memUsedTotal, p.Tags)
|
memUsedItem := core.GaugeValue("proc.mem.used", memUsedTotal, p.Tags)
|
||||||
memUtilItem := funcs.GaugeValue("proc.mem.util", memUtilTotal, p.Tags)
|
memUtilItem := core.GaugeValue("proc.mem.util", memUtilTotal, p.Tags)
|
||||||
cpuUtilItem := funcs.GaugeValue("proc.cpu.util", cpuUtilTotal, p.Tags)
|
cpuUtilItem := core.GaugeValue("proc.cpu.util", cpuUtilTotal, p.Tags)
|
||||||
items = []*dataobj.MetricValue{procNumItem, memUsedItem, memUtilItem, cpuUtilItem}
|
items = []*dataobj.MetricValue{procNumItem, memUsedItem, memUtilItem, cpuUtilItem}
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
for _, item := range items{
|
for _, item := range items {
|
||||||
item.Step = int64(p.Step)
|
item.Step = int64(p.Step)
|
||||||
item.Timestamp = now
|
item.Timestamp = now
|
||||||
item.Endpoint = identity.Identity
|
item.Endpoint = identity.Identity
|
||||||
}
|
}
|
||||||
|
|
||||||
funcs.Push(items)
|
core.Push(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isProc(p *process.Process, method, target string) bool {
|
func isProc(p *process.Process, method, target string) bool {
|
||||||
|
|
Loading…
Reference in New Issue