fix writable
This commit is contained in:
parent
406086a119
commit
f9c8f623dc
|
@ -1,23 +1,43 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check if argument is provided
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided"
|
||||
echo "./check_writable.sh [path to directory to test]"
|
||||
exit 3
|
||||
# Default exit code for Nagios
|
||||
STATE_OK=0
|
||||
STATE_WARNING=1
|
||||
STATE_CRITICAL=2
|
||||
STATE_UNKNOWN=3
|
||||
|
||||
# Parse command line options
|
||||
while getopts "p:" OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
p)
|
||||
path=$OPTARG
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 -p <path>"
|
||||
exit $STATE_UNKNOWN
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if path is set
|
||||
if [ -z "$path" ]; then
|
||||
echo "No path specified"
|
||||
echo "./check_not_writable.sh -p [directory to check]"
|
||||
exit $STATE_UNKNOWN
|
||||
fi
|
||||
|
||||
# Check if directory exists
|
||||
if [ ! -d "$1" ]; then
|
||||
echo "UNKNOWN - $1 is not a directory"
|
||||
if [ ! -d "$path" ]; then
|
||||
echo "UNKNOWN - $path is not a directory"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Check if directory is not writable
|
||||
if [ ! -w "$1" ]; then
|
||||
echo "OK - $1 is not writable"
|
||||
exit 0
|
||||
# Check if directory is writable
|
||||
if [ ! -w "$path" ]; then
|
||||
echo "OK - $path is not writable"
|
||||
exit $STATE_OK
|
||||
else
|
||||
echo "CRITICAL - $1 is writable"
|
||||
echo "CRITICAL - $path is writable"
|
||||
exit 2
|
||||
fi
|
||||
|
|
|
@ -1,23 +1,43 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check if argument is provided
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided"
|
||||
echo "./check_writable.sh [path to directory to test]"
|
||||
exit 3
|
||||
# Default exit code for Nagios
|
||||
STATE_OK=0
|
||||
STATE_WARNING=1
|
||||
STATE_CRITICAL=2
|
||||
STATE_UNKNOWN=3
|
||||
|
||||
# Parse command line options
|
||||
while getopts "p:" OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
p)
|
||||
path=$OPTARG
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 -p <path>"
|
||||
exit $STATE_UNKNOWN
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if path is set
|
||||
if [ -z "$path" ]; then
|
||||
echo "No path specified"
|
||||
echo "./check_writable.sh -p [directory to check]"
|
||||
exit $STATE_UNKNOWN
|
||||
fi
|
||||
|
||||
# Check if directory exists
|
||||
if [ ! -d "$1" ]; then
|
||||
echo "UNKNOWN - $1 is not a directory"
|
||||
if [ ! -d "$path" ]; then
|
||||
echo "UNKNOWN - $path is not a directory"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Check if directory is writable
|
||||
if [ -w "$1" ]; then
|
||||
echo "OK - $1 is writable"
|
||||
exit 0
|
||||
if [ -w "$path" ]; then
|
||||
echo "OK - $path is writable"
|
||||
exit $STATE_OK
|
||||
else
|
||||
echo "CRITICAL - $1 is not writable"
|
||||
echo "CRITICAL - $path is not writable"
|
||||
exit 2
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue