mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-25 13:44:10 -08:00
Fix pressure collector nil reference (#3016)
Check that the PSI metrics are returned in order to avoid nil pointer dereference. * Update fixutre to match real-world samples. Fixes: https://github.com/prometheus/node_exporter/issues/3015 Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
parent
66fab10db4
commit
3afc0a341e
|
@ -1 +1,2 @@
|
||||||
some avg10=0.00 avg60=0.00 avg300=0.00 total=14036781
|
some avg10=0.00 avg60=0.00 avg300=0.00 total=14036781
|
||||||
|
full avg10=0.00 avg60=0.00 avg300=0.00 total=0
|
||||||
|
|
|
@ -102,6 +102,14 @@ func (c *pressureStatsCollector) Update(ch chan<- prometheus.Metric) error {
|
||||||
}
|
}
|
||||||
return fmt.Errorf("failed to retrieve pressure stats: %w", err)
|
return fmt.Errorf("failed to retrieve pressure stats: %w", err)
|
||||||
}
|
}
|
||||||
|
if vals.Some == nil {
|
||||||
|
level.Debug(c.logger).Log("msg", "pressure information returned no 'some' data")
|
||||||
|
return ErrNoData
|
||||||
|
}
|
||||||
|
if vals.Full == nil {
|
||||||
|
level.Debug(c.logger).Log("msg", "pressure information returned no 'full' data")
|
||||||
|
return ErrNoData
|
||||||
|
}
|
||||||
switch res {
|
switch res {
|
||||||
case "cpu":
|
case "cpu":
|
||||||
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, float64(vals.Some.Total)/1000.0/1000.0)
|
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, float64(vals.Some.Total)/1000.0/1000.0)
|
||||||
|
|
Loading…
Reference in a new issue