Special time schedule

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
sszabo
Posts: 3
Joined: Wed Nov 09, 2011 3:40 am

Special time schedule

Post by sszabo »

Hi All,

I have a question related to the check scheduling.
I'd like to create a check whick will run the same specific time in every hours. E.g. I'd like to run a check at 01:10 and 02:10 and 03:10 ...
Can I do this anyhow?

I know the following possibilities:
- I can create a service with a check_interval 60 minutes, but in this case I cannot force the exact time of the check within the hour.
- I can create a special time period with value '00:10-00:05,01:10-01:15,02:10-02-15...' and I can leave the check_interval's value on 5 minutes, but this is ang ugly solution.

Is there any 'elegant' solution for this issue?

Thanks for your help.
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Special time schedule

Post by jsmurphy »

To the best of my knowledge there is no more elegant solution to achieve this, the other option is to make that check passive if possible.
sszabo
Posts: 3
Joined: Wed Nov 09, 2011 3:40 am

Re: Special time schedule

Post by sszabo »

This is not good. :(

However, I have created a quite elegant solution for this issue. This is a '3rd party' solution.
I have created a script which check the current time on the machine and if the minutes are not between the desired values it sends back an information message about the check postpone and exit with OK state.

Here is the script:

Code: Select all

#!/bin/bash
#
# Check scheduler for check_clamav
#
# Copyright Sandor Szabo <sszabo@taylorandtaylor.hu>, (c) 2011.
# Revised: 2011.11.16.
#

MINUTES=`date | sed -r 's/.*:([0-9][0-9]):.*/\1/g'`

if [[ $MINUTES -ge 10 && $MINUTES -le 15 ]]
then
   ./check_something $*
else
   echo "Service OK: Check postponed to next hour"
   exit 0
fi
If anybody needs it feel free to modify and use it.
Note: The script should be in the same directory as the original check.
sszabo
Posts: 3
Joined: Wed Nov 09, 2011 3:40 am

Re: Special time schedule

Post by sszabo »

I have one modification for my earlier post (code).
The checker script should be used with full path, so e.g. the related row should be modified to this:

Code: Select all

   /usr/lib/nagios/plugins/check_service $*
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Special time schedule

Post by jsmurphy »

Very cool way of doing it, glad you find a solution.
Locked