File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -109,12 +109,16 @@ func (dc *diskCollector) collect() {
109
109
110
110
for deviceName , ioCountersStat := range ioCountersStats {
111
111
// Calculate average IO queue length since last measurement.
112
- lastIOTime := dc .historyIOTime [deviceName ]
112
+ lastIOTime , historyExist := dc .historyIOTime [deviceName ]
113
113
lastWeightedIO := dc .historyWeightedIO [deviceName ]
114
114
115
115
dc .historyIOTime [deviceName ] = ioCountersStat .IoTime
116
116
dc .historyWeightedIO [deviceName ] = ioCountersStat .WeightedIO
117
117
118
+ if ! historyExist {
119
+ // Ignore first collected stats.
120
+ return
121
+ }
118
122
avgQueueLen := float64 (0.0 )
119
123
if lastIOTime != ioCountersStat .IoTime {
120
124
avgQueueLen = float64 (ioCountersStat .WeightedIO - lastWeightedIO ) / float64 (ioCountersStat .IoTime - lastIOTime )
You can’t perform that action at this time.
0 commit comments