Scheduling a weekly check

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
cunningrat
Posts: 29
Joined: Mon Nov 18, 2013 5:51 pm

Scheduling a weekly check

Post by cunningrat »

Got a problem configuring a check: I'm not sure how to implement it.

A file arrives on the server on Friday, some time between 4 and 6 PM. What I need to do is as follows:
* Look for the file's presence. If it's not present, don't panic yet: it may arrive later.
* If the file is present, scan it for certain strings. If they're not present, panic.
* If the file isn't present by 6 PM, panic.

I can script most of the logic on the monitored server side, that's not an issue.
Running the script only on Friday between 4 and 6 PM is not an issue either, I can use the timeperiod definitions to do that.
The question is, how can I configure Nagios to keep checking, but only send out an alert if the file doesn't contain the right strings OR if it's not present by 6 PM?

One way to do it that I've thought of is to make my script that scans the file also check the time, and return a CRITICAL result if the file's not there by 6 PM. Any other ways anyone can think of?
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Scheduling a weekly check

Post by sreinhardt »

I would 100% agree with having the script handle all of the logic for alerting. My thought would be:

Code: Select all

if file is present { (file is present)
 are certain strings there{ (strings are present)
        echo "File is there, and strings are present"
        exit 0
  } (end strings yes)
  else { (strings are not there)
       echo "File present, strings are missing"
       exit 2
     } (end strings no)
} (end file present yes)
elseif, is past 6pm { (file is not present, is past 6)
  echo "File not present, and is past 6pm"
  exit 2
} (end file present no, and past 6)
else { (file not present, not past 6)
  echo "File not present, not past 6pm"
  exit 0
} (end file not present, not past 6) 
echo "Script did not complete correctly"
exit 3 (message and exit code for unknown in the case of script failure)
does that make sense for what you would like to do?
edit: hopefully it is clear that this is pseudo code and will not actually function. :D
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked