Add metric for configured refresh interval

This commit is contained in:
Robert Jacob 2020-06-27 18:17:33 +02:00
parent 4456ed8649
commit db8d1cbbf4

View file

@ -15,13 +15,17 @@ var (
"Zero if there was an error during the last refresh try.", "Zero if there was an error during the last refresh try.",
nil, nil) nil, nil)
refreshPrefix = prefix + "last_refresh" refreshIntervalDesc = prometheus.NewDesc(
prefix+"refresh_interval_seconds",
"Contains the configured refresh interval in seconds. This is provided as a convenience for calculations with the cache update time.",
nil, nil)
refreshPrefix = prefix + "last_refresh_"
refreshTimestampDesc = prometheus.NewDesc( refreshTimestampDesc = prometheus.NewDesc(
refreshPrefix+"_time", refreshPrefix+"time",
"Contains the time of the last refresh try, successful or not.", "Contains the time of the last refresh try, successful or not.",
nil, nil) nil, nil)
refreshDurationDesc = prometheus.NewDesc( refreshDurationDesc = prometheus.NewDesc(
refreshPrefix+"_duration_seconds", refreshPrefix+"duration_seconds",
"Contains the time it took for the last refresh to complete, even if it was unsuccessful.", "Contains the time it took for the last refresh to complete, even if it was unsuccessful.",
nil, nil) nil, nil)
@ -139,6 +143,7 @@ func (c *NetatmoCollector) Collect(mChan chan<- prometheus.Metric) {
upValue = 0 upValue = 0
} }
c.sendMetric(mChan, netatmoUpDesc, prometheus.GaugeValue, upValue) c.sendMetric(mChan, netatmoUpDesc, prometheus.GaugeValue, upValue)
c.sendMetric(mChan, refreshIntervalDesc, prometheus.GaugeValue, c.RefreshInterval.Seconds())
c.sendMetric(mChan, refreshTimestampDesc, prometheus.GaugeValue, convertTime(c.lastRefresh)) c.sendMetric(mChan, refreshTimestampDesc, prometheus.GaugeValue, convertTime(c.lastRefresh))
c.sendMetric(mChan, refreshDurationDesc, prometheus.GaugeValue, c.lastRefreshDuration.Seconds()) c.sendMetric(mChan, refreshDurationDesc, prometheus.GaugeValue, c.lastRefreshDuration.Seconds())