Projet

Général

Profil

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

root / plugins / rsync / rsyncd_bytes @ 17f78427

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

1
#!/bin/bash
2
#
3
# Plugin to monitor rsyncd.
4
# based on previous work by jintxo
5
#
6
# Parameters understood:
7
#
8
# 	config   (required)
9
# 	autoconf (optional)
10
#
11
#
12

    
13
mktempfile () {
14
mktemp -t $1
15
}
16

    
17
RSYNCD_LOG=${logfile:-/var/log/rsyncd.log}
18
LOGTAIL=${logtail:-`which logtail`}
19
STATEFILE=$MUNIN_PLUGSTATE/rsync-bytes.offset
20

    
21
if [ "$1" = "autoconf" ]; then
22
        if [ -f "${RSYNCD_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
23
		echo yes
24
		exit 0
25
	else
26
		echo no
27
		exit 1
28
	fi
29
fi
30

    
31
if [ "$1" = "config" ]; then
32
	echo 'graph_title Rsync Server Bytes'
33
        echo 'graph_args --base 1000 -l 0'
34
	echo 'graph_order send recv'
35
	echo 'graph_category filetransfer'
36
	echo 'graph_vlabel Rsync Bytes'
37
	echo 'send.label Bytes Send'
38
	echo 'recv.label Bytes Recv'
39
	exit 0
40
fi
41

    
42
send=U
43
recv=U
44

    
45
TEMP_FILE=`mktempfile munin-rsync-bytes.XXXXXX`
46

    
47
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
48
then
49
	$LOGTAIL ${RSYNCD_LOG} $STATEFILE | grep ".* Total .* bytes\." > ${TEMP_FILE}
50
	send=`grep ' send .* bytes' ${TEMP_FILE} | awk '{s += $10} END { if ( s ) print s ; else print "0" }'`
51
	recv=`grep ' recv .* bytes' ${TEMP_FILE} | awk '{s += $10} END { if ( s ) print s ; else print "0" }'`
52

    
53
	/bin/rm -f $TEMP_FILE
54
fi
55

    
56
echo "send.value ${send}"
57
echo "recv.value ${recv}"
58

    
59