Export Battery status, Wifi and RF signal strength (#4)

This commit is contained in:
herver 2018-10-06 15:24:55 +02:00 committed by Robert Jacob
parent 1078a7301d
commit 95b0de08dd
1 changed files with 26 additions and 0 deletions

View File

@ -78,6 +78,22 @@ var (
"Rain amount in millimeters",
varLabels,
nil)
batteryDesc = prometheus.NewDesc(
prefix+"battery_percent",
"Battery remaining life (10: low)",
varLabels,
nil)
wifiDesc = prometheus.NewDesc(
prefix+"wifi_signal_strength",
"Wifi signal strength (86: bad, 71: avg, 56: good)",
varLabels,
nil)
rfDesc = prometheus.NewDesc(
prefix+"rf_signal_strength",
"RF signal strength (90: lowest, 60: highest)",
varLabels,
nil)
)
type netatmoCollector struct {
@ -157,6 +173,16 @@ func collectData(ch chan<- prometheus.Metric, device *netatmo.Device, stationNam
if data.Rain != nil {
sendMetric(ch, rainDesc, prometheus.GaugeValue, float64(*data.Rain), moduleName, stationName)
}
if device.BatteryPercent != nil {
sendMetric(ch, batteryDesc, prometheus.GaugeValue, float64(*device.BatteryPercent), moduleName, stationName)
}
if device.WifiStatus != nil {
sendMetric(ch, wifiDesc, prometheus.GaugeValue, float64(*device.WifiStatus), moduleName, stationName)
}
if device.RFStatus != nil {
sendMetric(ch, rfDesc, prometheus.GaugeValue, float64(*device.RFStatus), moduleName, stationName)
}
}
func sendMetric(ch chan<- prometheus.Metric, desc *prometheus.Desc, valueType prometheus.ValueType, value float64, moduleName string, stationName string) {