check_file_age help

Justin T Pryzby justinp at norchemlab.com
Mon Jul 30 19:19:57 CEST 2012


Nagios probably doesn't use the shell, which is how wildcards get
expanded, so the plugin is just seeing "*" instead of a filename.

I suggest to use a shell wrapper, like

#! /bin/sh
set -e

d=/stuff/backup
pp=/usr/lib/nagios/plugins

x=`ls -lt "$d"` 1>&2 || exit 3
x=`echo "$x" |sed q`
exec $pp/check_file_age -f "$x" -w .. -c .. -W .. -C ..

Or you can keep a "current" symlink or such, pointing to the most
recent backup.

Justin

On Mon, Jul 30, 2012 at 12:57:21PM -0400, Jeremy Page wrote:
> Hello list, I am trying to use check_file_age on Ubuntu 10.04 to check a
> local file system. When I specify the file name it works but using a
> wildcard fails saying it cannot find the file. I need to use the
> wildcard - the files have unique names based on the date created.
> 
> Both work when run interactively from the command line as the Nagios
> service.
> 
> My check command is:
> define command {
>     command_name        check_file_age_v1
>     command_line        $USER1$/check_file_age -w $ARG1$ -c $ARG2$ -f $ARG3$
>     }
> 
> The service command is:
> 
> Works:
> define service{
>     host_name                 host.company.com
>     service_description    backup check - Is the file new in the past 24
> hours
>     check_command       
> check_file_age_v1!86400!172800!/stuff/backup/2012-07-30-02-01-30_backup.xml
>     use            generic-service
>     }
> 
> Does not work:
> define service{
>     host_name        host.company.com
>     service_description    backup check - Is the file new in the past 24
> hours
>     check_command        check_file_age_v1!86400!172800!/stuff/backup/*
>     use            generic-service
>     }
> 
> 
> 
> Please be advised that this email may contain confidential 
> information.  If you are not the intended recipient, please notify us 
> by email by replying to the sender and delete this message.  The 
> sender disclaims that the content of this email constitutes an offer 
> to enter into, or the acceptance of, any agreement; provided that the 
> foregoing does not invalidate the binding effect of any digital or 
> other electronic reproduction of a manual signature that is included 
> in any attachment.
> 
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null
> 

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list