pcp
[Top] [All Lists]

Patch to allow upgraded pcp to stop old pmcd

To: pcp@xxxxxxxxxxx
Subject: Patch to allow upgraded pcp to stop old pmcd
From: Michael Newton <kimbrr@xxxxxxx>
Date: Tue, 17 Jul 2007 12:43:54 +1000
Sender: pcp-bounce@xxxxxxxxxxx
Nathan has previously pointed out that if you install the 2.7.1
over an existing installation (eg rpm -U), the new /etc/init.d/pcp
cannot stop a pre-existing instance of pmcd. This was an oversight with
the pidfile change. While Nathan proposed just adding a fallback to
killall for this case, this was a problem for us as we have a build system
(based on SuSE's) for building in a chroot, and the killall means removing
the rpm from the chroot stops pcp for the whole machine. Although it would
be preferable to uninstall --noscripts, getting this change through SuSE
could take time, so for now, this patch assumes that if there is a pmcd,
but no pidfile or log file, we're in a chroot. In addition, there is now
a check that the pid in the pidfile matches that found for pmcd


--- a/mgmt/pcp/src/pmcd/rc_pcp  2007-07-17 12:30:43.000000000 +1000
+++ b/mgmt/pcp/src/pmcd/rc_pcp  2007-07-12 11:59:39.045688455 +1000
@@ -382,14 +382,44 @@
        return 0
     fi

+    # if pmcd is running but we can't find a pidfile, or a logfile at the
+    # configured or default location, assume chroot
+    #
+    logf=`_pmcd_logfile`
+    [ -f $logf ] || logf=$RUNDIR/pmcd.log
+    if [ ! -f $PCP_RUN_DIR/pmcd.pid -a ! -f $logf ]
+    then
+       echo "Process ..."
+       cat $tmp.tmp
+        echo "$prog:
+Warning: found no $PCP_RUN_DIR/pmcd.pid
+         and no $logf.
+         Assuming an uninstall from a chroot: PMCD not killed.
+         If this is incorrect, kill -TERM can be applied to the above PID."
+        exit
+
     # Send pmcd a SIGTERM, which is noted as a pending shutdown.
     # When finished the currently active request, pmcd will close any
     # connections, wait for any agents, and then exit.
     #
-    if [ -f $PCP_RUN_DIR/pmcd.pid ]
+    elif [ -f $PCP_RUN_DIR/pmcd.pid ]
     then
-       kill -TERM `cat $PCP_RUN_DIR/pmcd.pid`
-       rm -f $PCP_RUN_DIR/pmcd.pid
+       TOKILL=`cat $PCP_RUN_DIR/pmcd.pid`
+       if grep "^$TOKILL$" $tmp.tmp >/dev/null
+       then
+           kill -TERM $TOKILL >/dev/null 2>&1
+           rm -f $PCP_RUN_DIR/pmcd.pid
+       else
+           echo "Process ..."
+           cat $tmp.tmp
+           echo "$prog:
+Warning: process ID in $PCP_RUN_DIR/pmcd.pid is $TOKILL.
+         Check logfile $logf. When you are ready to proceed, remove
+         $PCP_RUN_DIR/pmcd.pid before retrying."
+           exit
+       fi
+    else
+       $PCP_KILLALL_PROG -TERM pmcd > /dev/null 2>&1
     fi
     $ECHO $PCP_ECHO_N "Waiting for PMCD to terminate ...""$PCP_ECHO_C"
     delay=200  # tenths of a second
@@ -471,7 +501,7 @@

   'start'|'restart')
        _get_pids_by_name pmcd >$tmp.tmp
-       [ -s $tmp.tmp ] && _shutdown
+       [ -f $PCP_RUN_DIR/pmcd.pid  -o -s $tmp.tmp ] && _shutdown

        # PMCD and PMDA messages should go to stderr, not the GUI notifiers
        #


Dr.Michael("Kimba")Newton  kimbrr@xxxxxxx

<Prev in Thread] Current Thread [Next in Thread>