Lines 12-17
Link Here
|
12 |
# Add the following lines to /etc/rc.conf to enable nagios: |
12 |
# Add the following lines to /etc/rc.conf to enable nagios: |
13 |
# nagios_enable (bool): Set to "NO" by default. |
13 |
# nagios_enable (bool): Set to "NO" by default. |
14 |
# Set it to "YES" to enable nagios. |
14 |
# Set it to "YES" to enable nagios. |
|
|
15 |
# nagios_precache (bool): Set to "NO" by default. |
16 |
# Set it to "YES" to enable pre-caching. |
15 |
# nagios_flags (str): Set to "" by default. |
17 |
# nagios_flags (str): Set to "" by default. |
16 |
# nagios_configfile (str): Set to "%%PREFIX%%/etc/nagios/nagios.cfg" by default. |
18 |
# nagios_configfile (str): Set to "%%PREFIX%%/etc/nagios/nagios.cfg" by default. |
17 |
# |
19 |
# |
Lines 30-46
Link Here
|
30 |
start_precmd="start_precmd" |
32 |
start_precmd="start_precmd" |
31 |
stop_postcmd="stop_postcmd" |
33 |
stop_postcmd="stop_postcmd" |
32 |
restart_precmd="nagios_checkconfig" |
34 |
restart_precmd="nagios_checkconfig" |
33 |
reload_precmd="nagios_checkconfig" |
35 |
reload_precmd="reload_precmd" |
34 |
sig_reload=HUP |
36 |
sig_reload=HUP |
35 |
|
37 |
|
36 |
[ -z "${nagios_enable}" ] && nagios_enable="NO" |
38 |
[ -z "${nagios_enable}" ] && nagios_enable="NO" |
37 |
[ -z "${nagios_configfile}" ] && nagios_configfile="%%PREFIX%%/etc/nagios/nagios.cfg" |
39 |
[ -z "${nagios_configfile}" ] && nagios_configfile="%%PREFIX%%/etc/nagios/nagios.cfg" |
|
|
40 |
[ -z "${nagios_precache}" ] && nagios_precache="NO" |
38 |
|
41 |
|
39 |
load_rc_config "${name}" |
42 |
load_rc_config "${name}" |
40 |
|
43 |
|
41 |
required_files="${nagios_configfile}" |
44 |
required_files="${nagios_configfile}" |
42 |
command_args="${command_args} ${nagios_configfile}" |
45 |
command_args="${command_args} ${nagios_configfile}" |
43 |
|
46 |
|
|
|
47 |
nagios_cacheconfig() { |
48 |
if ! checkyesno nagios_precache; then |
49 |
return 0 |
50 |
fi |
51 |
|
52 |
echo -n "Pre-Caching nagios configuration: " |
53 |
${command} -pv ${nagios_configfile} 2>&1 >/dev/null |
54 |
if [ $? != 0 ]; then |
55 |
echo "FAILED" |
56 |
${command} -v ${nagios_configfile} |
57 |
return 1 |
58 |
else |
59 |
command_args="-u -x ${command_args}" |
60 |
echo "OK" |
61 |
fi |
62 |
} |
63 |
|
44 |
nagios_checkconfig() { |
64 |
nagios_checkconfig() { |
45 |
echo -n "Performing sanity check of nagios configuration: " |
65 |
echo -n "Performing sanity check of nagios configuration: " |
46 |
${command} -v ${nagios_configfile} 2>&1 >/dev/null |
66 |
${command} -v ${nagios_configfile} 2>&1 >/dev/null |
Lines 53-63
Link Here
|
53 |
fi |
73 |
fi |
54 |
} |
74 |
} |
55 |
|
75 |
|
|
|
76 |
reload_precmd() { |
77 |
if ! nagios_checkconfig; then |
78 |
return 1 |
79 |
fi |
80 |
|
81 |
if ! nagios_cacheconfig; then |
82 |
return 1 |
83 |
fi |
84 |
} |
85 |
|
56 |
start_precmd() { |
86 |
start_precmd() { |
57 |
if ! nagios_checkconfig; then |
87 |
if ! nagios_checkconfig; then |
58 |
return 1 |
88 |
return 1 |
59 |
fi |
89 |
fi |
60 |
|
90 |
|
|
|
91 |
if ! nagios_cacheconfig; then |
92 |
return 1 |
93 |
fi |
94 |
|
61 |
su -m "${nagios_user}" -c "touch \"%%NAGIOSDIR%%/nagios.log\" \"%%NAGIOSDIR%%/status.sav\"" |
95 |
su -m "${nagios_user}" -c "touch \"%%NAGIOSDIR%%/nagios.log\" \"%%NAGIOSDIR%%/status.sav\"" |
62 |
rm -f "%%NAGIOSDIR%%/rw/nagios.cmd" |
96 |
rm -f "%%NAGIOSDIR%%/rw/nagios.cmd" |
63 |
} |
97 |
} |