mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-12 05:26:37 +00:00
fix iis collector panic
If the `dst_cache` slice is empty, the program panics when trying to access `dst_cache[0]`
added a `if len(dst_cache) > 0 {}` block around the use of that variable to prevent that panic.
This commit is contained in:
@@ -1738,6 +1738,7 @@ func (c *IISCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(dst_cache) > 0 {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ServiceCache_ActiveFlushedEntries,
|
||||
prometheus.GaugeValue,
|
||||
@@ -1946,6 +1947,7 @@ func (c *IISCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, e
|
||||
prometheus.CounterValue,
|
||||
float64(dst_cache[0].OutputCacheTotalFlushes),
|
||||
)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user