×


Monitoring VMware with Nagios XI

Nagios provides the capabilities to monitor an assortment of metrics on the various VMware platforms including VMware Workstation, ESX Hosts, vSphere or vCenter Servers.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Nagios related tasks.
In this context, we shall look into how to set up the Nagios XI system to monitor virtual machines.

Process of Monitoring VMware with Nagios XI ?

In order to monitor VMware with Nagios XI, you need to take note of the following:

i. Install the prerequisites for the VMware SDK
ii. Install the VMware Perl SDK on the Nagios XI server

We must download and install VMware SDK version 7.0 if we are installing on an RHEL/CentOS 8 system.
For all other supported OS distributions, we recommend to download and install WMware SDK version 6.5.
Also, we will focus on the steps to monitoring VMware with Nagios.

1. Install SDK Prerequisites
The VMware Perl SDK requires the installation of Perl modules and defining relevant environment variables.
Some of the Perl modules install using CPAN. This command may ask questions to proceed; normally pressing enter is enough to accept the default response.
Establish a terminal session to the Nagios XI server as the root user and execute the following commands:

For RHEL 6.x|CentOS 6.x|Oracle Linux 6.x:

export PERL_MM_USE_DEFAULT=1
yum install -y libxml2-devel xml2 libuuid-devel
cpan -i UUID XML::LibXML Socket Socket6 IO::Socket::INET6 YAML
cpan -i Nagios::Monitoring::Plugin Nagios::Monitoring::Plugin::Functions

For CentOS 7.x|RHEL 7.x|Oracle Linux 7.x:

yum install -y libxml2-devel xml2 libuuid-devel perl-XML-LibXML perl-Env
export PERL_MM_USE_DEFAULT=1
cpan -i App::cpanminus
cpanm –notest Module::Build Crypt::SSLeay
cpan -i Nagios::Monitoring::Plugin Nagios::Monitoring::Plugin::Functions


For RHEL 8.x|CentOS 8.x|Oracle Linux 8.x:

yum install -y libxml2-devel libxml2 libuuid-devel perl-XML-LibXML perl-Env
yum remove perl-Crypt-SSLeay -y
export PERL_MM_USE_DEFAULT=1
cpan -i App::cpanminus
cpanm Crypt::SSLeay –dev
cpan -i Nagios::Monitoring::Plugin Nagios::Monitoring::Plugin::Functions

For Ubuntu:

apt-get update
apt-get install -y libxml-libxml-perl libxml2-dev xml2 uuid-dev perl-doc rpm libsoap-lite-perl


For Debian:
VMware Perl SDK does not officially support Debian, however, there is a work-around. Simply creating a fake-release file fool the installer into thinking it is Ubuntu:

echo ubuntu > /etc/fake-release
apt-get update
apt-get install -y libxml-libxml-perl libxml2-dev xml2 uuid-dev perl-doc rpm libsoap-lite-perl


2. How to Install VMware SDK ?
Nagios XI is not able to pre-bundle the VMware Perl SDK due to license terms. Hence, we need to download and install the SDK on the Nagios XI server.
i. We can download the VMware Perl SDK from VMware’s website:
http://communities.vmware.com/community/developer/forums/vsphere_sdk_perl
ii. Download the .tar.gz SDK file that is appropriate for Nagios XI server, either i386 or x86_64.
iii. Then, transfer it to the Nagios XI server via SFTP. We assume that the file is transferred to the /tmp directory on the Nagios XI server.

3. Extract VMware Perl SDK Installer
We execute the following commands to extract the SDK on the Nagios XI server:

cd /tmp
tar xzf VMware-vSphere*SDK*.tar.gz
cd vmware-vsphere-cli-distrib/


Additional Step For Ubuntu 14.x|Debian 8.x:

The installer will fail on these distributions due to a command that fails in the script. It is this line:

safe_chmod(755, “$bindir/dcli”);

The workaround is to comment out this line by adding a # to the beginning. This command will do just that:

sed -i ‘s/safe.*r\/dcli/#&/’ vmware-install.pl

4. How to Install VMware Perl SDK?
We execute the following command to install the SDK on the Nagios XI server:

./vmware-install.pl EULA_AGREED=yes

The installation may require some Perl modules to install using CPAN and we will need to answer yes to proceed. Any other prompts such as the location for the executable files will accept the default location by pressing Enter.
The will be complete when we see the “Enjoy, –the VMware team” message. We can ignore any messages about Perl modules being too old, normally they do not cause an issue.

Additional Steps For RHEL/CentOS 8 and Debian 10:

i. Run the following command to fix an SDK issue:

mv /usr/bin/six.pyc /usr/bin/six.pyc.bak

ii. Update the following file:

/usr/share/perl5/VMware/VICommon.pm (El 8)

or

/usr/share/perl/<perl version number>VMware/VICommon.pm (Debian 10)

iii. Change this line:
#To remove SSL Warning, switching from IO::Socket::SSL to Net::SSL

# $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = “Net::SSL”;

iv. To the below to fix an issue with invalid certificates:
#To remove SSL Warning, switching from IO::Socket::SSL to Net::SSL

$ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = “Net::SSL”;

Now that the VMware SDK installation is complete, we can proceed to run the VMware wizard.

[Need help with the Linux Software installations ? We'd be happy to assist you!]


How to Use The VMware Wizard ?

To begin using the VMware wizard, navigate via the top menu bar to Configure > Run a configuring wizard, and select the VMware wizard. The search field allows us to quickly find a wizard.

a. Monitor the VMware host
i. Enter the Address, Username, and Password of the ESX/ESXi host.
ii. Select Monitor the VMware Host.
iii. Then click Next to go to Step 2.
iv. In step 2, we will configure all of the options for monitoring.
v. Here, we make sure to enter a valid Host Name.
vi. Then we select the VMware Host Metrics from the available list.
vii. Once we select the metrics, click Next.
viii. To finish up, click on Finish in the final step of the wizard.

This will create new hosts and services and begin monitoring.
Once the wizard applies the configuration, click the View status details for xxxxx link to see the new host and services.

b. Monitor a guest VM on the VMware host
i. Enter the Address, Username, and Password of ESX/ESXi host OR vCenter Server.
ii. Select Monitor a guest VM on the VMware host.
iii. Click Next to go to Step 2.
iv. In step 2 we make sure to enter a valid Host Name.
v. There are two tabs we need to select options on.
vi. The Monitored Metrics tab is selected by default.
vii. Then, select the VMware Guest Metrics from the available list.
viii. A service for each metric will create for each guest on the Guest Selection tab.
ix. After selecting the required metrics, click the Guest Selection tab.
x. On the Guest Selection tab, a list of all the available guests on the ESX(i) host or vCenter server will display.
xi. Checklist the guests we want to monitor. Once done, click Next.
xii. To finish up, click on Finish in the final step of the wizard.

This will create the new host and services and begin monitoring.
Once the wizard applies the configuration, click the View status details for xxxxx link to see the new host and services.

c. Common Problems with VMware.

Below are some common problems encountered when using the VMware wizard.

i. The wizard shows a big red box that says the VMware SDK is not installed, while it already exists.
Reinstall the VMware SDK. It is very easy to pass over an error in that install script. If we do not see “Enjoy –the VMware team” at the end of the install, then it did not install properly.
Another cause is that the check_esx3.pl does not exist in /usr/local/nagios/libexec/.

If this error persists past VMware SDK reinstall, then reinstall the wizard. If it persists past the wizard install, then manually place check_esx3.pl into /usr/local/nagios/libexec/ directory.
Similarly, if we have installed the SDK, make sure we have properly set the permissions for /usr/local/nagiosxi/html/includes/configwizards/vmware/scripts/getguests.pl as this has been an issue for some users.

ii. Nagios service and hostnames cannot contain special characters
If we wish to have absolute control over service names, make sure to not involve any shell characters or Nagios illegal characters.
Sometimes on RHEL/CentOS 7, we will need to make a change to one of the Perl files
We use the following command:

sed -i ‘s/length(/scalar(/g’ /usr/lib64/perl5/IO/Compress/Zlib/Extra.pm

This appears to be fixed in newer versions of this file, however, it is included here in case we get errors that reference that file.

When we try to monitor guests on an ESX host, we see a blank page in Step 2 of the wizard or we see an error similar to this one:

“Server version unavailable at ‘https://192.168.0.100:443/sdk/vimService.wsdl’ at /usr/share/perl/5.18/VMware/VICommon.pm line 734.”

Try downgrading the LWP Perl module by running the following commands:

cd /tmp
wget https://www.cpan.org/modules/by-module/LWP/GAAS/libwww-perl-5.837.tar.gz
tar xvf libwww-perl-5.837.tar.gz
cd libwww-perl-5.837/
perl Makefile.PL
make
make test
make install

Rerun the VMware monitoring wizard to check the resolution.

[Stuck with any other VMWARE problems? Contact us now!]


Conclusion

This article will guide you on the steps to Monitor VMware with #Nagios.
To Monitor the VMware host
i. Enter the Address, Username and Password of your #ESX / #ESXi host.
ii. Select Monitor the #VMware #Host.
iii. Click Next to go to Step 2.
iv. On step 2 you will configure all of the options for #monitoring.