Commit 5fb6109d authored by Philipp Steinpass's avatar Philipp Steinpass
Browse files

Script now works even when all quotas are met and everything is fine.

parent e329209c
......@@ -7,41 +7,42 @@ WARNOUTPUT=""
#Run Repquota and pip output to while, iterate over lines
$REPQUOTA $REPPATH |
while read -r line; do
#reportquota ends it's output with multiple newlines
if [[ $line == "" ]] ;then
#Remove last \n
OUTPUT=${CRITOUTPUT}${WARNOUTPUT}
OUTPUT=${OUTPUT::-2}
#Print Output
echo -e $OUTPUT
#reportquota ends it's output with multiple newlines
if [[ $line == "" ]] ;then
#Remove last \n
OUTPUT=${CRITOUTPUT}${WARNOUTPUT}
#Remove last lines of output if it exists and print it.
if [ -n "$OUTPUT" ]; then
OUTPUT=${OUTPUT::-2}
echo -e $OUTPUT
fi
#Set apropriet exit code
if [ -n "$CRITOUTPUT" ]; then
exit 2
elif [ -n "$WARNOUTPUT" ]; then
exit 1
else
echo "OK: All Quotas are met."
exit 0
fi
elif [ $HEADERDONE ] ;then
userName=`echo $line | awk '{ print $1 }'`
usedSpace=`echo $line | awk '{ print $3 }'`
softQuota=`echo $line | awk '{ print $4 }'`
hardQuota=`echo $line | awk '{ print $5 }'`
if (( $hardQuota == 0)); then
#do nothing
:
elif (( $softQuota == 0)); then
WARNOUTPUT+="WARNING: $userName has hard quota but no soft quota.\n"
elif (( $usedSpace >= $hardQuota )); then
CRITOUTPUT+="CRITICAL: $userName\n"
elif (( $usedSpace >= $softQuota)); then
WARNOUTPUT+="WARNING: $userName\n"
fi
#reportqota always sends a header, parse it out
elif [[ $line == "----------------------------------------------------------------------" ]] ;then
HEADERDONE=1
fi
done
#Set apropriet exit code
if [ -n "$CRITOUTPUT" ]; then
exit 2
elif [ -n "$WARNOUTPUT" ]; then
exit 1
else
echo "OK: All Quotas are met."
exit 0
fi
elif [ $HEADERDONE ] ;then
userName=`echo $line | awk '{ print $1 }'`
usedSpace=`echo $line | awk '{ print $3 }'`
softQuota=`echo $line | awk '{ print $4 }'`
hardQuota=`echo $line | awk '{ print $5 }'`
if (( $hardQuota == 0)); then
#do nothing
:
elif (( $softQuota == 0)); then
WARNOUTPUT+="WARNING: $userName has hard quota but no soft quota.\n"
elif (( $usedSpace >= $hardQuota )); then
CRITOUTPUT+="CRITICAL: $userName\n"
elif (( $usedSpace >= $softQuota)); then
WARNOUTPUT+="WARNING: $userName\n"
fi
#reportqota always sends a header, parse it out
elif [[ $line == "----------------------------------------------------------------------" ]] ;then
HEADERDONE=1
fi
done
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment