Download the Zenoss WMI library, compile and install.
wget http://dev.zenoss.org/svn/trunk/inst/externallibs/wmi-1.3.16.tar.bz2
tar xvjf wmi-1.3.16.tar.bz2
cd wmi-1.3.16
First, download the latest version and untar it. Copy both check_wmi_plus.pl and the check_wmi_plus.d folder to Nagios’ libexec folder.
- For me, this is /usr/local/nagios/libexec.
- I renamed the script to check_wmi_plus… I find it cleaner when Nagios plugins don’t have file extensions.
Make the script executable.
The WMI client
Check WMI Plus depends on wmic, the Linux WMI client. Previously, one would simply install the wmi-client package from apt and be on their way. However, this package is now unavailable for newer releases due to licensing issues.
So we compile from source!
First, make sure you’ve got what it takes.
Now, download the latest version of wmi from here. Untar the archive.
Open GNUmakefile, in the wmi-1.X.XX folder. We need to make a few mods so that everything compiles smoothly.
Delete or comment out (by adding a pound sign) the following lines (line numbers may vary slightly for you):
ZENPYTHON = $(ZENOSS_BINDIR)/python # Line 21
USE_BREAKPAD =1# Line 73
$(call check,directory,$(ZENHOME),"ZENHOME")# Line 111
$(call check,directory,$(ZENHOME),"ZENHOME")# Line 130
And change line 22 (where the PYTHON variable is declared) to this:
If necessary, substitute the path above for the path to python on your system.
Save and close GNUmakefile.
Enter the WMI directory, if you aren’t already there.
And compile WMI.
Copy the WMI client binary to your bin folder.
Now try running wmic.
Usage:[-?|--help][--usage][-d|--debuglevel DEBUGLEVEL][--debug-stderr]
[-s|--configfile CONFIGFILE][--option=name=value]
[-l|--log-basename LOGFILEBASE][--leak-report][--leak-report-full]
[-R|--name-resolve NAME-RESOLVE-ORDER]
[-O|--socket-options SOCKETOPTIONS][-n|--netbiosname NETBIOSNAME]
[-W|--workgroup WORKGROUP][--realm=REALM][-i|--scope SCOPE]
[-m|--maxprotocol MAXPROTOCOL][-U|--user [DOMAIN\]USERNAME[%PASSWORD]]
[-N|--no-pass][--password=STRING][-A|--authentication-file FILE]
[-S|--signing on|off|required][-P|--machine-pass]
[--simple-bind-dn=STRING][-k|--kerberos STRING]
[--use-security-mechanisms=STRING][-V|--version][--namespace=STRING]
[--delimiter=STRING]
//host query
Example: wmic -U [domain/]adminuser%password //host "select * from Win32_ComputerSystem"
Congrats! The WMI client is now installed on your system. You may delete the WMI source directory, now.
rm -r wmi-1*
Perl Modules
Certain Perl modules are also required for the plugin to work as intended.
Plugin Configuration
Finally, we need to configure the plugin so that it knows where certain files are located.
Open the check_wmi_plus script and change these lines with the appropriate paths (line numbers may vary slightly for you):
use lib "/usr/local/nagios/libexec";# Line 45
our $base_dir='/usr/local/nagios/libexec/check_wmi_plus.d';# Line 116
And open the check_wmi_plus.conf file, located in the check_wmi_plus.d folder, and change these lines with the appropriate paths (line numbers may, again, vary slightly for you):
$wmic_command="/usr/bin/wmic";# Line 24
$wmi_ini_file="$base_dir/check_wmi_plus.ini";# Line 31
$wmi_ini_dir="$base_dir";# Line 37
Save and close the file.
Try it out
By now, you should have a working check_wmi_plus script residing in Nagios’ libexec folder.
Here are just two example commands you can try. This checks CPU usage:
OK (SamplePeriod7 sec)-Average CPU Utilisation2.82%|'Avg CPU Utilisation'=2.82%;
And this checks the CPU usage of a particular process:
OK (SamplePeriod602 sec)-Found7Instance(s) of "msaccess" running. CPU_MSACCESS(PID=7996)=0.0% CPU_MSACCESS(PID=14124)=0.0% CPU_MSACCESS(PID=9704)=0.0% CPU_MSACCESS(PID=15020)=0.0% CPU_MSACCESS(PID=10856)=0.0% CPU_MSACCESS(PID=10036)=0.0% CPU_MSACCESS(PID=12996)=0.0% |'Process Count'=7;'Avg Utilisation CPU_MSACCESS'=0.0%;'Avg Utilisation CPU_MSACCESS'=0.0%;'Avg Utilisation CPU_MSACCESS'=0.0%;'Avg Utilisation CPU_MSACCESS'=0.0%;'Avg Utilisation CPU_MSACCESS'=0.0%;'Avg Utilisation CPU_MSACCESS'=0.0%;'Avg Utilisation CPU_MSACCESS'=0.0%;
Now, all that’s left for you to do is to read all the documentation on this plugin and discover all its options and possibilities and how awesome it really is.
Alot of help is actually bundled with the plugin..
Check_wmi_plus.pl plugin info can be found here.
cd /tmp
wget http://edcint.co.nz/checkwmiplus/sites/default/files/check_wmi_plus.v1.52.tar.gz
cd /usr/local/nagios/libexec/360viewpoint
tar xvzf /tmp/check_wmi_plus.v1.52.tar.gz
cpan install ExtUtils::MakeMaker
cpan install Perl::OSType
cpan install Module::Build::Compat
cpan install Config::IniFiles
Check the versions of the installed perl modules:
./check_wmi_plus.pl -d -d | head -n 20
cpan install Data::Dumper
cpan install Scalar::Util
cpan install Storable
cpan install Getopt::Long
Leave a Reply