projects
/
rabbit_go
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8eca8b7
)
heap metrics on reprocess
master
author
jweigele
<jweigele@local>
Wed, 14 Aug 2024 02:43:28 +0000
(19:43 -0700)
committer
jweigele
<jweigele@local>
Wed, 14 Aug 2024 02:43:28 +0000
(19:43 -0700)
Dockerfile.reprocess
patch
|
blob
|
history
reprocess/main.go
patch
|
blob
|
history
diff --git
a/Dockerfile.reprocess
b/Dockerfile.reprocess
index 3d325552716ce8dffd6e38db26b099b2e03c8bce..0f68dacd69d06a6eaee7df2bb5fa8b068f09a0a9 100644
(file)
--- a/
Dockerfile.reprocess
+++ b/
Dockerfile.reprocess
@@
-1,5
+1,5
@@
# STEP 1 build executable binary
# STEP 1 build executable binary
-FROM golang:alpine
as
builder
+FROM golang:alpine
AS
builder
# Install SSL ca certificates
RUN apk update && apk add git && apk add ca-certificates
# Create appuser
# Install SSL ca certificates
RUN apk update && apk add git && apk add ca-certificates
# Create appuser
diff --git
a/reprocess/main.go
b/reprocess/main.go
index ad571314c919f20feec9deca03fffab7e484db7e..6e7e569eeebecb9ed4792d2b34eb42a510c9b1bc 100644
(file)
--- a/
reprocess/main.go
+++ b/
reprocess/main.go
@@
-92,6
+92,14
@@
var (
[]string{"location", "app_version", "idf_version", "mac", "ext"},
)
[]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",
uptimeGauge = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "sensor_uptime",
@@
-132,6
+140,7
@@
var (
co2Expire = make(map[string]time.Time)
humidityExpire = make(map[string]time.Time)
versionExpire = make(map[string]time.Time)
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)
uptimeExpire = make(map[string]time.Time)
internalTempExpire = make(map[string]time.Time)
@@
-342,9
+351,10
@@
func handleVersion(obj map[string]interface{}) {
"ext": extAddr,
}).Set(1)
"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()
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
}
versionExpire[versionHash.getHash()] = now
}
@@
-562,6
+572,18
@@
func hexCommon(location string, friendlyName string, obj map[string]interface{},
processUptime(location, friendlyName, uptime, sendChannel)
}
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()
}
func (dev *hexdevice) handleHex(obj map[string]interface{}, sendChannel chan helper.RabbitSend) {
//now := time.Now().UTC()
@@
-801,6
+823,7
@@
func expireStaleMetrics() {
expireStaleMetric(co2Expire, co2Gauge)
expireStaleMetric(humidityExpire, humidityGauge)
expireStaleMetric(versionExpire, versionGauge)
expireStaleMetric(co2Expire, co2Gauge)
expireStaleMetric(humidityExpire, humidityGauge)
expireStaleMetric(versionExpire, versionGauge)
+ expireStaleMetric(heapExpire, heapGauge)
expireStaleMetric(uptimeExpire, uptimeGauge)
expireStaleMetric(internalTempExpire, internalTempGauge)
expireStaleMetric(uptimeExpire, uptimeGauge)
expireStaleMetric(internalTempExpire, internalTempGauge)