» Nagios Plugins
Nagios Plugin: check_esxi_hardware.py
Last Update:
April 24, 2013
This script is a Nagios plugin to monitor the hardware of ESX and ESXi servers.
It can also be used as standalone script to check the hardware - Nagios isn't
necessary to run it. The plugin is written in python, so you need to have python
installed. See Requirements for more information.
Jump to:
Download
Version History
FAQ
Requirements
Definition of parameters
Usage / Command-line usage
Command definition examples
Service definition examples
Using username/password in file
Screenshots
------------
Download
 |
check_esxi_hardware.py
Download plugin and save it in your Nagios plugin folder (e.g. /usr/local/nagios/libexec)
20920 downloads so far... |
------------
Version History
20080820 Initial release by David
Ligeret
20080821 Add verbose mode by David
Ligeret
20090219 Add try/except to catch AuthError and CIMError by Joshua
Daniel Franklin
20100202 Added HP Support (HealthState) by
Branden Schneider
20100512
Combined different versions (Joshua and Branden) and added hardware type switch
20100628
Outputs server model, s/n and bios version and set Unknown as default exit code
by Samir Ibradzic
20100702 GlobalStatus was incorrectly getting (re)set to OK with every CIM element
check by Aaron Rogers
20100705
After last version all Dell servers return UNKNOWN instead of OK, added Aaron's
logic for Dell checks as well
20101028 Changed text in Usage and Example so people dont forget to use https://
20110110
If Dell Blade Servers were used, Serial Number of Chassis instead of Blade was
returned - by Ludovic Hutin
20110207 Bugfix/new feature for Intel server systems by Carsten
Schoene
20110215
Plugin now catches Socket Error (Timeout Error) and added a timeout parameter
by Ludovic Hutin
20110221
Removed recently added timeout parameter due to incompatibility on Windows systems
20110221
Changed plugin name from check_esxi_wbem.py to check_esxi_hardware.py
20110426
Added 'ibm' hardware type (compatible to Dell output). Tested by Keith Erekson
on an IBM x3550
20110503
Plugin rewritten, added automatic hardware detection, opt params, perfdata and
much more by Phil
Randal
20110504
Some minor code changes, removed typo, bugfix for voltage sensors on IBM server
by Phil
Randal
20110505
Added possibility to use first line of a file as password (file:) by Fredrik
Åslund
20110507 A lot of bugfixes and enhancements from Phil
Randal (see changelog in plugin for details)
20110520
Bugfix for IBM Blade Servers by Bertrand Jomin
20110614
Rewrote external file handling, file can now be used for password AND username
20111003
Added ignore option to ignore certain elements by Ian
Chard
20120402
Making plugin GPL compatible (Copyright) and preparing for OpenBSD port
20120405
Fix lookup of warranty info for Dell by Phil
Randal
20120501
Bugfix in manufacturer discovery when cim entry not found or empty by Craig
Hart
20121027
Workaround for Dell PE x620 for Riser Config Err 0: Connected element (wrong
return code)
20130424
Another workaround for Dell systems "System Board 1 LCD Cable Pres 0: Connected"
------------
FAQ
Take a look at this article to find some frequently asked questions and their
answers:
http://www.claudiokuenzler.com/blog/308/check-esxi-hardware-faq-frequently-asked-questions
------------
Requirements
- Python must be installed
- The Python extension pywbem
must be installed
Windows users click here for a step-by-step guide how to install
Python and PyWBEM on a Windows server.
- If there is a firewall between your monitoring and ESXi server, open ports
443 and 5989
------------
Definition of the parameters
| Short |
Long |
Description |
| -H |
--host |
Hostname or IP address of ESX/ESXi server |
| -U |
--user |
Username to check (must be a local user on target host) Note:
If you don't want to use your root user, use this
workaround
Use file:/path/to/.file to use first string as username |
| -P |
--password |
Password for given user Use file:/path/to/.file to use second
string as password - this won't show the password in servers process list |
| -V |
--vendor |
(hw_type) Define the vendor of the server: auto, dell, hp, ibm, intel,
unknown (default) |
| auto |
Plugin tries to determine hardware itself by using CIM entries |
| dell |
For DELL servers use dell as hw/vendor type |
| hp |
For HP servers use hp as hw/vendor type |
| ibm |
For IBM servers use ibm as hw/vendor type |
| intel |
For some servers using Intel motherboards this might be needed |
| unknown |
If no hw/vendor type was given, unknown will be used (like auto) |
| -i |
--ignore |
Ignore given list (comma separated) of elements |
| -v |
--verbose |
Verbose/detailled output for debugging |
| -p |
--perfdata |
Include server perfdata for graphics like PNP4Nagios or Nagiosgraph |
| -I |
--html |
Add web-links to hardware manuals for Dell servers (use your country extension) |
------------
Usage
./check_esxi_hardware.py -H esxi-server-ip -U username
-P mypass [-V -i -v -p -I xx]
./check_esxi_hardware.py --host esxi-server-ip --user username --password mypass
[--vendor --ignore --verbose --perfdata --html xx]
./check_esxi_hardware.py -H esxi-server-ip -U -P file:/path/to/.passwdfile [--vendor
--ignore --verbose --perfdata --html xx]
./check_esxi_hardware.py -H esxi-server-ip -U file:/path/to/.passwdfile -P file:/path/to/.passwdfile
[--vendor -i -v -p --html xx]
Examples:
./check_esxi_hardware.py -H 10.0.0.200 -U root -P mypass
-V dell -p -I de
./check_esxi_hardware.py --host esxiserver1 --user root --password mypass --vendor
hp --perfdata
./check_esxi_hardware.py --host esxiserver2 --user root --password mypass --vendor
dell --html us
./check_esxi_hardware.py -H esxiserver1 -U root -P file:/root/.esxipass -V dell
./check_esxi_hardware.py -H esxiserver1 -U file:/root/.esxipass -P file:/root/.esxipass
-V dell
./check_esxi_hardware.py -H esxiserver1 -U root -P mypass -V dell -i "IPMI
SEL"
------------
Command definition
in your commands.cfg:
# 'check_esxi_hardware' command definition
define command{
command_name check_esxi_hardware
command_line $USER1$/check_esxi_hardware.py -H $HOSTADDRESS$ -U $ARG1$ -P $ARG2$ -V $ARG3$
}
Command definition in your commands.cfg with optional parameter:
# 'check_esxi_hardware' command definition
define command{
command_name check_esxi_hardware
command_line $USER1$/check_esxi_hardware.py -H $HOSTADDRESS$ -U $ARG1$ -P $ARG2$ -V $ARG3$ $ARG4$
}
Command definition in your commands.cfg with password read from file:
# 'check_esxi_hardware' command definition
define command{
command_name check_esxi_hardware
command_line $USER1$/check_esxi_hardware.py -H $HOSTADDRESS$ -U $ARG1$ -P file:$ARG2$ -V $ARG3$ $ARG4$
}
Command definition in your commands.cfg with user and password
read from file:
# 'check_esxi_hardware' command definition
define command{
command_name check_esxi_hardware
command_line $USER1$/check_esxi_hardware.py -H $HOSTADDRESS$ -U file:$ARG1$ -P file:$ARG2$ -V $ARG3$ $ARG4$
}
------------
Service check on a HP Server:
# Check HP Server hardware
define service{
use generic-service
host_name esxi1
service_description Hardware
check_command check_esxi_hardware!root!mypass!hp
}
Service check on a DELL Server:
# Check DELL Server hardware
define service{
use generic-service
host_name esxi2
service_description Hardware
check_command check_esxi_hardware!root!mypass!dell
}
Service check on a DELL Server with perfdata:
# Check DELL Server hardware
define service{
use generic-service
host_name esxi2
service_description Hardware
check_command check_esxi_hardware!root!mypass!dell!--perfdata
}
Service check on a DELL Server with password read from file:
# Check DELL Server hardware
define service{
use generic-service
host_name esxi2
service_description Hardware
check_command check_esxi_hardware!root!/home/nagios/.esxipass!dell
}
Service check on a HP Server with user and password read from file:
# Check HP Server hardware
define service{
use generic-service
host_name esxi1
service_description Hardware
check_command check_esxi_hardware!/home/nagios/.esxipass!/home/nagios/.esxipass!hp
}
Service check on an IBM Server:
# Check IBM Server hardware
define service{
use generic-service
host_name esxi3
service_description Hardware
check_command check_esxi_hardware!root!mypass!ibm
}
Service check on an IBM Server where System Event Log alerts should
be ignored :
# Check IBM Server hardware
define service{
use generic-service
host_name esxi3
service_description Hardware
check_command check_esxi_hardware!root!mypass!ibm!-i "IPMI SEL"
}
------------
File handling for user and password (for
better security!)
Since version 20110505 it is possible to use a file as password-source. The
string in the given file is used as password.
Since version 20110614 the file can be used for both username and password.
This is a big security advantage, because the process on the Nagios server won't
show the username or password in cleartext. If no file is used, these values
will be shown in cleartext in the processlist.
Please watch out for the correct usage!
Example 1: You want to use a file (/home/nagios/.esxipass) which contains username and password. Note that two strings are separated by a space:
# cat /home/nagios/.esxipass
root mypass123
# ./check_esxi_hardware.py -H 172.17.16.131 -U file:/home/nagios/.esxipass -P file:/home/nagios/.esxipass -V dell
Example 2: You only want to use a file for the password. Note that there is only one string in the file:
# cat /home/nagios/.esxipass
mypass123
# ./check_esxi_hardware.py -H 172.17.16.131 -U root -P file:/home/nagios/.esxipass -V dell
------------
Nagios Screenshots

DELL: Status Critical: Disk Fault/Raid degraded

DELL: Status Critical: IPMI SEL (=System Event Log)

HP: Status Warning: Storage Battery

HP: Status OK
|