retire da-backup checks
[mirror/dsa-nagios.git] / dsa-nagios-checks / checks / dsa-check-file
index 01e5c01..4013fa8 100755 (executable)
@@ -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