-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add optional usage_active and time_active CPU metrics #2943
Add optional usage_active and time_active CPU metrics #2943
Conversation
482e520
to
c1b7bb1
Compare
My $0.02:
|
@phemmer Good points. What would your thoughts be on tweaking the formula for busy to be The first point about computed fields is also a good one, and I'm not sure if this is something that is typically avoided in other input plugins as a matter of style/convention/agreed upon best practice. |
In general I agree with @phemmer, we should not have values that are computed based on other fields. However, this metric has been frequently requested since it's removal, since it is the most user friendly way of viewing cpu use. This is why I think we should probably make an exception here. Maybe we should take a page from collectd and add an "active" state if a |
I like the configurable option (false by default?) because it allows someone optionally to trade off a small amount of overhead for the convenience of having this computed field. Seems very flexible. Anyway, I've updated this PR accordingly to reflect that approach and have also addressed the iowait issue mentioned in the comments above. |
plugins/inputs/system/cpu.go
Outdated
@@ -116,6 +129,11 @@ func totalCpuTime(t cpu.TimesStat) float64 { | |||
return total | |||
} | |||
|
|||
func activeCpuTime(t cpu.TimesStat) float64 { | |||
active := totalCpuTime(t) - t.Idle - t.Iowait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't subtract Iowait, to match collectd.
@danielnelson the iowait subtraction issue should be addressed |
Thanks! |
An approach for solving #2710. Uses the existing code, but adds two new metrics with the assumption that
%busy=100-%idle
, andtime busy=total time-time idle
.Required for all PRs: