mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-26 10:58:12 +00:00
fixed other bug
This commit is contained in:
parent
1ad50ae465
commit
011dc2e21b
1 changed files with 16 additions and 16 deletions
|
@ -1,11 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# pure-ftpd plugin
|
# pure-ftpd-bw plugin
|
||||||
|
# show the bandwidth used by pure-ftpd, counts the bytes sent and received
|
||||||
# made by Dju
|
# made by Dju
|
||||||
# v1.1
|
# v1.2
|
||||||
#
|
#
|
||||||
# commands needed: logtail - grep - awk
|
# commands needed: logtail - grep
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Parameters
|
# Parameters
|
||||||
|
@ -25,12 +26,9 @@ LOGTAIL=$(which logtail)
|
||||||
OFFSET_FILE=/var/lib/munin/plugin-state/pure-ftpd-bw.offset
|
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 [ "$1" = "autoconf" ]; then
|
||||||
if [ -f $LOGFILE ]; then
|
if [ -f $LOGFILE ]; then
|
||||||
if [ $LT_OK -eq 1 ]; then
|
if [ ! -z "$LOGTAIL" -a -f $LOGTAIL -a -x $LOGTAIL ]; then
|
||||||
echo yes
|
echo yes
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
|
@ -43,27 +41,29 @@ if [ "$1" = "autoconf" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
echo 'graph_title Pure Ftpd Bandwidth'
|
echo 'graph_title Pure Ftpd Bandwidth'
|
||||||
echo 'graph_args --base 1000 -l 0'
|
echo 'graph_args --base 1000 -l 0'
|
||||||
echo 'graph_vlabel Datas sent / received'
|
echo 'graph_vlabel Datas sent / received'
|
||||||
echo 'graph_category pure-ftp'
|
echo 'graph_category pure-ftpd'
|
||||||
echo 'dl.label Bytes downloaded'
|
echo 'dl.label Bytes downloaded'
|
||||||
echo 'ul.label Bytes uploaded'
|
echo 'ul.label Bytes uploaded'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
TMP1=`mktemp`
|
TMP1=`mktemp`
|
||||||
if [ -f $TMP1 ]; then
|
if [ -f $TMP1 ]; then
|
||||||
$LOGTAIL -o $OFFSET_FILE $LOGFILE | grep 'GET \|PUT ' > $TMP1
|
$LOGTAIL -o $OFFSET_FILE $LOGFILE | grep 'GET \|PUT ' > $TMP1
|
||||||
echo -n "dl.value "
|
dls=$(awk '/GET / {print $9}' $TMP1)
|
||||||
awk '/GET / {DL = DL + $NF} END {print DL}' $TMP1
|
dl=0
|
||||||
echo -n "ul.value "
|
for d in $dls; do dl=$(expr $dl + $d); done
|
||||||
awk '/PUT / {UL = UDL + $NF} END {print UL}' $TMP1
|
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
|
rm $TMP1
|
||||||
else
|
else
|
||||||
echo "cant create temp file"
|
echo "cant write temp file"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
Loading…
Add table
Add a link
Reference in a new issue