We need to install an open source WMI Client, as previous versions (Ubuntu packaged .deb versions of WMI-Client, for example) do not work with newer versions of Windows (2008, 7, etc).
We also need to install the check_wmi_plus.pl script, which requires some configuration, along with some modules via CPAN/APT.
In the example environment used for this setup, we have a Ubuntu 10.04 x64 server, however aside from the plugins/packages downloaded by APT (which can be downloaded via alternatives package managers) the steps are nearly identical.
Click to enlarge
Firstly, we must install some pre-requisite packages on our server. These are “gcc”, “automake” and “DateTime.pm” (A perl module required):
sudo apt-get install autoconf gcc libdatetime-perl
Once done, we will now install the underlying WMI client. Firstly, change directory to /home/user (or wherever you would like the config work to be done, however this is all relative).
Secondly, download the source from the link below and extract:
tar -xvf wmi-1.3.16.tar
Now we are in the wmi folder, we will need to set the location of our “../bin/python” directory; in our case using Ubuntu, it is in /usr, so:
This tells the program to look for /bin/python in /usr, i.e. /usr/bin/python (the fqdn).
Next, we will need to edit “GNUmakefile” as below, and find and comment out / delete the line “USE_BREAKPAD=1”:
And comment out the line, so it looks like “#USE_BREAKPAD=1”.
Finally, we need to run “make” and the compilation will begin, this can take up to 10 minutes.
Lastly, we will need to move the newly created wmic into /bin, using the command below:
cp /home/ubuntu/wmi/wmi-1.3.16/Samba/source/bin/wmic /bin
Next we will need to install some Perl modules required:
perl -MCPAN -e shell
cpan>o conf urllist http://ppm.activestate.com/CPAN http://cpan.perl.org
cpan>o conf commit
cpan>o conf prerequisites_policy follow
cpan>o conf commit
Once done, we will next need to download the check_wmi_plus plugin and compile. To do this, we must first download and extract using the commands:
tar -zxvf check_wmi_plus.v1.52.tar.gz
You should “cd
.” again to a suitable location to extract and
work on the plugin. Once extracted, we will need to copy/rename the
sample config, so we have a copy we are working on, as below:
cp check_wmi_plus.conf.sample check_wmi_plus.conf
Once done, we will need to edit the new config using nano/vim etc:
There are a few items we need to edit:
- $base_dir="home/ubuntu/wmi/”; << This needs to be the folder where we extracted wmi, i.e. where the folder “wmi-1.3.16” lives.
- $wmic_command="/bin/wmic"; << This should be ok if you followed instructions, as this is where we moved our newly compiled “wmic” to.
- $wmi_ini_file='/home/ubuntu/wmi/check_wmi_plus.d/check_wmi_plus.ini'; << This should be where the “check_wmi_plus.ini” file lives, normally within the extracted “check_wmi_plus.d” folder.
- $wmi_ini_dir="/home/ubuntu/wmi/check_wmi_plus.d/" << As above.
Once this file is edited and tailored per your system/install, we should be almost ready to test. Finally, we need to edit the plugin itself and edit the value, so:
To point to our newly created/edited config file at /home/ubuntu/wmi/.
So now we should have the wmic program downloaded and compiled, the required Perl modules downloaded and installed, and the check_wmi_plus plugin downloaded, compiled and customised.
We can test our plugin against a WMI enabled Windows machine (WMI enabled means someone has gone into the server, “start > run > services.msc (enter) >” scrolled down to “WMI Performance Adapter” and “started” it.
To test, run a command similar to below:
[email protected]:/home/ubuntu/wmi# ./check_wmi_plus.pl -H 192.168.11.107 -u root -p opsview -m checkcpu
OK (Sample Period 489 sec) - Average CPU Utilisation 6.69%|'Avg CPU Utilisation'=6.69%;
Where “-H” is for host, “-u” is for user, and “-p” is for password. “-m” is the mode (“-s” is where we add the sub-mode). If the command works, you should see an output as above.
If you see the output as above, congratulations - your Opsview server is now monitoring a Windows server without an agent!