Projet

Général

Profil

Révision b925a101

IDb925a10155b05e93eaea9c8cbcc3d0cfa2fb6b0d
Parent e62a8e31
Enfant 9c1689fb

Ajouté par Lars Kruse il y a plus de 7 ans

Plugin proftpd_bytes: fix shellcheck issues

Voir les différences:

plugins/ftp/proftpd_bytes
14 14
#%# family=auto
15 15
#%# capabilities=autoconf
16 16

  
17
MAXLABEL=20
18 17

  
19 18
mktempfile () {
20
mktemp -t $1
21
}       
19
    mktemp -t "$1"
20
}
22 21

  
23 22
LOGFILE=${logfile:-/var/log/proftpd/xferlog}
24
LOGTAIL=${logtail:-`which logtail`}
23
LOGTAIL=${logtail:-$(which logtail)}
25 24
STATEFILE=$MUNIN_PLUGSTATE/xferlog-bytes.offset
26 25

  
27 26
if [ "$1" = "autoconf" ]; then
28
        if [ -f "${LOGFILE}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
29
		echo yes
30
	else
31
		echo "no (missing logfile or 'logtail' executable)"
32
	fi
33
	exit 0
27
    if [ -f "$LOGFILE" ] && [ -n "$LOGTAIL" ] && [ -x "$LOGTAIL" ] ; then
28
            echo yes
29
    else
30
            echo "no (missing logfile or 'logtail' executable)"
31
    fi
32
    exit 0
34 33
fi
35 34

  
36 35
if [ "$1" = "config" ]; then
37
        echo 'graph_title FTP Server Bytes'
38
        echo 'graph_args --base 1000 -l 0'
39
        echo 'graph_vlabel FTP Server Bytes'
40
	echo 'graph_category network'
41
        echo 'ftp_get.label Bytes GET'
42
        echo 'ftp_put.label Bytes PUT'
43
        exit 0
36
    echo 'graph_title FTP Server Bytes'
37
    echo 'graph_args --base 1000 -l 0'
38
    echo 'graph_vlabel FTP Server Bytes'
39
    echo 'graph_category network'
40
    echo 'ftp_get.label Bytes GET'
41
    echo 'ftp_put.label Bytes PUT'
42
    exit 0
44 43
fi
45 44

  
46 45

  
47 46
ftp_get=U
48 47
ftp_put=U
49 48

  
50
TEMP_FILE=`mktempfile munin-xferlog-bytes.XXXXXX`
49
TEMP_FILE=$(mktempfile munin-xferlog-bytes.XXXXXX)
51 50

  
52
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
51
if [ -n "$TEMP_FILE" ] && [ -f "$TEMP_FILE" ]
53 52
then
54
	$LOGTAIL ${LOGFILE} $STATEFILE | grep "[[:space:]][oi][[:space:]]" > ${TEMP_FILE}
55
	ftp_get=`grep "[[:space:]]o[[:space:]]" ${TEMP_FILE} | awk '{s += $8} END { if ( s ) print s ; else print "0" }'`
56
	ftp_put=`grep "[[:space:]]i[[:space:]]" ${TEMP_FILE} | awk '{s += $8} END { if ( s ) print s ; else print "0" }'`
53
        "$LOGTAIL" "$LOGFILE" "$STATEFILE" | grep "[[:space:]][oi][[:space:]]" >"$TEMP_FILE"
54
        ftp_get=$(grep "[[:space:]]o[[:space:]]" "$TEMP_FILE" | awk '{s += $8} END { if ( s ) print s ; else print "0" }')
55
        ftp_put=$(grep "[[:space:]]i[[:space:]]" "$TEMP_FILE" | awk '{s += $8} END { if ( s ) print s ; else print "0" }')
57 56

  
58
	/bin/rm -f $TEMP_FILE
57
        /bin/rm -f "$TEMP_FILE"
59 58
fi
60 59

  
61
echo "ftp_get.value ${ftp_get}"
62
echo "ftp_put.value ${ftp_put}"
63

  
60
echo "ftp_get.value $ftp_get"
61
echo "ftp_put.value $ftp_put"

Formats disponibles : Unified diff