From a3d13528778518c8a808716beb77529843c9366a Mon Sep 17 00:00:00 2001 From: cn Date: Wed, 11 Jan 2012 11:58:34 +0100 Subject: [PATCH 1/2] Merged the syslog5mins script as a function into postfix_mailqueue Removed standalone script, you may extract it at your wish. --- postfix_mailqueue | 23 ++++++++++++++++++----- syslog5mins | 15 --------------- 2 files changed, 18 insertions(+), 20 deletions(-) delete mode 100755 syslog5mins diff --git a/postfix_mailqueue b/postfix_mailqueue index 3e3b11c..d4d2249 100755 --- a/postfix_mailqueue +++ b/postfix_mailqueue @@ -79,7 +79,6 @@ munin-node. =cut MAILLOG="/var/log/mail.log" -SYSLOG5MINS="/opt/syslog5mins" # atempt to get spooldir via postconf, but environment overrides. @@ -89,16 +88,30 @@ SPOOLDIR=${spooldir:-$POSTCONFSPOOL} . $MUNIN_LIBDIR/plugins/plugin.sh +syslog5mins() { + #for (( i = 4; i >= 0; i-- )) ; do + for i in 4 3 2 1 0; do + # In %_d the underscore is important since it demands `date` + # to pad with spaces (like syslog for e.g. "Jan 1" to "Jan 9") + # instead of zeros. + dstring=`LANG=C date -d "-$i min" +"%b %_d %R"` + #echo "Entries for '$dstring':" + grep "^$dstring:.. " $1 + done +} + +# main logic + case $1 in autoconf|detect) - if [ -d $SPOOLDIR ] ; then echo yes exit 0 else echo "no (spooldir not found)" exit 0 - fi;; + fi;; + config) cat <<'EOF' graph_title Postfix Mailqueue @@ -130,10 +143,10 @@ cd $SPOOLDIR >/dev/null 2>/dev/null || { } cat <= 0; i-- )) ; do - # In %_d the underscore is important since it demands `date` - # to pad with spaces (like syslog for e.g. "Jan 1" to "Jan 9") - # instead of zeros. - dstring=`LANG=C date -d "-$i min" +"%b %_d %R"` - #echo "Entries for '$dstring':" - grep "^$dstring:.. " $1 -done From a44c79d4bc4bcbd2073716a3e25922dad67b7a4e Mon Sep 17 00:00:00 2001 From: cn Date: Thu, 12 Jan 2012 17:02:52 +0100 Subject: [PATCH 2/2] Update README --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 42ec1a5..6e36770 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,5 @@ action of postfix. syslog5mins ----------- -This little script returns the entries of a (syslog created) file of the last -5 minutes. -**You should modify the scripts location in postfix_mailqueue script!** +This little bash function returns the entries of a file (created in format of +syslog default template; especially timestamp) of the last 5 minutes.