fada68
From d152f45d874546db7615b5caa54633130ee733bf Mon Sep 17 00:00:00 2001
fada68
From: Ken Gaillot <kgaillot@redhat.com>
fada68
Date: Thu, 15 Sep 2016 09:40:48 -0500
fada68
Subject: [PATCH 1/3] Fix: tools: make crm_report sanitize CIB before
fada68
 generating readable version
fada68
fada68
---
fada68
 tools/report.collector | 18 +++++++++++++-----
fada68
 1 file changed, 13 insertions(+), 5 deletions(-)
fada68
fada68
diff --git a/tools/report.collector b/tools/report.collector
fada68
index e75a790..83218ee 100644
fada68
--- a/tools/report.collector
fada68
+++ b/tools/report.collector
fada68
@@ -249,13 +249,17 @@ getconfig() {
fada68
     else
fada68
 	echo "$host" > $target/STOPPED
fada68
     fi
fada68
+}
fada68
+
fada68
+get_readable_cib() {
fada68
+    target="$1"; shift;
fada68
 
fada68
     if [ -f "$target/$CIB_F" ]; then
fada68
-	crm_verify -V -x $target/$CIB_F >$target/$CRM_VERIFY_F 2>&1
fada68
+        crm_verify -V -x "$target/$CIB_F" >"$target/$CRM_VERIFY_F" 2>&1
fada68
         if which crm >/dev/null 2>&1 ; then
fada68
-            CIB_file=$target/$CIB_F crm configure show >$target/$CIB_TXT_F 2>&1
fada68
+            CIB_file="$target/$CIB_F" crm configure show >"$target/$CIB_TXT_F" 2>&1
fada68
         elif which pcs >/dev/null 2>&1 ; then
fada68
-            pcs config -f $target/$CIB_F >$target/$CIB_TXT_F 2>&1
fada68
+            pcs config -f "$target/$CIB_F" >"$target/$CIB_TXT_F" 2>&1
fada68
         fi
fada68
     fi
fada68
 }
fada68
@@ -735,12 +739,16 @@ cf=""
fada68
 if [ ! -z "$cluster_cf" ]; then
fada68
    cf=`basename $cluster_cf`
fada68
 fi
fada68
-for f in $cf $CIB_F $CIB_TXT_F $CIB_F.live pengine/*; do
fada68
+for f in "$cf" "$CIB_F" "$CIB_F.live" pengine/*; do
fada68
     if [ -f "$f" ]; then
fada68
-	sanitize $f
fada68
+	sanitize "$f"
fada68
     fi
fada68
 done
fada68
 
fada68
+# For convenience, generate human-readable version of CIB and any XML errors
fada68
+# in it (AFTER sanitizing, so we don't need to sanitize this output)
fada68
+get_readable_cib "$REPORT_HOME/$REPORT_TARGET"
fada68
+
fada68
 # Grab logs
fada68
 start=`date -d @${LOG_START} +"%F %T"`
fada68
 end=`date -d @${LOG_END} +"%F %T"`
fada68
-- 
fada68
1.8.3.1
fada68
fada68
fada68
From 700c8004fc62ca5de39b1558825ea6aba4edab53 Mon Sep 17 00:00:00 2001
fada68
From: Ken Gaillot <kgaillot@redhat.com>
fada68
Date: Thu, 15 Sep 2016 10:50:48 -0500
fada68
Subject: [PATCH 2/3] Low: tools: make crm_report skip global disk searches
fada68
 when pacemaker_remoted present
fada68
fada68
This saves a lot of time in the common cases, and the only case where it's
fada68
worse is where pacemaker_remoted is installed in a standard location but the
fada68
other pacemaker components are not (and if someone manages to do that, it's no
fada68
wonder they have problems).
fada68
---
fada68
 tools/report.common.in | 62 +++++++++++++++++++++++++++++++-------------------
fada68
 1 file changed, 39 insertions(+), 23 deletions(-)
fada68
fada68
diff --git a/tools/report.common.in b/tools/report.common.in
fada68
index f9ed6f5..9b43486 100644
fada68
--- a/tools/report.common.in
fada68
+++ b/tools/report.common.in
fada68
@@ -82,6 +82,9 @@ SYSLOGS="
fada68
     /var/log/cluster/*
fada68
 "
fada68
 
fada68
+# Whether pacemaker_remoted was found (0 = yes, 1 = no, -1 = haven't looked yet)
fada68
+REMOTED_STATUS=-1
fada68
+
fada68
 #
fada68
 # keep the user posted
fada68
 #
fada68
@@ -129,13 +132,23 @@ is_running() {
fada68
 }
fada68
 
fada68
 has_remoted() {
fada68
-    # TODO: the binary might be elsewhere
fada68
-    if which pacemaker_remoted >/dev/null 2>&1; then
fada68
-        return 0
fada68
-    elif [ -x "@sbindir@/pacemaker_remoted" ]; then
fada68
-        return 0
fada68
+    if [ $REMOTED_STATUS -eq -1 ]; then
fada68
+        REMOTED_STATUS=1
fada68
+        if which pacemaker_remoted >/dev/null 2>&1; then
fada68
+            REMOTED_STATUS=0
fada68
+        elif [ -x "@sbindir@/pacemaker_remoted" ]; then
fada68
+            REMOTED_STATUS=0
fada68
+        else
fada68
+            # @TODO: the binary might be elsewhere,
fada68
+            # but a global search is too expensive
fada68
+            for d in /{usr,opt}/{local/,}{s,}bin; do
fada68
+                if [ -x "${d}/pacemaker_remoted" ]; then
fada68
+                    REMOTED_STATUS=0
fada68
+                fi
fada68
+            done
fada68
+        fi
fada68
     fi
fada68
-    return 1
fada68
+    return $REMOTED_STATUS
fada68
 }
fada68
 
fada68
 # found_dir <description> <dirname>
fada68
@@ -158,18 +171,19 @@ detect_daemon_dir() {
fada68
         fi
fada68
     done
fada68
 
fada68
+    # Pacemaker Remote nodes don't need to install daemons
fada68
+    if has_remoted; then
fada68
+        info "Pacemaker daemons not found (this appears to be a Pacemaker Remote node)"
fada68
+        return
fada68
+    fi
fada68
+
fada68
     for f in $(find / -maxdepth $maxdepth -type f -name pengine -o -name lrmd_test); do
fada68
         d=$(dirname "$f")
fada68
         found_dir "daemons" "$d"
fada68
         return
fada68
     done
fada68
 
fada68
-    # Pacemaker Remote nodes don't need to install daemons
fada68
-    if has_remoted; then
fada68
-        info "Not found (this appears to be a Pacemaker Remote node)"
fada68
-    else
fada68
-        fatal "Pacemaker daemons not found (nonstandard installation?)"
fada68
-    fi
fada68
+    fatal "Pacemaker daemons not found (nonstandard installation?)"
fada68
 }
fada68
 
fada68
 detect_cib_dir() {
fada68
@@ -180,6 +194,12 @@ detect_cib_dir() {
fada68
         fi
fada68
     done
fada68
 
fada68
+    # Pacemaker Remote nodes don't need a CIB
fada68
+    if has_remoted; then
fada68
+        info "Pacemaker config not found (this appears to be a Pacemaker Remote node)"
fada68
+        return
fada68
+    fi
fada68
+
fada68
     info "Searching for where Pacemaker keeps config information... this may take a while"
fada68
     # TODO: What about false positives where someone copied the CIB?
fada68
     for f in $(find / -maxdepth $maxdepth -type f -name cib.xml); do
fada68
@@ -188,12 +208,7 @@ detect_cib_dir() {
fada68
         return
fada68
     done
fada68
 
fada68
-    # Pacemaker Remote nodes don't need a CIB
fada68
-    if has_remoted; then
fada68
-        info "Not found (this appears to be a Pacemaker Remote node)"
fada68
-    else
fada68
-        warning "Pacemaker config not found (nonstandard installation?)"
fada68
-    fi
fada68
+    warning "Pacemaker config not found (nonstandard installation?)"
fada68
 }
fada68
 
fada68
 detect_state_dir() {
fada68
@@ -217,17 +232,18 @@ detect_pe_dir() {
fada68
         return
fada68
     fi
fada68
 
fada68
+    if has_remoted; then
fada68
+        info "Pacemaker policy engine inputs not found (this appears to be a Pacemaker Remote node)"
fada68
+        return
fada68
+    fi
fada68
+
fada68
     info "Searching for where Pacemaker keeps Policy Engine inputs... this may take a while"
fada68
     for d in $(find / -maxdepth $maxdepth -type d -name pengine); do
fada68
         found_dir "policy engine inputs" "$d"
fada68
         return
fada68
     done
fada68
 
fada68
-    if has_remoted; then
fada68
-        info "Not found (this appears to be a Pacemaker Remote node)"
fada68
-    else
fada68
-        fatal "Pacemaker policy engine inputs not found (nonstandard installation?)"
fada68
-    fi
fada68
+    fatal "Pacemaker policy engine inputs not found (nonstandard installation?)"
fada68
 }
fada68
 
fada68
 detect_host() {
fada68
-- 
fada68
1.8.3.1
fada68
fada68
fada68
From 03f013076c191c61470a73dd8fa1d6ceae6e5fb1 Mon Sep 17 00:00:00 2001
fada68
From: Ken Gaillot <kgaillot@redhat.com>
fada68
Date: Thu, 15 Sep 2016 11:46:18 -0500
fada68
Subject: [PATCH 3/3] Doc: tools: document crm_report --sos-mode option in help
fada68
 text/man page
fada68
fada68
---
fada68
 tools/crm_report.in | 2 ++
fada68
 1 file changed, 2 insertions(+)
fada68
fada68
diff --git a/tools/crm_report.in b/tools/crm_report.in
fada68
index 848b6b9..0a456af 100755
fada68
--- a/tools/crm_report.in
fada68
+++ b/tools/crm_report.in
fada68
@@ -73,6 +73,8 @@ Options:
fada68
   -u, --user user	ssh username for cluster nodes (default: root)
fada68
   -D, --depth           search depth to use when attempting to locate files
fada68
   -e, --rsh		specify the remote shell to use (default: ssh -T)
fada68
+  --sos-mode            use defaults suitable for being called by sosreport tool
fada68
+                        (behavior subject to change and not useful to end users)
fada68
   --dest       		a custom destination directory/file
fada68
   dest			a custom destination directory/file
fada68
 
fada68
-- 
fada68
1.8.3.1
fada68