Closed thepiwo closed 3 years ago
Hi thepiwo,
for debugging this issue, please use sendToFile.sh
as callback. Then in another window do tail -f data.txt
and have a look if there are the current values which are also shown on the displays of the sensor.
Indeed logging to file seems to be current all the time with the display on the sensor, in the data file as well as the python log.
Does that mean the pushgateway is just to slow and getting stuck in some queue?
Actually it seems like exactly this, the sendToPrometheus script is always at 100% CPU. Can I limit the interval of the sending some way?
What device are you running on? How many sensors do you use?
Can I limit the interval of the sending some way?
The easiest way is to change these parameters 2500ms x 4 = 10.000ms, this means every 10 seconds a new value. So increase these parameters for having less frequent new data transmitted via callback.
It's the LYWSD03MMC, with 11 devices total, 5 on one pi zero, 6 on the other.
Thanks, I guess I'll look for a solution where I integrate the sendToPrometheus in the main script on order to not have the full python initialization for each value to be sent.
I don't have experience with Prometheus, but perhaps it is also possible to get the data via MQTT into it. Or you have to look into the script and change it that way that the prometheus code is integrated. I would also then check if prometheus accepted that data, so that it is retransmitted when prometheus was offline and goes back online and no data is lost.
Thank you so far, I will try out a few things.
indeed initializing python for each callback was the bottleneck, I copied the prometheus push to gateway over the default callback and it works without issue and without increased cpu load.
https://github.com/thepiwo/MiTemperature2/commit/adce55bc89cd84ac81773249f7d4c2b59f317be9
using this command:
/home/pi/MiTemperature2/LYWSD03MMC.py --atc --watchdogtimer 5 --battery --round -deb -call ./prometheus/sendToPrometheus.py --devicelistfile /home/pi/MiTemperature2/devicefile.ini --onlydevicelist
ATC Firmware with Atc1441 type otherwise default values of 2500ms interval.
Reported values in call seems to be stuck over time and what's send doesn't change in a significant way. I fail to find where the actual values that are sent are gathered.
Before a restart of the script the values only change in minor way. After restart the values change instantly to the actually broadcasted values. The Android MijiaTemp App always reports the correct latest values, as does the BLE packet log.
e.g.