X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-file;h=4013fa86deaa8ce83848b338a6e6e541d944638b;hb=a2dcd23b60c89f3921424732f5eb40f2267af8bb;hp=01e5c01216379d807130d3518fd8ca12d97e48b3;hpb=283693decf60d93f93691c92c41a194eea75aa4d;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/checks/dsa-check-file b/dsa-nagios-checks/checks/dsa-check-file index 01e5c01..4013fa8 100755 --- a/dsa-nagios-checks/checks/dsa-check-file +++ b/dsa-nagios-checks/checks/dsa-check-file @@ -25,6 +25,7 @@ FILE='' EXIT=0 +LEVEL='' usage(){ ret=$1 @@ -36,19 +37,28 @@ $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 @@ -56,8 +66,7 @@ fi if [ ! -f "$FILE" ]; then printf "file %s is missing\n" $FILE - exit 2 + exit $EXIT fi - -printf "file %s OK: %s\n" $FILE +printf "file %s does exist %s\n" $FILE