60 lines
1.1 KiB
Plaintext
60 lines
1.1 KiB
Plaintext
|
#!/bin/bash
|
||
|
#
|
||
|
# Plugin to monitor rsyncd.
|
||
|
# based on previous work by jintxo
|
||
|
#
|
||
|
# Parameters understood:
|
||
|
#
|
||
|
# config (required)
|
||
|
# autoconf (optional)
|
||
|
#
|
||
|
#
|
||
|
|
||
|
mktempfile () {
|
||
|
mktemp -t $1
|
||
|
}
|
||
|
|
||
|
RSYNCD_LOG=${logfile:-/var/log/rsyncd.log}
|
||
|
LOGTAIL=${logtail:-`which logtail`}
|
||
|
STATEFILE=/var/lib/munin/plugin-state/rsync-count.offset
|
||
|
|
||
|
if [ "$1" = "autoconf" ]; then
|
||
|
if [ -f "${RSYNCD_LOG}" -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 Rsync Server Transfers'
|
||
|
echo 'graph_args --base 1000 -l 0'
|
||
|
echo 'graph_order send recv'
|
||
|
echo 'graph_category rsync'
|
||
|
echo 'graph_vlabel Rsync Server Transfers'
|
||
|
echo 'send.label Files Send'
|
||
|
echo 'recv.label Files Recv'
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
send=U
|
||
|
recv=U
|
||
|
|
||
|
TEMP_FILE=`mktempfile munin-rsync-count.XXXXXX`
|
||
|
|
||
|
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
|
||
|
then
|
||
|
$LOGTAIL ${RSYNCD_LOG} $STATEFILE | grep ".* Total .* bytes\." > ${TEMP_FILE}
|
||
|
send=`grep ' send .* bytes' ${TEMP_FILE} | wc -l`
|
||
|
recv=`grep ' recv .* bytes' ${TEMP_FILE} | wc -l`
|
||
|
|
||
|
/bin/rm -f $TEMP_FILE
|
||
|
fi
|
||
|
|
||
|
echo "send.value ${send}"
|
||
|
echo "recv.value ${recv}"
|
||
|
|
||
|
|