84 lines
1.7 KiB
Plaintext
84 lines
1.7 KiB
Plaintext
|
#!/bin/bash
|
||
|
#
|
||
|
#
|
||
|
# pure-ftpd plugin
|
||
|
# show what the users did on your ftp server
|
||
|
# made by Dju
|
||
|
#
|
||
|
# commands needed: logtail - grep
|
||
|
#
|
||
|
#
|
||
|
# Parameters
|
||
|
#
|
||
|
# config (required)
|
||
|
# autoconf (optional - used by munin-config)
|
||
|
#
|
||
|
#
|
||
|
# Magic markers (optional - used by munin-config and installation scripts):
|
||
|
#
|
||
|
#%# family=auto
|
||
|
#%# capabilities=autoconf
|
||
|
|
||
|
|
||
|
LOGFILE=/var/log/syslog
|
||
|
LOGTAIL=$(which logtail)
|
||
|
OFFSET_FILE=/var/lib/munin/plugin-state/pure-ftpd-conns.offset
|
||
|
|
||
|
|
||
|
if [ "$1" = "autoconf" ]; then
|
||
|
if [ -f $LOGFILE ]; then
|
||
|
if [ ! -z "$LOGTAIL" -a -f $LOGTAIL -a -x $LOGTAIL ]; then
|
||
|
echo yes
|
||
|
exit 0
|
||
|
else
|
||
|
echo "no (logtail not found)"
|
||
|
exit 1
|
||
|
fi
|
||
|
else
|
||
|
echo "no (logfile ${LOGFILE} does not exist)"
|
||
|
exit 1
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
if [ "$1" = "config" ]; then
|
||
|
echo 'graph_title Pure Ftpd Logs'
|
||
|
echo 'graph_args --base 1000 -l 0'
|
||
|
echo 'graph_vlabel Connections number'
|
||
|
echo 'graph_category pure-ftp'
|
||
|
echo 'nc.label new connection'
|
||
|
echo 'al.label anonymous logged'
|
||
|
echo 'ul.label auth user logged'
|
||
|
echo 'af.label auth failed'
|
||
|
echo 'to.label timeout'
|
||
|
echo 'dl.label download'
|
||
|
echo 'upl.label upload'
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
TMP1=`mktemp`
|
||
|
$LOGTAIL -o $OFFSET_FILE $LOGFILE | grep ' pure-ftpd: ' > $TMP1
|
||
|
|
||
|
echo -en "nc.value "
|
||
|
grep '\[INFO\] New connection from ' $TMP1 | wc -l
|
||
|
|
||
|
echo -en "al.value "
|
||
|
grep '\[INFO\] Anonymous user logged in' $TMP1 | wc -l
|
||
|
|
||
|
echo -en "ul.value "
|
||
|
grep '\[INFO\] .*is now logged in' $TMP1 | wc -l
|
||
|
|
||
|
echo -en "to.value "
|
||
|
grep ' Timeout ' $TMP1 | wc -l
|
||
|
|
||
|
echo -en "af.value "
|
||
|
grep '\[WARNING\] Authentication failed' $TMP1 | wc -l
|
||
|
|
||
|
echo -en "dl.value "
|
||
|
grep '\[NOTICE\].* downloaded ' $TMP1 | wc -l
|
||
|
|
||
|
echo -en "upl.value "
|
||
|
grep '\[NOTICE\].* uploaded ' $TMP1 | wc -l
|
||
|
|
||
|
rm $TMP1
|
||
|
|