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

Adds CPU busy time and percentages #111

Closed
wants to merge 1 commit into from

Conversation

jpalay
Copy link
Contributor

@jpalay jpalay commented Aug 13, 2015

The CPU plugin now collects the percentage of time the processor spends in various areas. It does this by remembering the CPU metrics it gathered the last time telegraf ran the plugin. It then looks at the difference between the current CPU metrics and the CPU metrics gathered last in order to determine how the CPU has spent its time.

Also, because InfluxDB 0.9 does not support adding together values from different series, I updated the CPU plugin to also collect one calculated metric, busy time, which is just the sum of all the CPU metrics besides the idle time.

return nil
}

func busyAndTotalCpuTime(t cpu.CPUTimesStat) (float64, float64) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please document this function with a comment stating what the two float64 values are

@sparrc
Copy link
Contributor

sparrc commented Aug 13, 2015

@jpalay looks good I can merge once these few small things have been taken care of, and thank you for the thorough testing!

}

if totalDelta == 0 {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be continue instead of return nil, otherwise if we can't get percentages for one CPU then we get no stats at all for the rest.

sparrc added a commit that referenced this pull request Aug 13, 2015
sparrc added a commit that referenced this pull request Aug 13, 2015
@sparrc
Copy link
Contributor

sparrc commented Aug 13, 2015

I started working on some CPU things and wanted to get this in, so I went ahead and rebased it, made some small changes like those I commented on, and pushed

thanks much @jpalay!

@sparrc sparrc closed this Aug 13, 2015
@jpalay
Copy link
Contributor Author

jpalay commented Aug 13, 2015

Ok great, thanks! I also had some other thoughts about the CPU plugin, but I'll propose them in a separate PR

@jpalay jpalay deleted the cpu_percentages_with_busy branch August 14, 2015 00:46
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 this pull request may close these issues.

2 participants