File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -68,17 +68,20 @@ func CollectProcessMetrics(refresh time.Duration) {
68
68
}
69
69
// Iterate loading the different stats and updating the meters
70
70
for i := 1 ; ; i ++ {
71
- runtime .ReadMemStats (memstats [i % 2 ])
72
- memAllocs .Mark (int64 (memstats [i % 2 ].Mallocs - memstats [(i - 1 )% 2 ].Mallocs ))
73
- memFrees .Mark (int64 (memstats [i % 2 ].Frees - memstats [(i - 1 )% 2 ].Frees ))
74
- memInuse .Mark (int64 (memstats [i % 2 ].Alloc - memstats [(i - 1 )% 2 ].Alloc ))
75
- memPauses .Mark (int64 (memstats [i % 2 ].PauseTotalNs - memstats [(i - 1 )% 2 ].PauseTotalNs ))
71
+ location1 := i % 2
72
+ location2 := (i - 1 )% 2
76
73
77
- if ReadDiskStats (diskstats [i % 2 ]) == nil {
78
- diskReads .Mark (diskstats [i % 2 ].ReadCount - diskstats [(i - 1 )% 2 ].ReadCount )
79
- diskReadBytes .Mark (diskstats [i % 2 ].ReadBytes - diskstats [(i - 1 )% 2 ].ReadBytes )
80
- diskWrites .Mark (diskstats [i % 2 ].WriteCount - diskstats [(i - 1 )% 2 ].WriteCount )
81
- diskWriteBytes .Mark (diskstats [i % 2 ].WriteBytes - diskstats [(i - 1 )% 2 ].WriteBytes )
74
+ runtime .ReadMemStats (memstats [location1 ])
75
+ memAllocs .Mark (int64 (memstats [location1 ].Mallocs - memstats [location2 ].Mallocs ))
76
+ memFrees .Mark (int64 (memstats [location1 ].Frees - memstats [location2 ].Frees ))
77
+ memInuse .Mark (int64 (memstats [location1 ].Alloc - memstats [location2 ].Alloc ))
78
+ memPauses .Mark (int64 (memstats [location1 ].PauseTotalNs - memstats [location2 ].PauseTotalNs ))
79
+
80
+ if ReadDiskStats (diskstats [location1 ]) == nil {
81
+ diskReads .Mark (diskstats [location1 ].ReadCount - diskstats [location2 ].ReadCount )
82
+ diskReadBytes .Mark (diskstats [location1 ].ReadBytes - diskstats [location2 ].ReadBytes )
83
+ diskWrites .Mark (diskstats [location1 ].WriteCount - diskstats [location2 ].WriteCount )
84
+ diskWriteBytes .Mark (diskstats [location1 ].WriteBytes - diskstats [location2 ].WriteBytes )
82
85
}
83
86
time .Sleep (refresh )
84
87
}
You can’t perform that action at this time.
0 commit comments