-
Notifications
You must be signed in to change notification settings - Fork 78
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
Implement load averages for Windows #115
Conversation
Chatted with @narph and @andrewkroh off-PR and came up with a few things to look into:
|
Here's the code of how Linux calculates load averages: https://github.com/torvalds/linux/blob/master/kernel/sched/loadavg.c |
@ycombinator Given that we closed elastic/beats#9944 were you thinking that we would keep this open or close it? |
Thanks @cachedout. Yes, we should close this one too. |
Resolves #114.
This PR attempts to implement this method:
gosigar/sigar_windows.go
Lines 57 to 59 in 7bed239
Concretely, it does the following:
Whenever the above method is called, i.e. load averages for a Windows system are requested, the code actually takes a sample of the current load average. This load average is based on the length of the processor queue, which is the number of processes waiting for CPU time. It's not a perfect approximation of system load.
Over time, several samples get collected. Adding a new sample also does a bit of clean up to make sure we don't keep samples older than 15 minutes, which is the max. time necessary to generate the 15-minute load average.
The samples are used to compute the 1-minute, 10-minute, and 15-minute averages.
Caveats
This implementation is simple but suffers from a couple of drawbacks:
The first few invocations of the above method will not return useful load averages, as enough samples have not yet been collected.
The frequency of sample collection == frequency of method invocation. So if the method is invoked very infrequently, fewer samples will be collected, leading to very imprecise load averages.
An alternative implementation could involve decoupling the sampling from the invocation of the above method. Sampling go happen on a timer in a goroutine.