enviroplus_exporter
enviroplus_exporter copied to clipboard
Sleep at end of main thread (or option to)
Hello,
When running the exporter, I noticed on a ZeroW it's pretty much pegging the CPU at 50% all the time. Looking at your code I can see that you're trying to gather the sensor data in a really tight loop. For my needs this isn't necessary, so I added a 10s sleep which cuts the CPU usage to essentially zero (~2% when gathering). Prometheus is only scraping every 10s anyway, so updating the sensor data more often isn't necessary.
It would be nice if this was an option, so that we can reduce CPU usage when we don't need the most up-to-date sensor data on every metrics poll.
Alternatively adding a 1s sleep in may be enough to limit CPU usage while still providing up-to-date data - it's unlikely anyone (sensible) is running Prometheus with a sub-second scrape interval.
Makes sense to include this. Will introduce this when I have the time.