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

NaN returned for CPU Usage #4

Open
g-m-o-n-e-y opened this issue Dec 6, 2022 · 2 comments · May be fixed by #5
Open

NaN returned for CPU Usage #4

g-m-o-n-e-y opened this issue Dec 6, 2022 · 2 comments · May be fixed by #5

Comments

@g-m-o-n-e-y
Copy link

We're getting check output that's not helpful

check-cpu-usage OK: NaN% CPU usage | cpu_idle=NaN, cpu_system=NaN, cpu_user=+Inf, cpu_nice=NaN, cpu_iowait=NaN, cpu_irq=NaN, cpu_softirq=NaN, cpu_steal=NaN, cpu_guest=NaN, cpu_guestnice=NaN

It seems that the check is not safe from dividing by zero.

@g-m-o-n-e-y
Copy link
Author

This may only be a problem on an LXC container...I'll double check

@g-m-o-n-e-y
Copy link
Author

The issue seems to be (surprise, surprise) floating-point math. Since startTotal and endTotal are large float64s we lose the precision from a smaller User value. On our server, Idle was so large that adding it with the User removed smaller changes in value. This caused diff to always be 0 which resulted in NaN for values printed.

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 a pull request may close this issue.

1 participant