Blame SOURCES/bz1062443.patch

95ec45
commit 0b1500ff74341c54c3da4412eb8ee8db9c58cf41
95ec45
Author: Nathan Scott <nathans@redhat.com>
95ec45
Date:   Tue Feb 11 09:54:07 2014 +1100
95ec45
95ec45
    Allow PMDA Install scripts to be run even when pmcd is stopped.
95ec45
    
95ec45
    Following the Install recipe from the GFS2 PMDA man page, users
95ec45
    can run into difficulty if pmcd is not running first.  There's
95ec45
    no mention of that, and the error message is cryptic.  This fix
95ec45
    extends the generic PMDA installation process to allow any PMDA
95ec45
    to kick-start the pmcd process if it needs to.  The one wrinkle
95ec45
    there is a chicken-and-egg with the namespace setup, but that's
95ec45
    tackled via addition of a Rebuild call in the right spot.
95ec45
    
95ec45
    Reported by Andrew Price, tested by Paul Evans, myself and now
95ec45
    also PCP QA test 755.
95ec45
    
95ec45
    Resolves Red Hat bug #1062443.
95ec45
95ec45
diff --git a/qa/755 b/qa/755
95ec45
new file mode 100755
95ec45
index 0000000..be5ae14
95ec45
--- /dev/null
95ec45
+++ b/qa/755
95ec45
@@ -0,0 +1,98 @@
95ec45
+#!/bin/sh
95ec45
+# PCP QA Test No. 755
95ec45
+# Exercise the Apache PMDA Install/Remove, as well as the
95ec45
+# mechanism by which a PMDA can be installed with no pmcd
95ec45
+# process running.
95ec45
+#
95ec45
+# Copyright (c) 2014 Red Hat.
95ec45
+#
95ec45
+
95ec45
+seq=`basename $0`
95ec45
+echo "QA output created by $seq"
95ec45
+
95ec45
+# get standard environment, filters and checks
95ec45
+. ./common.product
95ec45
+. ./common.filter
95ec45
+. ./common.check
95ec45
+
95ec45
+status=1	# failure is the default!
95ec45
+done_clean=false
95ec45
+rm -f $seq.full
95ec45
+
95ec45
+install_on_cleanup=false
95ec45
+pminfo apache >/dev/null 2>&1 && install_on_cleanup=true
95ec45
+
95ec45
+_cleanup()
95ec45
+{
95ec45
+    if $done_clean
95ec45
+    then
95ec45
+        :
95ec45
+    else
95ec45
+        [ -f $tmp.pmcd.conf ] && $sudo mv $tmp.pmcd.conf $PCP_PMCDCONF_PATH
95ec45
+        rm -f $tmp.*
95ec45
+        $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
95ec45
+        _wait_for_pmcd
95ec45
+        _wait_for_pmlogger
95ec45
+        if $install_on_cleanup
95ec45
+        then
95ec45
+            ( cd $PCP_PMDAS_DIR/apache; $sudo ./Install </dev/null >/dev/null 2>&1 )
95ec45
+        else
95ec45
+            ( cd $PCP_PMDAS_DIR/apache; $sudo ./Remove >/dev/null 2>&1 )
95ec45
+        fi
95ec45
+        done_clean=true
95ec45
+    fi
95ec45
+}
95ec45
+
95ec45
+trap "_cleanup; exit \$status" 0 1 2 3 15
95ec45
+
95ec45
+_filter_apache()
95ec45
+{
95ec45
+    # cull message resulting from no running httpd
95ec45
+    grep -v 'Information not currently available'
95ec45
+}
95ec45
+
95ec45
+# real QA test starts here
95ec45
+home=$PCP_PMDAS_DIR
95ec45
+iam=apache
95ec45
+cd $home/$iam
95ec45
+unset ROOT MAKEFLAGS
95ec45
+
95ec45
+# copy the pmcd config file to restore state later.
95ec45
+cp $PCP_PMCDCONF_PATH $tmp.pmcd.conf
95ec45
+
95ec45
+# start from a known starting point
95ec45
+$sudo ./Remove >/dev/null 2>&1
95ec45
+$sudo $PCP_RC_DIR/pmcd stop
95ec45
+
95ec45
+echo
95ec45
+echo "=== $iam agent installation ==="
95ec45
+$sudo ./Install </dev/null >$tmp.out 2>&1
95ec45
+# Check apache metrics have appeared ... X metrics and Y values
95ec45
+_filter_pmda_install <$tmp.out \
95ec45
+| sed \
95ec45
+        -e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
95ec45
+        -e 's/[0-9][0-9]* warnings, //' \
95ec45
+| $PCP_AWK_PROG '
95ec45
+/Check apache metrics have appeared/    { if ($7 >= 20 && $7 <= 80) $7 = "X"
95ec45
+                                          if ($10 >= 0 && $10 <= 80) $10 = "Y"
95ec45
+                                        }
95ec45
+                                        { print }'
95ec45
+
95ec45
+# pmcd should have been started by the Install process - check
95ec45
+if pminfo -v $iam > $tmp.info 2> $tmp.err
95ec45
+then
95ec45
+    :
95ec45
+else
95ec45
+    echo "... failed! ... here is the Install log ..."
95ec45
+    cat $tmp.out
95ec45
+fi
95ec45
+cat $tmp.info $tmp.err | _filter_apache
95ec45
+
95ec45
+echo
95ec45
+echo "=== remove $iam agent ==="
95ec45
+$sudo ./Remove >$tmp.out 2>&1
95ec45
+_filter_pmda_remove <$tmp.out
95ec45
+
95ec45
+# success, all done
95ec45
+status=0
95ec45
+exit
95ec45
diff --git a/qa/755.out b/qa/755.out
95ec45
new file mode 100644
95ec45
index 0000000..50b4b3b
95ec45
--- /dev/null
95ec45
+++ b/qa/755.out
95ec45
@@ -0,0 +1,23 @@
95ec45
+QA output created by 755
95ec45
+Waiting for pmcd to terminate ...
95ec45
+
95ec45
+=== apache agent installation ===
95ec45
+Installing the "apache" Performance Metrics Domain Agent (PMDA) ...
95ec45
+
95ec45
+Apache port number [80]? Updating the Performance Metrics Name Space (PMNS) ...
95ec45
+Terminate PMDA if already installed ...
95ec45
+[...install files, make output...]
95ec45
+Updating the PMCD control file, and notifying PMCD ...
95ec45
+Starting pmcd ... 
95ec45
+Starting pmlogger ... 
95ec45
+Check apache metrics have appeared ... X metrics and Y values
95ec45
+
95ec45
+=== remove apache agent ===
95ec45
+Culling the Performance Metrics Name Space ...
95ec45
+apache ... done
95ec45
+Updating the PMCD control file, and notifying PMCD ...
95ec45
+[...removing files...]
95ec45
+Check apache metrics have gone away ... OK
95ec45
+Waiting for pmcd to terminate ...
95ec45
+Starting pmcd ... 
95ec45
+Starting pmlogger ... 
95ec45
diff --git a/qa/group b/qa/group
95ec45
index bb752f1..0cb02fe 100644
95ec45
--- a/qa/group
95ec45
+++ b/qa/group
95ec45
@@ -130,6 +130,7 @@ pmda
95ec45
 pmda.install
95ec45
 
95ec45
 # Assorted PMDAs
95ec45
+pmda.apache
95ec45
 pmda.cisco
95ec45
 pmda.environ
95ec45
 pmda.gfs2
95ec45
@@ -888,6 +889,7 @@ avahi
95ec45
 748 pmlogrewrite pmda.mysql local oss
95ec45
 749 pmcd local oss
95ec45
 750 pmda.rpm local oss
95ec45
+755 pmda.apache pmda.install local oss
95ec45
 768 pmlogextract local oss
95ec45
 775 sanity pmfind local oss
95ec45
 783 pmda.rpm local oss
95ec45
diff --git a/src/pmcd/pmdaproc.sh b/src/pmcd/pmdaproc.sh
95ec45
index 43cffa7..bab0161 100644
95ec45
--- a/src/pmcd/pmdaproc.sh
95ec45
+++ b/src/pmcd/pmdaproc.sh
95ec45
@@ -1163,6 +1163,22 @@ _install()
95ec45
     # Install the namespace
95ec45
     #
95ec45
 
95ec45
+    if [ ! -f $NAMESPACE ]
95ec45
+    then
95ec45
+	# We may be installing an agent right after an install -
95ec45
+	# before pmcd startup, which has a pre-execution step of
95ec45
+	# rebuilding the namespace root.  Do so now.
95ec45
+	if [ -x $PMNSDIR/Rebuild ]
95ec45
+	then
95ec45
+	    echo "$prog: cannot Rebuild the PMNS for \"$NAMESPACE\""
95ec45
+	    exit 1
95ec45
+	fi
95ec45
+	cd $PMNSDIR
95ec45
+	./Rebuild -dus
95ec45
+	cd $__here
95ec45
+	forced_restart=true
95ec45
+    fi
95ec45
+
95ec45
     for __n in $pmns_name
95ec45
     do
95ec45
 	if pminfo $__ns_opt $__n >/dev/null 2>&1