Skip to content

Commit

Permalink
refactor(inputs.diskio): Differentiate guage and counter from counter.(
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangxianfu committed Oct 2, 2024
1 parent c455ac4 commit 20b20f2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions plugins/inputs/diskio/diskio.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,16 @@ func (d *DiskIO) Gather(acc telegraf.Accumulator) error {
"write_time": io.WriteTime,
"io_time": io.IoTime,
"weighted_io_time": io.WeightedIO,
"iops_in_progress": io.IopsInProgress,
"merged_reads": io.MergedReadCount,
"merged_writes": io.MergedWriteCount,
}
fieldsG := map[string]interface{}{
"iops_in_progress": io.IopsInProgress,
}
if lastValue, exists := d.lastIOCounterStat[k]; exists {
deltaRWCount := float64(io.ReadCount + io.WriteCount - lastValue.ReadCount - lastValue.WriteCount)
deltaRWTime := float64(io.ReadTime + io.WriteTime - lastValue.ReadTime - lastValue.WriteTime)
deltaIOTime := float64(io.IoTime - lastValue.IoTime)
fieldsG := make(map[string]interface{})
if deltaRWCount > 0 {
fieldsG["io_await"] = deltaRWTime / deltaRWCount
fieldsG["io_svctm"] = deltaIOTime / deltaRWCount
Expand All @@ -144,10 +145,8 @@ func (d *DiskIO) Gather(acc telegraf.Accumulator) error {
if itv > 0 {
fieldsG["io_util"] = 100 * deltaIOTime / itv
}
if len(fieldsG) > 0 {
acc.AddGauge("diskio", fieldsG, tags)
}
}
acc.AddGauge("diskio", fieldsG, tags)
acc.AddCounter("diskio", fieldsC, tags)
}
d.lastCollectTime = collectTime
Expand Down

0 comments on commit 20b20f2

Please sign in to comment.