projects
/
mirror
/
dsa-nagios.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
barriere on wheezy
[mirror/dsa-nagios.git]
/
dsa-nagios-checks
/
checks
/
dsa-check-file
diff --git
a/dsa-nagios-checks/checks/dsa-check-file
b/dsa-nagios-checks/checks/dsa-check-file
index
01e5c01
..
4013fa8
100755
(executable)
--- a/
dsa-nagios-checks/checks/dsa-check-file
+++ b/
dsa-nagios-checks/checks/dsa-check-file
@@
-25,6
+25,7
@@
FILE=''
EXIT=0
FILE=''
EXIT=0
+LEVEL=''
usage(){
ret=$1
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
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
}
-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" ;;
case "$opt" in
f) FILE="$OPTARG" ;;
+ w) LEVEL="WARNING";;
h) usage 0
esac
done
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
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
if [ ! -f "$FILE" ]; then
printf "file %s is missing\n" $FILE
- exit
2
+ exit
$EXIT
fi
fi
-
-printf "file %s OK: %s\n" $FILE
+printf "file %s does exist %s\n" $FILE