collector/diskstats: don't fail if there are extra stats, just ignore… (#1125)

* collector/diskstats: don't fail if there are extra stats, just ignore them

Signed-off-by: Paul Gier <pgier@redhat.com>
This commit is contained in:
Paul Gier 2018-10-30 12:45:00 -05:00 committed by Ben Kochie
parent 9bd4416822
commit 38163f234f
3 changed files with 7 additions and 7 deletions

View file

@ -182,7 +182,7 @@ func NewDiskstatsCollector() (Collector, error) {
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, diskSubsystem, "discarded_sectors_total"),
"The total number of sectors discard successfully.",
"The total number of sectors discarded successfully.",
diskLabelNames,
nil,
), valueType: prometheus.CounterValue,
@ -212,11 +212,11 @@ func (c *diskstatsCollector) Update(ch chan<- prometheus.Metric) error {
continue
}
if len(stats) > len(c.descs) {
return fmt.Errorf("invalid line for %s for %s", procFilePath(diskstatsFilename), dev)
}
for i, value := range stats {
// ignore unrecognized additional stats
if i >= len(c.descs) {
break
}
v, err := strconv.ParseFloat(value, 64)
if err != nil {
return fmt.Errorf("invalid value %s in diskstats: %s", value, err)

View file

@ -293,7 +293,7 @@ node_cpu_seconds_total{cpu="7",mode="user"} 290.98
# HELP node_disk_discard_time_seconds_total This is the total number of seconds spent by all discards.
# TYPE node_disk_discard_time_seconds_total counter
node_disk_discard_time_seconds_total{device="sdb"} 11.13
# HELP node_disk_discarded_sectors_total The total number of sectors discard successfully.
# HELP node_disk_discarded_sectors_total The total number of sectors discarded successfully.
# TYPE node_disk_discarded_sectors_total counter
node_disk_discarded_sectors_total{device="sdb"} 1.925173784e+09
# HELP node_disk_discards_completed_total The total number of discards completed successfully.

View file

@ -293,7 +293,7 @@ node_cpu_seconds_total{cpu="7",mode="user"} 290.98
# HELP node_disk_discard_time_seconds_total This is the total number of seconds spent by all discards.
# TYPE node_disk_discard_time_seconds_total counter
node_disk_discard_time_seconds_total{device="sdb"} 11.13
# HELP node_disk_discarded_sectors_total The total number of sectors discard successfully.
# HELP node_disk_discarded_sectors_total The total number of sectors discarded successfully.
# TYPE node_disk_discarded_sectors_total counter
node_disk_discarded_sectors_total{device="sdb"} 1.925173784e+09
# HELP node_disk_discards_completed_total The total number of discards completed successfully.