Monitoring VMware with Nagios XI is possible with the VMware monitoring wizard.
As part of our Server Management Services, we assist our customers with several Nagios queries.
Today, let us focus on how to set up the Nagios XI system to monitor virtual machines.
Monitoring VMware with Nagios XI
In order to monitor VMware with Nagios XI, our Support Engineers suggests to:
a) Install the prerequisites for the VMware SDK
b) 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.
Furthermore, let us focus on the steps our Support Techs employ for monitoring VMware with Nagios
-
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:
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
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
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
Ubuntu
apt-get update
apt-get install -y libxml-libxml-perl libxml2-dev xml2 uuid-dev perl-doc rpm libsoap-lite-perl
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
-
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.
We can download the VMware Perl SDK from VMware’s website:
http://communities.vmware.com/community/developer/forums/vsphere_sdk_perl
Download the .tar.gz
SDK file that is appropriate for Nagios XI server, either i386 or x86_64.
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.
-
Extract 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
-
Install 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:
- Run the following command to fix an SDK issue:
mv /usr/bin/six.pyc /usr/bin/six.pyc.bak
- Update the following file:
/usr/share/perl5/VMware/VICommon.pm (El 8) or /usr/share/perl/<perl version number>VMware/VICommon.pm (Debian 10)
- Change this line:
#To remove SSL Warning, switching from IO::Socket::SSL to Net::SSL # $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = “Net::SSL”;
- 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 installations? We’d be happy to assist you!]
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.
-
Monitor the VMware host
- Enter the Address, Username, and Password of the ESX/ESXi host.
- Select Monitor the VMware Host.
- Then click Next to go to Step 2.
- In step 2, we will configure all of the options for monitoring.
- Here, we make sure to enter a valid Host Name.
- Then we select the VMware Host Metrics from the available list.
- Once we select the metrics, click Next.
- 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.
-
Monitor a guest VM on the VMware host
- Enter the Address, Username, and Password of ESX/ESXi host OR vCenter Server.
- Select Monitor a guest VM on the VMware host.
- Click Next to go to Step 2.
- In step 2 we make sure to enter a valid Host Name.
- There are two tabs we need to select options on.
- The Monitored Metrics tab is selected by default.
- Then, select the VMware Guest Metrics from the available list.
- A service for each metric will create for each guest on the Guest Selection tab.
- After selecting the required metrics, click the Guest Selection tab.
- On the Guest Selection tab, a list of all the available guests on the ESX(i) host or vCenter server will display.
- Checklist the guests we want to monitor. Once done, click Next.
- 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.
-
Common Problems
Below are some common problems encountered when using the VMware wizard.
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.
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 problem? Contact us now!]
Conclusion
In short, we saw a few steps our Support Engineers found the best fit for Monitoring VMware with Nagios.
0 Comments