ports/139848: add pre-caching to net-mgmt/nagios rc.d script
kimo
kimor79 at yahoo.com
Thu Oct 22 20:50:02 UTC 2009
>Number: 139848
>Category: ports
>Synopsis: add pre-caching to net-mgmt/nagios rc.d script
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu Oct 22 20:50:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: kimo
>Release:
>Organization:
>Environment:
FreeBSD ops1.lab1.bitgravity.com 7.1-RELEASE-p8 FreeBSD 7.1-RELEASE-p8 #0: Thu Oct 15 18:59:54 UTC 2009 kimo at bitgravity.com:/usr/obj/usr/src/sys/BITGRAVITY amd64
>Description:
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.
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
--- /tmp/nagios.in.orig 2009-10-22 13:33:01.000000000 -0700
+++ /tmp/nagios.in 2009-10-22 13:35:46.000000000 -0700
@@ -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 @@
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 @@
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"
}
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list