#!/bin/bash # # # pure-ftpd plugin # made by Dju # v1.1 # # commands needed: logtail - grep - awk # # # Parameters # # config (required) # autoconf (optional - used by munin-config) # # # Magic markers (optional - used by munin-config and installation scripts): # #%# family=auto #%# capabilities=autoconf LOGFILE=/var/log/pure-ftpd/transfer.log LOGTAIL=$(which logtail) OFFSET_FILE=/var/lib/munin/plugin-state/pure-ftpd-bw.offset [ ! -z "$LOGTAIL" -a -f $LOGTAIL -a -x $LOGTAIL ] && LT_OK=1 || LT_OK=0 if [ "$1" = "autoconf" ]; then if [ -f $LOGFILE ]; then if [ $LT_OK -eq 1 ]; then echo yes exit 0 else echo "no (logtail not found)" exit 1 fi else echo "no (logfile $LOGFILE does not exist)" exit 1 fi fi if [ "$1" = "config" ]; then echo 'graph_title Pure Ftpd Bandwidth' echo 'graph_args --base 1000 -l 0' echo 'graph_vlabel Datas sent / received' echo 'graph_category pure-ftp' echo 'dl.label Bytes downloaded' echo 'ul.label Bytes uploaded' exit 0 fi TMP1=`mktemp` if [ -f $TMP1 ]; then $LOGTAIL -o $OFFSET_FILE $LOGFILE | grep 'GET \|PUT ' > $TMP1 echo -n "dl.value " awk '/GET / {DL = DL + $NF} END {print DL}' echo -n "ul.value " awk '/PUT / {UL = UDL + $NF} END {print UL}' rm $TMP1 else echo "cant create temp file" exit 1 fi