Projet

Général

Profil

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

root / plugins / ftp / pure-ftpd-bw @ 4b2fcbf8

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

1
#!/bin/bash
2
#
3
#
4
# pure-ftpd-bw plugin
5
# show the bandwidth used by pure-ftpd, counts the bytes sent and received
6
# made by Dju
7
# v1.2
8
#
9
# commands needed: logtail - grep
10
#
11
#
12
# Configuration:
13
# Maybe need to add following 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
# 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=$MUNIN_PLUGSTATE/pure-ftpd-bw.offset
36

    
37

    
38
if [ "$1" = "autoconf" ]; then
39
        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
fi
52

    
53
if [ "$1" = "config" ]; then
54
        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 network'
58
        echo 'dl.label Bytes downloaded'
59
        echo 'ul.label Bytes uploaded'
60
        exit 0
61
fi
62

    
63
TMP1=`mktemp`
64
if [ -f $TMP1 ]; then
65
        $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
else
76
        echo "cant write temp file"
77
        exit 1
78
fi
79

    
80