From 9c1689fbefff27141643bd231f43a9f3732d86b5 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Thu, 2 Aug 2018 00:15:53 +0200 Subject: [PATCH] Plugin proftpd_count: fix shellcheck issues --- plugins/ftp/proftpd_count | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/plugins/ftp/proftpd_count b/plugins/ftp/proftpd_count index d147c49a..b0f10b50 100755 --- a/plugins/ftp/proftpd_count +++ b/plugins/ftp/proftpd_count @@ -14,14 +14,13 @@ #%# 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-count.offset if [ "$1" = "autoconf" ]; then @@ -34,30 +33,28 @@ if [ "$1" = "autoconf" ]; then fi if [ "$1" = "config" ]; then - echo 'graph_title FTP Server Transfers' - echo 'graph_args --base 1000 -l 0' - echo 'graph_vlabel FTP Server Transfers' - echo 'graph_category network' - echo 'ftp_get.label Files GET' - echo 'ftp_put.label Files PUT' - exit 0 + echo 'graph_title FTP Server Transfers' + echo 'graph_args --base 1000 -l 0' + echo 'graph_vlabel FTP Server Transfers' + echo 'graph_category network' + 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` +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` +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" | wc -l) + ftp_put=$(grep "[[:space:]]i[[:space:]]" "$TEMP_FILE" | wc -l) - /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"