From fff4fa817398747f04255879bacf5972d84a3442 Mon Sep 17 00:00:00 2001 From: Martin Zobel-Helas Date: Sat, 24 Jul 2010 15:47:07 +0200 Subject: [PATCH] add an optional -w --- dsa-nagios-checks/checks/dsa-check-file | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 -- 2.20.1