mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-06 10:36:36 +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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(dst_cache) > 0 {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ServiceCache_ActiveFlushedEntries,
|
c.ServiceCache_ActiveFlushedEntries,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -1946,6 +1947,7 @@ func (c *IISCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, e
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(dst_cache[0].OutputCacheTotalFlushes),
|
float64(dst_cache[0].OutputCacheTotalFlushes),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user