Blame SOURCES/rhbz1107734.patch

1cd73a
diff -Naurp pcp-3.9.10-orig/configure pcp-3.9.10-fche/configure
1cd73a
--- pcp-3.9.10-orig/configure	2014-09-05 14:18:39.000000000 +1000
1cd73a
+++ pcp-3.9.10-fche/configure	2014-09-06 02:50:03.000000000 +1000
1cd73a
@@ -622,7 +622,12 @@ ac_includes_default="\
1cd73a
 ac_subst_vars='PACKAGE_CONFIGURE
1cd73a
 BUILD_PMMGR
1cd73a
 HAVE_RPMLIB
1cd73a
+HAVE_CAIRO
1cd73a
+cairo_LIBS
1cd73a
+cairo_CFLAGS
1cd73a
 HAVE_LIBMICROHTTPD
1cd73a
+libmicrohttpd_LIBS
1cd73a
+libmicrohttpd_CFLAGS
1cd73a
 lib_for_curses
1cd73a
 lib_for_readline
1cd73a
 pcp_mpi_dirs
1cd73a
@@ -935,7 +940,11 @@ YACC
1cd73a
 YFLAGS
1cd73a
 SYSTEMD_CFLAGS
1cd73a
 SYSTEMD_LIBS
1cd73a
-XMKMF'
1cd73a
+XMKMF
1cd73a
+libmicrohttpd_CFLAGS
1cd73a
+libmicrohttpd_LIBS
1cd73a
+cairo_CFLAGS
1cd73a
+cairo_LIBS'
1cd73a
 
1cd73a
 
1cd73a
 # Initialize some variables set by options.
1cd73a
@@ -1622,6 +1631,13 @@ Some influential environment variables:
1cd73a
   SYSTEMD_LIBS
1cd73a
               linker flags for SYSTEMD, overriding pkg-config
1cd73a
   XMKMF       Path to xmkmf, Makefile generator for X Window System
1cd73a
+  libmicrohttpd_CFLAGS
1cd73a
+              C compiler flags for libmicrohttpd, overriding pkg-config
1cd73a
+  libmicrohttpd_LIBS
1cd73a
+              linker flags for libmicrohttpd, overriding pkg-config
1cd73a
+  cairo_CFLAGS
1cd73a
+              C compiler flags for cairo, overriding pkg-config
1cd73a
+  cairo_LIBS  linker flags for cairo, overriding pkg-config
1cd73a
 
1cd73a
 Use these variables to override the choices made by `configure' or to help
1cd73a
 it to find libraries and programs with nonstandard names/locations.
1cd73a
@@ -13784,33 +13800,153 @@ $as_echo "no" >&6; }
1cd73a
 fi
1cd73a
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1cd73a
 
1cd73a
-savedLIBS=$LIBS
1cd73a
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmicrohttpd > 0.9.9" >&5
1cd73a
-$as_echo_n "checking for libmicrohttpd > 0.9.9... " >&6; }
1cd73a
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1cd73a
-/* end confdefs.h.  */
1cd73a
-#include <microhttpd.h>
1cd73a
-int
1cd73a
-main ()
1cd73a
-{
1cd73a
-(void)MHD_RESPMEM_PERSISTENT;
1cd73a
-  ;
1cd73a
-  return 0;
1cd73a
-}
1cd73a
-_ACEOF
1cd73a
-if ac_fn_c_try_compile "$LINENO"; then :
1cd73a
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1cd73a
-$as_echo "yes" >&6; }
1cd73a
-    have_libmicrohttpd=1
1cd73a
+
1cd73a
+pkg_failed=no
1cd73a
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmicrohttpd" >&5
1cd73a
+$as_echo_n "checking for libmicrohttpd... " >&6; }
1cd73a
+
1cd73a
+if test -n "$libmicrohttpd_CFLAGS"; then
1cd73a
+    pkg_cv_libmicrohttpd_CFLAGS="$libmicrohttpd_CFLAGS"
1cd73a
+ elif test -n "$PKG_CONFIG"; then
1cd73a
+    if test -n "$PKG_CONFIG" && \
1cd73a
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmicrohttpd > 0.9.9\""; } >&5
1cd73a
+  ($PKG_CONFIG --exists --print-errors "libmicrohttpd > 0.9.9") 2>&5
1cd73a
+  ac_status=$?
1cd73a
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1cd73a
+  test $ac_status = 0; }; then
1cd73a
+  pkg_cv_libmicrohttpd_CFLAGS=`$PKG_CONFIG --cflags "libmicrohttpd > 0.9.9" 2>/dev/null`
1cd73a
+		      test "x$?" != "x0" && pkg_failed=yes
1cd73a
 else
1cd73a
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1cd73a
+  pkg_failed=yes
1cd73a
+fi
1cd73a
+ else
1cd73a
+    pkg_failed=untried
1cd73a
+fi
1cd73a
+if test -n "$libmicrohttpd_LIBS"; then
1cd73a
+    pkg_cv_libmicrohttpd_LIBS="$libmicrohttpd_LIBS"
1cd73a
+ elif test -n "$PKG_CONFIG"; then
1cd73a
+    if test -n "$PKG_CONFIG" && \
1cd73a
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmicrohttpd > 0.9.9\""; } >&5
1cd73a
+  ($PKG_CONFIG --exists --print-errors "libmicrohttpd > 0.9.9") 2>&5
1cd73a
+  ac_status=$?
1cd73a
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1cd73a
+  test $ac_status = 0; }; then
1cd73a
+  pkg_cv_libmicrohttpd_LIBS=`$PKG_CONFIG --libs "libmicrohttpd > 0.9.9" 2>/dev/null`
1cd73a
+		      test "x$?" != "x0" && pkg_failed=yes
1cd73a
+else
1cd73a
+  pkg_failed=yes
1cd73a
+fi
1cd73a
+ else
1cd73a
+    pkg_failed=untried
1cd73a
+fi
1cd73a
+
1cd73a
+
1cd73a
+
1cd73a
+if test $pkg_failed = yes; then
1cd73a
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1cd73a
 $as_echo "no" >&6; }
1cd73a
-    have_libmicrohttpd=0
1cd73a
+
1cd73a
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1cd73a
+        _pkg_short_errors_supported=yes
1cd73a
+else
1cd73a
+        _pkg_short_errors_supported=no
1cd73a
+fi
1cd73a
+        if test $_pkg_short_errors_supported = yes; then
1cd73a
+	        libmicrohttpd_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libmicrohttpd > 0.9.9" 2>&1`
1cd73a
+        else
1cd73a
+	        libmicrohttpd_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libmicrohttpd > 0.9.9" 2>&1`
1cd73a
+        fi
1cd73a
+	# Put the nasty error message in config.log where it belongs
1cd73a
+	echo "$libmicrohttpd_PKG_ERRORS" >&5
1cd73a
+
1cd73a
+	have_libmicrohttpd=
1cd73a
+elif test $pkg_failed = untried; then
1cd73a
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1cd73a
+$as_echo "no" >&6; }
1cd73a
+	have_libmicrohttpd=
1cd73a
+else
1cd73a
+	libmicrohttpd_CFLAGS=$pkg_cv_libmicrohttpd_CFLAGS
1cd73a
+	libmicrohttpd_LIBS=$pkg_cv_libmicrohttpd_LIBS
1cd73a
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1cd73a
+$as_echo "yes" >&6; }
1cd73a
+	have_libmicrohttpd=1
1cd73a
 fi
1cd73a
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1cd73a
 HAVE_LIBMICROHTTPD=$have_libmicrohttpd
1cd73a
 
1cd73a
-LIBS=$savedLIBS
1cd73a
+
1cd73a
+
1cd73a
+pkg_failed=no
1cd73a
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cairo" >&5
1cd73a
+$as_echo_n "checking for cairo... " >&6; }
1cd73a
+
1cd73a
+if test -n "$cairo_CFLAGS"; then
1cd73a
+    pkg_cv_cairo_CFLAGS="$cairo_CFLAGS"
1cd73a
+ elif test -n "$PKG_CONFIG"; then
1cd73a
+    if test -n "$PKG_CONFIG" && \
1cd73a
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2\""; } >&5
1cd73a
+  ($PKG_CONFIG --exists --print-errors "cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2") 2>&5
1cd73a
+  ac_status=$?
1cd73a
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1cd73a
+  test $ac_status = 0; }; then
1cd73a
+  pkg_cv_cairo_CFLAGS=`$PKG_CONFIG --cflags "cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2" 2>/dev/null`
1cd73a
+		      test "x$?" != "x0" && pkg_failed=yes
1cd73a
+else
1cd73a
+  pkg_failed=yes
1cd73a
+fi
1cd73a
+ else
1cd73a
+    pkg_failed=untried
1cd73a
+fi
1cd73a
+if test -n "$cairo_LIBS"; then
1cd73a
+    pkg_cv_cairo_LIBS="$cairo_LIBS"
1cd73a
+ elif test -n "$PKG_CONFIG"; then
1cd73a
+    if test -n "$PKG_CONFIG" && \
1cd73a
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2\""; } >&5
1cd73a
+  ($PKG_CONFIG --exists --print-errors "cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2") 2>&5
1cd73a
+  ac_status=$?
1cd73a
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1cd73a
+  test $ac_status = 0; }; then
1cd73a
+  pkg_cv_cairo_LIBS=`$PKG_CONFIG --libs "cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2" 2>/dev/null`
1cd73a
+		      test "x$?" != "x0" && pkg_failed=yes
1cd73a
+else
1cd73a
+  pkg_failed=yes
1cd73a
+fi
1cd73a
+ else
1cd73a
+    pkg_failed=untried
1cd73a
+fi
1cd73a
+
1cd73a
+
1cd73a
+
1cd73a
+if test $pkg_failed = yes; then
1cd73a
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1cd73a
+$as_echo "no" >&6; }
1cd73a
+
1cd73a
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1cd73a
+        _pkg_short_errors_supported=yes
1cd73a
+else
1cd73a
+        _pkg_short_errors_supported=no
1cd73a
+fi
1cd73a
+        if test $_pkg_short_errors_supported = yes; then
1cd73a
+	        cairo_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2" 2>&1`
1cd73a
+        else
1cd73a
+	        cairo_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2" 2>&1`
1cd73a
+        fi
1cd73a
+	# Put the nasty error message in config.log where it belongs
1cd73a
+	echo "$cairo_PKG_ERRORS" >&5
1cd73a
+
1cd73a
+	have_cairo=0
1cd73a
+elif test $pkg_failed = untried; then
1cd73a
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1cd73a
+$as_echo "no" >&6; }
1cd73a
+	have_cairo=0
1cd73a
+else
1cd73a
+	cairo_CFLAGS=$pkg_cv_cairo_CFLAGS
1cd73a
+	cairo_LIBS=$pkg_cv_cairo_LIBS
1cd73a
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1cd73a
+$as_echo "yes" >&6; }
1cd73a
+	have_cairo=1
1cd73a
+fi
1cd73a
+HAVE_CAIRO=$have_cairo
1cd73a
+
1cd73a
 
1cd73a
 savedLIBS=$LIBS
1cd73a
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rpmlib > 4.4.2" >&5
1cd73a
diff -Naurp pcp-3.9.10-orig/configure.ac pcp-3.9.10-fche/configure.ac
1cd73a
--- pcp-3.9.10-orig/configure.ac	2014-09-05 14:18:39.000000000 +1000
1cd73a
+++ pcp-3.9.10-fche/configure.ac	2014-09-06 02:50:03.000000000 +1000
1cd73a
@@ -2456,18 +2456,12 @@ AC_TRY_COMPILE(
1cd73a
 ], AC_DEFINE(HAVE_AI_ADDRCONFIG) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
1cd73a
 
1cd73a
 dnl Do you have system microhttpd libraries for pmwebapi?
1cd73a
-savedLIBS=$LIBS
1cd73a
-AC_MSG_CHECKING([for libmicrohttpd > 0.9.9])
1cd73a
-AC_COMPILE_IFELSE(
1cd73a
-   [AC_LANG_PROGRAM([[#include <microhttpd.h>]],
1cd73a
-                    [[(void)MHD_RESPMEM_PERSISTENT;]])],
1cd73a
-   [AC_MSG_RESULT([yes])
1cd73a
-    have_libmicrohttpd=1],
1cd73a
-   [AC_MSG_RESULT([no])
1cd73a
-    have_libmicrohttpd=0])
1cd73a
-dnl AC_CHECK_LIB(microhttpd,MHD_start_daemon,[have_libmicrohttpd=1],[have_libmicrohttpd=0])
1cd73a
+PKG_CHECK_MODULES([libmicrohttpd], [libmicrohttpd > 0.9.9], [have_libmicrohttpd=1], [have_libmicrohttpd=])
1cd73a
 AC_SUBST(HAVE_LIBMICROHTTPD,[$have_libmicrohttpd])
1cd73a
-LIBS=$savedLIBS
1cd73a
+
1cd73a
+dnl Do you have graphics libraries for pmwebapi?
1cd73a
+PKG_CHECK_MODULES([cairo], [cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2], [have_cairo=1], [have_cairo=0])
1cd73a
+AC_SUBST(HAVE_CAIRO,[$have_cairo])
1cd73a
 
1cd73a
 dnl Do you have RPM Package Manager libraries for pmdarpm?
1cd73a
 savedLIBS=$LIBS
1cd73a
diff -Naurp pcp-3.9.10-orig/qa/666 pcp-3.9.10-fche/qa/666
1cd73a
--- pcp-3.9.10-orig/qa/666	1970-01-01 10:00:00.000000000 +1000
1cd73a
+++ pcp-3.9.10-fche/qa/666	2014-09-06 02:50:03.000000000 +1000
1cd73a
@@ -0,0 +1,179 @@
1cd73a
+#! /bin/sh
1cd73a
+# PCP QA Test No. 666
1cd73a
+# checks basic pmmgr functionality
1cd73a
+#
1cd73a
+# Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
1cd73a
+#
1cd73a
+seq=`basename $0`
1cd73a
+echo "QA output created by $seq"
1cd73a
+
1cd73a
+# get standard environment, filters and checks
1cd73a
+. ./common.product
1cd73a
+. ./common.filter
1cd73a
+. ./common.check
1cd73a
+
1cd73a
+
1cd73a
+which pmmgr >/dev/null 2>&1 || _notrun "No pmmgr binary installed"
1cd73a
+echo pmmgr ok
1cd73a
+
1cd73a
+$sudo rm -fr $tmp.dir
1cd73a
+$sudo rm -f $tmp.*
1cd73a
+rm -f $seq.full
1cd73a
+
1cd73a
+signal=$PCP_BINADM_DIR/pmsignal
1cd73a
+status=1	# failure is the default!
1cd73a
+username=`id -u -n`
1cd73a
+trap "_cleanup" 0 1 2 3 15
1cd73a
+
1cd73a
+
1cd73a
+# Shorten timeouts because of the rapid-fire pmcd/pmmgr-daemon livespan tests
1cd73a
+PMCD_WAIT_TIMEOUT=1
1cd73a
+PMCD_CONNECT_TIMEOUT=1
1cd73a
+PMCD_RECONNECT_TIMEOUT=1
1cd73a
+
1cd73a
+
1cd73a
+_cleanup()
1cd73a
+{
1cd73a
+    if [ -n "$pid" ]; then kill $pid; fi
1cd73a
+    $sudo rm -fr $tmp.dir
1cd73a
+    $sudo rm -f $tmp.*
1cd73a
+    exit $status
1cd73a
+}
1cd73a
+
1cd73a
+_filter()
1cd73a
+{
1cd73a
+    tee -a $seq.full |
1cd73a
+    sed -e 's,^\[.*\],TIMESTAMP,' \
1cd73a
+        -e 's,pmmgr.[0-9]*/[0-9]*.,pmmgr(PID/TID),' \
1cd73a
+        -e 's,hostid [a-zA-Z0-9_-.]*,hostid HOSTID,' \
1cd73a
+        -e 's,at [a-zA-Z0-9_-.:]*,at LOCAL,' \
1cd73a
+        -e 's,'$tmp.dir',TMPDIR,'
1cd73a
+}
1cd73a
+
1cd73a
+_filter2()
1cd73a
+{
1cd73a
+    tee -a $seq.full |
1cd73a
+    sed -e 's,'`hostname`',HOSTNAME,' \
1cd73a
+        -e 's,[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9],YYYYMMDD-HHMMSS,'
1cd73a
+}
1cd73a
+
1cd73a
+# This test prereqs only pmcd running locally.
1cd73a
+# In the future, remote, avahi
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== 1. prepare blank pmmgr config directory  ===" | tee -a $seq.full
1cd73a
+$sudo rm -rf $tmp.dir
1cd73a
+mkdir $tmp.dir
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== 2. pmmgr barenaked startup  ===" | tee -a $seq.full
1cd73a
+echo 'local:' > $tmp.dir/target-host
1cd73a
+echo 'localhost' > $tmp.dir/target-host
1cd73a
+echo 'localhost6' > $tmp.dir/target-host
1cd73a
+$PCP_BINADM_DIR/pmmgr -U $username -v -p 4 -l $tmp.out -c $tmp.dir &
1cd73a
+pid=$!
1cd73a
+echo "pid=$!" >>$seq.full
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== 3. look for pmmgr starting no daemons ===" | tee -a $seq.full
1cd73a
+sleep 30
1cd73a
+ls -1 $tmp.dir # should be almost empty
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== 4. add control files to start pmlogger and pmie ===" | tee -a $seq.full
1cd73a
+echo '-t 10' > $tmp.dir/pmlogger
1cd73a
+touch $tmp.dir/pmie
1cd73a
+touch $tmp.dir/pmlogconf
1cd73a
+touch $tmp.dir/pmieconf
1cd73a
+echo $tmp.dir > $tmp.dir/log-directory  # same dir
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== 5. restart pmcd a few times to get a bunch of pmlogger archives ===" | tee -a $seq.full
1cd73a
+for x in `seq 4`
1cd73a
+do
1cd73a
+echo $x
1cd73a
+$sudo $PCP_RC_DIR/pmcd restart >/dev/null 2>&1
1cd73a
+sleep 30 # give time for pmlogconf/pmieconf to run
1cd73a
+done
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== 6. check the directories ===" | tee -a $seq.full
1cd73a
+ls -1 $tmp.dir/`hostname` | _filter2
1cd73a
+ls -lR $tmp.dir >> $seq.full # for reference
1cd73a
+for f in $tmp.dir/`hostname`/*.meta; do
1cd73a
+    echo == $f ==>> $seq.full
1cd73a
+    pmloglabel -L $f >> $seq.full
1cd73a
+done
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== 7. add log-merging/rewriting, stop pmFOOconf and kill pmcd once more ===" | tee -a $seq.full
1cd73a
+$sudo $PCP_RC_DIR/pmcd stop >/dev/null 2>&1
1cd73a
+touch $tmp.dir/pmlogrewrite
1cd73a
+touch $tmp.dir/pmlogmerge
1cd73a
+echo '-t 1 -c '$tmp.dir/`hostname`/config.pmlogger > $tmp.dir/pmlogger
1cd73a
+echo '-c '$tmp.dir/`hostname`/config.pmie > $tmp.dir/pmie
1cd73a
+rm $tmp.dir/pmlogconf
1cd73a
+rm $tmp.dir/pmieconf
1cd73a
+# ^^^ so pmmgr will react to pmcd restarts rather quickly
1cd73a
+echo 6min > $tmp.dir/pmlogmerge-retain
1cd73a
+sleep 10
1cd73a
+$sudo $PCP_RC_DIR/pmcd restart >/dev/null 2>&1
1cd73a
+sleep 30 # enough time to get new daemons started up 
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== 8. recheck the directories past retain/merge ===" | tee -a $seq.full
1cd73a
+ls -1 $tmp.dir/`hostname` | _filter2
1cd73a
+ls -lR $tmp.dir >> $seq.full # for reference
1cd73a
+for f in $tmp.dir/`hostname`/*.meta; do
1cd73a
+    echo == $f == >> $seq.full
1cd73a
+    pmloglabel -L $f >> $seq.full
1cd73a
+done
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== 9. how about some granular mode ===" | tee -a $seq.full
1cd73a
+$sudo $PCP_RC_DIR/pmcd stop >/dev/null 2>&1
1cd73a
+echo 30sec > $tmp.dir/pmlogmerge
1cd73a
+rm $tmp.dir/pmlogrewrite # separately tested
1cd73a
+touch $tmp.dir/pmlogmerge-granular
1cd73a
+echo 90sec > $tmp.dir/pmlogmerge-retain
1cd73a
+sleep 20  # ensure pmmgr has killed all the daemons
1cd73a
+$sudo $PCP_RC_DIR/pmcd restart >/dev/null 2>&1
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== 10. wait a bit ===" | tee -a $seq.full
1cd73a
+# long enough for all the old archives to age out, only new granular stuff to survive
1cd73a
+# not an exact multiple of the pmlogmerge period, to avoid testing the edge moments
1cd73a
+for x in `seq 9`
1cd73a
+do
1cd73a
+    echo $x
1cd73a
+    sleep 15
1cd73a
+done
1cd73a
+$sudo $PCP_RC_DIR/pmcd stop >/dev/null 2>&1  # ensure daemons stop & no new ones are started
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== 11. admire grained / retained data ===" | tee -a $seq.full
1cd73a
+ls -1 $tmp.dir/`hostname` | _filter2
1cd73a
+ls -lR $tmp.dir >> $seq.full # for reference
1cd73a
+for f in $tmp.dir/`hostname`/*.meta; do
1cd73a
+    echo == $f ==>> $seq.full
1cd73a
+    pmloglabel -L $f >> $seq.full
1cd73a
+done
1cd73a
+
1cd73a
+date >> $seq.full
1cd73a
+echo "=== ZZZ kill pmmgr ===" | tee -a $seq.full
1cd73a
+kill $pid
1cd73a
+pid=
1cd73a
+sleep 2
1cd73a
+
1cd73a
+echo "== full pmmgr logs:" >> $seq.full
1cd73a
+cat $tmp.out >> $seq.full
1cd73a
+
1cd73a
+echo "== recent daemon logs:" >> $seq.full
1cd73a
+grep . $tmp.dir/`hostname`/*.log >> $seq.full
1cd73a
+
1cd73a
+# restart pmcd
1cd73a
+$sudo $PCP_RC_DIR/pmcd restart >/dev/null 2>&1
1cd73a
+
1cd73a
+status=0
1cd73a
+sleep 2
1cd73a
+exit
1cd73a
diff -Naurp pcp-3.9.10-orig/qa/666.out pcp-3.9.10-fche/qa/666.out
1cd73a
--- pcp-3.9.10-orig/qa/666.out	1970-01-01 10:00:00.000000000 +1000
1cd73a
+++ pcp-3.9.10-fche/qa/666.out	2014-09-06 02:50:03.000000000 +1000
1cd73a
@@ -0,0 +1,70 @@
1cd73a
+QA output created by 666
1cd73a
+pmmgr ok
1cd73a
+=== 1. prepare blank pmmgr config directory  ===
1cd73a
+=== 2. pmmgr barenaked startup  ===
1cd73a
+=== 3. look for pmmgr starting no daemons ===
1cd73a
+target-host
1cd73a
+=== 4. add control files to start pmlogger and pmie ===
1cd73a
+=== 5. restart pmcd a few times to get a bunch of pmlogger archives ===
1cd73a
+1
1cd73a
+2
1cd73a
+3
1cd73a
+4
1cd73a
+=== 6. check the directories ===
1cd73a
+archive-YYYYMMDD-HHMMSS.0
1cd73a
+archive-YYYYMMDD-HHMMSS.index
1cd73a
+archive-YYYYMMDD-HHMMSS.meta
1cd73a
+archive-YYYYMMDD-HHMMSS.0
1cd73a
+archive-YYYYMMDD-HHMMSS.index
1cd73a
+archive-YYYYMMDD-HHMMSS.meta
1cd73a
+archive-YYYYMMDD-HHMMSS.0
1cd73a
+archive-YYYYMMDD-HHMMSS.index
1cd73a
+archive-YYYYMMDD-HHMMSS.meta
1cd73a
+archive-YYYYMMDD-HHMMSS.0
1cd73a
+archive-YYYYMMDD-HHMMSS.index
1cd73a
+archive-YYYYMMDD-HHMMSS.meta
1cd73a
+config.pmie
1cd73a
+config.pmlogger
1cd73a
+pmie.log
1cd73a
+pmlogger.log
1cd73a
+=== 7. add log-merging/rewriting, stop pmFOOconf and kill pmcd once more ===
1cd73a
+=== 8. recheck the directories past retain/merge ===
1cd73a
+archive-YYYYMMDD-HHMMSS.0
1cd73a
+archive-YYYYMMDD-HHMMSS.index
1cd73a
+archive-YYYYMMDD-HHMMSS.meta
1cd73a
+archive-YYYYMMDD-HHMMSS.0
1cd73a
+archive-YYYYMMDD-HHMMSS.index
1cd73a
+archive-YYYYMMDD-HHMMSS.meta
1cd73a
+config.pmie
1cd73a
+config.pmlogger
1cd73a
+pmie.log
1cd73a
+pmlogger.log
1cd73a
+=== 9. how about some granular mode ===
1cd73a
+=== 10. wait a bit ===
1cd73a
+1
1cd73a
+2
1cd73a
+3
1cd73a
+4
1cd73a
+5
1cd73a
+6
1cd73a
+7
1cd73a
+8
1cd73a
+9
1cd73a
+=== 11. admire grained / retained data ===
1cd73a
+archive-YYYYMMDD-HHMMSS.0
1cd73a
+archive-YYYYMMDD-HHMMSS.index
1cd73a
+archive-YYYYMMDD-HHMMSS.meta
1cd73a
+archive-YYYYMMDD-HHMMSS.0
1cd73a
+archive-YYYYMMDD-HHMMSS.index
1cd73a
+archive-YYYYMMDD-HHMMSS.meta
1cd73a
+archive-YYYYMMDD-HHMMSS.0
1cd73a
+archive-YYYYMMDD-HHMMSS.index
1cd73a
+archive-YYYYMMDD-HHMMSS.meta
1cd73a
+archive-YYYYMMDD-HHMMSS.0
1cd73a
+archive-YYYYMMDD-HHMMSS.index
1cd73a
+archive-YYYYMMDD-HHMMSS.meta
1cd73a
+config.pmie
1cd73a
+config.pmlogger
1cd73a
+pmie.log
1cd73a
+pmlogger.log
1cd73a
+=== ZZZ kill pmmgr ===
1cd73a
diff -Naurp pcp-3.9.10-orig/src/include/builddefs.in pcp-3.9.10-fche/src/include/builddefs.in
1cd73a
--- pcp-3.9.10-orig/src/include/builddefs.in	2014-09-05 14:18:45.000000000 +1000
1cd73a
+++ pcp-3.9.10-fche/src/include/builddefs.in	2014-09-06 02:50:03.000000000 +1000
1cd73a
@@ -116,6 +116,7 @@ NSSCFLAGS = @NSSCFLAGS@
1cd73a
 NSPRCFLAGS = @NSPRCFLAGS@
1cd73a
 SASLCFLAGS = @SASLCFLAGS@
1cd73a
 AVAHICFLAGS = @avahi_CFLAGS@
1cd73a
+LIBMICROHTTPDCFLAGS = @libmicrohttpd_CFLAGS@
1cd73a
 
1cd73a
 LDFLAGS += $(PLDFLAGS) $(WARN_OFF) $(PCP_LIBS) $(LLDFLAGS)
1cd73a
 
1cd73a
@@ -238,9 +239,12 @@ LIB_FOR_SASL = @lib_for_sasl@
1cd73a
 LIB_FOR_SSL = @lib_for_ssl@
1cd73a
 LIB_FOR_AVAHI = @lib_for_avahi@
1cd73a
 LIB_FOR_ATOMIC = @lib_for_atomic@
1cd73a
+LIB_FOR_CAIRO = @cairo_LIBS@
1cd73a
+LIB_FOR_LIBMICROHTTPD = @libmicrohttpd_LIBS@
1cd73a
 
1cd73a
 HAVE_LIBMICROHTTPD = @HAVE_LIBMICROHTTPD@
1cd73a
 HAVE_RPMLIB = @HAVE_RPMLIB@
1cd73a
+HAVE_CAIRO = @HAVE_CAIRO@
1cd73a
 
1cd73a
 SHELL = /bin/sh
1cd73a
 IMAGES_DIR = $(TOPDIR)/all-images
1cd73a
diff -Naurp pcp-3.9.10-orig/src/pmmgr/pmmgr.cxx pcp-3.9.10-fche/src/pmmgr/pmmgr.cxx
1cd73a
--- pcp-3.9.10-orig/src/pmmgr/pmmgr.cxx	2014-06-30 11:46:07.000000000 +1000
1cd73a
+++ pcp-3.9.10-fche/src/pmmgr/pmmgr.cxx	2014-09-06 02:50:03.000000000 +1000
1cd73a
@@ -19,7 +19,6 @@
1cd73a
 #include "impl.h"
1cd73a
 
1cd73a
 #include <sys/stat.h>
1cd73a
-#include <cassert>
1cd73a
 #include <cstdlib>
1cd73a
 #include <fstream>
1cd73a
 #include <iostream>
1cd73a
@@ -628,8 +627,26 @@ pmmgr_daemon::~pmmgr_daemon()
1cd73a
   if (pid != 0)
1cd73a
     {
1cd73a
       int ignored;
1cd73a
+
1cd73a
       (void) kill ((pid_t) pid, SIGTERM);
1cd73a
-      (void) waitpid ((pid_t) pid, &ignored, 0); // collect zombie
1cd73a
+
1cd73a
+      // Unfortunately, some daemons don't always respond to SIGTERM
1cd73a
+      // immediately, so we mustn't simply hang in a waitpid().  This
1cd73a
+      // has been observed with 3.9.6-era pmie.
1cd73a
+
1cd73a
+      for (unsigned c=0; c<10; c++) { // try to kill/reap only a brief while
1cd73a
+        struct timespec killpoll;
1cd73a
+        killpoll.tv_sec = 0;
1cd73a
+        killpoll.tv_nsec = 250*1000*1000; // 250 milliseconds
1cd73a
+        (void) nanosleep (&killpoll, NULL);
1cd73a
+
1cd73a
+        int rc = waitpid ((pid_t) pid, &ignored, WNOHANG); // collect zombie
1cd73a
+        if (rc == pid)
1cd73a
+          break;
1cd73a
+
1cd73a
+        // not dead yet ... try again a little harder
1cd73a
+        (void) kill ((pid_t) pid, SIGKILL);
1cd73a
+      }
1cd73a
       if (pmDebug & DBG_TRACE_APPL0)
1cd73a
         timestamp(cout) << "daemon pid " << pid << " killed" << endl;
1cd73a
     }
1cd73a
@@ -653,6 +670,11 @@ void pmmgr_daemon::poll()
1cd73a
             timestamp(cout) << "daemon pid " << pid << " found dead" << endl;
1cd73a
           pid = 0;
1cd73a
           // we will try again immediately
1cd73a
+          sleep (1);
1cd73a
+          // .. but but quite immediately; if a pmmgr daemon in
1cd73a
+          // granular mode shut down one second before the end of its
1cd73a
+          // period, the restarted form shouldn't be started in that
1cd73a
+          // exact same second.
1cd73a
         }
1cd73a
     }
1cd73a
 
1cd73a
@@ -813,7 +835,14 @@ pmmgr_pmlogger_daemon::daemon_command_li
1cd73a
           __pmtimevalNow (&now_tv);
1cd73a
           time_t period_s = period_tv.tv_sec;
1cd73a
           if (period_s < 1) period_s = 1; // at least one second
1cd73a
-          time_t period_end = ((now_tv.tv_sec + period_s - 1) / period_s) * period_s;
1cd73a
+          time_t period_end = ((now_tv.tv_sec + 1 + period_s) / period_s) * period_s - 1;
1cd73a
+
1cd73a
+          // Assert calculation sanity: we want to avoid the case
1cd73a
+          // where a daemon launches for 0 seconds.  This should already
1cd73a
+          // be prevented by the "+ 1" above.
1cd73a
+          if (period_end == now_tv.tv_sec)
1cd73a
+            period_end ++;
1cd73a
+
1cd73a
           period = string(" @") +
1cd73a
             string(ctime(& period_end)).substr(0,24); // 24: ctime(3) magic value, sans \n
1cd73a
         }
1cd73a
@@ -833,8 +862,10 @@ pmmgr_pmlogger_daemon::daemon_command_li
1cd73a
           __pmtimevalNow (&now_tv);
1cd73a
           time_t period_s = period_tv.tv_sec;
1cd73a
           if (period_s < 1) period_s = 1; // at least one second
1cd73a
-          time_t prior_period_start = ((now_tv.tv_sec - period_s) / period_s) * period_s;
1cd73a
-          time_t prior_period_end = prior_period_start + period_s;
1cd73a
+          time_t prior_period_start = ((now_tv.tv_sec + 1 - period_s) / period_s) * period_s;
1cd73a
+          time_t prior_period_end = prior_period_start + period_s - 1; 
1cd73a
+          // schedule end -before- the period boundary, so that the
1cd73a
+          // last recorded metric timestamp is strictly before the end
1cd73a
 
1cd73a
           for (unsigned i=0; i
1cd73a
             {