« GFS+drbd | トップページ | Linkstationでrsync »

2008年11月20日 (木)

munin+qmail

muninを使用中
うちのqmailは普通にsyslogdで取っているのでmunin exchangeで配布しているqmailsendが使えない。
なので、courier_を改造してqmailsendを作った。

#!/bin/sh
#
# Plugin to show amount of individual outgoing smtp-replies per hour
#
# Contributed by Memoro@cocolog
#
#based on courier_

#%# family=manual
#%# capabilities=autoconf


# Set the location of the mail logs
COURIER_LOG=${logfile:-/var/log/maillog}
SERVICE="qmail"
OFFSET_FILE=/var/lib/munin/plugin-state/qmsends_${SERVICE}.offset
LOGTAIL=${logtail:-/usr/bin/logtail}

mktempfile () {
mktemp -p /tmp/ $1
}

case $1 in
autoconf|detect)
if [ -f ${COURIER_LOG} -a -x ${LOGTAIL} ]
then
echo yes
exit 0
else
echo "no (either $COURIER_LOG was not found, or logtail was not in your path)"
exit 1
fi
;;
config)
cat < graph_title Qmail outgoing SMTP replies
graph_args --base 1000 -l 0
graph_vlabel replies/hour
graph_category Mail
graph_total Total
graph_info This graph shows qmail-send transaction response codes.
graph_order res250 res421 res441 res442 res450 res451 res452 res454 res472 res500 res501 res511 res522 res550 res551 res552 res553 res554 res557
res250.label 250 Mail delivery ok
res250.min 0
res250.draw LINE1
res421.label 421 Service unavail or timeout
res421.min 0
res421.draw LINE1
res441.label 441 No established connection
res441.min 0
res441.draw LINE1
res442.label 442 Connection Died
res442.min 0
res442.draw LINE1
res450.label 450 Mbox unavail or greylist
res450.min 0
res450.draw LINE1
res451.label 451 Err processing or greylist
res451.min 0
res451.draw LINE1
res452.label 452 Insufficient storage space
res452.min 0
res452.draw LINE1
res454.label 454 TLS not available now
res454.min 0
res454.draw LINE1
res472.label 472 DNS transaction timeout
res472.min 0
res472.draw LINE1
res500.label 500 Unsolicited mail
res500.min 0
res500.draw LINE1
res501.label 501 Syntax error
res501.min 0
res501.draw LINE1
res511.label 511 Blocked or blacklisted
res511.min 0
res511.draw LINE1
res522.label 522 Mailbox full
res522.min 0
res522.draw LINE1
res550.label 550 Mailbox unavailable
res550.min 0
res550.draw LINE1
res551.label 551 User not local
res551.min 0
res551.draw LINE1
res552.label 552 Content or storage error
res552.min 0
res552.draw LINE1
res553.label 553 Mailbox name not allowed
res553.min 0
res553.draw LINE1
res554.label 554 Session failed or blocked
res554.min 0
res554.draw LINE1
res557.label 557 Too many duplicate msgs
res557.min 0
res557.draw LINE1
EOF
exit 0
;;
esac


ARGS=0
`$LOGTAIL /etc/hosts 2>/dev/null >/dev/null`
if [ $? = 66 ]; then
if [ ! -n "$logtail" ]; then
ARGS=1
fi
fi

TEMP_FILE=`mktempfile munin-qmail.XXXXXX`

if [ -z "$TEMP_FILE" -o ! -f "$TEMP_FILE" ]; then
exit 3
fi

if [ $ARGS != 0 ]; then
${LOGTAIL} -f ${COURIER_LOG} -o ${OFFSET_FILE} | grep "$SERVICE" > ${TEMP_FILE}
else
${LOGTAIL} ${COURIER_LOG} ${OFFSET_FILE} | grep "$SERVICE" > ${TEMP_FILE}
fi

echo res250.value `grep _250_ ${TEMP_FILE} | wc -l`
echo res421.value `grep _421_ ${TEMP_FILE} | wc -l`
echo res441.value `grep \#4\\.4\\.1 ${TEMP_FILE} | wc -l`
echo res442.value `grep \#4\\.4\\.2 ${TEMP_FILE} | wc -l`
echo res450.value `grep _450_ ${TEMP_FILE} | wc -l`
echo res451.value `grep _451_ ${TEMP_FILE} | wc -l`
echo res452.value `grep _452_ ${TEMP_FILE} | wc -l`
echo res454.value `grep _454_ ${TEMP_FILE} | wc -l`
echo res472.value `grep _472_ ${TEMP_FILE} | wc -l`
echo res500.value `grep _500_ ${TEMP_FILE} | wc -l`
echo res501.value `grep _501_ ${TEMP_FILE} | wc -l`
echo res511.value `grep _511_ ${TEMP_FILE} | wc -l`
echo res522.value `grep _522_ ${TEMP_FILE} | wc -l`
echo res550.value `grep _550_ ${TEMP_FILE} | wc -l`
echo res551.value `grep _551_ ${TEMP_FILE} | wc -l`
echo res552.value `grep _552_ ${TEMP_FILE} | wc -l`
echo res553.value `grep _553_ ${TEMP_FILE} | wc -l`
echo res554.value `grep _554_ ${TEMP_FILE} | wc -l`
echo res557.value `grep _557_ ${TEMP_FILE} | wc -l`

rm ${TEMP_FILE}

|

« GFS+drbd | トップページ | Linkstationでrsync »

Linux」カテゴリの記事

Web/メールサーバ」カテゴリの記事

サーバ」カテゴリの記事

プログラム」カテゴリの記事

コメント

コメントを書く



(ウェブ上には掲載しません)


コメントは記事投稿者が公開するまで表示されません。



トラックバック

この記事のトラックバックURL:
http://app.f.cocolog-nifty.com/t/trackback/522499/25512029

この記事へのトラックバック一覧です: munin+qmail:

« GFS+drbd | トップページ | Linkstationでrsync »