diff options
author | pgollucci <pgollucci@FreeBSD.org> | 2010-01-08 09:19:53 +0800 |
---|---|---|
committer | pgollucci <pgollucci@FreeBSD.org> | 2010-01-08 09:19:53 +0800 |
commit | 36d1704182c561643b9345c3e653826200ba4d73 (patch) | |
tree | aaa44335bc5a599ddae558fc5a8af4a96fe9f3ea /net-mgmt | |
parent | 925241c19dfb7b8eb516008cbeaf504f065f619e (diff) | |
download | freebsd-ports-graphics-36d1704182c561643b9345c3e653826200ba4d73.tar.gz freebsd-ports-graphics-36d1704182c561643b9345c3e653826200ba4d73.tar.zst freebsd-ports-graphics-36d1704182c561643b9345c3e653826200ba4d73.zip |
- The nagios documentation
(http://nagios.sourceforge.net/docs/3_0/faststartup.html) recommends,
for faster startup times, pre-caching the configuration file. This patch
adds a "nagios_precache" rcvar which controls using the pre-cache
startup method.
- also fix a trailing \
PR: ports/139848
Submitted by: kimo <kimor79@yahoo.com>
Approved by: maintainer (Jarrod Sayers <jarrod@netleader.com.au>)
Diffstat (limited to 'net-mgmt')
-rw-r--r-- | net-mgmt/nagios/files/nagios.in | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/net-mgmt/nagios/files/nagios.in b/net-mgmt/nagios/files/nagios.in index 33356a0ee3f..f16cbf1f748 100644 --- a/net-mgmt/nagios/files/nagios.in +++ b/net-mgmt/nagios/files/nagios.in @@ -12,6 +12,8 @@ # Add the following lines to /etc/rc.conf to enable nagios: # nagios_enable (bool): Set to "NO" by default. # Set it to "YES" to enable nagios. +# nagios_precache (bool): Set to "NO" by default. +# Set it to "YES" to enable pre-caching. # nagios_flags (str): Set to "" by default. # nagios_configfile (str): Set to "%%PREFIX%%/etc/nagios/nagios.cfg" by default. # @@ -30,17 +32,35 @@ nagios_user="%%NAGIOSUSER%%" start_precmd="start_precmd" stop_postcmd="stop_postcmd" restart_precmd="nagios_checkconfig" -reload_precmd="nagios_checkconfig" +reload_precmd="reload_precmd" sig_reload=HUP [ -z "${nagios_enable}" ] && nagios_enable="NO" [ -z "${nagios_configfile}" ] && nagios_configfile="%%PREFIX%%/etc/nagios/nagios.cfg" +[ -z "${nagios_precache}" ] && nagios_precache="NO" load_rc_config "${name}" required_files="${nagios_configfile}" command_args="${command_args} ${nagios_configfile}" +nagios_cacheconfig() { + if ! checkyesno nagios_precache; then + return 0 + fi + + echo -n "Pre-Caching nagios configuration: " + ${command} -pv ${nagios_configfile} 2>&1 >/dev/null + if [ $? != 0 ]; then + echo "FAILED" + ${command} -v ${nagios_configfile} + return 1 + else + command_args="-u -x ${command_args}" + echo "OK" + fi +} + nagios_checkconfig() { echo -n "Performing sanity check of nagios configuration: " ${command} -v ${nagios_configfile} 2>&1 >/dev/null @@ -53,11 +73,25 @@ nagios_checkconfig() { fi } +reload_precmd() { + if ! nagios_checkconfig; then + return 1 + fi + + if ! nagios_cacheconfig; then + return 1 + fi +} + start_precmd() { if ! nagios_checkconfig; then return 1 fi + if ! nagios_cacheconfig; then + return 1 + fi + su -m "${nagios_user}" -c "touch \"%%NAGIOSDIR%%/nagios.log\" \"%%NAGIOSDIR%%/status.sav\"" rm -f "%%NAGIOSDIR%%/rw/nagios.cmd" } |