The WMI Plus File Checks

The WMI Plus nagios plugin (found at is an agentless ‘agent’ that comes with several different built in checks. One particularly useful WMI Plus check is the checkfiles collection of checks which consist of checkfileage and checkfilesize. Note that you will need to either feed your username and password into the command or make a file that contains both your username and password for the windows machine and then on the WMI Plus setup, point the authentication path to the credentials path.

Checking for the Age of a File

Checkfileage allows a user to obtain the age of the file as a check. It takes two arguments, the first being the full path of the file and the second being a time multiplier (the result will be converted to the chosen multiplier). Also a warning/critical threshold can be set. The threshold, while normally is in seconds by default, can be converted to a multipler (wk, yr, hr, sec, mth, min, day).

[jd@server ~]$ /usr/nagios/libexec/ -H host -u username -p password -m checkfileage -a c:/testfile.txt -w 1wk
WARNING - [Triggered by _FileAge>1wk] - Age of File c:/testfile.txt is 8 days 19:47:16 (12707min) or 211.79hr(s).|'c:/testfile.txt Age'=211.79hr;168;

In the above, you can notice that a warning is triggered since the warning threshold for the file age was set for ‘1wk’.

Check for the size of a file

Checkfilesize allows a user to obtain the size of a specified file as a check. It takes one argument which is the the path of the file and can be given a ‘—nodatamode’ flag to use warning/critical thresholds on the item count. Note that the item count can only ever be 0 or 1, where a 0 signifies that the given file does not exist.

[jd@server ~]$ /usr/nagios/libexec/ -H host -u username -p password -m checkfilesize -a c:/testfile.txt -w 2
OK - File c:/testfile.txt is 0B. Found 1 instance(s).|'c:/testfile.txt Size'=0bytes;2; 'File Count'=1;

in the above, a warning will only be triggered if filesize is greater than 2.

Setting Up the Check on Nagios

To add a WMI check to Nagios XI go to the Nagios Core Configuration Manager page and add a new service. For the server management go ahead and add the following:

Note: There exist 2 wmiplus check commands: check_xi_service_wmiplus and check_xi_service_wmiplus_authfile. The former only works when you pass in username and password arguments. The latter works if there is a file containing authentication information.

Now we click the ‘Run Check Command’ button to verify the check works then save and apply the changes to nagios.