2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

dovecot: avoid using sort & wc when grepping

egrep has the -c option, that does a wc -l.
Also, there's no need to sort the output prior counting it.
This commit is contained in:
Steve Schnepp 2013-09-05 00:27:02 +02:00
parent 2a72cc32dd
commit 88e1563b48

View File

@ -61,7 +61,7 @@ fi
# Total Logins
######################
echo -en "login_total.value "
VALUE=$(egrep '[dovecot]?.*Login' $LOGFILE | sort | wc -l)
VALUE=$(egrep -c '[dovecot]?.*Login' $LOGFILE)
if [ ! -z "$VALUE" ]; then
echo "$VALUE"
else
@ -71,8 +71,8 @@ echo -n
######################
# Connected Users
######################
DISCONNECTS=$(egrep '[dovecot]?.*Disconnected' $LOGFILE | sort | wc -l)
CONNECTS=$(egrep '[dovecot]?.*Login' $LOGFILE | sort | wc -l)
DISCONNECTS=$(egrep -c '[dovecot]?.*Disconnected' $LOGFILE)
CONNECTS=$(egrep -c '[dovecot]?.*Login' $LOGFILE)
VALUE=$($EXPR_BIN $CONNECTS - $DISCONNECTS)
if [ -z "$DISCON" ] || [ "$DISCON" -lt 0 ]; then
DISCON=0
@ -84,7 +84,7 @@ echo -n
# TLS Logins
######################
echo -en "login_tls.value "
VALUE=$(egrep '[dovecot]?.*Login.*TLS' $LOGFILE | sort | wc -l)
VALUE=$(egrep -c '[dovecot]?.*Login.*TLS' $LOGFILE)
if [ ! -z "$VALUE" ]; then
echo "$VALUE"
else
@ -95,7 +95,7 @@ echo -n
# SSL Logins
######################
echo -en "login_ssl.value "
VALUE=$(egrep '[dovecot]?.*Login.*SSL' $LOGFILE | sort | wc -l)
VALUE=$(egrep -c '[dovecot]?.*Login.*SSL' $LOGFILE)
if [ ! -z "$VALUE" ]; then
echo "$VALUE"
else
@ -106,7 +106,7 @@ echo -n
# IMAP Logins
######################
echo -en "login_imap.value "
VALUE=$(egrep '[dovecot]?.*imap.*Login' $LOGFILE | sort | wc -l)
VALUE=$(egrep -c '[dovecot]?.*imap.*Login' $LOGFILE)
if [ ! -z "$VALUE" ]; then
echo "$VALUE"
else
@ -117,7 +117,7 @@ echo -n
# POP3 Logins
######################
echo -en "login_pop3.value "
VALUE=$(egrep '[dovecot]?.*pop3.*Login' $LOGFILE | sort | wc -l)
VALUE=$(egrep -c '[dovecot]?.*pop3.*Login' $LOGFILE)
if [ ! -z "$VALUE" ]; then
echo "$VALUE"
else