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="" ...@@ -7,41 +7,42 @@ WARNOUTPUT=""
#Run Repquota and pip output to while, iterate over lines #Run Repquota and pip output to while, iterate over lines
$REPQUOTA $REPPATH | $REPQUOTA $REPPATH |
while read -r line; do while read -r line; do
#reportquota ends it's output with multiple newlines #reportquota ends it's output with multiple newlines
if [[ $line == "" ]] ;then if [[ $line == "" ]] ;then
#Remove last \n #Remove last \n
OUTPUT=${CRITOUTPUT}${WARNOUTPUT} OUTPUT=${CRITOUTPUT}${WARNOUTPUT}
OUTPUT=${OUTPUT::-2} #Remove last lines of output if it exists and print it.
if [ -n "$OUTPUT" ]; then
#Print Output OUTPUT=${OUTPUT::-2}
echo -e $OUTPUT echo -e $OUTPUT
fi
#Set apropriet exit code #Set apropriet exit code
if [ -n "$CRITOUTPUT" ]; then if [ -n "$CRITOUTPUT" ]; then
exit 2 exit 2
elif [ -n "$WARNOUTPUT" ]; then elif [ -n "$WARNOUTPUT" ]; then
exit 1 exit 1
else else
echo "OK: All Quotas are met." echo "OK: All Quotas are met."
exit 0 exit 0
fi fi
elif [ $HEADERDONE ] ;then elif [ $HEADERDONE ] ;then
userName=`echo $line | awk '{ print $1 }'` userName=`echo $line | awk '{ print $1 }'`
usedSpace=`echo $line | awk '{ print $3 }'` usedSpace=`echo $line | awk '{ print $3 }'`
softQuota=`echo $line | awk '{ print $4 }'` softQuota=`echo $line | awk '{ print $4 }'`
hardQuota=`echo $line | awk '{ print $5 }'` hardQuota=`echo $line | awk '{ print $5 }'`
if (( $hardQuota == 0)); then if (( $hardQuota == 0)); then
#do nothing #do nothing
: :
elif (( $softQuota == 0)); then elif (( $softQuota == 0)); then
WARNOUTPUT+="WARNING: $userName has hard quota but no soft quota.\n" WARNOUTPUT+="WARNING: $userName has hard quota but no soft quota.\n"
elif (( $usedSpace >= $hardQuota )); then elif (( $usedSpace >= $hardQuota )); then
CRITOUTPUT+="CRITICAL: $userName\n" CRITOUTPUT+="CRITICAL: $userName\n"
elif (( $usedSpace >= $softQuota)); then elif (( $usedSpace >= $softQuota)); then
WARNOUTPUT+="WARNING: $userName\n" WARNOUTPUT+="WARNING: $userName\n"
fi fi
#reportqota always sends a header, parse it out #reportqota always sends a header, parse it out
elif [[ $line == "----------------------------------------------------------------------" ]] ;then elif [[ $line == "----------------------------------------------------------------------" ]] ;then
HEADERDONE=1 HEADERDONE=1
fi fi
done 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