Skip to content
Snippets Groups Projects
Commit 8c1c70f3 authored by Peter Eriksson's avatar Peter Eriksson
Browse files

Added --cfg-file and --ignore-disks command line arguments

parent 6a32351b
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,8 @@ GAWK=gawk
IOSTAT=iostat
VERBOSE=0
CFG=/etc/check_iostatE.cfg
HOST=""
HWARN=2
......@@ -19,49 +21,69 @@ TCRIT=3
SWARN=8
SCRIT=20
IGNORE=""
parseconfig() {
eval "`nawk '($1 == "ignore-disks:") { print \"IGNORE=\\\"\"$2\"\\\"\" }' <$1`"
}
if [ -f "$CFG" ]; then
parseconfig $CFG
fi
while [ "$1" != "" ]; do
case "$1" in
-v|--verbose)
VERBOSE=1
;;
-I|--ignore-disks)
IGNORE="$2"
shift
;;
-C|--config-file)
parseconfig "$2"
shift
;;
-H|--host)
HOST=$2
HOST="$2"
shift
;;
-R|--rsh)
RSH=$2
-R|--rsh-command)
RSH="$2"
shift
;;
-hc|--hard-critical)
HCRIT=$2
HCRIT="$2"
shift
;;
-hw|--hard-warning)
HWARN=$2
HWARN="$2"
shift
;;
-tc|--transport-critical)
TCRIT=$2
TCRIT="$2"
shift
;;
-tw|--transport-warning)
TWARN=$2
TWARN="$2"
shift
;;
-sc|--soft-critical)
SCRIT=$2
SCRIT="$2"
shift
;;
-sw|--soft-warning)
SWARN=$2
SWARN="$2"
shift
;;
......@@ -98,10 +120,10 @@ else
fi
exec $CMD | $GAWK -vverbose=$VERBOSE \
-vhcrit=$HCRIT -vhwarn=$HWARN \
-vtcrit=$TCRIT -vtwarn=$TWARN \
-vscrit=$SCRIT -vswarn=$SWARN \
exec $CMD | $GAWK -vignore="$IGNORE" -vverbose="$VERBOSE" \
-vhcrit="$HCRIT" -vhwarn="$HWARN" \
-vtcrit="$TCRIT" -vtwarn="$TWARN" \
-vscrit="$SCRIT" -vswarn="$SWARN" \
'\
BEGIN { gtotal=0; ndisks=0; disks=""; ncrit=0; nwarn=0; crits=""; warns="" } \
/^c[0-9][0-9]*t[0-9][0-9]*d[0-9][0-9]*/ { dev=$1; serr[dev]=$4; herr[dev]=$7; terr[dev]=$10; vendor[dev]=""; pfa[dev]="" } \
......@@ -115,7 +137,8 @@ exec $CMD | $GAWK -vverbose=$VERBOSE \
total[dev]=serr[dev]+herr[dev]+terr[dev];
if (verbose) \
print dev, "(" vendor[dev]""product[dev], rev[dev] ")", ":", total[dev], ":", serr[dev], herr[dev], terr[dev], ":", merr[dev], dnrerr[dev], nderr[dev], rerr[dev], irerr[dev], pfa[dev];\
if ( product[dev] !~ /^CD/ && product[dev] !~ /^DVD/ ) { \
if (!(product[dev] ~ /^CD/ || product[dev] ~ /^DVD/ || \
(ignore != "" && dev ~ ignore))) { \
gtotal += total[dev]; \
ndisks++; disks=disks " " dev; \
nsoft+=serr[dev]; nhard+=herr[dev]; ntran+=terr[dev]; \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment