monitor incoming file for 1hr; go warning->critical at end of hour

Jim Avery jim at jimavery.me.uk
Sat Sep 11 12:52:54 CEST 2010


On 11 September 2010 00:33, Lylex Ryan <lylexryan at yahoo.com> wrote:
> I want to monitor a service over the course of one hour each day, waiting for the arrival of a critical file on the client. The check command initiates a script on the client via snmp, which looks for the file and returns a found or not-found. The check is now running fine when forced, and correctly indicates the arrival or absence of the file.
>
> During that hour, I'd like to see the service in a Warning state if the file hasn't arrived, then change to Critical at the end of the hour if there's still no sign of the file.
>
> My first thought was to monitor once every 10min, and go from Warning to Critical after 6 negative results. Here's my first attempt at the service config parameters, but I think I'm off in the deep weeds:
> check_interval 10
> max_check_attempts 6
> retry_interval 10
>
> Any advice is appreciated. Thanks....Lyle


I would use a passive check for this.  Set up a script in cron which
starts running at the beginning of the hour in question each day and
does something like this:


#!/bin/sh
count=60
while [ $count -ge 0 ]
do
  if `checkforfile`
  then
    (send an ok passive check to Nagios)
    exit 0
  else
    (send a warning passive check to Nagios)
  fi
  count=`expr $count - 1`
  sleep 60
done
(send a critical passive check to Nagios)
# script ends


You can use freshness checking to alert if no check result at all has
been received for more than 25 hours, which will cover the scenario
where your cron job has failed to run.

If you are running the script on the Nagios server, you can send the
check to Nagios using the command interface, alternatively use
send_nsca.  Personally I always use send_nsca as the script is more
portable then.

How long does the file exist for on the server?

Cheers,

Jim

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
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