Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

check_software_ver

Rating
0 votes
Favoured:
0
Current Version
1.0.0.0
Last Release Date
2012-03-08
Compatible With
  • Nagios 3.x
Owner
License
Other
Hits
70526
Files:
FileDescription
check_software_ver.wsfWSH File using VBScript
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
This script was written for Nagios/NRPE. It queries Windows WMI for Software Version with optional checks for validation against specific version, plus a mismatch allowance.
This script was written for Nagios/NRPE, and uses WSH/VBScript.

It queries Windows WMI and makes a Software Version Check with optional validation against minimum version, plus a mismatch allowance.

It requires one argument (Package Name - $ARG1$), and you can feed it two optional arguments of a version ($ARG2$) for comparison, and a mismatch allowance ($ARG3$) defining how many figures - starting from the right - can be ignored.

If just $ARG1$ is provided it simply returns the Software/Version. ($ARG1$ can use % as a wildcard for matching.)
If $ARG1$ and $ARG2$ are provided it also makes a strict version check.
If $ARG3$ is also provided it makes a version check according to the leeway provided by the argument. (Number must be 1 less that the component count in the version number provided by $ARG2$. Special Cases are "0", meaning strict check, and 99 meaning any later version is OK.)

Downside: This will only report software that registers itself with WMI. (All MSI Installations should do this, but many self-installers do not.)


Nagios Config:
Command:
I personally use a custom command for this, as it takes arguments from the service. I also needed to increase the timeout here (as well as in the Nagios/NRPE/NSClient++ configs) because WMI calls can take some time on old hardware.

define command {
command_name check_nt_software
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -t 300 -c $ARG1$ -a $ARG2$ $ARG3$ $ARG4$
}

Service:
You'll need a service per package, and I'll use a strict check of Flash Player for my example. (I always tend to give the allowance argument, even though it's not technically required when doing a strict check. I use 0 in these cases.)

define service {
use INSERT-TEMPLATE-HERE
host_name INSERT-HOSTNAME-HERE
service_description check_flash_player
display_name Check Flash Player Version
contact_groups INSERT-GROUPS-HERE
check_command check_nt_software!check_software_ver!%flash%player%!11.1.102.62!0
check_interval 10080
notification_interval 10080
}

Client Requirements:
Windows obviously. (2000 and upwards.)
WMI installed and the Win32_Product Class available. (To check, go to an admin command prompt and type "wmic product". If you see a list of software, it's working.)
NSClient++ (or similar)
Arguments allowed for NRPE.

nsc.ini (If using NSClient++)
Ensure the following are set.
[NRPE]
allow_arguments=1
command_timeout=290

[NRPE Handlers]
check_software_ver=cscript.exe //NoLogo //T:280 "check_software_ver.wsf" $ARG1$ $ARG2$ $ARG3$


Notes:
Return Codes:
The following are returned;

Unknown: (3)
Software Package(s) not found.
$ARG3$ Allowance exceeds 3.

Critical: (2)
$ARG1$ missing or blank.
$ARG1$ is literally "$ARG1$" (You've got a Nagios/NRPE/NSClient config problem somewhere.)
Version Check with unsuccessful strict match.
Software found, but Version Allowance equals or exceeds number of components in the Version given in $ARG2$.

Warning: (1)
Version Check with unsuccessful match with Allowance

OK: (0)
Version Report Only
Version Check with successful Strict match
Version Check with successful match with Allowance


Other Execution Examples;
(check_command)

1. Report All Adobe Software Versions
check_nt_software!check_software_ver!%adobe%

2. Check All Flash Player Levels using strict versioning.
check_nt_software!check_software_ver!%Flash%Player%!11.0.1.152

3. Check VMWare Workstation Level ignoring build figure
check_nt_software!check_software_ver!%VMWare%Workstation%!7.1.5.19539!1

4. Check VMWare Workstation Level, using specific major version
check_nt_software!check_software_ver!%VMWare%Workstation%!7.0!1

5. Check Minimum VMWare Workstation Level, also allowing any higher major version
check_nt_software!check_software_ver!%VMWare%Workstation%!7!99

You should be able to work out any command needed from those.