mirror of
				https://github.com/prometheus/node_exporter.git
				synced 2025-08-20 18:33:52 -07: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
							
								
									e824cde4e8
								
							
						
					
					
						commit
						31e0145786
					
				|  | @ -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