2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/other/pure-ftpd-bw
2011-12-18 15:10:27 +01:00

70 lines
1.3 KiB
Bash
Executable File

#!/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