MonitoringExchange
NagiosForge
NagiosWiki
Nagios Community Platform powered by NETWAYS

Plugin:check vmware3.pl

Search  
From NagiosWiki
Jump to: navigation, search

Contents

check_vmware3.pl

  • It checks the host and the virtual machines on a vmware esx server via the VMware perl API.
  • The status of a virtual machine is OK if its heartbeat is green and CRITICAL in any other case. This is the most reliable information you can get as far as we know.
  • It gives CPU and memory usage of the VMware server
  • And it also prints performance data of the guest: net I/O, disk I/O, CPU usage, memory usage

Warning

  • sorry, this is not realy lightwight. It pumps about 2MB from VMware Server to the checkhost on every run.
  • so maybe it is a good idea to perform the check on the VMware Server itself via check_by_ssh

get it on NagiosExchange

check_vmware3.pl on Nagios Exchange

what do you need

  • Nagios
  • VMware Infrastructure (VI) Perl Toolkit (VMware-VIPerl-1-1.6.0-104313.i386.tar.gz or VMware-VIPerl-1.6.0-104313.x86_64.tar.gz)
  • maybe the patch for VICommon.pm
  • and perl of course
  • nothing else

Why is this better than a other check plugin?

  • one main difference to the check_esx3.pl from op5 is that we test the heartbeat status of the virtual machines.
  • second - you may define: check all configured vms exept those matching the regexp "test".
  • the plugin only depends on the API and do not need any other perl module.
  • the grapher templates are part of the package.

Example

nagios@nagioswiki.org:~/
./check_vmware3.pl --server 10.10.0.32 --username readonlyuser --password secret --protocol https --portnumber 8333 --host my.vmware.server.com --ignore '.' --ensure 'VPN'

Sample Nagios Look

The plugin will warn you if it cannot find the API.

Image:Vmware_nagios_unknown_missing_api.png

Nagios will get critical if a virtual machine is missing or not running fine (bad) unless you defined to ignore it.

Image:Vmware_nagios_critical_missing_vm.png

Help Output

nagios@nagioswiki.org:~/
$ ./check_vmware3.pl --help

Synopsis: /usr/lib/nagios/plugins/NETWAYS/check_vmware3.pl OPTIONS 


Command-specific options:
   --ensure
      List of VM-Names (separated by comma, regexp possible) for which state must be green
   --host
      Name of the host
   --ignore
      List of VM-Names (separated by comma, regexp possible) to ignore if state not green
   --timeout
      Timeout in seconds
   --verboseVMs
      list VM names as plugin output
   --vmname
      one single VM to check - the other checks will be suppressed

Common VI options: 
   --config (variable VI_CONFIG)
      Location of the VI Perl configuration file
   --encoding (variable VI_ENCODING, default 'utf8')
      Encoding: utf8, cp936 (Simplified Chinese), iso-8859-1 (German), shiftjis (Japanese)
   --help
      Display usage information for the script
   --passthroughauth (variable VI_PASSTHROUGHAUTH)
      Attempt to use pass-through authentication
   --passthroughauthpackage (variable VI_PASSTHROUGHAUTHPACKAGE, default 'Negotiate')
      Pass-through authentication negotiation package
   --password (variable VI_PASSWORD)
      Password
   --portnumber (variable VI_PORTNUMBER)
      Port used to connect to server
   --protocol (variable VI_PROTOCOL, default 'https')
      Protocol used to connect to server
   --savesessionfile (variable VI_SAVESESSIONFILE)
      File to save session ID/cookie to utilize
   --server (variable VI_SERVER, default 'localhost')
      VI server to connect to. Required if url is not present
   --servicepath (variable VI_SERVICEPATH, default '/sdk/webService')
      Service path used to connect to server
   --sessionfile (variable VI_SESSIONFILE)
      File containing session ID/cookie to utilize
   --url (variable VI_URL)
      VI SDK URL to connect to. Required if server is not present
   --username (variable VI_USERNAME)
      Username
   --verbose (variable VI_VERBOSE)
      Display additional debugging information
   --version
      Display version information for the script

Comments

on SUSE you may need to install Class::MethodMaker from CPAN if you get the following error message:

nagios@nagioswiki.org:~/
/usr/bin/perl: symbol lookup error: /usr/lib/perl5/site_perl/5.10.0/i586-linux-thread-multi/auto/Class/MethodMaker/MethodMaker.so: undefined symbol: Perl_Tstack_sp_ptr
do it like this:
nagios@nagioswiki.org:~/
perl -MCPAN -e shell
install Class::MethodMaker

you may need to apply the patch like this:

nagios@nagioswiki.org:~/
$ patch -p0 < VICommon.pm.patch
patch:
nagios@nagioswiki.org:~/
--- /root/vmware-viperl-distrib/lib/VMware/share/VMware/VICommon.pm	2008-07-13 05:39:51.000000000 +0200
+++ /usr/lib/perl5/site_perl/5.8.8/VMware/VICommon.pm	2008-11-20 10:23:55.000000000 +0100
@@ -1796,7 +1796,7 @@
                   Carp::confess("Internal error: server returned '$val' as a boolean value");
                }
             } else {
-               $val = $child_class_name->deserialize($_);
+               $val = ($_->toString =~ /^<device xsi:type="VirtualMachineVMCIDevice">/) ? XML::LibXML::Element->new("void") : $child_class_name->deserialize($_);
             }
          } else {
             $val = $_->textContent;

Sample Grapher Output

The graph will get a pink top if a virtual machine is missing. Image:Vmware_counter.png Image:Vmware_guest_diskusage.png Image:Vmware_guest_net_io.png Image:Vmware_guest_cpu.png Image:Vmware_guest_cpu_change.png Image:Vmware_host_cpu.png Image:Vmware_host_memory.png