mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 09:57:09 +00:00
Initial version
This commit is contained in:
parent
e78a159051
commit
ee6b3d527e
1 changed files with 69 additions and 0 deletions
69
plugins/other/pure-ftpd-bw
Executable file
69
plugins/other/pure-ftpd-bw
Executable file
|
@ -0,0 +1,69 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
#
|
||||
# pure-ftpd-bw plugin
|
||||
# show the bandwidth used by pure-ftpd, counts the bytes sent and received
|
||||
# made by Dju
|
||||
#
|
||||
# commands needed: logtail - grep
|
||||
#
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
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
|
||||
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`
|
||||
$LOGTAIL -o $OFFSET_FILE $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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue