2007-05-25 19:53:02 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Plugin to monitor FTP files.
|
|
|
|
# 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
|
|
|
|
|
|
|
|
mktempfile () {
|
|
|
|
mktemp -t $1
|
|
|
|
}
|
|
|
|
|
2015-07-10 15:38:38 +02:00
|
|
|
LOGFILE=${logfile:-/var/log/proftpd/xferlog}
|
2007-05-25 19:53:02 +02:00
|
|
|
LOGTAIL=${logtail:-`which logtail`}
|
2017-04-18 23:32:55 +02:00
|
|
|
STATEFILE=$MUNIN_PLUGSTATE/xferlog-count.offset
|
2007-05-25 19:53:02 +02:00
|
|
|
|
|
|
|
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 Transfers'
|
|
|
|
echo 'graph_args --base 1000 -l 0'
|
|
|
|
echo 'graph_vlabel FTP Server Transfers'
|
2017-02-24 04:26:39 +01:00
|
|
|
echo 'graph_category network'
|
2007-05-25 19:53:02 +02:00
|
|
|
echo 'ftp_get.label Files GET'
|
|
|
|
echo 'ftp_put.label Files PUT'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
ftp_get=U
|
|
|
|
ftp_put=U
|
|
|
|
|
|
|
|
TEMP_FILE=`mktempfile munin-xferlog-count.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} | wc -l`
|
|
|
|
ftp_put=`grep "[[:space:]]i[[:space:]]" ${TEMP_FILE} | wc -l`
|
|
|
|
|
|
|
|
/bin/rm -f $TEMP_FILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "ftp_get.value ${ftp_get}"
|
|
|
|
echo "ftp_put.value ${ftp_put}"
|
|
|
|
|