From owner-freebsd-ports-bugs@FreeBSD.ORG Thu Oct 22 20:50:02 2009 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0676C1065670 for ; Thu, 22 Oct 2009 20:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BD92B8FC19 for ; Thu, 22 Oct 2009 20:50:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n9MKo13r026121 for ; Thu, 22 Oct 2009 20:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n9MKo1Me026120; Thu, 22 Oct 2009 20:50:01 GMT (envelope-from gnats) Resent-Date: Thu, 22 Oct 2009 20:50:01 GMT Resent-Message-Id: <200910222050.n9MKo1Me026120@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, kimo Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D52491065693 for ; Thu, 22 Oct 2009 20:47:59 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id AB40D8FC43 for ; Thu, 22 Oct 2009 20:47:59 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n9MKlxc3045193 for ; Thu, 22 Oct 2009 20:47:59 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n9MKlxdv045192; Thu, 22 Oct 2009 20:47:59 GMT (envelope-from nobody) Message-Id: <200910222047.n9MKlxdv045192@www.freebsd.org> Date: Thu, 22 Oct 2009 20:47:59 GMT From: kimo To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/139848: add pre-caching to net-mgmt/nagios rc.d script X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2009 20:50:02 -0000 >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@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: