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