Fix for Prometheus

* Fix pushToGateway needs grouping

* Add a timeout on python3 polling

* Set executable bit on scripts
This commit is contained in:
Poil 2020-12-30 12:07:09 +01:00 committed by GitHub
parent 7f61b12c3b
commit a2fcc6a911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 20 additions and 3 deletions

0
LYWSD03MMC.py Normal file → Executable file
View File

0
iniToJSON.py Normal file → Executable file
View File

0
jsonToIni.py Normal file → Executable file
View File

View File

@ -18,7 +18,7 @@ honor_labels: true
Script will make one mesure and call script that send data to prometheus push gateway
> python3 ./LYWSD03MMC.py --device XX:XX:XX:XX:XX:XX --round --debounce -call ./prometheus/promExporter.py -n living_room -c 1
> python3 ./LYWSD03MMC.py --device XX:XX:XX:XX:XX:XX --round --debounce -call ./prometheus/sendToPrometheus.py -n living_room -c 1
## Grafana Dashboard

4
prometheus/sendToPrometheus.py Normal file → Executable file
View File

@ -3,7 +3,7 @@
import sys
from prometheus_client import CollectorRegistry, Gauge, push_to_gateway
PROMETHEUS_URL = "http://raspberrypi:9091"
PROMETHEUS_URL = "http://localhost:9091"
val_sensor = sys.argv[2]
val_temp = sys.argv[3]
@ -20,4 +20,4 @@ t.labels(val_sensor).set(val_temp)
h.labels(val_sensor).set(val_hum)
bv.labels(val_sensor).set(val_bat)
push_to_gateway(PROMETHEUS_URL, job='tempBatch', registry=registry)
push_to_gateway(PROMETHEUS_URL, job='tempBatch', grouping_key={'sensor': val_sensor}, registry=registry)

0
sendToFile.sh Normal file → Executable file
View File

0
sendToInflux.sh Normal file → Executable file
View File

0
sendToMQTT.sh Normal file → Executable file
View File

0
sendToNodeRed.sh Normal file → Executable file
View File

17
sendToPrometheusPushGateway.sh Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/bash
captors="A4:C1:38:0B:F8:E1 cave_garage
A4:C1:38:1E:8E:43 escalier_sous_sol
A4:C1:38:5D:FB:DC salle_de_bain
A4:C1:38:6F:1D:80 salon
A4:C1:38:78:6D:F6 cave_bureau
A4:C1:38:9C:E3:70 chambre_verte
A4:C1:38:BB:54:29 cave_buanderie
A4:C1:38:CF:FD:78 chambre_bleue"
while :; do
echo "$captors" | while read captor; do
# python3 ./LYWSD03MMC.py --device ${captor% *} --round --debounce -c 1
timeout -k 5 30 python3 ./LYWSD03MMC.py --device ${captor% *} --round --debounce -call ./prometheus/sendToPrometheus.py -n ${captor#* } -c 1 -urc 1
done
done