mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-08-23 06:06:25 +00:00
Only disk_avg_queue_len is distorted on first collection
This commit is contained in:
@@ -115,15 +115,6 @@ func (dc *diskCollector) collect() {
|
||||
dc.historyIOTime[deviceName] = ioCountersStat.IoTime
|
||||
dc.historyWeightedIO[deviceName] = ioCountersStat.WeightedIO
|
||||
|
||||
if !historyExist {
|
||||
// Ignore first collected stats.
|
||||
return
|
||||
}
|
||||
avgQueueLen := float64(0.0)
|
||||
if lastIOTime != ioCountersStat.IoTime {
|
||||
avgQueueLen = float64(ioCountersStat.WeightedIO-lastWeightedIO) / float64(ioCountersStat.IoTime-lastIOTime)
|
||||
}
|
||||
|
||||
// Attach label {"device_name": deviceName} to the metrics.
|
||||
tags := map[string]string{deviceNameLabel: deviceName}
|
||||
if dc.mIOTime != nil {
|
||||
@@ -132,8 +123,14 @@ func (dc *diskCollector) collect() {
|
||||
if dc.mWeightedIO != nil {
|
||||
dc.mWeightedIO.Record(tags, int64(ioCountersStat.WeightedIO-lastWeightedIO))
|
||||
}
|
||||
if dc.mAvgQueueLen != nil {
|
||||
dc.mAvgQueueLen.Record(tags, avgQueueLen)
|
||||
if historyExist {
|
||||
avgQueueLen := float64(0.0)
|
||||
if lastIOTime != ioCountersStat.IoTime {
|
||||
avgQueueLen = float64(ioCountersStat.WeightedIO-lastWeightedIO) / float64(ioCountersStat.IoTime-lastIOTime)
|
||||
}
|
||||
if dc.mAvgQueueLen != nil {
|
||||
dc.mAvgQueueLen.Record(tags, avgQueueLen)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user