mirror of
https://github.com/cmur2/munin-postfix.git
synced 2024-11-18 12:56:17 +01:00
Merged the syslog5mins script as a function into postfix_mailqueue
Removed standalone script, you may extract it at your wish.
This commit is contained in:
parent
8f5d97e002
commit
a3d1352877
@ -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,9 +88,22 @@ 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
|
||||
@ -99,6 +111,7 @@ case $1 in
|
||||
echo "no (spooldir not found)"
|
||||
exit 0
|
||||
fi;;
|
||||
|
||||
config)
|
||||
cat <<'EOF'
|
||||
graph_title Postfix Mailqueue
|
||||
@ -130,10 +143,10 @@ cd $SPOOLDIR >/dev/null 2>/dev/null || {
|
||||
}
|
||||
|
||||
cat <<EOF
|
||||
outgoing.value `$SYSLOG5MINS $MAILLOG | grep "postfix/smtp\[.*status=sent" | wc -l`
|
||||
outgoing.value `syslog5mins $MAILLOG | grep "postfix/smtp\[.*status=sent" | wc -l`
|
||||
deferred.value `(test -d deferred && find deferred -type f ) | wc -l`
|
||||
maildrop.value `(test -d maildrop && find maildrop -type f ) | wc -l`
|
||||
incoming.value `$SYSLOG5MINS $MAILLOG | grep "postfix/pipe\[.*status=sent" | wc -l`
|
||||
incoming.value `syslog5mins $MAILLOG | grep "postfix/pipe\[.*status=sent" | wc -l`
|
||||
corrupt.value `(test -d corrupt && find corrupt -type f ) | wc -l`
|
||||
hold.value `( test -d hold && find hold -type f ) | wc -l`
|
||||
EOF
|
||||
|
15
syslog5mins
15
syslog5mins
@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
echo "No file given!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for (( i = 4; i >= 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
|
Loading…
Reference in New Issue
Block a user