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

Wrong CPU Usage percentage #202

Open
RootGeorg opened this issue Jan 24, 2023 · 7 comments · May be fixed by #206
Open

Wrong CPU Usage percentage #202

RootGeorg opened this issue Jan 24, 2023 · 7 comments · May be fixed by #206

Comments

@RootGeorg
Copy link

RootGeorg commented Jan 24, 2023

I'm having troubles with the CPU usage trying to monitor an ESXi host directly (not through vCenter).
It returns me an usage of 0.0n or 0.nn when it's absolutely wrong:
OK: CPU usage=0.16%|'cpu_usage'=0.16%;;;;
I tried with the old check_vmware_api.pl and it works fine:
CHECK_VMWARE_API.PL OK - cpu usage=43.98 % | cpu_usage=43.98%;;
My environment:
perl version:
v5.32.1
vmware SDK version:
vSphere SDK for Perl version: 6.5.0
Script 'vmware-cmd' version: 6.5.0
ESXi Hosts version: 6.5

@RootGeorg RootGeorg changed the title Worng CPU Usage percentage Wrong CPU Usage percentage Jan 24, 2023
@BaldMansMojo
Copy link
Owner

Strange. Nobody else reported that error. I need your check definition. So I can try to reproduce it.

@jhuebner79
Copy link

We had the same, first of all there is a factor of * 0.01 (L.174 and L.178 in host_cpu_info.pm), which seems wrong - and even after removing that from host_cpu_info.pm the values were different from the old check_vmware_api.pl, which we now use for the CPU percentage.

@jhuebner79
Copy link

So the diff/command in our case is/was:

 object CheckCommand "vmware_api_CPU_Usage" {
   import "plugin-check-command"
-  command = CustomPluginDir + "/check_vmware_esx.pl -H '$address$' -u '$vmware_user$' -p '$vmware_password$' -S cpu -s usage -w 80 -c 90"
+  command = CustomPluginDir + "/check_vmware_api.pl -H '$address$' -u '$vmware_user$' -p '$vmware_password$' -l cpu -s usage -w 80 -c 90"
 }

@RootGeorg
Copy link
Author

If i execute the check directly it also fails. With check_vmware_esx:
root@hostname:/usr/local/nagios/libexec# ./check_vmware_esx -H x.x.x.x -u nagiosuser -p passwd -S cpu -s usage -w 80 -c 90
OK: CPU usage=0.10%|'cpu_usage'=0.10%;80;90;;
With check_vmware_api:
root@hostname:/usr/local/nagios/libexec# ./check_vmware_api.pl -H x.x.x.x -u nagiosuser -p passwd -l cpu -s usage -w 80 -c 90
CHECK_VMWARE_API.PL OK - cpu usage=43.94 % | cpu_usage=43.94%;80;90

@onkelbeh
Copy link

onkelbeh commented Mar 1, 2023

same here with 7.03

@ironiq
Copy link

ironiq commented Jul 12, 2023

I think i tracked down what the problem can be: in L178 of host_cpu_info.pm the array entry is wrong. It should be $$values[0][3]->value. This gives me exactly the same result as check_vmware_api.pl. Shall i open a pull request for this?

edit: i forgot to mention that i tried it with both 6.5 and 7.0.3 ESXi versions.

@ironiq ironiq linked a pull request Jul 12, 2023 that will close this issue
@BaldMansMojo
Copy link
Owner

YeThx. Faster than my answer.

antonfischl1980 added a commit to antonfischl1980/icinga that referenced this issue Jul 18, 2023
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.

5 participants