CPU idle time in cpu utilization and counter improvements #308
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Go psutil library was already reporting cpu idle time, take and expose it in the check.
Additionally, fix some of the bugs in the counter class, add getFirst() to get the earliest written value in the counter, add checkRetention() to check if the counter is designed to hold values with that much distance apart with its size.
Use these counter functions to return a nil result if the counter cannot fit the query range for check_cpu, even if it was extended. Like the case where user asks for 1 week of cpu utilization time when the counter can hold up to 1 hour.
Log information about the query range and the range recorded in the counters, and if the counter range is representative of the query. The check will return if the counter recorded cpu utilization in an interval no matter how small it is, but will complain if the recorded range is less than %50 of the query range in the logs.