|
|
@ -73,28 +73,26 @@ func CollectProcessMetrics(refresh time.Duration) { |
|
|
|
diskstats[i] = new(DiskStats) |
|
|
|
diskstats[i] = new(DiskStats) |
|
|
|
} |
|
|
|
} |
|
|
|
// Define the various metrics to collect
|
|
|
|
// Define the various metrics to collect
|
|
|
|
cpuSysLoad := GetOrRegisterGauge("system/cpu/sysload", DefaultRegistry) |
|
|
|
var ( |
|
|
|
cpuSysWait := GetOrRegisterGauge("system/cpu/syswait", DefaultRegistry) |
|
|
|
cpuSysLoad = GetOrRegisterGauge("system/cpu/sysload", DefaultRegistry) |
|
|
|
cpuProcLoad := GetOrRegisterGauge("system/cpu/procload", DefaultRegistry) |
|
|
|
cpuSysWait = GetOrRegisterGauge("system/cpu/syswait", DefaultRegistry) |
|
|
|
|
|
|
|
cpuProcLoad = GetOrRegisterGauge("system/cpu/procload", DefaultRegistry) |
|
|
|
memPauses := GetOrRegisterMeter("system/memory/pauses", DefaultRegistry) |
|
|
|
cpuThreads = GetOrRegisterGauge("system/cpu/threads", DefaultRegistry) |
|
|
|
memAllocs := GetOrRegisterMeter("system/memory/allocs", DefaultRegistry) |
|
|
|
cpuGoroutines = GetOrRegisterGauge("system/cpu/goroutines", DefaultRegistry) |
|
|
|
memFrees := GetOrRegisterMeter("system/memory/frees", DefaultRegistry) |
|
|
|
|
|
|
|
memHeld := GetOrRegisterGauge("system/memory/held", DefaultRegistry) |
|
|
|
memPauses = GetOrRegisterMeter("system/memory/pauses", DefaultRegistry) |
|
|
|
memUsed := GetOrRegisterGauge("system/memory/used", DefaultRegistry) |
|
|
|
memAllocs = GetOrRegisterMeter("system/memory/allocs", DefaultRegistry) |
|
|
|
|
|
|
|
memFrees = GetOrRegisterMeter("system/memory/frees", DefaultRegistry) |
|
|
|
var diskReads, diskReadBytes, diskWrites, diskWriteBytes Meter |
|
|
|
memHeld = GetOrRegisterGauge("system/memory/held", DefaultRegistry) |
|
|
|
var diskReadBytesCounter, diskWriteBytesCounter Counter |
|
|
|
memUsed = GetOrRegisterGauge("system/memory/used", DefaultRegistry) |
|
|
|
if err := ReadDiskStats(diskstats[0]); err == nil { |
|
|
|
|
|
|
|
diskReads = GetOrRegisterMeter("system/disk/readcount", DefaultRegistry) |
|
|
|
diskReads = GetOrRegisterMeter("system/disk/readcount", DefaultRegistry) |
|
|
|
diskReadBytes = GetOrRegisterMeter("system/disk/readdata", DefaultRegistry) |
|
|
|
diskReadBytes = GetOrRegisterMeter("system/disk/readdata", DefaultRegistry) |
|
|
|
diskReadBytesCounter = GetOrRegisterCounter("system/disk/readbytes", DefaultRegistry) |
|
|
|
diskReadBytesCounter = GetOrRegisterCounter("system/disk/readbytes", DefaultRegistry) |
|
|
|
diskWrites = GetOrRegisterMeter("system/disk/writecount", DefaultRegistry) |
|
|
|
diskWrites = GetOrRegisterMeter("system/disk/writecount", DefaultRegistry) |
|
|
|
diskWriteBytes = GetOrRegisterMeter("system/disk/writedata", DefaultRegistry) |
|
|
|
diskWriteBytes = GetOrRegisterMeter("system/disk/writedata", DefaultRegistry) |
|
|
|
diskWriteBytesCounter = GetOrRegisterCounter("system/disk/writebytes", DefaultRegistry) |
|
|
|
diskWriteBytesCounter = GetOrRegisterCounter("system/disk/writebytes", DefaultRegistry) |
|
|
|
} else { |
|
|
|
) |
|
|
|
log.Debug("Failed to read disk metrics", "err", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Iterate loading the different stats and updating the meters
|
|
|
|
// Iterate loading the different stats and updating the meters
|
|
|
|
for i := 1; ; i++ { |
|
|
|
for i := 1; ; i++ { |
|
|
|
location1 := i % 2 |
|
|
|
location1 := i % 2 |
|
|
@ -104,6 +102,8 @@ func CollectProcessMetrics(refresh time.Duration) { |
|
|
|
cpuSysLoad.Update((cpuStats[location1].GlobalTime - cpuStats[location2].GlobalTime) / refreshFreq) |
|
|
|
cpuSysLoad.Update((cpuStats[location1].GlobalTime - cpuStats[location2].GlobalTime) / refreshFreq) |
|
|
|
cpuSysWait.Update((cpuStats[location1].GlobalWait - cpuStats[location2].GlobalWait) / refreshFreq) |
|
|
|
cpuSysWait.Update((cpuStats[location1].GlobalWait - cpuStats[location2].GlobalWait) / refreshFreq) |
|
|
|
cpuProcLoad.Update((cpuStats[location1].LocalTime - cpuStats[location2].LocalTime) / refreshFreq) |
|
|
|
cpuProcLoad.Update((cpuStats[location1].LocalTime - cpuStats[location2].LocalTime) / refreshFreq) |
|
|
|
|
|
|
|
cpuThreads.Update(int64(threadCreateProfile.Count())) |
|
|
|
|
|
|
|
cpuGoroutines.Update(int64(runtime.NumGoroutine())) |
|
|
|
|
|
|
|
|
|
|
|
runtime.ReadMemStats(memstats[location1]) |
|
|
|
runtime.ReadMemStats(memstats[location1]) |
|
|
|
memPauses.Mark(int64(memstats[location1].PauseTotalNs - memstats[location2].PauseTotalNs)) |
|
|
|
memPauses.Mark(int64(memstats[location1].PauseTotalNs - memstats[location2].PauseTotalNs)) |
|
|
|