[]string{"location", "app_version", "idf_version", "mac", "ext"},
)
+ heapGauge = promauto.NewGaugeVec(
+ prometheus.GaugeOpts{
+ Name: "sensor_heap",
+ Help: "Heap free for a given mac",
+ },
+ []string{"location"},
+ )
+
uptimeGauge = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "sensor_uptime",
co2Expire = make(map[string]time.Time)
humidityExpire = make(map[string]time.Time)
versionExpire = make(map[string]time.Time)
+ heapExpire = make(map[string]time.Time)
uptimeExpire = make(map[string]time.Time)
internalTempExpire = make(map[string]time.Time)
"ext": extAddr,
}).Set(1)
- versionHash := labelValHash{labelValues: []string{obj["location"].(string), obj["app_version"].(string), obj["idf_version"].(string), obj["mac"].(string), extAddr}}
expireMutex.Lock()
defer expireMutex.Unlock()
+
+ versionHash := labelValHash{labelValues: []string{obj["location"].(string), obj["app_version"].(string), obj["idf_version"].(string), obj["mac"].(string), extAddr}}
versionExpire[versionHash.getHash()] = now
}
processUptime(location, friendlyName, uptime, sendChannel)
}
+ // older versions don't contain heap
+ heapVal, ok := obj["heap"].(float64)
+ if ok {
+ now := time.Now().UTC()
+ expireMutex.Lock()
+ defer expireMutex.Unlock()
+ heapGauge.With(prometheus.Labels{"location": obj["location"].(string)}).Set(heapVal)
+ heapHash := labelValHash{labelValues: []string{obj["location"].(string)}}
+ heapExpire[heapHash.getHash()] = now
+
+ }
+
}
func (dev *hexdevice) handleHex(obj map[string]interface{}, sendChannel chan helper.RabbitSend) {
//now := time.Now().UTC()
expireStaleMetric(co2Expire, co2Gauge)
expireStaleMetric(humidityExpire, humidityGauge)
expireStaleMetric(versionExpire, versionGauge)
+ expireStaleMetric(heapExpire, heapGauge)
expireStaleMetric(uptimeExpire, uptimeGauge)
expireStaleMetric(internalTempExpire, internalTempGauge)