Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sleep at end of main thread (or option to) #14

Open
Xiol opened this issue Mar 24, 2021 · 1 comment
Open

Sleep at end of main thread (or option to) #14

Xiol opened this issue Mar 24, 2021 · 1 comment

Comments

@Xiol
Copy link

Xiol commented Mar 24, 2021

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.

@tijmenvandenbrink
Copy link
Owner

Makes sense to include this. Will introduce this when I have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants