From 07fe1d77c03173f0291da02360a806260542b559 Mon Sep 17 00:00:00 2001 From: Subhendu Ghosh Date: Sun, 9 Feb 2003 14:16:29 +0000 Subject: more contribs git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@300 f882894a-f735-0410-b71e-b25c423dba1c --- contrib/sched_downtime.pl | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 contrib/sched_downtime.pl (limited to 'contrib/sched_downtime.pl') diff --git a/contrib/sched_downtime.pl b/contrib/sched_downtime.pl new file mode 100644 index 00000000..b46b482c --- /dev/null +++ b/contrib/sched_downtime.pl @@ -0,0 +1,47 @@ +#! /usr/bin/perl -w +# +# Marko Riedel, EDV Neue Arbeit gGmbH, mriedel@neuearbeit.de +# +# +# +# +use POSIX qw(strtol); + +my $command_file = '/usr/local/nagios/var/rw/nagios.cmd'; + +my $hour = (60*60); +my $next_day = (24*60*60); + +my $downtimes = + [ + { + host => 'somehost', + service => 'SERVICE', + times => [ ["00:00", 9], ["18:00", 6] ] + } + ]; + +foreach my $entry (@$downtimes) { + my ($secstart, $secend, $cmd, $current); + + $current = `/bin/date +"%s"`; + chomp $current; + + foreach my $tperiod (@{ $entry->{times} }){ + $secstart = strtol(`/bin/date -d "$tperiod->[0]" +"%s"`); + $secend = $secstart+$tperiod->[1]*$hour; + + $secstart += $next_day; + $secend += $next_day; + + $cmd = "[$current] SCHEDULE_SVC_DOWNTIME;"; + $cmd .= "$entry->{host};$entry->{service};"; + $cmd .= "$secstart;$secend;"; + $cmd .= "1;0;$0;automatically scheduled;\n"; + + print STDERR $cmd; + + system "echo \"$cmd\" >> $command_file"; + } +} + -- cgit v1.2.3-74-g34f1