Newer
Older
icinga-plugins / check_ftp_space
Paul Staroch on 21 Dec 2017 702 bytes updated plugin check_ftp_space
#!/bin/bash

# requires ftp-space.sh to be run regularly

# for nagios-nrpe-server:
# command[check_ftp_space]=/opt/icinga/check_ftp_space -w 15 -c 10

if [ "$1" != "-w" ]; then
	echo "Usage error."
	exit 3
fi
if [ "$3" != "-c" ]; then
	echo "Usage error."
	exit 3
fi
FREE=`cat /etc/ftp-space/free`
TOTAL=`cat /etc/ftp-space/total`
if [ "$FREE" == "" ]; then
	echo "Invalid value in /etc/ftp-space/free."
	exit 3
fi
if [ "$TOTAL" == "" ]; then
	echo "Invalid value in /etc/ftp-space/total."
	exit 3
fi
PERCENT=$((100*FREE/TOTAL))

echo "FTP backup space: $PERCENT% free ($FREE bytes of $TOTAL bytes)"
if [ "$PERCENT" -le "$4" ]; then
	exit 2
elif [ "$PERCENT" -le "$2" ]; then
	exit 1
else
	exit 0
fi