From 38163f234fe793d45400d45c04cc9d25eee267cd Mon Sep 17 00:00:00 2001 From: Paul Gier Date: Tue, 30 Oct 2018 12:45:00 -0500 Subject: [PATCH] =?UTF-8?q?collector/diskstats:=20don't=20fail=20if=20ther?= =?UTF-8?q?e=20are=20extra=20stats,=20just=20ignore=E2=80=A6=20(#1125)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * collector/diskstats: don't fail if there are extra stats, just ignore them Signed-off-by: Paul Gier --- collector/diskstats_linux.go | 10 +++++----- collector/fixtures/e2e-64k-page-output.txt | 2 +- collector/fixtures/e2e-output.txt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/collector/diskstats_linux.go b/collector/diskstats_linux.go index b3d85b11..8efffd9e 100644 --- a/collector/diskstats_linux.go +++ b/collector/diskstats_linux.go @@ -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) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index decad909..cf67e153 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -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. diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index a1e3d76e..9cbfce16 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -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.