Ad Widget

Collapse

Ideas on how best to monitor Qmail stats

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eWebtricity
    Junior Member
    • Mar 2005
    • 27

    #1

    Ideas on how best to monitor Qmail stats

    Any ideas on ways to monitor Qmail stats?
  • sauron
    Senior Member
    • Jan 2005
    • 215

    #2
    Use external params in zabbix agent. If scripts works slowly (run time more 0.5 secs) use zabbix_trapper

    Comment

    • eWebtricity
      Junior Member
      • Mar 2005
      • 27

      #3
      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

      Code:
      [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

      Code:
      [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.

      Comment

      • Alexei
        Founder, CEO
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Sep 2004
        • 5654

        #4
        /var/qmail/bin/qmail-qstat |cut -f2 -d":"|head -1 is probably what you want.
        Alexei Vladishev
        Creator of Zabbix, Product manager
        New York | Tokyo | Riga
        My Twitter

        Comment

        • eWebtricity
          Junior Member
          • Mar 2005
          • 27

          #5
          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
          Last edited by eWebtricity; 06-05-2005, 15:35.

          Comment

          • eWebtricity
            Junior Member
            • Mar 2005
            • 27

            #6
            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

            Comment

            • eWebtricity
              Junior Member
              • Mar 2005
              • 27

              #7
              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?

              Comment

              • johnl
                Junior Member
                • Jan 2005
                • 27

                #8
                Use cron job to output result to a file

                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

                Comment

                • Alexei
                  Founder, CEO
                  Zabbix Certified Trainer
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Sep 2004
                  • 5654

                  #9
                  Originally posted by johnl
                  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
                  Alexei Vladishev
                  Creator of Zabbix, Product manager
                  New York | Tokyo | Riga
                  My Twitter

                  Comment

                  • johnl
                    Junior Member
                    • Jan 2005
                    • 27

                    #10
                    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

                    Comment

                    • xaeth
                      Member
                      • Nov 2004
                      • 67

                      #11
                      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), 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
                      Code:
                      #!/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
                      Code:
                      ### 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.
                      Code:
                      */1 * * * * root /etc/cron.etc/qmailqueue
                      Inside the web interface I did the following (i like keeping data extended periods):
                      Code:
                      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

                      Comment

                      • shalako
                        Member
                        • Apr 2006
                        • 30

                        #12
                        I'm trying to set up qmail queue monitoring like this, but am not getting any data.

                        zabbix_agentd.log:

                        Code:
                        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:
                        Code:
                        #
                        # Added to check the number of emails in queue
                        #
                        UserParameter=qmail[qmailstat],cat /home/zabbix/qmailstat
                        qmailstat.sh (cronjob every 10 min):
                        Code:
                        #! /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:
                        Code:
                        169
                        zabbix gui item config:
                        Code:
                        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?
                        Last edited by shalako; 08-02-2007, 00:22.

                        Comment

                        • shalako
                          Member
                          • Apr 2006
                          • 30

                          #13
                          from zabbix_server.log

                          Code:
                          002930:20070207:151600 Parameter [qmail[qmailstat]] is not supported by agent on host [tin01.2vega.com] Old status [0]

                          Comment

                          • shalako
                            Member
                            • Apr 2006
                            • 30

                            #14
                            Figured it out. Server and agent don't like the 'qmailstat' in brackets for UserParameter and Key, as in:

                            Code:
                            UserParameter=qmail[qmailstat],cat /home/zabbix/qmailstat
                            this worked:

                            Code:
                            UserParameter=qmail,cat /home/zabbix/qmailstat
                            I updated the key in the gui.

                            Comment

                            • marcelein
                              Junior Member
                              • Apr 2008
                              • 21

                              #15
                              Code:
                              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)
                              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
                              Last edited by marcelein; 09-06-2008, 17:39. Reason: definition

                              Comment

                              Working...