2007-05-25 19:51:46 +02:00
|
|
|
#!/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
|
|
|
|
|
|
|
|
|
|
|
|
mktempfile () {
|
2018-08-02 00:09:36 +02:00
|
|
|
mktemp -t "$1"
|
|
|
|
}
|
2007-05-25 19:51:46 +02:00
|
|
|
|
2015-07-10 15:37:19 +02:00
|
|
|
LOGFILE=${logfile:-/var/log/proftpd/xferlog}
|
2018-08-02 00:09:36 +02:00
|
|
|
LOGTAIL=${logtail:-$(which logtail)}
|
2017-04-18 23:32:55 +02:00
|
|
|
STATEFILE=$MUNIN_PLUGSTATE/xferlog-bytes.offset
|
2007-05-25 19:51:46 +02:00
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
2018-08-02 00:09:36 +02:00
|
|
|
if [ -f "$LOGFILE" ] && [ -n "$LOGTAIL" ] && [ -x "$LOGTAIL" ] ; then
|
|
|
|
echo yes
|
|
|
|
else
|
|
|
|
echo "no (missing logfile or 'logtail' executable)"
|
|
|
|
fi
|
|
|
|
exit 0
|
2007-05-25 19:51:46 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
2018-08-02 00:09:36 +02:00
|
|
|
echo 'graph_title FTP Server Bytes'
|
|
|
|
echo 'graph_args --base 1000 -l 0'
|
|
|
|
echo 'graph_vlabel FTP Server Bytes'
|
|
|
|
echo 'graph_category network'
|
|
|
|
echo 'ftp_get.label Bytes GET'
|
|
|
|
echo 'ftp_put.label Bytes PUT'
|
|
|
|
exit 0
|
2007-05-25 19:51:46 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
ftp_get=U
|
|
|
|
ftp_put=U
|
|
|
|
|
2018-08-02 00:09:36 +02:00
|
|
|
TEMP_FILE=$(mktempfile munin-xferlog-bytes.XXXXXX)
|
2007-05-25 19:51:46 +02:00
|
|
|
|
2018-08-02 00:09:36 +02:00
|
|
|
if [ -n "$TEMP_FILE" ] && [ -f "$TEMP_FILE" ]
|
2007-05-25 19:51:46 +02:00
|
|
|
then
|
2018-08-02 00:09:36 +02:00
|
|
|
"$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" }')
|
2007-05-25 19:51:46 +02:00
|
|
|
|
2018-08-02 00:09:36 +02:00
|
|
|
/bin/rm -f "$TEMP_FILE"
|
2007-05-25 19:51:46 +02:00
|
|
|
fi
|
|
|
|
|
2018-08-02 00:09:36 +02:00
|
|
|
echo "ftp_get.value $ftp_get"
|
|
|
|
echo "ftp_put.value $ftp_put"
|