Skip to content

Commit

Permalink
utests.sh - add -v for verbose output
Browse files Browse the repository at this point in the history
  • Loading branch information
qaxi committed Nov 9, 2017
1 parent 8821994 commit 6b89b71
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions utests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

CAPWARN=80 # warning at 80% of used disc capacity
CAPCRIT=90 # warnint at 90% of user disc capacity
VERBOSE=0 # verbose

PRGNAME=$(basename "$0")

DBG="n"
function dbg() { [ "$DBG" = "y" ] && echo "DBG: $*" >&2 ; }

OPTS=':hH:i:u:p:w:c:d-:' # first : and lsast - is mandatory
OPTS=':hH:i:u:p:w:c:vd-:' # first : and lsast - is mandatory
function usage() {
[ -n "$*" ] && {
exec 1>&2 # redirect STDOUT to STDERR for rest of script
Expand All @@ -19,7 +20,7 @@ function usage() {
echo "Tests for check_3par.
Copyright (c) 2010-2017 various developers - look in source code
Usage: ${PRGNAME} -h | -H <3PAR> [-d] [-u <username>] [-i <inform_cli> [-p <password_file>]] [-w <warning>] [-c <critical>] <volumename> <quorum_witeness>
Usage: ${PRGNAME} -h | -H <3PAR> [-d] [-v] [-u <username>] [-i <inform_cli> [-p <password_file>]] [-w <warning>] [-c <critical>] <volumename> <quorum_witeness>
Options:
-h, --help
Expand All @@ -38,7 +39,8 @@ Options:
Critical treshold
-d, --debug
Turn on debugging
-v, --verbose
Verbose output
"
exit 128

Expand All @@ -50,6 +52,7 @@ while getopts "$OPTS" OPTION ; do
dbg "option $OPTION optind $OPTIND optarg $OPTARG"
case "$OPTION" in
d ) DBG="y";;
v ) VERBOSE=$((++VERBOSE)) ;;
h ) usage ;;
H ) INSERV="$OPTARG" ;;
i ) INFORMBIN="$OPTARG" ;;
Expand All @@ -64,6 +67,7 @@ while getopts "$OPTS" OPTION ; do
dbg "- option $OPTION optind $OPTIND optarg $OPTARG"
case $OPTION in
--debug ) DBG="y" ;;
--verbose ) VERBOSE=$((++VERBOSE)) ;;
--help ) usage ;;
--hostname ) INSERV="$OPTARG" ;;
--inform-bin ) INFORMBIN="$OPTARG" ;;
Expand Down Expand Up @@ -129,7 +133,11 @@ function utest() {

if [ $CMDRET -eq $RET ]
then
echo "### OK # \$CMD $@"
echo "### OK # $CMD $@"
if [ "${VERBOSE}" -gt 0 ]
then
echo "${CMDOUT}"
fi
else
echo
echo "############################################"
Expand Down

0 comments on commit 6b89b71

Please sign in to comment.