best expression of a timeperiod with same hours every day

Martin Melin martinm at op5.org
Mon Jan 25 08:33:03 CET 2010


There is no way to avoid having one line per weekday in the config, but that
doesn't mean that you have to write the definitions out by hand :-) A quick
shellscript to echo each weekday with an argument and you should be good to
go. Here you go:

#!/bin/sh
echo "sunday            $1"
echo "monday            $1"
echo "tuesday           $1"
echo "wednesday $1"
echo "thursday  $1"
echo "friday            $1"
echo "saturday  $1"

Add the above to a dir in your path, then when you need to add a timeperiod
definition you can use ":r ! timeperiod.sh 04:00-21:00" in vi, or something
similar in your editor of choice.

On Sun, Jan 24, 2010 at 7:41 PM, Justin Pryzby <justinp at norchemlab.com>wrote:

> Is there a shorter way of expressing this?  We have several cases
> where we need this, with different intervals.  I was hoping there was
> a way of writing it in fewer than 10 lines each.
>
> define timeperiod {
>        sunday          04:00-21:00
>        monday          04:00-21:00
>        tuesday         04:00-21:00
>        wednesday       04:00-21:00
>        thursday        04:00-21:00
>        friday          04:00-21:00
>        saturday        04:00-21:00
> }
>
> Thanks,
> Justin
>
>
> ------------------------------------------------------------------------------
> Throughout its 18-year history, RSA Conference consistently attracts the
> world's best and brightest in the field, creating opportunities for
> Conference
> attendees to learn about information security's most important issues
> through
> interactions with peers, luminaries and emerging and established companies.
> http://p.sf.net/sfu/rsaconf-dev2dev
> _______________________________________________
> 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
>



-- 
Martin Melin
____________________________
op5 AB
http://www.op5.com

http://www.op5.org/
http://www.op5.com/op5/products/network-monitor/nagios/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20100125/215c6155/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
-------------- next part --------------
_______________________________________________
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