From c8e93fdb8c23d8e03807678a3fe1347d37002240 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Fri, 16 Feb 2018 11:57:51 -0500 Subject: [PATCH] Merge pull request #16986 from jeffmcutter/fix_tools_miqssh Two small fixes to tools/miqssh (cherry picked from commit e582ac7b532af201c9ae55ac0c8d2713500cdc14) https://bugzilla.redhat.com/show_bug.cgi?id=1553364 --- tools/miqssh/miqssh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/miqssh/miqssh b/tools/miqssh/miqssh index 8e7c075e2c5..129dc976f45 100755 --- a/tools/miqssh/miqssh +++ b/tools/miqssh/miqssh @@ -5,7 +5,7 @@ TAIL_NUMBER=3 ALL_TAIL_NUMBER=999999999999999 -NAME=$(basename $(realpath $0)) +NAME=$(basename $0) DIR=$(dirname $0) miqhosts_cmd="$DIR/miqhosts.rb" miqhosts_file="$DIR/miqhosts" @@ -495,7 +495,13 @@ then "miqssh") ansible all -i $HOSTS -f $PARALLELISM -m shell -a "$ARGS" ;; "miqscp") ansible all -i $HOSTS -f $PARALLELISM -m copy -a "src=$1 dest=$2" ;; "miqcollect") ansible all -i $HOSTS -f $PARALLELISM -m fetch -a "src=$1 dest=$2/$(basename $1)-{{ inventory_hostname }} flat=yes" ;; - "miqgrep") ansible all -i $HOSTS -f $PARALLELISM -m shell -a "$GREP \"$PATTERN\" $LOG | perl -pe 's/^\/.*?://' | sed -e \"s/^/[\$(hostname -s)] /\"" | tee $TMPFILE ;; + "miqgrep") + if [ -n "$PATTERN" ] + then + ansible all -i $HOSTS -f $PARALLELISM -m shell -a "$GREP \"$PATTERN\" $LOG | perl -pe 's/^\/.*?://' | sed -e \"s/^/[\$(hostname -s)] /\"" | tee $TMPFILE + else + ansible all -i $HOSTS -f $PARALLELISM -m shell -a "$GREP $LOG | perl -pe 's/^\/.*?://' | sed -e \"s/^/[\$(hostname -s)] /\"" | tee $TMPFILE + fi ;; esac else