mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Plugin proftpd_bytes: fix shellcheck issues
This commit is contained in:
parent
e62a8e3142
commit
b925a10155
1 changed files with 24 additions and 26 deletions
|
@ -14,50 +14,48 @@
|
|||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
MAXLABEL=20
|
||||
|
||||
mktempfile () {
|
||||
mktemp -t $1
|
||||
}
|
||||
mktemp -t "$1"
|
||||
}
|
||||
|
||||
LOGFILE=${logfile:-/var/log/proftpd/xferlog}
|
||||
LOGTAIL=${logtail:-`which logtail`}
|
||||
LOGTAIL=${logtail:-$(which logtail)}
|
||||
STATEFILE=$MUNIN_PLUGSTATE/xferlog-bytes.offset
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -f "${LOGFILE}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
|
||||
echo yes
|
||||
else
|
||||
echo "no (missing logfile or 'logtail' executable)"
|
||||
fi
|
||||
exit 0
|
||||
if [ -f "$LOGFILE" ] && [ -n "$LOGTAIL" ] && [ -x "$LOGTAIL" ] ; then
|
||||
echo yes
|
||||
else
|
||||
echo "no (missing logfile or 'logtail' executable)"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
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
|
||||
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
|
||||
fi
|
||||
|
||||
|
||||
ftp_get=U
|
||||
ftp_put=U
|
||||
|
||||
TEMP_FILE=`mktempfile munin-xferlog-bytes.XXXXXX`
|
||||
TEMP_FILE=$(mktempfile munin-xferlog-bytes.XXXXXX)
|
||||
|
||||
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
|
||||
if [ -n "$TEMP_FILE" ] && [ -f "$TEMP_FILE" ]
|
||||
then
|
||||
$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" }'`
|
||||
"$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" }')
|
||||
|
||||
/bin/rm -f $TEMP_FILE
|
||||
/bin/rm -f "$TEMP_FILE"
|
||||
fi
|
||||
|
||||
echo "ftp_get.value ${ftp_get}"
|
||||
echo "ftp_put.value ${ftp_put}"
|
||||
|
||||
echo "ftp_get.value $ftp_get"
|
||||
echo "ftp_put.value $ftp_put"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue