From: Martin Zobel-Helas Date: Sat, 24 Jul 2010 13:47:07 +0000 (+0200) Subject: add an optional -w X-Git-Url: https://wiki.adam-barratt.org.uk/gitweb/?a=commitdiff_plain;h=fff4fa817398747f04255879bacf5972d84a3442;p=mirror%2Fdsa-nagios.git add an optional -w --- diff --git a/dsa-nagios-checks/checks/dsa-check-file b/dsa-nagios-checks/checks/dsa-check-file index e53d3e6..61cd6cf 100755 --- a/dsa-nagios-checks/checks/dsa-check-file +++ b/dsa-nagios-checks/checks/dsa-check-file @@ -36,28 +36,36 @@ $0: usage: File checker for nagios. Will alert if the named file does not exist -h This help message + -w If the file does not exist, this is only warning -f File to check EOF exit $ret } -while getopts f:i:h opt ; do +while getopts f:hw opt ; do case "$opt" in f) FILE="$OPTARG" ;; + w) LEVEL="WARNING";; h) usage 0 esac done +if [ "$LEVEL" = "WARNING" ]; then + EXIT=1 +else + EXIT=2 + LEVEL="CRITICAL" +fi + if [ -z "$FILE" ]; then echo "Need file argument!" >&2 usage 3 fi if [ ! -f "$FILE" ]; then - printf "CRITICAL: file %s is missing\n" $FILE - exit 2 + printf "%s: file %s is missing\n" $LEVEL $FILE + exit $EXIT fi - printf "OK: file %s does exist %s\n" $FILE