Fixed typo in check_disk
[monitoring-plugins.git] / contrib / sched_downtime.pl
blobb46b482c33a899b891f007205df1bc8aead4011a
1 #! /usr/bin/perl -w
3 # Marko Riedel, EDV Neue Arbeit gGmbH, mriedel@neuearbeit.de
8 use POSIX qw(strtol);
10 my $command_file = '/usr/local/nagios/var/rw/nagios.cmd';
12 my $hour = (60*60);
13 my $next_day = (24*60*60);
15 my $downtimes =
18 host => 'somehost',
19 service => 'SERVICE',
20 times => [ ["00:00", 9], ["18:00", 6] ]
24 foreach my $entry (@$downtimes) {
25 my ($secstart, $secend, $cmd, $current);
27 $current = `/bin/date +"%s"`;
28 chomp $current;
30 foreach my $tperiod (@{ $entry->{times} }){
31 $secstart = strtol(`/bin/date -d "$tperiod->[0]" +"%s"`);
32 $secend = $secstart+$tperiod->[1]*$hour;
34 $secstart += $next_day;
35 $secend += $next_day;
37 $cmd = "[$current] SCHEDULE_SVC_DOWNTIME;";
38 $cmd .= "$entry->{host};$entry->{service};";
39 $cmd .= "$secstart;$secend;";
40 $cmd .= "1;0;$0;automatically scheduled;\n";
42 print STDERR $cmd;
44 system "echo \"$cmd\" >> $command_file";