2
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Merge pull request #600 from driskell/feature/vsftpd_improvements

Improve vsftpd plugin
This commit is contained in:
Stig Sandbeck Mathisen 2015-03-14 19:46:36 +01:00
commit 3aec3d5d3d

View file

@ -1,58 +1,104 @@
LOGFILE=/var/log/vsftpd.log #!/bin/bash
logfile=${logfile:-/var/log/vsftpd.log}
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if [ -f "${LOGFILE}" ]; then if [ -f "${logfile}" ]; then
echo yes echo yes
exit 0 exit 0
else else
echo no echo no
exit 1 exit 1
fi fi
fi fi
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then
echo 'graph_title FTP Server' cat <<EOF
echo 'graph_args --base 1000 -l 0' graph_title vsftpd Server
echo 'graph_vlabel Requests' graph_args --base 1000 -l 0
echo 'graph_category FTP' graph_vlabel Requests
echo 'ftp_c.label connections' graph_category ftp
echo 'ftp_sl.label successful_logins' ftp_c.label connections
echo 'ftp_fl.label failed_logins' ftp_c.type DERIVE
echo 'ftp_su.label successful_uploads' ftp_c.min 0
echo 'ftp_fu.label failed_uploads' ftp_sl.label successful_logins
echo 'ftp_sd.label successful_downloads' ftp_sl.type DERIVE
echo 'ftp_fd.label failed_downloads' ftp_sl.min 0
echo 'ftp_sde.label successful_deletes' ftp_fl.label failed_logins
echo 'ftp_fde.label failed_deletes' ftp_fl.type DERIVE
exit 0 ftp_fl.min 0
ftp_su.label successful_uploads
ftp_su.type DERIVE
ftp_su.min 0
ftp_fu.label failed_uploads
ftp_fu.type DERIVE
ftp_fu.min 0
ftp_sd.label successful_downloads
ftp_sd.type DERIVE
ftp_sd.min 0
ftp_fd.label failed_downloads
ftp_fd.type DERIVE
ftp_fd.min 0
ftp_sr.label successful_renames
ftp_sr.type DERIVE
ftp_sr.min 0
ftp_fr.label failed_renames
ftp_fr.type DERIVE
ftp_fr.min 0
ftp_sde.label successful_deletes
ftp_sde.type DERIVE
ftp_sde.min 0
ftp_fde.label failed_deletes
ftp_fde.type DERIVE
ftp_fde.min 0
EOF
exit 0
fi fi
ftp_c=U if [ -f "${logfile}" ]; then
ftp_sl=U awk '
ftp_fl=U BEGIN {
ftp_su=U counts["ftp_c"] = 0;
ftp_fu=U counts["ftp_sl"] = 0;
ftp_sd=U counts["ftp_fl"] = 0;
ftp_fd=U counts["ftp_su"] = 0;
ftp_sde=U counts["ftp_fu"] = 0;
ftp_fde=U counts["ftp_sd"] = 0;
counts["ftp_fd"] = 0;
ftp_c=`grep "CONNECT" ${LOGFILE} | wc -l` counts["ftp_sr"] = 0;
ftp_sl=`grep "OK LOGIN" ${LOGFILE} | wc -l` counts["ftp_fr"] = 0;
ftp_fl=`grep "FAIL LOGIN" ${LOGFILE} | wc -l` counts["ftp_sde"] = 0;
ftp_su=`grep "OK UPLOAD" ${LOGFILE} | wc -l` counts["ftp_fde"] = 0;
ftp_fu=`grep "FAIL UPLOAD" ${LOGFILE} | wc -l` }
ftp_sd=`grep "OK DOWNLOAD" ${LOGFILE} |wc -l` /CONNECT/ { counts["ftp_c"]++; next; }
ftp_fd=`grep "FAIL DOWNLOAD" ${LOGFILE} | wc -l` /OK LOGIN/ { counts["ftp_sl"]++; next; }
ftp_sde=`grep "OK DELETE" ${LOGFILE} |wc -l` /FAIL LOGIN/ { counts["ftp_fl"]++; next; }
ftp_fde=`grep "FAIL DELETE" ${LOGFILE} | wc -l` /OK UPLOAD/ { counts["ftp_su"]++; next; }
/FAIL UPLOAD/ { counts["ftp_fu"]++; next; }
echo "ftp_c.value ${ftp_c}" /OK DOWNLOAD/ { counts["ftp_sd"]++; next; }
echo "ftp_sl.value ${ftp_sl}" /FAIL DOWNLOAD/ { counts["ftp_fd"]++; next; }
echo "ftp_fl.value ${ftp_fl}" /OK RENAME/ { counts["ftp_sr"]++; next; }
echo "ftp_su.value ${ftp_su}" /FAIL RENAME/ { counts["ftp_fr"]++; next; }
echo "ftp_fu.value ${ftp_fu}" /OK DELETE/ { counts["ftp_sde"]++; next; }
echo "ftp_sd.value ${ftp_sd}" /FAIL DELETE/ { counts["ftp_fde"]++; next; }
echo "ftp_fd.value ${ftp_fd}" END {
echo "ftp_sde.value ${ftp_sde}" for (idx in counts) {
echo "ftp_fde.value ${ftp_fde}" printf "%s.value %d\n", idx, counts[idx];
}
}
' "${logfile}"
else
cat <<EOF
ftp_c.value U
ftp_sl.value U
ftp_fl.value U
ftp_su.value U
ftp_fu.value U
ftp_sd.value U
ftp_fd.value U
ftp_sr.value U
ftp_fr.value U
ftp_sde.value U
ftp_fde.value U
EOF
fi