Title: [opsview] [10519] rc.opsview-agent pid detection improvements
Revision
10519
Author
dferguson
Date
2012-10-18 15:52:33 +0100 (Thu, 18 Oct 2012)

Log Message

rc.opsview-agent pid detection improvements

On some systems it seems nrpe can double fork but not update the nrpe.pid file.  Amend rc.opsview-agent init script to pick up when this happens and update the nrpe.pid file with the correct pid again so 'status' works correctly.  This is for use by puppet or other configuration engine system.

Modified Paths

Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2012-10-18 14:52:30 UTC (rev 10518)
+++ trunk/CHANGES	2012-10-18 14:52:33 UTC (rev 10519)
@@ -13,6 +13,7 @@
     Fixed apache configuration for redundancy, specifically removing apache_proxy_ssl.conf and replacing with apache_ssl.conf
     Fixed messages for set state
     Fixed display of check_snmp_interfaces_cascade so that bits/s to Gbps is using division by 1000^3 rather than 1024^3
+    Fixed rc.opsview-agent init script to pick up when nrpe is running on an incorrectly recorded pid
 
 3.20120925
     FEATURES:

Modified: trunk/opsview-core/bin/rc.opsview-agent
===================================================================
--- trunk/opsview-core/bin/rc.opsview-agent	2012-10-18 14:52:30 UTC (rev 10518)
+++ trunk/opsview-core/bin/rc.opsview-agent	2012-10-18 14:52:33 UTC (rev 10519)
@@ -94,6 +94,32 @@
         return 0
       fi
     fi
+
+    # BEWARE: if this is solaris global zone we may get more NRPE
+    # processes than expected due to all the zones so don't do any 
+    # more on Solaris systems to be on safe side
+    uname -s | grep SunOS 1>/dev/null
+    if [ $? = 0 ]; then
+      echo "NRPE is not running"
+      return 1
+    fi
+
+    # this section should cater for when:
+    #   PID recorded AND (its an active AND its not nrpe) OR inactive pid
+
+    # check to ensure its not on another pid
+    PID=`ps -eo pid,comm | awk '$2 == "nrpe" {print $1}'`
+    if [ "x$PID" != "x" ]; then
+      # PID file is wrong for some reason, so update it
+      if [ "`echo $PID | wc -w`" -gt 1 ]; then
+        echo "FATAL: more than 1 nrpe process found:"
+        echo $PID
+        exit 1
+      fi
+      echo $PID > $PIDFILE
+      echo "NRPE is running as process $PID"
+      return 0
+    fi
   fi
 
   echo "NRPE is not running"
@@ -115,7 +141,6 @@
     return
   fi
 
-
   # also check to ensure nrpe isnt running on another pid
   PID=`ps -eo pid,comm | awk '$2 == "nrpe" {print $1}'`
   if [ "x$PID" != "x" ]; then

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to