Monitoring VMware ESXi and vSphere with Nagios

Installation Requirements
Perl 5.8
Several supporting Perl modules:
Crypt-SSLeay (0.51) [Crypt::SSLeay]
Data-Dumper (2.102) [Data::Dumper]
MethodMaker (2.0.8) [Class::MethodMaker]
XML-LibXML (1.60) [XML::LibXML]
libwww-perl (5.805) [LWP]

Install all the dependencies of Perl SDK.

[root@nagios~]# perl -MCPAN -e shell

The above command shall bring you to the perl cpan install CLI. This will allow you to install requirements for Perl.


cpan> install Crypt::SSLeay


The prerequisite for the plugin to work is to install the VMWare Perl SDK.

Download the VMWare Perl SDK  from following url and untar it:


[root@nagios~]# tar xvzf VMware-vSphere-Perl-SDK-5.0.0-422456.i386.tar

set http and ftp proxy to null before running the installer

[root@nagios~]# export http_proxy=

[root@nagios~]# export ftp_proxy=

[root@nagios~]# cd vmware-vsphere-cli-distrib/


“Creating a new vSphere CLI installer database using the tar4 format.

Installing vSphere CLI.

You must read and accept the vSphere CLI End User License Agreement to continue.
Press enter to display it.”

“Read through the License Agreement”

“Do you accept? (yes/no)”

“In which directory do you want to install the executable files?

“The following Perl modules were found on the system but may be too old to work
with vSphere CLI:


The installation of vSphere CLI 4.0.0 build-161974 for Linux mcompleted successfully. You can decide to remove this software from your system at any time
by invoking the following command:


Now Download nagios check plugin from

[root@nagios~]# git clone git://

Now make the plugin executable and run it

[root@nagios~]# cd op5plugins/

[root@nagios~]# chmod +x *.pl

Change the ownership to nagios for all plugins

[root@nagios~]# chown nagios:nagios *.pl

[root@nagios~]# ./

Note: sometimes it will give you error that perl-nagios plugin is not found. Install the required plugin and related dependencies.

Download the required rpms from the url given below

[root@nagios~]# wget

[root@nagios~]# wget

[root@nagios~]# wget

[root@nagios~]# rpm -ivh perl-Nagios-Plugin-0.35-1.el6.noarch.rpm perl-Config-Tiny-2.12-7.1.el6.noarch.rpm perl-Params-Validate-0.92-3.el6.i686.rpm

Now try to run the check_vmware_api plugin

[root@nagios~]# ./

Copy all the plugins from vmware-vsphere-cli-distrib/ directory to /usr/local/nagios/libexec

[root@nagios~]# cd /root/vmware-vsphere-cli-distrib/

[root@nagios~]# cp -arv *.pl /usr/local/nagios/libexec/

Now its time to configure nagios so that it can monitor the esxi hosts.

First of all we’ll need a username and password to access the ESXi host,define those Nagios variables in /etc/nagios/resource.cfg

we’ll be monitoring these resources : CPU, memory usage, net usage, runtime status and IO/read/write.

create vmware definition (servers which you want to monitor)

# vim /usr/local/nagios/etc/objects/vmware.cfg

First define all your hosts as shown below

Similarly you can define all the hosts

# Now define a hostgroup for your Esxi Hosts:

# Now create the service definition as shown below

Define the commands related to ESXi in the /usr/local/nagios/etc/objects/command.cfg file

# vim /usr/local/nagios/etc/objects/commands.cfg

Now give the path of file in which you have defined your esxi hosts and hosts-group in nagios.cfg

vim /usr/local/nagios/etc/nagios.cfg


That is it. Restart your nagios service and you are ready to monitor your esxi servers.

One thought on “Monitoring VMware ESXi and vSphere with Nagios

  1. For Debian Edit

    # check for e2fsprogs-devel installed
    if ( direct_command(“cat /etc/*release | grep -i ubuntu”) || direct_command(“cat /proc/version | grep -i ubuntu”) ) {

    # check for e2fsprogs-devel installed
    if ( direct_command(“cat /etc/issue | grep -i debian”) || direct_command(“cat /proc/version | grep -i debian”) ) {