From 662a69f2837c5103ce06fc7c5451c2c398164378 Mon Sep 17 00:00:00 2001 From: Jim Popovitch Date: Fri, 25 May 2007 19:51:46 +0200 Subject: [PATCH] Initial version --- plugins/other/proftpd_bytes | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 plugins/other/proftpd_bytes diff --git a/plugins/other/proftpd_bytes b/plugins/other/proftpd_bytes new file mode 100755 index 00000000..e1cdb31d --- /dev/null +++ b/plugins/other/proftpd_bytes @@ -0,0 +1,64 @@ +#!/bin/bash +# +# Plugin to monitor FTP bytes. +# based on previous work by jintxo +# +# Parameters understood: +# +# config (required) +# autoconf (optional) +# +# Magic markers (optional - used by munin-config and installation +# scripts): +# +#%# family=auto +#%# capabilities=autoconf + +MAXLABEL=20 + +mktempfile () { +mktemp -t $1 +} + +LOGFILE=${logfile:-/var/log/xferlog} +LOGTAIL=${logtail:-`which logtail`} +STATEFILE=/var/lib/munin/plugin-state/xferlog-bytes.offset + +if [ "$1" = "autoconf" ]; then + if [ -f "${LOGFILE}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then + echo yes + exit 0 + else + echo no + exit 1 + fi +fi + +if [ "$1" = "config" ]; then + echo 'graph_title FTP Server Bytes' + echo 'graph_args --base 1000 -l 0' + echo 'graph_vlabel FTP Server Bytes' + echo 'graph_category FTP' + echo 'ftp_get.label Bytes GET' + echo 'ftp_put.label Bytes PUT' + exit 0 +fi + + +ftp_get=U +ftp_put=U + +TEMP_FILE=`mktempfile munin-xferlog-bytes.XXXXXX` + +if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ] +then + $LOGTAIL ${LOGFILE} $STATEFILE | grep "[[:space:]][oi][[:space:]]" > ${TEMP_FILE} + ftp_get=`grep "[[:space:]]o[[:space:]]" ${TEMP_FILE} | awk '{s += $8} END { if ( s ) print s ; else print "0" }'` + ftp_put=`grep "[[:space:]]i[[:space:]]" ${TEMP_FILE} | awk '{s += $8} END { if ( s ) print s ; else print "0" }'` + + /bin/rm -f $TEMP_FILE +fi + +echo "ftp_get.value ${ftp_get}" +echo "ftp_put.value ${ftp_put}" +