大网数据广告活动
服务器运维问答

How to monitor the postfix mail queue using monit?

· 52CE 我爱测

Is there a way to monitor the postfix mail queue using monit? the available scripts just check, up/down/memory or CPU. I would like notices when the queue starts filling up. it would be nice to be able to set monitors on the diff…

问题原文

原帖链接 · Sean Kimball · CC BY-SA 3.0

Is there a way to monitor the postfix mail queue using monit? the available scripts just check, up/down/memory or CPU. I would like notices when the queue starts filling up. it would be nice to be able to set monitors on the different queues to be able to react appropriately.

已采纳解答

原帖链接 · Miguel Bonera · CC BY-SA 3.0

You have to use the "program" feature of Monit.

If your monitrc file includes include /etc/monit.d/*.cfg, then in your /etc/monit.d, create a .cfg file with the content (add the appropriate include statement in your monitrc file if you don't include all *.cfg files in /etc/monit.d)

check program mail-queue path "/usr/local/sbin/check_postfix_queue"
    if status != 0 then alert

Then create the script /usr/local/sbin/check_postfix_queue with this content:

#!/bin/bash

MAXMSG=20
MSG=$( postqueue -p | egrep '\-\- [0-9]+ Kbytes in [0-9]+ Request[s]*\.' | awk '{ print $5 }'  )
[ ${MSG:-0} -le $MAXMSG ] && exit 0 || exit 1

MAXMSG is the message queue limit: if number of messages is above that parameter, monit emits an alert.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-06-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。