dhodovsk / source-git / pacemaker

Forked from source-git/pacemaker 3 years ago
Clone

Blame tools/crm_report.in

rpm-build 3ee90c
#!/bin/sh
rpm-build 3ee90c
#
rpm-build 3ee90c
# Copyright 2010-2019 the Pacemaker project contributors
rpm-build 3ee90c
#
rpm-build 3ee90c
# The version control history for this file may have further details.
rpm-build 3ee90c
#
rpm-build 3ee90c
# This source code is licensed under the GNU General Public License version 2
rpm-build 3ee90c
# or later (GPLv2+) WITHOUT ANY WARRANTY.
rpm-build 3ee90c
#
rpm-build 3ee90c
rpm-build 3ee90c
TEMP=`@GETOPT_PATH@			\
rpm-build 3ee90c
    -o hv?xl:f:t:n:T:L:p:c:dSCu:D:MVse:	\
rpm-build 3ee90c
    --long help,corosync,cts:,cts-log:,dest:,node:,nodes:,from:,to:,sos-mode,logfile:,as-directory,single-node,cluster:,user:,max-depth:,version,features,rsh:	\
rpm-build 3ee90c
    -n 'crm_report' -- "$@"`
rpm-build 3ee90c
# The quotes around $TEMP are essential
rpm-build 3ee90c
eval set -- "$TEMP"
rpm-build 3ee90c
rpm-build 3ee90c
progname=$(basename "$0")
rpm-build 3ee90c
rsh="ssh -T"
rpm-build 3ee90c
tests=""
rpm-build 3ee90c
nodes=""
rpm-build 3ee90c
compress=1
rpm-build 3ee90c
cluster="any"
rpm-build 3ee90c
ssh_user="root"
rpm-build 3ee90c
search_logs=1
rpm-build 3ee90c
sos_mode=0
rpm-build 3ee90c
report_data=`dirname $0`
rpm-build 3ee90c
maxdepth=5
rpm-build 3ee90c
rpm-build 3ee90c
extra_logs=""
rpm-build 3ee90c
sanitize_patterns="passw.*"
rpm-build 3ee90c
log_patterns="CRIT: ERROR:"
rpm-build 3ee90c
rpm-build 3ee90c
usage() {
rpm-build 3ee90c
cat<
rpm-build 3ee90c
$progname - Create archive of everything needed when reporting cluster problems
rpm-build 3ee90c
rpm-build 3ee90c
rpm-build 3ee90c
Usage: $progname [options] [DEST]
rpm-build 3ee90c
rpm-build 3ee90c
Required option:
rpm-build 3ee90c
  -f, --from TIME       time prior to problems beginning
rpm-build 3ee90c
                        (as "YYYY-M-D H:M:S" including the quotes)
rpm-build 3ee90c
rpm-build 3ee90c
Options:
rpm-build 3ee90c
  -V                    increase verbosity (may be specified multiple times)
rpm-build 3ee90c
  -h, --help            display this message
rpm-build 3ee90c
  -v, --version         display software version
rpm-build 3ee90c
  --features            display software features
rpm-build 3ee90c
  -t, --to TIME         time at which all problems were resolved
rpm-build 3ee90c
                        (as "YYYY-M-D H:M:S" including the quotes; default "now")
rpm-build 3ee90c
  -T, --cts TEST        CTS test or set of tests to extract
rpm-build 3ee90c
  --cts-log             CTS master logfile
rpm-build 3ee90c
  -n, --nodes NODES     node names for this cluster (only needed if cluster is
rpm-build 3ee90c
                        not active on this host; accepts -n "a b" or -n a -n b)
rpm-build 3ee90c
  -M                    do not search for cluster logs
rpm-build 3ee90c
  -l, --logfile FILE    log file to collect (in addition to detected logs if -M
rpm-build 3ee90c
                        is not specified; may be specified multiple times)
rpm-build 3ee90c
  -p PATT               additional regular expression to match variables to be
rpm-build 3ee90c
                        masked in output (default: "passw.*")
rpm-build 3ee90c
  -L PATT               additional regular expression to match in log files for
rpm-build 3ee90c
                        analysis (default: $log_patterns)
rpm-build 3ee90c
  -S, --single-node     don't attempt to collect data from other nodes
rpm-build 3ee90c
  -c, --cluster TYPE    force the cluster type instead of detecting
rpm-build 3ee90c
                        (currently only corosync is supported)
rpm-build 3ee90c
  -C, --corosync        force the cluster type to be corosync
rpm-build 3ee90c
  -u, --user USER       username to use when collecting data from other nodes
rpm-build 3ee90c
                        (default root)
rpm-build 3ee90c
  -D, --max-depth       search depth to use when attempting to locate files
rpm-build 3ee90c
  -e, --rsh             command to use to run commands on other nodes
rpm-build 3ee90c
                        (default ssh -T)
rpm-build 3ee90c
  -d, --as-directory    leave result as a directory tree instead of archiving
rpm-build 3ee90c
  --sos-mode            use defaults suitable for being called by sosreport tool
rpm-build 3ee90c
                        (behavior subject to change and not useful to end users)
rpm-build 3ee90c
  DEST, --dest DEST     custom destination directory or file name
rpm-build 3ee90c
rpm-build 3ee90c
$progname works best when run from a cluster node on a running cluster,
rpm-build 3ee90c
but can be run from a stopped cluster node or a Pacemaker Remote node.
rpm-build 3ee90c
rpm-build 3ee90c
If neither --nodes nor --single-node is given, $progname will guess the
rpm-build 3ee90c
node list, but may have trouble detecting Pacemaker Remote nodes.
rpm-build 3ee90c
Unless --single-node is given, the node names (whether specified by --nodes
rpm-build 3ee90c
or detected automatically) must be resolvable and reachable via the command
rpm-build 3ee90c
specified by -e/--rsh using the user specified by -u/--user.
rpm-build 3ee90c
rpm-build 3ee90c
Examples:
rpm-build 3ee90c
   $progname -f "2011-12-14 13:05:00" unexplained-apache-failure
rpm-build 3ee90c
   $progname -f 2011-12-14 -t 2011-12-15 something-that-took-multiple-days
rpm-build 3ee90c
   $progname -f 13:05:00   -t 13:12:00   brief-outage
rpm-build 3ee90c
EOF
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
case "$1" in
rpm-build 3ee90c
    -v|--version)   echo "$progname @VERSION@-@BUILD_VERSION@"; exit 0;;
rpm-build 3ee90c
    --features)     echo "@VERSION@-@BUILD_VERSION@: @PCMK_FEATURES@"; exit 0;;
rpm-build 3ee90c
    --|-h|--help) usage; exit 0;;
rpm-build 3ee90c
esac
rpm-build 3ee90c
rpm-build 3ee90c
# Prefer helpers in the same directory if they exist, to simplify development
rpm-build 3ee90c
if [ ! -f $report_data/report.common ]; then
rpm-build 3ee90c
    report_data=@datadir@/@PACKAGE@
rpm-build 3ee90c
else
rpm-build 3ee90c
    echo "Using local helpers"
rpm-build 3ee90c
fi
rpm-build 3ee90c
rpm-build 3ee90c
. $report_data/report.common
rpm-build 3ee90c
rpm-build 3ee90c
while true; do
rpm-build 3ee90c
    case "$1" in
rpm-build 3ee90c
	-x) set -x; shift;;
rpm-build 3ee90c
	-V) verbose=`expr $verbose + 1`; shift;;
rpm-build 3ee90c
	-T|--cts) tests="$tests $2"; shift; shift;;
rpm-build 3ee90c
	   --cts-log) ctslog="$2"; shift; shift;;
rpm-build 3ee90c
	-f|--from) start_time=`get_time "$2"`; shift; shift;;
rpm-build 3ee90c
	-t|--to) end_time=`get_time "$2"`; shift; shift;;
rpm-build 3ee90c
	-n|--node|--nodes) nodes="$nodes $2"; shift; shift;;
rpm-build 3ee90c
	-S|--single-node) nodes="$host"; shift;;
rpm-build 3ee90c
	-l|--logfile) extra_logs="$extra_logs $2"; shift; shift;;
rpm-build 3ee90c
	-p) sanitize_patterns="$sanitize_patterns $2"; shift; shift;;
rpm-build 3ee90c
	-L) log_patterns="$log_patterns `echo $2 | sed 's/ /\\\W/g'`"; shift; shift;;
rpm-build 3ee90c
	-d|--as-directory) compress=0; shift;;
rpm-build 3ee90c
	-C|--corosync)  cluster="corosync";  shift;;
rpm-build 3ee90c
	-c|--cluster)   cluster="$2"; shift; shift;;
rpm-build 3ee90c
	-e|--rsh)       rsh="$2";     shift; shift;;
rpm-build 3ee90c
	-u|--user)      ssh_user="$2"; shift; shift;;
rpm-build 3ee90c
        -D|--max-depth)     maxdepth="$2"; shift; shift;;
rpm-build 3ee90c
	-M) search_logs=0; shift;;
rpm-build 3ee90c
        --sos-mode) sos_mode=1; nodes="$host"; shift;;
rpm-build 3ee90c
	--dest) DESTDIR=$2; shift; shift;;
rpm-build 3ee90c
	--) if [ ! -z $2 ]; then DESTDIR=$2; fi; break;;
rpm-build 3ee90c
	-h|--help) usage; exit 0;;
rpm-build 3ee90c
	# Options for compatibility with hb_report
rpm-build 3ee90c
	-s) shift;;
rpm-build 3ee90c
rpm-build 3ee90c
	*) echo "Unknown argument: $1"; usage; exit 1;;
rpm-build 3ee90c
    esac
rpm-build 3ee90c
done
rpm-build 3ee90c
rpm-build 3ee90c
rpm-build 3ee90c
collect_data() {
rpm-build 3ee90c
    label="$1"
rpm-build 3ee90c
    start=`expr $2 - 10`
rpm-build 3ee90c
    end=`expr $3 + 10`
rpm-build 3ee90c
    masterlog=$4
rpm-build 3ee90c
rpm-build 3ee90c
    if [ "x$DESTDIR" != x ]; then
rpm-build 3ee90c
	echo $DESTDIR | grep -e "^/" -qs
rpm-build 3ee90c
	if [ $? = 0 ]; then
rpm-build 3ee90c
	    l_base=$DESTDIR
rpm-build 3ee90c
	else
rpm-build 3ee90c
	    l_base="`pwd`/$DESTDIR"
rpm-build 3ee90c
	fi
rpm-build 3ee90c
	debug "Using custom scratch dir: $l_base"
rpm-build 3ee90c
	r_base=`basename $l_base`
rpm-build 3ee90c
    else
rpm-build 3ee90c
	l_base=$HOME/$label
rpm-build 3ee90c
	r_base=$label
rpm-build 3ee90c
    fi
rpm-build 3ee90c
rpm-build 3ee90c
    if [ -e $l_base ]; then
rpm-build 3ee90c
	fatal "Output directory $l_base already exists, specify an alternate name with --dest"
rpm-build 3ee90c
    fi
rpm-build 3ee90c
    mkdir -p $l_base
rpm-build 3ee90c
rpm-build 3ee90c
    if [ "x$masterlog" != "x" ]; then
rpm-build 3ee90c
	dumplogset "$masterlog" $start $end > "$l_base/$HALOG_F"
rpm-build 3ee90c
    fi
rpm-build 3ee90c
rpm-build 3ee90c
    for node in $nodes; do
rpm-build 3ee90c
	cat <<EOF >$l_base/.env
rpm-build 3ee90c
LABEL="$label"
rpm-build 3ee90c
REPORT_HOME="$r_base"
rpm-build 3ee90c
REPORT_MASTER="$host"
rpm-build 3ee90c
REPORT_TARGET="$node"
rpm-build 3ee90c
LOG_START=$start
rpm-build 3ee90c
LOG_END=$end
rpm-build 3ee90c
REMOVE=1
rpm-build 3ee90c
SANITIZE="$sanitize_patterns"
rpm-build 3ee90c
CLUSTER=$cluster
rpm-build 3ee90c
LOG_PATTERNS="$log_patterns"
rpm-build 3ee90c
EXTRA_LOGS="$extra_logs"
rpm-build 3ee90c
SEARCH_LOGS=$search_logs
rpm-build 3ee90c
SOS_MODE=$sos_mode
rpm-build 3ee90c
verbose=$verbose
rpm-build 3ee90c
maxdepth=$maxdepth
rpm-build 3ee90c
EOF
rpm-build 3ee90c
rpm-build 3ee90c
	if [ $host = $node ]; then
rpm-build 3ee90c
	    cat <<EOF >>$l_base/.env
rpm-build 3ee90c
REPORT_HOME="$l_base"
rpm-build 3ee90c
EOF
rpm-build 3ee90c
	    cat $l_base/.env $report_data/report.common $report_data/report.collector > $l_base/collector
rpm-build 3ee90c
	    bash $l_base/collector
rpm-build 3ee90c
	else
rpm-build 3ee90c
	    cat $l_base/.env $report_data/report.common $report_data/report.collector \
rpm-build 3ee90c
		| $rsh -l $ssh_user $node -- "mkdir -p $r_base; cat > $r_base/collector; bash $r_base/collector" | (cd $l_base && tar mxf -)
rpm-build 3ee90c
	fi
rpm-build 3ee90c
    done
rpm-build 3ee90c
rpm-build 3ee90c
    analyze $l_base > $l_base/$ANALYSIS_F
rpm-build 3ee90c
    if [ -f $l_base/$HALOG_F ]; then
rpm-build 3ee90c
	node_events $l_base/$HALOG_F > $l_base/$EVENTS_F
rpm-build 3ee90c
    fi
rpm-build 3ee90c
rpm-build 3ee90c
    for node in $nodes; do
rpm-build 3ee90c
	cat $l_base/$node/$ANALYSIS_F >> $l_base/$ANALYSIS_F
rpm-build 3ee90c
	if [ -s $l_base/$node/$EVENTS_F ]; then
rpm-build 3ee90c
	    cat $l_base/$node/$EVENTS_F >> $l_base/$EVENTS_F
rpm-build 3ee90c
	elif [ -s $l_base/$HALOG_F ]; then
rpm-build 3ee90c
	    awk "\$4==\"$nodes\"" $l_base/$EVENTS_F >> $l_base/$n/$EVENTS_F
rpm-build 3ee90c
	fi
rpm-build 3ee90c
    done
rpm-build 3ee90c
rpm-build 3ee90c
    log " "
rpm-build 3ee90c
    if [ $compress = 1 ]; then
rpm-build 3ee90c
	fname=`shrink $l_base`
rpm-build 3ee90c
	rm -rf $l_base
rpm-build 3ee90c
	log "Collected results are available in $fname"
rpm-build 3ee90c
	log " "
rpm-build 3ee90c
	log "Please create a bug entry at"
rpm-build 3ee90c
	log "    @BUG_URL@"
rpm-build 3ee90c
	log "Include a description of your problem and attach this tarball"
rpm-build 3ee90c
	log " "
rpm-build 3ee90c
	log "Thank you for taking time to create this report."
rpm-build 3ee90c
    else
rpm-build 3ee90c
	log "Collected results are available in $l_base"
rpm-build 3ee90c
    fi
rpm-build 3ee90c
    log " "
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
#
rpm-build 3ee90c
# check if files have same content in the cluster
rpm-build 3ee90c
#
rpm-build 3ee90c
cibdiff() {
rpm-build 3ee90c
    d1=$(dirname $1)
rpm-build 3ee90c
    d2=$(dirname $2)
rpm-build 3ee90c
rpm-build 3ee90c
    if [ -f "$d1/RUNNING" ] && [ ! -f "$d2/RUNNING" ]; then
rpm-build 3ee90c
        DIFF_OK=0
rpm-build 3ee90c
    elif [ -f "$d1/STOPPED" ] && [ ! -f "$d2/STOPPED" ]; then
rpm-build 3ee90c
        DIFF_OK=0
rpm-build 3ee90c
    else
rpm-build 3ee90c
        DIFF_OK=1
rpm-build 3ee90c
    fi
rpm-build 3ee90c
rpm-build 3ee90c
    if [ $DIFF_OK -eq 1 ]; then
rpm-build 3ee90c
	if which crm_diff > /dev/null 2>&1; then
rpm-build 3ee90c
	    crm_diff -c -n $1 -o $2
rpm-build 3ee90c
	else
rpm-build 3ee90c
	    info "crm_diff(8) not found, cannot diff CIBs"
rpm-build 3ee90c
	fi
rpm-build 3ee90c
    else
rpm-build 3ee90c
	echo "can't compare cibs from running and stopped systems"
rpm-build 3ee90c
    fi
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
diffcheck() {
rpm-build 3ee90c
    [ -f "$1" ] || {
rpm-build 3ee90c
	echo "$1 does not exist"
rpm-build 3ee90c
	return 1
rpm-build 3ee90c
    }
rpm-build 3ee90c
    [ -f "$2" ] || {
rpm-build 3ee90c
	echo "$2 does not exist"
rpm-build 3ee90c
	return 1
rpm-build 3ee90c
    }
rpm-build 3ee90c
    case $(basename "$1") in
rpm-build 3ee90c
        $CIB_F)  cibdiff $1 $2 ;;
rpm-build 3ee90c
        *)       diff -u $1 $2 ;;
rpm-build 3ee90c
    esac
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
#
rpm-build 3ee90c
# remove duplicates if files are same, make links instead
rpm-build 3ee90c
#
rpm-build 3ee90c
consolidate() {
rpm-build 3ee90c
    for n in $nodes; do
rpm-build 3ee90c
	if [ -f $1/$2 ]; then
rpm-build 3ee90c
	    rm $1/$n/$2
rpm-build 3ee90c
	else
rpm-build 3ee90c
	    mv $1/$n/$2 $1
rpm-build 3ee90c
	fi
rpm-build 3ee90c
	ln -s ../$2 $1/$n
rpm-build 3ee90c
    done
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
analyze_one() {
rpm-build 3ee90c
    rc=0
rpm-build 3ee90c
    node0=""
rpm-build 3ee90c
    for n in $nodes; do
rpm-build 3ee90c
	if [ "$node0" ]; then
rpm-build 3ee90c
	    diffcheck $1/$node0/$2 $1/$n/$2
rpm-build 3ee90c
	    rc=$(($rc+$?))
rpm-build 3ee90c
	else
rpm-build 3ee90c
	    node0=$n
rpm-build 3ee90c
	fi
rpm-build 3ee90c
    done
rpm-build 3ee90c
    return $rc
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
analyze() {
rpm-build 3ee90c
    flist="$MEMBERSHIP_F $CIB_F $CRM_MON_F $SYSINFO_F"
rpm-build 3ee90c
    for f in $flist; do
rpm-build 3ee90c
	printf "Diff $f... "
rpm-build 3ee90c
	ls $1/*/$f >/dev/null 2>&1 || {
rpm-build 3ee90c
	    echo "no $1/*/$f :/"
rpm-build 3ee90c
	    continue
rpm-build 3ee90c
	}
rpm-build 3ee90c
	if analyze_one $1 $f; then
rpm-build 3ee90c
	    echo "OK"
rpm-build 3ee90c
	    [ "$f" != $CIB_F ] && consolidate $1 $f
rpm-build 3ee90c
	else
rpm-build 3ee90c
	    echo ""
rpm-build 3ee90c
	fi
rpm-build 3ee90c
    done
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
do_cts() {
rpm-build 3ee90c
    test_sets=`echo $tests | tr ',' ' '`
rpm-build 3ee90c
    for test_set in $test_sets; do
rpm-build 3ee90c
rpm-build 3ee90c
	start_time=0
rpm-build 3ee90c
	start_test=`echo $test_set | tr '-' ' ' | awk '{print $1}'`
rpm-build 3ee90c
rpm-build 3ee90c
	end_time=0
rpm-build 3ee90c
	end_test=`echo $test_set | tr '-' ' ' | awk '{print $2}'`
rpm-build 3ee90c
rpm-build 3ee90c
	if [ x$end_test = x ]; then
rpm-build 3ee90c
	    msg="Extracting test $start_test"
rpm-build 3ee90c
	    label="CTS-$start_test-`date +"%b-%d-%Y"`"
rpm-build 3ee90c
	    end_test=`expr $start_test + 1`
rpm-build 3ee90c
	else
rpm-build 3ee90c
	    msg="Extracting tests $start_test to $end_test"
rpm-build 3ee90c
	    label="CTS-$start_test-$end_test-`date +"%b-%d-%Y"`"
rpm-build 3ee90c
	    end_test=`expr $end_test + 1`
rpm-build 3ee90c
	fi
rpm-build 3ee90c
rpm-build 3ee90c
	if [ $start_test = 0 ]; then
rpm-build 3ee90c
	    start_pat="BEGINNING [0-9].* TESTS"
rpm-build 3ee90c
	else
rpm-build 3ee90c
	    start_pat="Running test.*\[ *$start_test\]"
rpm-build 3ee90c
	fi
rpm-build 3ee90c
rpm-build 3ee90c
	if [ x$ctslog = x ]; then
rpm-build 3ee90c
	    ctslog=`findmsg 1 "$start_pat"`
rpm-build 3ee90c
rpm-build 3ee90c
	    if [ x$ctslog = x ]; then
rpm-build 3ee90c
		fatal "No CTS control file detected"
rpm-build 3ee90c
	    else
rpm-build 3ee90c
		log "Using CTS control file: $ctslog"
rpm-build 3ee90c
	    fi
rpm-build 3ee90c
	fi
rpm-build 3ee90c
rpm-build 3ee90c
	line=`grep -n "$start_pat" $ctslog | tail -1 | sed 's/:.*//'`
rpm-build 3ee90c
	if [ ! -z "$line" ]; then
rpm-build 3ee90c
	    start_time=`linetime $ctslog $line`
rpm-build 3ee90c
	fi
rpm-build 3ee90c
rpm-build 3ee90c
	line=`grep -n "Running test.*\[ *$end_test\]" $ctslog | tail -1 | sed 's/:.*//'`
rpm-build 3ee90c
	if [ ! -z "$line" ]; then
rpm-build 3ee90c
	    end_time=`linetime $ctslog $line`
rpm-build 3ee90c
	fi
rpm-build 3ee90c
rpm-build 3ee90c
	if [ -z "$nodes" ]; then
rpm-build 3ee90c
	    nodes=`grep CTS: $ctslog | grep -v debug: | grep " \* " | sed s:.*\\\*::g | sort -u  | tr '\\n' ' '`
rpm-build 3ee90c
	    log "Calculated node list: $nodes"
rpm-build 3ee90c
	fi
rpm-build 3ee90c
rpm-build 3ee90c
	if [ $end_time -lt $start_time ]; then
rpm-build 3ee90c
	    debug "Test didn't complete, grabbing everything up to now"
rpm-build 3ee90c
	    end_time=`date +%s`
rpm-build 3ee90c
	fi
rpm-build 3ee90c
rpm-build 3ee90c
	if [ $start_time != 0 ];then
rpm-build 3ee90c
	    log "$msg (`time2str $start_time` to `time2str $end_time`)"
rpm-build 3ee90c
	    collect_data $label $start_time $end_time $ctslog
rpm-build 3ee90c
	else
rpm-build 3ee90c
	    fatal "$msg failed: not found"
rpm-build 3ee90c
	fi
rpm-build 3ee90c
    done
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
node_names_from_xml() {
rpm-build 3ee90c
    awk '
rpm-build 3ee90c
      /uname/ {
rpm-build 3ee90c
            for( i=1; i<=NF; i++ )
rpm-build 3ee90c
                    if( $i~/^uname=/ ) {
rpm-build 3ee90c
                            sub("uname=.","",$i);
rpm-build 3ee90c
                            sub("\".*","",$i);
rpm-build 3ee90c
                            print $i;
rpm-build 3ee90c
                            next;
rpm-build 3ee90c
                    }
rpm-build 3ee90c
      }
rpm-build 3ee90c
    ' | tr '\n' ' '
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
getnodes() {
rpm-build 3ee90c
    cluster="$1"
rpm-build 3ee90c
rpm-build 3ee90c
    # 1. Live (cluster nodes or Pacemaker Remote nodes)
rpm-build 3ee90c
    # TODO: This will not detect Pacemaker Remote nodes unless they
rpm-build 3ee90c
    # have ever had a permanent node attribute set, because it only
rpm-build 3ee90c
    # searches the nodes section. It should also search the config
rpm-build 3ee90c
    # for resources that create Pacemaker Remote nodes.
rpm-build 3ee90c
    cib_nodes=$(cibadmin -Ql -o nodes 2>/dev/null)
rpm-build 3ee90c
    if [ $? -eq 0 ]; then
rpm-build 3ee90c
	debug "Querying CIB for nodes"
rpm-build 3ee90c
        echo "$cib_nodes" | node_names_from_xml
rpm-build 3ee90c
        return
rpm-build 3ee90c
    fi
rpm-build 3ee90c
rpm-build 3ee90c
    # 2. Saved
rpm-build 3ee90c
    if [ -f "@CRM_CONFIG_DIR@/cib.xml" ]; then
rpm-build 3ee90c
	debug "Querying on-disk CIB for nodes"
rpm-build 3ee90c
        grep "node " "@CRM_CONFIG_DIR@/cib.xml" | node_names_from_xml
rpm-build 3ee90c
        return
rpm-build 3ee90c
    fi
rpm-build 3ee90c
rpm-build 3ee90c
    # 3. logs
rpm-build 3ee90c
    # TODO: Look for something like crm_update_peer
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
if [ $compress -eq 1 ]; then
rpm-build 3ee90c
    require_tar
rpm-build 3ee90c
fi
rpm-build 3ee90c
rpm-build 3ee90c
if [ "x$tests" != "x" ]; then
rpm-build 3ee90c
    do_cts
rpm-build 3ee90c
rpm-build 3ee90c
elif [ "x$start_time" != "x" ]; then
rpm-build 3ee90c
    masterlog=""
rpm-build 3ee90c
rpm-build 3ee90c
    if [ -z "$sanitize_patterns" ]; then
rpm-build 3ee90c
	log "WARNING: The tarball produced by this program may contain"
rpm-build 3ee90c
	log "         sensitive information such as passwords."
rpm-build 3ee90c
	log ""
rpm-build 3ee90c
	log "We will attempt to remove such information if you use the"
rpm-build 3ee90c
	log "-p option. For example: -p \"pass.*\" -p \"user.*\""
rpm-build 3ee90c
	log ""
rpm-build 3ee90c
	log "However, doing this may reduce the ability for the recipients"
rpm-build 3ee90c
	log "to diagnose issues and generally provide assistance."
rpm-build 3ee90c
	log ""
rpm-build 3ee90c
	log "IT IS YOUR RESPONSIBILITY TO PROTECT SENSITIVE DATA FROM EXPOSURE"
rpm-build 3ee90c
	log ""
rpm-build 3ee90c
    fi
rpm-build 3ee90c
rpm-build 3ee90c
    # If user didn't specify a cluster stack, make a best guess if possible.
rpm-build 3ee90c
    if [ -z "$cluster" ] || [ "$cluster" = "any" ]; then
rpm-build 3ee90c
        cluster=$(get_cluster_type)
rpm-build 3ee90c
    fi
rpm-build 3ee90c
rpm-build 3ee90c
    # If user didn't specify node(s), make a best guess if possible.
rpm-build 3ee90c
    if [ -z "$nodes" ]; then
rpm-build 3ee90c
	nodes=`getnodes $cluster`
rpm-build 3ee90c
        if [ -n "$nodes" ]; then
rpm-build 3ee90c
            log "Calculated node list: $nodes"
rpm-build 3ee90c
        else
rpm-build 3ee90c
            fatal "Cannot determine nodes; specify --nodes or --single-node"
rpm-build 3ee90c
        fi
rpm-build 3ee90c
    fi
rpm-build 3ee90c
rpm-build 3ee90c
    if
rpm-build 3ee90c
	echo $nodes | grep -qs $host
rpm-build 3ee90c
    then
rpm-build 3ee90c
	debug "We are a cluster node"
rpm-build 3ee90c
    else
rpm-build 3ee90c
	debug "We are a log master"
rpm-build 3ee90c
	masterlog=`findmsg 1 "pacemaker-controld\\|CTS"`
rpm-build 3ee90c
    fi
rpm-build 3ee90c
rpm-build 3ee90c
rpm-build 3ee90c
    if [ -z $end_time ]; then
rpm-build 3ee90c
	end_time=`perl -e 'print time()'`
rpm-build 3ee90c
    fi
rpm-build 3ee90c
    label="pcmk-`date +"%a-%d-%b-%Y"`"
rpm-build 3ee90c
    log "Collecting data from $nodes (`time2str $start_time` to `time2str $end_time`)"
rpm-build 3ee90c
    collect_data $label $start_time $end_time $masterlog
rpm-build 3ee90c
else
rpm-build 3ee90c
    fatal "Not sure what to do, no tests or time ranges to extract"
rpm-build 3ee90c
fi
rpm-build 3ee90c
rpm-build 3ee90c
# vim: set expandtab tabstop=8 softtabstop=4 shiftwidth=4 textwidth=80: