options:
-n <nodes> Comma separated list of nodes to operate on
-c Ignore comment lines (starting with '#') in file comparisons
+ -l Run in local mode
-w Ignore whitespace in file comparisons
--no-ads Do not use commands that assume an Active Directory Server
EOF
}
nodes=$(ctdb listnodes -X | cut -d'|' -f2)
+local_mode=false
bad_nodes=""
diff_opts=
no_ads=false
parse_options ()
{
- temp=$(getopt -n "ctdb_diagnostics" -o "n:cwh" -l no-ads,help -- "$@")
+ temp=$(getopt -n "ctdb_diagnostics" -o "n:clwh" -l no-ads,help -- "$@")
# No! Checking the exit code afterwards is actually clearer...
# shellcheck disable=SC2181
case "$1" in
-n) nodes=$(echo "$2" | sed -e 's@,@ @g') ; shift 2 ;;
-c) diff_opts="${diff_opts} -I ^#.*" ; shift ;;
+ -l) local_mode=true ; shift ;;
-w) diff_opts="${diff_opts} -w" ; shift ;;
--no-ads) no_ads=true ; shift ;;
--) shift ; break ;;
# Filter nodes. Remove any nodes we can't contact from $node and add
# them to $bad_nodes.
+
_nodes=""
+if ! $local_mode ; then
for _i in $nodes ; do
if onnode "$_i" true >/dev/null 2>&1 ; then
_nodes="${_nodes}${_nodes:+ }${_i}"
bad_nodes="${bad_nodes}${bad_nodes:+,}${_i}"
fi
done
+fi
+
nodes="$_nodes"
nodes_comma=$(echo "$nodes" | sed -e 's@[[:space:]]@,@g')
}
show_all() {
- echo "running $1 on nodes $nodes_comma"
- onnode "$nodes_comma" "hostname; date; $1 2>&1 | sed 's/^/ /'" 2>&1
+ if $local_mode ; then
+ echo "running on local node"
+ hostname; date; $1 2>&1 | sed 's/^/ /' 2>&1
+ else
+ echo "running $1 on nodes $nodes_comma"
+ onnode "$nodes_comma" "hostname; date; $1 2>&1 | sed 's/^/ /'" 2>&1
+ fi
}
show_and_compare_files () {
# Intentional multi-word splitting on CONFIG_FILES_MUST
# shellcheck disable=SC2086
-show_and_compare_files \
+
+if ! $local_mode ; then
+ show_and_compare_files \
"%s is missing on node %d" \
$CONFIG_FILES_MUST
+else
+ for f in $CONFIG_FILES_MUST ; do
+ show_file $f
+ done
+fi
# Intentional multi-word splitting on CONFIG_FILES_MAY
# shellcheck disable=SC2086
-show_and_compare_files \
+if ! $local_mode ; then
+ show_and_compare_files \
"Optional file %s is not present on node %d" \
$CONFIG_FILES_MAY
+else
+ for f in $CONFIG_FILES_MAY ; do
+ show_file $f
+ done
+fi
cat <<EOF
--------------------------------------------------------------------