X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-file;h=4013fa86deaa8ce83848b338a6e6e541d944638b;hb=f79acba81afea4a50183dd6754d7aeb064e0e4e1;hp=e53d3e66e1cc143c898eb583e1264110df820380;hpb=39fe69f3cd789482652d4fbeab510b7512cf7c0f;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/checks/dsa-check-file b/dsa-nagios-checks/checks/dsa-check-file index e53d3e6..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,28 +37,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 "file %s is missing\n" $FILE + exit $EXIT fi - -printf "OK: file %s does exist %s\n" $FILE +printf "file %s does exist %s\n" $FILE