Check_fileage.vbs is plugin for nagios that uses NRPE_NT and works for Microsoft machines.
I tried to make it as flexible as posible, allowing nagios to pass simple but helpfull arguments.
I use it to find out for example what was the last antivirus definition update, I set if its older then 7 days warn if it is older then 10 critical. Although antivirus update is a centralized automated everyday task, many times admins stop worrying about it or just don’t have the time to keep checking. Well again nagios is here to save us!
The purpose is to check how old the file is compare to today (checks by LastModified Date)
‘Example of my use: get Last Time Antivirus MCAfee Enterprise (Version 8.0i) was Updated
IMPORTANT: PATHS MUST NOT CONTAIN SPACES, AND DOUBLE SLASHES, its a sad NRPE_NT argument passing problem, why developers didnt allow using quotes to separate arguments is something that I dont understand. Well I got around that, also the slashes must be doubled
Tip: use dir /ad /x and find the short path
‘Command example: check_av.vbs -f  “C://PROGRA~1//COMMON~1//NETWOR~1//Engine//scan.dat” -w 10 -c 7
‘Command example: check_av.vbs -f  “C:PROGRA~1COMMON~1NETWOR~1Enginescan.dat” -w 10 -c 7
‘check_av.vbs -f <File path and Location> -w <warning for days old> -c <Critical for days old>
‘NOTE: the -w -c are only triger if value is Higher then specified, if you put 2 it will only raise alarm on 3.
Nagios checkcommands.cfg
define command{
command_name  check_nrpe_fileage
command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -u -c check_fileage -a  $ARG1$  $ARG2$  $ARG3$
}

Nagios services.cfg
define service{
hostgroup_name                  DIBA_Win2k3_Exchange
service_description             Antivirus Actualizado
use                             DIBA-generic
check_command                   check_nrpe_fileage!C://PROGRA~1//COMMON~1//NETWOR~1//Engine//scan.dat!10!7
max_check_attempts                      2
normal_check_interval           1441
retry_check_interval            20
active_checks_enabled           1
passive_checks_enabled          0
process_perf_data                       0
notification_interval           1441
notifications_enabled           0
}

NRPE_NT c:nrpe_ntnrpe.cfg

command[check_fileage]=cscript.exe //nologo //T:90 c:nrpe_ntpluginsv2check_fileage.vbs -f $ARG1$ -w $ARG2$ -c $ARG3$
Download check_fileage.vbs

Tags: , , , , , ,

23 thoughts on “Check FileAge Nagios Plugin

  1. I have tried to check files on a network like serverdir$ but it won’t work. Is someone out there who did solve this problem?

    1. Hey Peter,
      You must use the correct arguments and remember always to have the path with double slashes
      Take a look at http://felipeferreira.net/?p=53
      check_filesize -p “c:windowssystem32” -f “services.exe,notepad.exe” -w 1 -c 5
      cheers,
      Felipe

  2. Hello Felipe,
    Thanks for your answer. Still I’m puzzled. I cannot address network drives, nor with check_fileage nor with check_filesize. When I set the debug switch to 7 in the nrpe_nt.cfg I see the actual command in the nrpe_nt.log. When I copy the command from the log-file and drop it into a DOS-box it works fine. It seems that if the nrpe_nt.exe is activated by nagios it can not address network drives. A small detail: local drives like C: give no problem.

  3. Hello Felipe,
    An important fact I forgot to mention. I even hard-coded the network drive into the code of the your script(s): CheckFolder “O:clearing”, sFile
    The check “If oFSO.FolderExists(objFolder)” returns always False.
    Regqrds, Peter

    1. Peter,
      I have never tried doing for a remote drive. CHeck if there is any Option Explicit if so remove it. You can even comment that If.
      You are the right path, first test the .vbs local then from nrpe. Try using resume next inside that function.
      Good luck,
      Felipe

  4. Is there a way to check the values in relation to minutes vs days? I have a file I want to make sure is changed every 15 minutes.

  5. I was beeing scouring the WWW for such info and i wanted to thank you for this post. Also, just off topic, how can i download a copy of this theme? – Regards

  6. Hello, is it possible to use a wildcard (*) for multiple files? Ultimately, I am trying to make sure that all files in a specific directory are not older than X amount of days. Since my backup files in the directory are configured to include the date, the filename will never be the same.
    Thanks in advance.

  7. We got a little problemen at work with some values not returning a OK, Warning or Critical status with some configurations. Also, Nagios uses exitcode 3 as UNKNOWN. In your script it is ERROR. We made the next adjustments for our needs. Maybe someone else could use them aswell:
    ‘ CheckAge compare with arguments
    outputmsgstats = “UNKNOWN ”
    intExit = intError
    If (dif >= intCrit) Then
    outputmsgstats = “CRITICAL ”
    intExit = intCritical
    Elseif (dif >= intWarn) Then
    outputmsgstats = “WARNING ”
    intExit = intWarning
    Else outputmsgstats = “OK ”
    intExit = intOK
    With the next line you get performance graphs in Nagios:
    outputmsgstats = outputmsgstats & “Difference is ” & dif & ” day(s) |days=” & dif & “;” & intWarn & “;” & intCrit & “;;”
    Many thanks for the script..

  8. I have done all the configuration as per stated above when started monitoring it from nagios getting error as “Request contained arguments (not currently allowed, check the allow arguments option)”.
    I am running #./check_nrpe -H 192.168.25.23 -p 5666 -t 30 -c check_fileage -a w 10 c 7
    from nagios /usr/etc/local/nagios/libexec.
    What could be the reason and who would i correct. Your quick reply will be highly appreciable.

  9. Hi Felipe,
    Your links are not working – can you please post the source?
    Cheers,
    H

  10. Team,
    I’m looking for instructions to setup monitoring to find the Number of files in a folder and the oldest file in that folder.
    Could some one please assist me with this?

  11. Check_fileage.vbs link in the begining of the page is giving 404 error. Can i get the file sent in email or a link where i can download?

Leave a Reply

Your email address will not be published. Required fields are marked *