diff options
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2003-02-09 14:16:29 +0000 |
---|---|---|
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2003-02-09 14:16:29 +0000 |
commit | 07fe1d77c03173f0291da02360a806260542b559 (patch) | |
tree | fdd11279ed05b38759afef2262f92b51cc091ba3 /contrib/sched_downtime.pl | |
parent | d4f25e47a0b89bdbcee8172fd2c0be8bf3b7f112 (diff) | |
download | monitoring-plugins-07fe1d77c03173f0291da02360a806260542b559.tar.gz |
more contribs
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@300 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/sched_downtime.pl')
-rw-r--r-- | contrib/sched_downtime.pl | 47 |
1 files changed, 47 insertions, 0 deletions
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 @@ | |||
1 | #! /usr/bin/perl -w | ||
2 | # | ||
3 | # Marko Riedel, EDV Neue Arbeit gGmbH, mriedel@neuearbeit.de | ||
4 | # | ||
5 | # | ||
6 | # | ||
7 | # | ||
8 | use POSIX qw(strtol); | ||
9 | |||
10 | my $command_file = '/usr/local/nagios/var/rw/nagios.cmd'; | ||
11 | |||
12 | my $hour = (60*60); | ||
13 | my $next_day = (24*60*60); | ||
14 | |||
15 | my $downtimes = | ||
16 | [ | ||
17 | { | ||
18 | host => 'somehost', | ||
19 | service => 'SERVICE', | ||
20 | times => [ ["00:00", 9], ["18:00", 6] ] | ||
21 | } | ||
22 | ]; | ||
23 | |||
24 | foreach my $entry (@$downtimes) { | ||
25 | my ($secstart, $secend, $cmd, $current); | ||
26 | |||
27 | $current = `/bin/date +"%s"`; | ||
28 | chomp $current; | ||
29 | |||
30 | foreach my $tperiod (@{ $entry->{times} }){ | ||
31 | $secstart = strtol(`/bin/date -d "$tperiod->[0]" +"%s"`); | ||
32 | $secend = $secstart+$tperiod->[1]*$hour; | ||
33 | |||
34 | $secstart += $next_day; | ||
35 | $secend += $next_day; | ||
36 | |||
37 | $cmd = "[$current] SCHEDULE_SVC_DOWNTIME;"; | ||
38 | $cmd .= "$entry->{host};$entry->{service};"; | ||
39 | $cmd .= "$secstart;$secend;"; | ||
40 | $cmd .= "1;0;$0;automatically scheduled;\n"; | ||
41 | |||
42 | print STDERR $cmd; | ||
43 | |||
44 | system "echo \"$cmd\" >> $command_file"; | ||
45 | } | ||
46 | } | ||
47 | |||