I had a little time today and needed to mentally switch gears so I took a look again at the 3i storage script for Nagios and made some changes to it to clean it up a little bit. I also made clones…er …versions rather…. for monitoring CPU status, memory status, and sensor data (i.e. fan speeds, power supply status etc). The new version takes one less command line option and connects to the host managed object a little more directly.
As discussed earlier you could use IPMI just as easily to get the sensor data as the VMware APIs, but I added it just for consistency’s sake rather than having to manage two interfaces and sets of ids and passwords. Since the only servers I have access to at the moment are new Dell Poweredge’s right now I can only assume that these will also work with other manufacturers servers as they become supported.
As a reminder you need to install the appropriate VMware pieces for these scripts to run. Namely the VMware VI-Perl toolkit.
Script arguments are the same for all four of these scripts :
check_3i_storage –password <passwd> –username <user> –server <ip addr/hostname>
check_3i_cpu –password <passwd> –username <user> –server <ip addr/hostname>
check_3i_memory –password <passwd> –username <user> –server <ip addr/hostname>
check_3i_sensors –password <passwd> –username <user> –server <ip addr/hostname>
I’ve also included the updated service and command definitions I’ve used in my test Nagios environment for reference.
define service{
use generic-service
host_name svr-esx-test-01.company.com
service_description ESX 3i Storage Status
check_command check_3i_storage!root!mypassword!
}
define command{
command_name check_3i_storage
command_line $USER1$/check_3i_storage --server $HOSTADDRESS$ --username $ARG1$ --password $ARG2$
}


[...] of the things I wanted to check in looking at Zabbix was how hard it would be to use the Nagios plugins I wrote/modified for monitoring ESX 3i in [...]
[Translate]
Hi Carlos,
I found your script and tried to use them.
I installed the VI-Perl toolkit from VMware (VMware-VIPerl-1.5.0-67153.x86_64.tar.gz) but I’m facing the following error:
Can’t locate object method “healthSystemRuntime” via package “HostRuntimeInfo” at ./check_3i_cpu.pl line 80.
I added the following line in your scripts:
use VMware::VIM2Runtime;
use VMware::VILib;
Any idea?
Regards,
Xavier
[Translate]
Hi,
I’m getting these errors when running esxi nagios scripts:
debiantest:/home/stephen# ./check_3i_cpu.pl
Name “Util::script_version” used only once: possible typo at ./check_3i_cpu.pl line 36.
Undefined subroutine &Opts::add_options called at ./check_3i_cpu.pl line 46.
[Translate]
Hei Carlos,
The check_3i_storage works as root from the command line but nagios responds with:
**ePN /usr/lib/nagios/plugins/check_3i_storage: “Can’t locate object method “BINMODE” via package “OutputTrap” at /usr/local/lib/perl5/site_perl/5.10.0/VMware/VILib.pm line 419,”.
Any thoughts?
[Translate]
peter,
I have made similiar experiences.
I suscpect the epn causing this issue. The script hangs when calling the Opts::parse() method. As a workaround I moved Carlos’s scripts to /usr/lib/nagios/plugins/esx3i/
and created shell scripts in /usr/lib/nagios/plugins/ that then call the plugin scripts.
e.g.
#!/bin/sh
/usr/lib/nagios/plugins/esx3i/check_3i_storage $*
PS: Adding a “# nagios: -epn” line to the original scripts did not work
[Translate]
I have on my to-do list to update this post. In talking with Peter about this issue earlier on it appears that between the time I wrote these original scripts (around January/February 2008) and Update 2t the toolkit has undergone some changes.
What I suggested to Peter is that he comment out lines in the file VILib.pm (425-427) which shouldn’t affect functionality. The commented out lines use binmode which in theory should have no affect on Unix/Linux based systems.
I believe Peter said this works for him even if it is not ideal.
===========================================
sub parse {
my ($pass_through_option) = @_;
if (!defined($pass_through_option)) {
$pass_through_option = ‘no_pass_through’;
}
parse_cmdline($pass_through_option);
# bug 182644
$app_name = $0;
$0 = “Hiding the command line arguments”;
parse_environment;
parse_config;
parse_stdin;
# user overwrites system encoding
$enc = get_option(‘encoding’);
if ($enc eq “utf8″) {
$enc = getencname();
}
if (defined($enc)) {
# binmode(STDIN, “:encoding($enc)”);
# binmode(STDOUT, “:encoding($enc)”);
# binmode(STDERR, “:encoding($enc)”);
}
return;
}
=======================================
[Translate]
cars,
thanks for the info. It confirms that EPN most likely causes the errors. I prefer to stay with my workaround as it don’t require to patch the perl tool kit.
If have packaged (and slightly modified the output string) your scripts into a RPM http://mirror.contribs.org/smeserver/contribs/michaelw/sme7/nagios/packages/
Cheers,
Michael
[Translate]
hi i just started to use these plugins and i get ” (Return code of 255 is out of bounds) ” in nagios. i am using nagios 3.0.3 on a centos 5 machine. any ideas? i tried commenting out the binmode stuff and it did not work. it works via command line by the way.
[Translate]
[...] sind unter http://cars.lostroncos.org/2008/03/07/updated-esx-3i-scripts-for-nagios/ einige Nagios Plugins zu finden die per VMWare PerlAPI diverse Zustände auslesen und damit eine [...]
[Translate]
We are using these scripts to monitor 2 ESX3i machines. Which is working great except that every 2 weeks we have to restart the management services on these hosts. They start responding slow to VI client requests. Also the script itself starts to indicate it can’t get any status updates from the counters anymore. After restarting the management services everything is OK again. Guests are not impacted so it’s not a big issue.
As we have support I opened a call with Vmware but they are saying they don’t want to look into it as the problem does not occur when not monitoring. Anyone els got this problem or even better: suggestions as how to prove this might be a bug (memory leak in monitoring services?) in ESX?
[Translate]
Hi Carlos,
Really nice script!However I have the same problem as “slackamp”, i got a (Return code of 255 is out of bounds) in my nagios webinterface. However manual checking goes succesful. Could you help me with that?
[Translate]
[...] while now. I thought about using Nagios to monitor your ESXi server(s) and found an article on the blog of Carlos with a great way to monitor your ESXi’s in Nagios. Carlos created the scripts, however [...]
[Translate]
[...] is just an update, but the scripts I wrote for use with Nagios and ESX3i seem to work just fine with ESX4i (at least in my home lab environment using Dell Poweredge [...]
[Translate]
[...] gotten a couple of emails recently about issues with the Nagios plugins I’ve got here. The people having issues appeared to be using really early versions of the VI-Perl toolkit from [...]
[Translate]
Thanks Carlos for this great scripts, they are very usefull.
I´ve been working with them and have the same problem mentioned in previous comments “(Return code of 255 is out of bounds)”
While the check works fine from the command line, it doesn´t in Nagios.
I´ve SOLVED it!!
The problem resides on the command definition example you´ve posted here:
define command{
command_name check_3i_storage
command_line $USER1$/check_3i_storage –server $HOSTADDRESS$ –username $ARG1$ –password $ARG2$}
On the last line, the last character should´t be “}”, this character shoud be alone in a new line:
define command{
command_name check_3i_storage
command_line $USER1$/check_3i_storage –server $HOSTADDRESS$ –username $ARG1$ –password $ARG2$
}
For copy&paste people like me this could be a trouble
This way works perfect and no more “(Return code of 255 is out of bounds)”
Glad to help others!
Facundo.
[Translate]
I started messing with this stuff just for getting the temperature value. I`m working on a Dell PE2950 and VIclient shows the temp.
I can reach the value via web console:
https://server-ip/mob/?moid=ha-host&doPath=runtime.healthSystemRuntime.systemHealthInfo.numericSensorInfo
[4] HostNumericSensorInfo
NAME TYPE VALUE
baseUnits string “Degrees C”
currentReading long 2200
That`s 22º!
I`m trying to customize the request but it`s beating me…
Can you help me with the script to get the temp into nagios??
Thanks!!
[Translate]
[...] a while now. I thought about using Nagios to monitor my ESXi server(s) and found an article on the blog of Carlos with a great way to monitor your ESXi’s in Nagios. Carlos created the scripts, however I want to [...]
[Translate]
Facundo – Thanks for the catch, I’ll fix the post.
[Translate]
jfacundo – modified the scripts to solve his particular need. With his permission, it’s available here.
[Translate]
Hi,
Thank you for the script. I need your help with the check_3i_storage script. The script only changes status when the status in Virtual Client changes to Warning or Alarm. However, when the status in VC is unknown, the script does not update the status in Nagios to reflect that. Please help me with the script to get it to recognize the unknown status. Btw all the plugin links points to check_3i_storage. Can you fix that as well? Thank you!!
[Translate]
Re: http://cars.lostroncos.org/2008/03/07/updated-esx-3i-scripts-for-nagios/comment-page-1/#comment-43 – You can also prefix the check command with “/usr/bin/perl ” (no quotes). It also takes care of the issue.
[Translate]
Great scripts BTW! Im using the modified script at:
http://cars.lostroncos.org/wp-content/uploads/2009/09/check_dell2950_temp.txt
to show the amps, but the output “Power Supply 1 Current 1 – Normal has status of 68 Amps” on the Nagios URL is alerting as critical even though it is normal. Is there something i am missing?
[Translate]