-
Notifications
You must be signed in to change notification settings - Fork 3
/
proftpd_bytes
executable file
·64 lines (53 loc) · 1.39 KB
/
proftpd_bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/bash
#
# Plugin to monitor FTP bytes.
# based on previous work by jintxo
#
# Parameters understood:
#
# config (required)
# autoconf (optional)
#
# Magic markers (optional - used by munin-config and installation
# scripts):
#
#%# family=auto
#%# capabilities=autoconf
MAXLABEL=20
PATH=/opt/local/bin:${PATH}
mktempfile () {
mktemp -t $1
}
LOGFILE=${logfile:-/var/log/proftpd/xferlog}
LOGTAIL=${logtail:-`which logtail`}
STATEFILE=/opt/local/var/munin/plugin-state/xferlog-bytes.offset
if [ "$1" = "autoconf" ]; then
if [ -f "${LOGFILE}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
echo yes
exit 0
else
echo no
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title FTP Server Bytes'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel FTP Server Bytes'
echo 'graph_category FTP'
echo 'ftp_get.label Bytes GET'
echo 'ftp_put.label Bytes PUT'
exit 0
fi
ftp_get=U
ftp_put=U
TEMP_FILE=`mktempfile munin-xferlog-bytes.XXXXXX`
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
then
$LOGTAIL ${LOGFILE} $STATEFILE | grep "[[:space:]][oi][[:space:]]" > ${TEMP_FILE}
ftp_get=`grep "[[:space:]]o[[:space:]]" ${TEMP_FILE} | awk '{s += $8} END { if ( s ) print s ; else print "0" }'`
ftp_put=`grep "[[:space:]]i[[:space:]]" ${TEMP_FILE} | awk '{s += $8} END { if ( s ) print s ; else print "0" }'`
rm -f $TEMP_FILE
fi
echo "ftp_get.value ${ftp_get}"
echo "ftp_put.value ${ftp_put}"