View Full Version : Ideas on how best to monitor Qmail stats
eWebtricity
04-05-2005, 06:09
Any ideas on ways to monitor Qmail stats?
Use external params in zabbix agent. If scripts works slowly (run time more 0.5 secs) use zabbix_trapper
eWebtricity
06-05-2005, 05:22
My graphs are staying at zero becuase I think Zabbix is reading the last line of output, which is a zero. Any ideas how to pull each line of stats individually, i can't seem to make it happen yet.
I'm using this command line argument to base my graphs stats from
[root@server zabbix]# /var/qmail/bin/qmail-qstat
messages in queue: 40
messages in queue but not yet preprocessed: 0
Here's what I'm trying to use
[root@titan zabbix]# su - root -c /var/qmail/bin/qmail-qstat |cut -f2 -d":"
40
0
I think it's staying at zero because of the last line which is always zero.
/var/qmail/bin/qmail-qstat |cut -f2 -d":"|head -1 is probably what you want.
eWebtricity
06-05-2005, 15:19
That works great! Thanks.
I've added this line to the server zabbix_agentd.conf
#
# Added to check the number of emails in queue
#
UserParameter=qmail[qmailstat],su - root -c "/var/qmail/bin/qmail-qstat |cut -f2 -d":"|head -1"
and then I setup an item in the mgmt gui with these parameters
Description: Messages in Queue
Host: hostname
Type: Zabbix Agent
Key: qmail[qmailstat]
Units: <empty>
Multiplier: <empty>
Update Interval: 60
Keep History: 7
Status: Monitored
Type Information: Numeric
Store Value: Delta
But I'm getting this error in the zabbix_agentd.log on the server i'm monitoring and the item in the mgmt gui changes to "Not Supported" so it's failing for some reason.
[root@server zabbix]# tail -f /tmp/zabbix_agentd.log
027700:20050506:093107 Got signal. Exiting ...
027701:20050506:093107 Got signal. Exiting ...
027699:20050506:093107 Got signal. Exiting ...
027697:20050506:093107 Got signal. Exiting ...
028065:20050506:093113 zabbix_agentd started
028066:20050506:093113 zabbix_agentd 28066 started
028067:20050506:093113 zabbix_agentd 28067 started
028068:20050506:093113 zabbix_agentd 28068 started
028069:20050506:093113 zabbix_agentd 28069 started
028070:20050506:093113 zabbix_agentd 28070 started
standard in must be a tty
eWebtricity
07-05-2005, 06:50
Looks like it's a permissions problem. Zabbix doesn't like it when i try to su to the qmail user and it complains when zabbix can't access the qmail directories. I'm not sure how to get around this. Latest error message
[root@server zabbix]# find: queue/mess/*: Permission denied
eWebtricity
11-05-2005, 01:32
Using this External Parameter in the zabbix_agentd.conf
UserParameter=qmail[qmailstat],/var/qmail/bin/zabbix-qmail
Getting this error message on the zabbix_agentd.log
005314:20050510:190834 zabbix_agentd 5314 started
005315:20050510:190834 zabbix_agentd 5315 started
find: queue/mess/*: Permission denied
find: queue/mess/*: Permission denied
Zabbix doesn't seem to like the use of sudo or su to execute the qmail-qstat script. Any suggestions?
what you could do is to create a cron job that runs this script and output the result to a file that zabbix has permissions to read. we do this for a number of services we monitor. it works but at the moment we are experiencing a problem whereby the UserParameter switches to Unsupported after a period of time. let me know if you experience this too.
regards
john
it works but at the moment we are experiencing a problem whereby the UserParameter switches to Unsupported after a period of time. let me know if you experience this too.I believe it happens because you're doing something like this:
1. command >file
2. UserParameter=qmail, cat file
This is wrong, because when 1. is executed the file becomes (for a 0.01 sec) empty, therefore ZABBIX sets status of the item to Unsupported.
Do this instead:
1. command >file.tmp
2. mv file.tmp file; rm file.tmp
3. UserParameter=qmail, cat file
thanks alexei,
you were exactly right. outputting the result to a tmp file and then moving it so zabbix can access it has done the trick.
thanks for the help and the great software.
john
I don't know if this would be beneficial to anyone, and I haven't run it for very long, but here is how I'm doing this. I realize it might be a bit much, but I was trying to keep the code in the zabbix_agentd.conf 1 liners cleaner, and still get all 3 portions of the queue. The only thing I am trying to resolve is right this second I am seeing a bit of a discrepancy between qmailctl stat and qmqtool -s, but i'm not sure where it originates from. If I cant figure it out I may get add qmailctl stat's count just for the sake of finding out the nature of the discrepancy.
To view the stats I use qmqtool (which can be found at jeremy.kister.net (http://jeremy.kister.net/code/qmqtool/)), which is run by the following simple script as a cronjob (I do it every minute, but i'm a touch more paranoid for specific reasons). Below are the files, or excerpt
qmailstats.sh
#!/bin/sh
/use/local/qmqtool/qmqtool -s > /tmp/queue.tmp
head -1 /tmp/queue.tmp | cut -f2 -d":" > /tmp/queue.local
head -2 /tmp/queue.tmp | tail -1 | cut -f2 -d":" > /tmp/queue.remote
tail -1 /tmp/queue.tmp | cut -f2 -d":" > /tmp/queue.todo
and from zabbix_agentd.conf
### Monitoring qmail queue
### Accompanies /etc/cron.etc/qmailqueue
UserParameter=qmail[qmaillocal],cat /tmp/queue.local
UserParameter=qmail[qmailremote],cat /tmp/queue.remote
UserParameter=qmail[qmailtodo],cat /tmp/queue.todo
and add then add to crontab something like: (change the 1 to 5 for 5 minute increments.
*/1 * * * * root /etc/cron.etc/qmailqueue
Inside the web interface I did the following (i like keeping data extended periods):
Description: Messages in qmail <whichever> queue
Host: <box>
Type: Zabbix agent
Key: qmail[qmail<whichever>]
Units: <none>
Use multiplier: <none>
Update interval (in sec): 60
Keep history (in days): 90
Keep trends (in days): 365
Status: Monitored
Type of information: Numeric
Store value: As is
I'm trying to set up qmail queue monitoring like this, but am not getting any data.
zabbix_agentd.log:
025050:20070207:142008 Can't add user specifed key "qmail[qmailstat]". Incorrect key!
025052:20070207:142008 zabbix_agentd started. ZABBIX 1.1.
025053:20070207:142008 zabbix_agentd 25053 started
025055:20070207:142008 zabbix_agentd 25055 started
025056:20070207:142008 zabbix_agentd 25056 started
025057:20070207:142008 zabbix_agentd 25057 started
025058:20070207:142008 zabbix_agentd 25058 started
025055:20070207:142111 Timeout while answering request
025053:20070207:142608 Timeout while answering request
025053:20070207:142809 Timeout while answering request
zabbix_agentd.conf:
#
# Added to check the number of emails in queue
#
UserParameter=qmail[qmailstat],cat /home/zabbix/qmailstat
qmailstat.sh (cronjob every 10 min):
#! /bin/bash
/var/qmail/bin/qmail-qstat |cut -f2 -d":"|head -1 > /home/zabbix/qmailstat.tmp
cp /home/zabbix/qmailstat.tmp /home/zabbix/qmailstat
chown zabbix:zabbix /home/zabbix/qmailstat
rm /home/zabbix/qmailstat.tmp
/home/zabbix/qmailstat:
169
zabbix gui item config:
Description Qmail Messages In Queue
Type ZABBIX agent
Key qmail[qmailstat]
Type of information Numeric (64bit integer)
Units blank
Use multiplier Do Not Use
Update interval (in sec) 60
Keep history (in days) 7
Keep trends (in days) 365
Status Active
Store value As is
Show value As is
After a short time, Status for this item turns to Not Supported. Why?
from zabbix_server.log
002930:20070207:151600 Parameter [qmail[qmailstat]] is not supported by agent on host [tin01.2vega.com] Old status [0]
Figured it out. Server and agent don't like the 'qmailstat' in brackets for UserParameter and Key, as in:
UserParameter=qmail[qmailstat],cat /home/zabbix/qmailstat
this worked:
UserParameter=qmail,cat /home/zabbix/qmailstat
I updated the key in the gui.
marcelein
09-06-2008, 17:35
UserParameter=qmail.qmaillocal,cat /tmp/queue.local
UserParameter=qmail.qmailremote,cat /tmp/queue.remote
UserParameter=qmail.qmailtodo,cat /tmp/queue.todo
UserParameter=qmail.procs,ps aux | grep qmail | wc -l
my mailserver screen has x columns for x servers
and 3 rows each showing a custom queue graph with local/remote/todo items
a graph with running qmail processes (qmail.procs) and on the last row there is the output of a transaction script which sends (authentificated) email to a native autoresponder and checks if this email comes back (script availible here (http://www.zabbix.com/forum/showthread.php?t=4645))
so i can see every problem related on the timeline to fix issues
a nice feature would be to grep qmail's different processes like qmailr, qmaild, qmaill, qmails (look at the qmail manual) and post them on a zabbix graph
Hi
very helpful guys. Im already monitor qmail queue with zabbix. But, one question, all of post talks about qmail queue, what if, you want to get the number of incoming and outgoing mails? I read a post on this forum about the same but with Postfix. Honestly, I don't know any comand or command and pipe to know this.
Any idea?
Thanks