diff options
author | Philip M. Gollucci <pgollucci@FreeBSD.org> | 2010-01-08 01:19:53 +0000 |
---|---|---|
committer | Philip M. Gollucci <pgollucci@FreeBSD.org> | 2010-01-08 01:19:53 +0000 |
commit | f2207a2a22ba92665b173fcd3a3d3c9c6e92b189 (patch) | |
tree | 27e559fe36c90ff0a0f54e8a9629f612994bddb8 /net-mgmt/nagios | |
parent | 2c35f85a6e1d8f39a1331a0ec90e761407f9888d (diff) |
- 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>)
Notes
Notes:
svn path=/head/; revision=247362
Diffstat (limited to 'net-mgmt/nagios')
-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 33356a0ee3fa..f16cbf1f748c 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" } |