Home > Nagios, plugins > Check FileAge Nagios Plugin

Check FileAge Nagios Plugin

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

  1. Peter
    June 18th, 2009 at 21:21 | #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?

    • admin
      June 19th, 2009 at 08:46 | #2

      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

  2. June 25th, 2009 at 09:07 | #3

    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. June 25th, 2009 at 17:14 | #4

    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

    • admin
      June 26th, 2009 at 13:28 | #5

      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,

  4. Jason
    July 14th, 2009 at 23:03 | #6

    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. Bruno Padilha
    May 20th, 2010 at 12:03 | #7

    Maybe you have to use “\serverfolder”

  6. September 21st, 2010 at 09:36 | #8

    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

  7. George
    March 28th, 2012 at 14:03 | #9

    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.

  8. Ferdi Ogier
    July 6th, 2012 at 08:56 | #10

    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..

  9. Sanjay
    September 5th, 2012 at 13:26 | #11

    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 -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.

  10. Dan Williams
    July 26th, 2013 at 16:01 | #12

    Can you post the source on here as the links not working?



  11. November 29th, 2013 at 14:24 | #13

    Hi Felipe,
    i’m interested in your plugin for nagios CheckFileAge for Windows. In my case this is a Windows 7 machine.
    I tried to download from your website the script but http://www.xoroz.com/files/scripts/nagios/check_fileage.txt don’t work…
    Another question : 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.


  12. Hamish
    March 3rd, 2015 at 19:40 | #14

    Hi Felipe,

    Your links are not working – can you please post the source?


  13. June 18th, 2015 at 16:37 | #15


    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?

  14. June 18th, 2015 at 16:38 | #16

    BTW it’s for windows Server

  15. Naveen
    March 17th, 2016 at 07:13 | #17

    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?

  16. SimonHansen
    August 25th, 2016 at 07:13 | #19

    I have the same problem as Naveen

  17. Ludmil
    August 25th, 2016 at 14:18 | #20

    The plugin’s download link – http://www.xoroz.com/files/scripts/nagios/check_fileage.txt gives me “404 – Not Found”. Can you fix it? Thanks!

  1. April 15th, 2009 at 10:20 | #1
  2. May 1st, 2009 at 07:00 | #2