nagios start script errors

Morty morty+nagios at frakir.org
Sat Feb 12 00:01:28 CET 2011


The default nagios start/stop script sends errors to stdout rather
than stderr.  This isn't proper *nix behavior.  It's also not good for
scripting around nagios.  I.e. I have a script that wants to do
/etc/init.d/nagios stop >/dev/null && $other_stuff &&
/etc/init.d/nagios start >/dev/null && $more_stuff.  If the nagios
stop or start fails, I want a useful error message; otherwise, I want
it to succeed quietly.  Easy enough to fix; patch follows.  [Should I
send this to a different mailing list instead?]

diff -ur nagios-3.2.3.orig/daemon-init.in nagios-3.2.3/daemon-init.in
--- nagios-3.2.3.orig/daemon-init.in	Sun Nov 30 17:22:58 2008
+++ nagios-3.2.3/daemon-init.in	Thu Feb  3 08:51:54 2011
@@ -73,7 +73,7 @@
 {
 
 	if test ! -f $NagiosRunFile; then
-		echo "No lock file found in $NagiosRunFile"
+		echo "No lock file found in $NagiosRunFile" >&2
 		exit 1
 	fi
 
@@ -107,13 +107,13 @@
 
 # Check that nagios exists.
 if [ ! -f $NagiosBin ]; then
-    echo "Executable file $NagiosBin not found.  Exiting."
+    echo "Executable file $NagiosBin not found.  Exiting." >&2
     exit 1
 fi
 
 # Check that nagios.cfg exists.
 if [ ! -f $NagiosCfgFile ]; then
-    echo "Configuration file $NagiosCfgFile not found.  Exiting."
+    echo "Configuration file $NagiosCfgFile not found.  Exiting." >&2
     exit 1
 fi
           
@@ -133,7 +133,7 @@
 			echo " done."
 			exit 0
 		else
-			echo "CONFIG ERROR!  Start aborted.  Check your Nagios configuration."
+			echo "CONFIG ERROR!  Start aborted.  Check your Nagios configuration." >&2
 			exit 1
 		fi
 		;;
@@ -160,7 +160,7 @@
  		done
  		if status_nagios > /dev/null; then
  		    echo ''
- 		    echo 'Warning - nagios did not exit in a timely manner'
+ 		    echo 'Warning - nagios did not exit in a timely manner' >&2
  		else
  		    echo 'done.'
  		fi
@@ -179,7 +179,7 @@
 		if [ $? -eq 0 ]; then
 			echo " OK."
 		else
-			echo " CONFIG ERROR!  Check your Nagios configuration."
+			echo " CONFIG ERROR!  Check your Nagios configuration." >&2
 			exit 1
 		fi
 		;;
@@ -192,7 +192,7 @@
 			$0 stop
 			$0 start
 		else
-			echo " CONFIG ERROR!  Restart aborted.  Check your Nagios configuration."
+			echo " CONFIG ERROR!  Restart aborted.  Check your Nagios configuration." >&2
 			exit 1
 		fi
 		;;
@@ -216,7 +216,7 @@
 				fi
 			fi
 		else
-			echo " CONFIG ERROR!  Reload aborted.  Check your Nagios configuration."
+			echo " CONFIG ERROR!  Reload aborted.  Check your Nagios configuration." >&2
 			exit 1
 		fi
 		;;


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list