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

CPU Usage Plugin #33

Closed
tylernisonoff opened this issue Jun 27, 2015 · 6 comments
Closed

CPU Usage Plugin #33

tylernisonoff opened this issue Jun 27, 2015 · 6 comments

Comments

@tylernisonoff
Copy link

I want to add support for CPU Usage (percentage). I've generally seen this done by querying /proc/stat, sleeping for a second, querying again, and calculating the percentage from the diff. Does this sound reasonable if added to the current cpu plugin?

@dennisjac
Copy link

Can plugins have state? If so you could store the values and time between runs and then on the next run subtract the values from the previous run and divide by the elapsed time between the runs (which should be the interval). That way you don't have to wait a second to get an actual value and you would get an average percentage over the whole interval which is probably what most people rather want anyway.

@steverweber
Copy link

I did what @dennisjac said. needed to store the previous state and calc the deltas. but you don't need to know the elapsed time... take the total delta in ticks and divide that with the [user, nice, system, idle].

Here is one i did for heka, its in lua not go but perhaps some of the logic is still helpful.
https://github.com/mozilla-services/heka/blob/dev/sandbox/lua/filters/procstat.lua

@sparrc
Copy link
Contributor

sparrc commented Aug 5, 2015

Sounds like a good idea, should probably be integrated into the existing system plugin

@sparrc
Copy link
Contributor

sparrc commented Aug 13, 2015

this has been implemented, thanks @jpalay!

@sparrc sparrc closed this as completed Aug 13, 2015
@deanefrati
Copy link

Hi, sorry but i may be missing something... i don't see any percentage measurements is there anything special that needs to be done in order to turn these on?

@sparrc
Copy link
Contributor

sparrc commented Aug 31, 2015

@deanefrati please open a new issue if you are having problems with CPU usage reporting. Please also include Telegraf version, command you are running, and output.

thanks!

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

No branches or pull requests

5 participants