The best script to monitor VMWare ESX using nagios was
developed by Steve Shipway.
1. Download the script
wget http://felipeferreira.net/wp-content/uploads/2015/05/VMWare.zip
unzip VMWare.zip
cd VMWare
chmod +x check_vmware.pl && sed -i -e ‘s/\r$//’ check_vmware.pl
./check_vmware.pl
OBS: It is normal to get an error “Can’t locate VMware/VIRuntime.pm”
2. Install the pre-reqs and VIPerl Toolkit
Debian based Linux:
sudo apt-get install ia32-libs build-essential gcc uuid uuid-dev perl libssl-dev perl-doc liburi-perl libxml-libxml-perl libcrypt-ssleay-perl
RedHat based:
Perl Libs and others used by vmware-vsphere-cli:
yum install openssl-devel perl-Class-MethodMaker.x86_64 uuid-perl.x86_64 perl-XML-LibXML.x86_64 libxml2.x86_64 perl-Archive-Zip.noarch perl-XML-Dumper.noarch dump.x86_64 perl-SOAP-Lite.noarch yum install libuuid.x86_64 libuuid-devel.x86_64
wget http://felipeferreira.net/wp-content/uploads/2015/05/VMware-vSphere-CLI-5.1.0-780721.x86_64.tar.gz
tar -zxvf VMware-vSphere-CLI-5.1.0-780721.x86_64.tar.gz
CLI 6.0 x64
wget “http://felipeferreira.net/wp-content/uploads/2015/05/VMware-vSphere-CLI-6.0.0-2503617.x86_64.tar.gz”
tar -zxvf VMware-vSphere-CLI-6.0.0-2503617.x86_64.tar.gz
VMware-vSphere-CLI-6.0.0-2503617.x86_64.tar
cd VMware-vSphere-CLI-5.1.0-780721.x86_64
sudo ./vmware-install.pl
(if it dosent work, look in troubleshooting)
(important hoave perl CPAN working)
./check_vmware.pl
Create a vmware.cfg file
vi vmware.cfg
VI_SERVER=
VI_USERNAME=
VI_PASSWORD=
Copy both the vmware.cfg and check_vmware.pl to Nagios plugin directory usually in /usr/local/nagios/libexec/
Testing:
check_vmware.pl –mode nagios –config=vmware.cfg –timeout 30 –cluster
3. Configure new command in nagios
/check_vmware.pl –generate nagios
APENDIX:
Sample commands:
./check_vmware.pl –mode nagios –config=/vmware.cfg –timeout 30 –host esx16 –report memory
./check_vmware.pl –mode nagios –config=/vmware.cfg –timeout 30 –host esx16 –report CPU
./check_vmware.pl –mode nagios –config=/vmware.cfg –timeout 30 –cluster CLUSTER
Pegar o CPU e memoria de uma maquina virtual
./check_vmware.pl –mode nagios –config=/vmware.cfg –timeout 30 –guest SERVIDOR –report cpu
./check_vmware.pl –mode nagios –config=/vmware.cfg –timeout 30 –guest SERVIDOR –report memory
Check other options:
./check_vmware.pl -h
TROUBLESHOOTING:
Not connecting?
Test network connectivity first
curl https://172.1.1.3:443/sdk/vimService.wsdl
/usr/lib/vmware-vcli/apps/general/connect.pl –url https://172.1.1.34/sdk –username XX –password XX
To install vmware-vsphere-cli you will need these perl libs
then run ./vmware-install.pl
Running Centos 6.7 I get the msg:
UUID 0.03 or newer
Data::Dump 1.15 or newer
“Data::Dump”
wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/Data-Dump-1.23.tar.gz
UUID 0.03 or newer
wget http://search.cpan.org/CPAN/authors/id/J/JR/JRM/UUID-0.24.tar.gz
To compile UUID needs libuuid-devel.x86_64
need Devel-CheckLib and
yum install gcc libuuid-devel.x86_64
“SOAP::Lite”
wget http://search.cpan.org/CPAN/authors/id/P/PH/PHRED/SOAP-Lite-1.19.tar.gz
Class::MethodMaker 2.10 or newer
wget http://search.cpan.org/CPAN/authors/id/S/SC/SCHWIGON/class-methodmaker/Class-MethodMaker-2.24.tar.gz
XML::LibXML::Common 0.13 or newer
wget http://search.cpan.org/CPAN/authors/id/S/SH/SHLOMIF/XML-LibXML-2.0122.tar.gz
XML::LibXML 1.63 or newer
wget http://search.cpan.org/CPAN/authors/id/S/SH/SHLOMIF/XML-LibXML-2.0122.tar.gz
“Archive::Zip” .
wget http://search.cpan.org/CPAN/authors/id/P/PH/PHRED/Archive-Zip-1.53.tar.gz
 
 
UPGRADING 
for upgrading be sure to run the uninstall
/usr/bin/vmware-uninstall-vSphere-CLI.pl
and the this cmd:
mv /usr/local/lib64/perl5/VMware /usr/local/lib64/perl5/VMware_OLD
to be sure you have right version:
/usr/bin/vmware-cmd –version
vSphere SDK for Perl version: 6.5.0
Script ‘vmware-cmd’ version: 6.5.0
Ref:
http://sourceforge.net/projects/viperltoolkit/
https://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.vcli.getstart.doc%2Fcli_install.4.3.html
Alernative plugin:
https://exchange.nagios.org/directory/Plugins/Operating-Systems/*-Virtual-Environments/VMWare/Vmware-ESX-%26-VM-host/details

Tags: , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *