aboutsummaryrefslogtreecommitdiffstats
path: root/metrics/metrics.go
diff options
context:
space:
mode:
Diffstat (limited to 'metrics/metrics.go')
-rw-r--r--metrics/metrics.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/metrics/metrics.go b/metrics/metrics.go
index 8ae7aec43..98e8ced25 100644
--- a/metrics/metrics.go
+++ b/metrics/metrics.go
@@ -61,18 +61,27 @@ func CollectProcessMetrics(refresh time.Duration) {
if !Enabled {
return
}
+ refreshFreq := int64(refresh / time.Second)
+
// Create the various data collectors
+ cpuStats := make([]*CPUStats, 2)
memstats := make([]*runtime.MemStats, 2)
diskstats := make([]*DiskStats, 2)
for i := 0; i < len(memstats); i++ {
+ cpuStats[i] = new(CPUStats)
memstats[i] = new(runtime.MemStats)
diskstats[i] = new(DiskStats)
}
// Define the various metrics to collect
+ cpuSysLoad := GetOrRegisterGauge("system/cpu/sysload", DefaultRegistry)
+ cpuSysWait := GetOrRegisterGauge("system/cpu/syswait", DefaultRegistry)
+ cpuProcLoad := GetOrRegisterGauge("system/cpu/procload", DefaultRegistry)
+
+ memPauses := GetOrRegisterMeter("system/memory/pauses", DefaultRegistry)
memAllocs := GetOrRegisterMeter("system/memory/allocs", DefaultRegistry)
memFrees := GetOrRegisterMeter("system/memory/frees", DefaultRegistry)
- memInuse := GetOrRegisterMeter("system/memory/inuse", DefaultRegistry)
- memPauses := GetOrRegisterMeter("system/memory/pauses", DefaultRegistry)
+ memHeld := GetOrRegisterGauge("system/memory/held", DefaultRegistry)
+ memUsed := GetOrRegisterGauge("system/memory/used", DefaultRegistry)
var diskReads, diskReadBytes, diskWrites, diskWriteBytes Meter
var diskReadBytesCounter, diskWriteBytesCounter Counter
@@ -91,11 +100,17 @@ func CollectProcessMetrics(refresh time.Duration) {
location1 := i % 2
location2 := (i - 1) % 2
+ ReadCPUStats(cpuStats[location1])
+ cpuSysLoad.Update((cpuStats[location1].GlobalTime - cpuStats[location2].GlobalTime) / refreshFreq)
+ cpuSysWait.Update((cpuStats[location1].GlobalWait - cpuStats[location2].GlobalWait) / refreshFreq)
+ cpuProcLoad.Update((cpuStats[location1].LocalTime - cpuStats[location2].LocalTime) / refreshFreq)
+
runtime.ReadMemStats(memstats[location1])
+ memPauses.Mark(int64(memstats[location1].PauseTotalNs - memstats[location2].PauseTotalNs))
memAllocs.Mark(int64(memstats[location1].Mallocs - memstats[location2].Mallocs))
memFrees.Mark(int64(memstats[location1].Frees - memstats[location2].Frees))
- memInuse.Mark(int64(memstats[location1].Alloc - memstats[location2].Alloc))
- memPauses.Mark(int64(memstats[location1].PauseTotalNs - memstats[location2].PauseTotalNs))
+ memHeld.Update(int64(memstats[location1].HeapSys - memstats[location1].HeapReleased))
+ memUsed.Update(int64(memstats[location1].Alloc))
if ReadDiskStats(diskstats[location1]) == nil {
diskReads.Mark(diskstats[location1].ReadCount - diskstats[location2].ReadCount)