Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / pure / pure-ftpd-bw @ 189c81ee

Historique | Voir | Annoter | Télécharger (1,92 ko)

1 ee6b3d52 Dju
#!/bin/bash
2
#
3
#
4 011dc2e2 Dju
# pure-ftpd-bw plugin
5
# show the bandwidth used by pure-ftpd, counts the bytes sent and received
6 ee6b3d52 Dju
# made by Dju
7 011dc2e2 Dju
# v1.2
8 ee6b3d52 Dju
#
9 011dc2e2 Dju
# commands needed: logtail - grep
10 ee6b3d52 Dju
#
11
#
12 31ee54bb rikr
# Configuration:
13
# Maybe need to add folowing lines to plugins config file
14
# (e.g. /etc/munin/plugin-conf.d/pure-ftpd) to run pure-ftpwho 
15
# as user with apropirate privilegs then restart munin-node.
16
#
17
# [pure-ftpd-bw]
18
# user root
19
#
20
#
21 ee6b3d52 Dju
# Parameters
22
#
23
#       config   (required)
24
#       autoconf (optional - used by munin-config)
25
#
26
#
27
# Magic markers (optional - used by munin-config and installation scripts):
28
#
29
#%# family=auto
30
#%# capabilities=autoconf
31
32
33
LOGFILE=/var/log/pure-ftpd/transfer.log
34
LOGTAIL=$(which logtail)
35
OFFSET_FILE=/var/lib/munin/plugin-state/pure-ftpd-bw.offset
36
37
38
if [ "$1" = "autoconf" ]; then
39 31ee54bb rikr
        if [ -f $LOGFILE ]; then
40
                if [ ! -z "$LOGTAIL" -a -f $LOGTAIL -a -x $LOGTAIL ]; then
41
                        echo yes
42
                        exit 0
43
                else
44
                        echo "no (logtail not found)"
45
                        exit 1
46
                fi
47
        else
48
                echo "no (logfile $LOGFILE does not exist)"
49
                exit 1
50
        fi
51 ee6b3d52 Dju
fi
52
53 d9b355b4 Dju
if [ "$1" = "config" ]; then
54 31ee54bb rikr
        echo 'graph_title Pure Ftpd Bandwidth'
55
        echo 'graph_args --base 1000 -l 0'
56
        echo 'graph_vlabel Datas sent / received'
57
        echo 'graph_category pure-ftpd'
58
        echo 'dl.label Bytes downloaded'
59
        echo 'ul.label Bytes uploaded'
60
        exit 0
61 ee6b3d52 Dju
fi
62
63 d9b355b4 Dju
TMP1=`mktemp`
64
if [ -f $TMP1 ]; then
65 31ee54bb rikr
        $LOGTAIL -o $OFFSET_FILE -f $LOGFILE | grep 'GET \|PUT ' > $TMP1
66
        dls=$(awk '/GET / {print $9}' $TMP1)
67
        dl=0
68
        for d in $dls; do dl=$(expr $dl + $d); done
69
        echo "dl.value ${dl}"
70
        uls=$(awk '/PUT / {print $9}' $TMP1)
71
        ul=0
72
        for u in $uls; do ul=$(expr $ul + $u); done
73
        echo "ul.value ${ul}"
74
        rm $TMP1
75 d9b355b4 Dju
else
76 31ee54bb rikr
        echo "cant write temp file"
77
        exit 1
78
fi
79