2004-02-11 04:56:00 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Add the following lines to /etc/rc.conf to enable nagios:
|
|
|
|
#
|
|
|
|
#nagios_enable="YES"
|
|
|
|
#
|
|
|
|
|
|
|
|
. %%RC_SUBR%%
|
|
|
|
|
|
|
|
name=nagios
|
|
|
|
rcvar=`set_rcvar`
|
|
|
|
|
|
|
|
prefix=%%PREFIX%%
|
|
|
|
|
|
|
|
required_files=${prefix}/etc/nagios/nagios.cfg
|
|
|
|
|
|
|
|
NagiosBin=${prefix}/bin/nagios
|
|
|
|
NagiosCfg=${prefix}/etc/nagios/nagios.cfg
|
2005-02-14 21:52:42 +00:00
|
|
|
NagiosVar=%%NAGIOSDIR%%
|
2004-02-11 04:56:00 +00:00
|
|
|
NagiosLog=${NagiosVar}/status.log
|
|
|
|
NagiosTmp=${NagiosVar}/nagios.tmp
|
|
|
|
NagiosSav=${NagiosVar}/status.sav
|
|
|
|
NagiosCmd=${NagiosVar}/rw/nagios.cmd
|
|
|
|
NagiosRun=${NagiosVar}/nagios.lock
|
|
|
|
|
|
|
|
pidfile=${NagiosRun}
|
|
|
|
command=${NagiosBin}
|
|
|
|
command_args="-d $NagiosCfg"
|
2005-02-14 21:52:42 +00:00
|
|
|
nagios_user=%%NAGIOSUSER%%
|
2004-02-11 04:56:00 +00:00
|
|
|
|
|
|
|
start_precmd=start_precmd
|
|
|
|
stop_postcmd=stop_postcmd
|
2005-05-19 15:56:37 +00:00
|
|
|
restart_precmd=nagios_checkconfig
|
2004-02-11 04:56:00 +00:00
|
|
|
|
|
|
|
# set defaults
|
|
|
|
|
|
|
|
nagios_enable=${nagios_enable:-"NO"}
|
|
|
|
nagios_flags=${nagios_flags:-""}
|
|
|
|
|
2005-05-19 15:56:37 +00:00
|
|
|
nagios_checkconfig()
|
|
|
|
{
|
|
|
|
echo -n 'Performing sanity check on Nagios configuration: '
|
|
|
|
$NagiosBin -v $NagiosCfg > /dev/null 2>&1
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo 'FAILED.'
|
|
|
|
echo "Use '$NagiosBin -v $NagiosCfg' command for details."
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
echo 'OK.'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2004-02-11 04:56:00 +00:00
|
|
|
start_precmd()
|
|
|
|
{
|
2005-05-19 15:56:37 +00:00
|
|
|
nagios_checkconfig; [ $? != 0 ] && return 1
|
|
|
|
|
2004-02-11 04:56:00 +00:00
|
|
|
su -m ${nagios_user} -c "touch ${NagiosVar}/nagios.log ${NagiosSav}"
|
|
|
|
rm -f ${NagiosCmd}
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_postcmd()
|
|
|
|
{
|
|
|
|
rm -f $NagiosLog $NagiosTmp $NagiosRun $NagiosCmd
|
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|