Projet

Général

Profil

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

root / plugins / other / proftpd_count @ ba2f09ff

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

1
#!/bin/bash
2
#
3
# Plugin to monitor FTP files.
4
# based on previous work by jintxo
5
#
6
# Parameters understood:
7
#
8
# 	config   (required)
9
# 	autoconf (optional)
10
#
11
# Magic markers (optional - used by munin-config and installation
12
# scripts):
13
#
14
#%# family=auto
15
#%# capabilities=autoconf
16

    
17
MAXLABEL=20
18

    
19
mktempfile () {
20
mktemp -t $1
21
}       
22

    
23
LOGFILE=${logfile:-/var/log/xferlog}
24
LOGTAIL=${logtail:-`which logtail`}
25
STATEFILE=/var/lib/munin/plugin-state/xferlog-count.offset
26

    
27
if [ "$1" = "autoconf" ]; then
28
        if [ -f "${LOGFILE}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
29
		echo yes
30
		exit 0
31
	else
32
		echo no
33
		exit 1
34
	fi
35
fi
36

    
37
if [ "$1" = "config" ]; then
38
        echo 'graph_title FTP Server Transfers'
39
        echo 'graph_args --base 1000 -l 0'
40
        echo 'graph_vlabel FTP Server Transfers'
41
	echo 'graph_category FTP'
42
        echo 'ftp_get.label Files GET'
43
        echo 'ftp_put.label Files PUT'
44
        exit 0
45
fi
46

    
47

    
48
ftp_get=U
49
ftp_put=U
50

    
51
TEMP_FILE=`mktempfile munin-xferlog-count.XXXXXX`
52

    
53
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
54
then
55
	$LOGTAIL ${LOGFILE} $STATEFILE | grep "[[:space:]][oi][[:space:]]" > ${TEMP_FILE}
56
	ftp_get=`grep "[[:space:]]o[[:space:]]" ${TEMP_FILE} | wc -l`
57
	ftp_put=`grep "[[:space:]]i[[:space:]]" ${TEMP_FILE} | wc -l`
58

    
59
	/bin/rm -f $TEMP_FILE
60
fi
61

    
62
echo "ftp_get.value ${ftp_get}"
63
echo "ftp_put.value ${ftp_put}"
64