2007-05-25 19:54:10 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Plugin to monitor rsyncd.
|
|
|
|
# based on previous work by jintxo
|
|
|
|
#
|
|
|
|
# Parameters understood:
|
|
|
|
#
|
|
|
|
# config (required)
|
|
|
|
# autoconf (optional)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
mktempfile () {
|
|
|
|
mktemp -t $1
|
2018-08-02 02:03:42 +02:00
|
|
|
}
|
2007-05-25 19:54:10 +02:00
|
|
|
|
|
|
|
RSYNCD_LOG=${logfile:-/var/log/rsyncd.log}
|
|
|
|
LOGTAIL=${logtail:-`which logtail`}
|
2017-04-18 23:32:55 +02:00
|
|
|
STATEFILE=$MUNIN_PLUGSTATE/rsync-bytes.offset
|
2007-05-25 19:54:10 +02:00
|
|
|
|
|
|
|
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 Bytes'
|
|
|
|
echo 'graph_args --base 1000 -l 0'
|
|
|
|
echo 'graph_order send recv'
|
2017-02-25 03:08:22 +01:00
|
|
|
echo 'graph_category filetransfer'
|
2007-05-25 19:54:10 +02:00
|
|
|
echo 'graph_vlabel Rsync Bytes'
|
|
|
|
echo 'send.label Bytes Send'
|
|
|
|
echo 'recv.label Bytes Recv'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
send=U
|
|
|
|
recv=U
|
|
|
|
|
|
|
|
TEMP_FILE=`mktempfile munin-rsync-bytes.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} | awk '{s += $10} END { if ( s ) print s ; else print "0" }'`
|
|
|
|
recv=`grep ' recv .* bytes' ${TEMP_FILE} | awk '{s += $10} END { if ( s ) print s ; else print "0" }'`
|
|
|
|
|
|
|
|
/bin/rm -f $TEMP_FILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "send.value ${send}"
|
|
|
|
echo "recv.value ${recv}"
|
|
|
|
|
|
|
|
|