Installation Terminal Session

This page shows a terminal session that includes:

  • Install and compile of wmic
  • wmic testing
  • Installation of check_wmi_plus
  • check_wmi_plus testing

This is all performed on a freshly installed Fedora 16 virtual machine. This is a minimal installation of Fedora that does not even include perl.
Some of the output has been collapsed because it is very large!
Some notes (not part of the original terminal session!) are in blue

Terminal Session

Install some packages that we need. There is no Nagios on this machine so we have to install nagios-plugins-perl at the very least to get the Nagios
Fed16 Min:~# yum -y install wget time make gcc autoconf nagios-plugins-perl perl-Config-IniFiles perl-DateTime perl-Scalar-List-Utils perl-Number-Format
Setting up Install Process
Resolving Dependencies

Fed16 Min:~# cd /tmp

Download wmic
Fed16 Min:/tmp# wget
–2012-11-18 17:23:45–
Connecting to||:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 3994744 (3.8M) [application/x-gzip]
Saving to: “wmi-1.3.14.tar.gz”

100%[=========================================================================================>] 3,994,744 419K/s in 11s

2012-11-18 17:23:57 (366 KB/s) – “wmi-1.3.14.tar.gz” saved [3994744/3994744]

Unpack wmic
Fed16 Min:/tmp# tar xzvf wmi-1.3.14.tar.gz

Fed16 Min:/tmp# cd wmi-1.3.14

Compile wmic (takes about 3-4 minutes)
Fed16 Min:/tmp/wmi-1.3.14# make
Update June 2015: You may need to use the following command line. Refer to this FAQ article.
Fed16 Min:/tmp/wmi-1.3.14# make “CPP=gcc -E -ffreestanding”
Update Nov 2015: If you get the error Can’t use ‘defined(@array)’ (Maybe you should just omit the defined()?) at ./pidl/pidl line 583.
(you are probably using Perl version 5.22+) then you need to edit line 583 of Samba/source/pidl/pidl and remove the “defined” from the start of the line (just like the error message says)

Test wmic
Fed16 Min:/tmp/wmi-1.3.14#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]
//host query

Example: wmic -U [domain/]adminuser%password //host “select * from Win32_ComputerSystem”
Fed16 Min:/tmp/wmi-1.3.14#/bin/wmic -U USER%PASS //HOST ‘Select Caption From Win32_OperatingSystem’
CLASS: Win32_OperatingSystem
Microsoft Windows XP Professional|Microsoft Windows XP Professional|C:\WINDOWS|\Device\Harddisk0\Partition1

Prepare for the installation of check_wmi_plus
Fed16 Min:/tmp/wmi-1.3.14#mkdir -p /opt/nagios/bin/plugins
Fed16 Min:/tmp/wmi-1.3.14#cd /opt/nagios/bin/plugins

Download check_wmi_plus
Fed16 Min:/opt/nagios/bin/plugins# wget
–2012-11-18 17:45:42–
Connecting to||:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 128697 (126K) [application/x-gzip]
Saving to: “check_wmi_plus.v1.54.tar.gz”

100%[=========================================================================================>] 128,697 109K/s in 1.1s

2012-11-18 17:45:44 (109 KB/s) – “check_wmi_plus.v1.54.tar.gz” saved [128697/128697]

Unpack check_wmi_plus
Fed16 Min:/opt/nagios/bin/plugins# tar xzvf check_wmi_plus.v1.54.tar.gz

Test check_wmi_plus
Fed16 Min:/opt/nagios/bin/plugins# /opt/nagios/bin/plugins/ -m checkcpu -H HOST -u USER -p PASS
Collecting first WMI sample because the previous state data file (/tmp/cwpss_checkcpu_HOST___.state) contained no data. Results will be shown the next time the plugin runs.

Run it again since checkcpu requires 2 data points
Fed16 Min:/opt/nagios/bin/plugins# /opt/nagios/bin/plugins/ -m checkcpu -H HOST -u USER -p PASS
OK (Sample Period 4 sec) – Average CPU Utilisation 10.24%|’Avg CPU Utilisation’=10.24%;