-
Notifications
You must be signed in to change notification settings - Fork 13
/
nagios_downtime.init
executable file
·96 lines (90 loc) · 2.02 KB
/
nagios_downtime.init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
# Copyright (c) 2008-2009 Lars Michelsen <[email protected]>
# All rights reserved.
#
# Author: Lars Michelsen <[email protected]>
#
# chkconfig: 345 99 01
# description: Schedules a downtime in Nagios
#
### BEGIN INIT INFO
# Provides: nagios_downtime
# Required-Start: $network
# Required-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: nagios_downtime schedules a downtime to Nagios
# Description: The nagios_downtime script schedules a downtime
# to the specified Nagios host. The downtime script needs HTTP-access
# to the Nagios cmd.cgi to be able to post a downtime.
### END INIT INFO
BAR_BIN=/usr/bin/nagios_downtime
#BAR_BIN=./nagios_downtime
# Source function library, for e.g. echo_success or echo_failure
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
echo_success() {
return 0
}
echo_failure() {
return 1
}
fi
# Check for missing binaries
test -x $BAR_BIN || {
echo "$BAR_BIN not installed";
if [ "$1" = "stop" ]; then
exit 0;
else
exit 5;
fi;
}
case "$1" in
stop)
echo -n "Scheduling Nagios downtime (nagios_downtime)... "
$BAR_BIN
if [ $? -eq 0 ]; then
if [ -f /var/lock/subsys/nagios_downtime ]; then
rm -f /var/lock/subsys/nagios_downtime
fi
echo_success
echo "done."
exit 0
else
if [ -f /var/lock/subsys/nagios_downtime ]; then
rm -f /var/lock/subsys/nagios_downtime
fi
echo_failure
echo "ERROR"
exit 1
fi
;;
start)
echo -n "Removing Nagios downtime (nagios_downtime)... "
$BAR_BIN -m del
if [ $? -eq 0 ]; then
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/nagios_downtime
fi
echo_success
echo "done."
exit 0
else
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/nagios_downtime
fi
echo_failure
echo "ERROR"
exit 1
fi
;;
status)
echo -n "Script only running while start or stop the System..."
;;
*)
# If no parameters are given, print which are avaiable
echo "Usage: $0 {stop|start}"
exit 1
;;
esac