2010-08-18 17:14:43 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
#
|
2010-09-07 02:52:09 +02:00
|
|
|
# pure-ftpd-bw plugin
|
|
|
|
# show the bandwidth used by pure-ftpd, counts the bytes sent and received
|
2010-08-18 17:14:43 +02:00
|
|
|
# made by Dju
|
2010-09-07 02:52:09 +02:00
|
|
|
# v1.2
|
2010-08-18 17:14:43 +02:00
|
|
|
#
|
2010-09-07 02:52:09 +02:00
|
|
|
# commands needed: logtail - grep
|
2010-08-18 17:14:43 +02:00
|
|
|
#
|
|
|
|
#
|
2011-02-11 11:27:43 +01:00
|
|
|
# Configuration:
|
2014-12-05 00:37:42 +01:00
|
|
|
# Maybe need to add following lines to plugins config file
|
2011-02-11 11:27:43 +01:00
|
|
|
# (e.g. /etc/munin/plugin-conf.d/pure-ftpd) to run pure-ftpwho
|
|
|
|
# as user with apropirate privilegs then restart munin-node.
|
|
|
|
#
|
|
|
|
# [pure-ftpd-bw]
|
|
|
|
# user root
|
|
|
|
#
|
|
|
|
#
|
2010-08-18 17:14:43 +02:00
|
|
|
# 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)
|
2017-04-18 23:32:55 +02:00
|
|
|
OFFSET_FILE=$MUNIN_PLUGSTATE/pure-ftpd-bw.offset
|
2010-08-18 17:14:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
2011-02-11 11:27:43 +01:00
|
|
|
if [ -f $LOGFILE ]; then
|
|
|
|
if [ ! -z "$LOGTAIL" -a -f $LOGTAIL -a -x $LOGTAIL ]; 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
|
2010-08-18 17:14:43 +02:00
|
|
|
fi
|
|
|
|
|
2010-09-07 02:15:14 +02:00
|
|
|
if [ "$1" = "config" ]; then
|
2011-02-11 11:27:43 +01:00
|
|
|
echo 'graph_title Pure Ftpd Bandwidth'
|
|
|
|
echo 'graph_args --base 1000 -l 0'
|
|
|
|
echo 'graph_vlabel Datas sent / received'
|
2017-02-24 04:26:39 +01:00
|
|
|
echo 'graph_category network'
|
2011-02-11 11:27:43 +01:00
|
|
|
echo 'dl.label Bytes downloaded'
|
|
|
|
echo 'ul.label Bytes uploaded'
|
|
|
|
exit 0
|
2010-08-18 17:14:43 +02:00
|
|
|
fi
|
|
|
|
|
2010-09-07 02:15:14 +02:00
|
|
|
TMP1=`mktemp`
|
|
|
|
if [ -f $TMP1 ]; then
|
2011-02-11 11:27:43 +01:00
|
|
|
$LOGTAIL -o $OFFSET_FILE -f $LOGFILE | grep 'GET \|PUT ' > $TMP1
|
|
|
|
dls=$(awk '/GET / {print $9}' $TMP1)
|
|
|
|
dl=0
|
|
|
|
for d in $dls; do dl=$(expr $dl + $d); done
|
|
|
|
echo "dl.value ${dl}"
|
|
|
|
uls=$(awk '/PUT / {print $9}' $TMP1)
|
|
|
|
ul=0
|
|
|
|
for u in $uls; do ul=$(expr $ul + $u); done
|
|
|
|
echo "ul.value ${ul}"
|
|
|
|
rm $TMP1
|
2010-09-07 02:15:14 +02:00
|
|
|
else
|
2011-02-11 11:27:43 +01:00
|
|
|
echo "cant write temp file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|