LOGFILE=/var/log/vsftpd.log

if [ "$1" = "autoconf" ]; then
    if [ -f "${LOGFILE}" ]; then
        echo yes
	exit 0
    else
        echo no
	exit 1
    fi
fi

if [ "$1" = "config" ]; then
        echo 'graph_title FTP Server'
        echo 'graph_args --base 1000 -l 0'
        echo 'graph_vlabel Requests'
	echo 'graph_category FTP'
        echo 'ftp_c.label connections'
        echo 'ftp_sl.label successful_logins'
	echo 'ftp_fl.label failed_logins'
	echo 'ftp_su.label successful_uploads'
	echo 'ftp_fu.label failed_uploads'
	echo 'ftp_sd.label successful_downloads'
	echo 'ftp_fd.label failed_downloads'
	echo 'ftp_sde.label successful_deletes'
	echo 'ftp_fde.label failed_deletes'
        exit 0
fi

ftp_c=U
ftp_sl=U
ftp_fl=U
ftp_su=U
ftp_fu=U
ftp_sd=U
ftp_fd=U
ftp_sde=U
ftp_fde=U

ftp_c=`grep "CONNECT" ${LOGFILE} | wc -l`
ftp_sl=`grep "OK LOGIN" ${LOGFILE} | wc -l`
ftp_fl=`grep "FAIL LOGIN" ${LOGFILE} | wc -l`
ftp_su=`grep "OK UPLOAD" ${LOGFILE} | wc -l`
ftp_fu=`grep "FAIL UPLOAD" ${LOGFILE} | wc -l`
ftp_sd=`grep "OK DOWNLOAD" ${LOGFILE} |wc -l`
ftp_fd=`grep "FAIL DOWNLOAD" ${LOGFILE} | wc -l`
ftp_sde=`grep "OK DELETE" ${LOGFILE} |wc -l`
ftp_fde=`grep "FAIL DELETE" ${LOGFILE} | wc -l`

echo "ftp_c.value ${ftp_c}"
echo "ftp_sl.value ${ftp_sl}"
echo "ftp_fl.value ${ftp_fl}"
echo "ftp_su.value ${ftp_su}"
echo "ftp_fu.value ${ftp_fu}"
echo "ftp_sd.value ${ftp_sd}"
echo "ftp_fd.value ${ftp_fd}"
echo "ftp_sde.value ${ftp_sde}"
echo "ftp_fde.value ${ftp_fde}"
