[Pkg-nagios-changes] nagios NEWS, 1.6, 1.7 README.mysql, 1.5, 1.6 README.pgsql, 1.5, 1.6 changelog, 1.82, 1.83 nagios-common.nagios.init, 1.9, 1.10

seanius at haydn.debian.org seanius at haydn.debian.org
Thu Nov 17 16:22:04 UTC 2005


Update of /cvsroot/pkg-nagios/nagios
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv3470

Modified Files:
	NEWS README.mysql README.pgsql changelog 
	nagios-common.nagios.init 
Log Message:
init script is now a little more flexible.  changelog has details.


Index: NEWS
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/NEWS,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- NEWS	3 Apr 2005 00:34:28 -0000	1.6
+++ NEWS	17 Nov 2005 16:22:00 -0000	1.7
@@ -1,3 +1,12 @@
+nagios (2:1.3-cvs.20050402-9) unstable; urgency=low
+
+  the nagios init script now dynamically determines the location of
+  the "command_file" named pipe and "nagios_check_command", which
+  should make your life easier if you have things somewhere the
+  init script doesn't automatically know about.
+
+ -- sean finney <seanius at debian.org>  Thu, 17 Nov 2005 16:59:58 +0100
+
 nagios (2:1.3-cvs.20050402-1) unstable; urgency=low
 
   if you're using nagios in a virtualhost and the latest version breaks

Index: README.mysql
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/README.mysql,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- README.mysql	11 May 2005 00:40:41 -0000	1.5
+++ README.mysql	17 Nov 2005 16:22:00 -0000	1.6
@@ -79,22 +79,20 @@
 
 Then you want the cgi-script and the init.d script to correctly
 know the status of nagios. To do this you will need something like the
-check_nagios_db file from /usr/share/doc/nagios-common/.  put it where you
-like but adjust the paths in the following examples. the default example
-will assume you put it in /etc/nagios/check_nagios_db as the init-script
-now already looks there by default and if it is there it will automagically
-use it.
+check_nagios_db file from /usr/share/doc/nagios-common/.  put it somewhere
+like /usr/local/sbin/check_nagios_db (which will be assumed for the
+rest of the document). 
 
 Make it executable:
-# chmod +x /etc/nagios/check_nagios_db
+# chmod +x /usr/local/sbin/check_nagios_db
 
-Now edit the /etc/nagios/cgi.cfg and put a # in front of the line
+Now edit the /etc/nagios/cgi.cfg and change the line:
 
 nagios_check_command=/usr/lib/nagios/plugins/check_nagios /var/log/nagios/status.log 5 'nagios'
 
-and remove the # in front of the line
+to read:
 
-nagios_check_command=/etc/nagios/check_nagios_db
+nagios_check_command=/usr/local/sbin/check_nagios_db
 
 and finally, now (re)start nagios
 
@@ -112,3 +110,5 @@
   by Jeff Bailey on the Debian GNU/Linux BTS (bug #163811).
 / updated by sean finney 20050215 with some clarifications about
   conf file defaults
+/ updated again by sean finney on 20051117 to reflect improvements to
+  the init script

Index: README.pgsql
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/README.pgsql,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- README.pgsql	25 Jul 2005 00:00:24 -0000	1.5
+++ README.pgsql	17 Nov 2005 16:22:00 -0000	1.6
@@ -66,8 +66,8 @@
 
    Then, create a copy of the check_nagios_db script:
 
-cp /usr/share/doc/nagios-pgsql/check_nagios_db /etc/nagios/
-chmod +x /etc/nagios/check_nagios_db
+cp /usr/share/doc/nagios-pgsql/check_nagios_db /usr/local/sbin/
+chmod +x /usr/local/sbin/check_nagios_db
 
    Apply these changes to check_nagios_db:
 
@@ -126,7 +126,7 @@
 
    In the same file, change the check command:
 
-nagios_check_command=/etc/nagios/check_nagios_db
+nagios_check_command=/usr/local/sbin/check_nagios_db
 
    Check and restart:
 

Index: changelog
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/changelog,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- changelog	3 Nov 2005 10:28:34 -0000	1.82
+++ changelog	17 Nov 2005 16:22:00 -0000	1.83
@@ -1,3 +1,19 @@
+nagios (2:1.3-cvs.20050402-9) UNRELEASED; urgency=low
+
+  * Sean Finney:
+    - rework the init script use the same nagios_check_command
+      as cgi.cfg, which should make life easier for people transitioning
+      from earlier versions, users of db-flavored nagioses, and also
+      anyone else who has a status log not where we think it ought to
+      be (closes: #339401).
+    - modified get_config to use arbitrary config files, so the
+      above improvements were possible.
+    - likewise, improved init script to get the location for
+      the named pipe dynamically.
+    - updated NEWS/README.* to reflect all this.
+
+ -- sean finney <seanius at debian.org>  Thu, 17 Nov 2005 16:46:43 +0100
+
 nagios (2:1.3-cvs.20050402-8) unstable; urgency=low
 
   * Sean Finney:

Index: nagios-common.nagios.init
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/nagios-common.nagios.init,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- nagios-common.nagios.init	15 Mar 2005 00:56:39 -0000	1.9
+++ nagios-common.nagios.init	17 Nov 2005 16:22:01 -0000	1.10
@@ -8,9 +8,9 @@
 NAME=nagios
 DESC=nagios
 NICENESS=5
-NAMEDPIPE=/var/run/nagios/nagios.cmd
 PIDFILE=/var/run/nagios/nagios.pid
 CONFIG=/etc/nagios/nagios.cfg
+CGICONFIG=/etc/nagios/cgi.cfg
 
 test -f $DAEMON || exit 0
 
@@ -25,19 +25,20 @@
 #	check_started()
 #
 # checks not only for the pid (which could be done by start-stop-daemon), 
-# but also for whether or not nagios is updating the status log (or database
-# in the case of nagios-mysql and nagios-pgsql)
+# but also for whether or not nagios is running according to the same
+# nagios_check_command as defined by the web interface in $CGICFG.  this
+# should make things easier for the db-flavored nagioses, or other
+# nagioses where the status log is in a different location too.
 #
 check_started () {
-	if [ -f /etc/nagios/check_nagios_db ]; then
-		if ! /etc/nagios/check_nagios_db > /dev/null; then
-			return 1 	# isn't started
-		fi
-	elif [ -f /usr/lib/nagios/plugins/check_nagios ]; then
-		if ! /usr/lib/nagios/plugins/check_nagios -e 15 -F /var/log/nagios/status.log -C '/usr/sbin/nagios' > /dev/null; then
-			return 1    # isn't started
-		fi
+	check_cmd=`get_config "nagios_check_command" "$CGICFG"`
+	if [ ! "$check_cmd" ]; then
+		echo "unable to determine nagios_check_command from $CGICFG!" >&2
+		return 1
 	fi
+
+	eval $check_cmd >/dev/null
+		
 	if [ -f $PIDFILE ]; then
 		pid=`cat $PIDFILE`
 		if [ "$pid" ] && ps $pid >/dev/null; then
@@ -47,9 +48,21 @@
 	return 1	# Isn't started
 }
 
+#
+#	get_config()
+#
+#	grab a config option from nagios.cfg (or possibly another nagios config
+#	file if specified).  everything after the '=' is echo'd out, making
+#	this a nice generalized way to get requested settings.
+#
 get_config () {
-    set -- `grep ^$1 $CONFIG | sed 's@=@ @'`
-    echo $2
+	if [ "$2" ]; then
+    	set -- `grep ^$1 $2 | sed 's@=@ @'`
+	else
+    	set -- `grep ^$1 $CONFIG | sed 's@=@ @'`
+	fi
+	shift
+    echo $*
 }
 
 check_config () {
@@ -73,43 +86,46 @@
 }
 
 check_named_pipe () {
-    if [ -p $NAMEDPIPE ]; then
-	return 1   # a named pipe exists
-    else
-	return 0   # no named pipe exists
-    fi
+	nagiospipe=`get_config command_file`
+	if [ -p "$nagiospipe" ]; then
+		return 1   # a named pipe exists
+	else
+		return 0   # no named pipe exists
+	fi
 }
 
 case "$1" in
-  start)
+start)
 	echo -n "Starting $DESC: "
 	if ! check_started; then
-	    if ! check_named_pipe; then
-		echo "named pipe exists - removing"
-		rm -f $NAMEDPIPE
-	    fi
+		if ! check_named_pipe; then
+			echo "named pipe exists - removing"
+			rm -f $nagiospipe
+		fi
 
-	    if check_config; then
-		rm -f $NAMEDPIPE		
-	    start-stop-daemon --start --quiet \
-			--nicelevel $NICENESS \
-		    --pidfile $PIDFILE \
-		    --make-pidfile --background --exec $DAEMON -- $CONFIG
-		echo "$NAME."
-	    else
-		echo "errors in config!"
-	    fi
+		if check_config; then
+			start-stop-daemon --start --quiet \
+			                  --nicelevel $NICENESS \
+			                  --pidfile $PIDFILE \
+			                  --make-pidfile --background \
+			                  --exec $DAEMON -- $CONFIG
+			echo "$NAME."
+		else
+			echo "errors in config!"
+		fi
 	else
-	    echo "already running"
+		echo "already running"
 	fi
 	;;
-  stop)
+stop)
 	echo -n "Stopping $DESC: "
 	start-stop-daemon --stop --quiet --pidfile $PIDFILE \
 		--oknodo --exec $DAEMON
 	echo "$NAME."
 	rm -f $PIDFILE
-	rm -f $NAMEDPIPE
+	if ! check_named_pipe; then
+		rm -f $nagiospipe
+	fi
 	;;
   reload|force-reload)
 	echo "Reloading $DESC configuration files."




More information about the Pkg-nagios-changes mailing list