Ad Widget

Collapse

Postfix basic stats (via UserParameter)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vipo
    Junior Member
    • Oct 2005
    • 1

    #1

    Postfix basic stats (via UserParameter)

    Stats are based on pflogsumm (http://jimsun.linxnet.com/postfix_contrib.html), which is a small perl program.
    (i actually use the german version: http://postfix.state-of-mind.de/patr...ter/pflogsumm/)

    -----
    crontab:
    */30 * * * * /usr/local/bin/postfixstats.sh > /tmp/postfixstats.log
    --
    The stats are build every 30 minutes from cron and the results stored in /tmp/postfixstats.log

    -----
    /usr/local/bin/postfixstats.sh:

    #!/bin/bash
    # show highlevel Postfix stats from yesterday
    PFLOG=/var/log/mail
    /usr/local/bin/pflogsumm -d today -h 0 -u 0 --no_bounce_detail --no_deferral_detail --no_reject_detail --no_no_msg_size --no_smtpd_warnings $PFLOG
    --
    Call pflogsumm with my set of params (see man pflogsumm).
    BTW: my mail file is logrotated

    -----
    zabbix_agentd.conf:

    UserParameter=postfix[empfangen],grep -m 1 empfangen /tmp/postfixstats.log|cut -f1 -d"e"
    UserParameter=postfix[zugestellt],grep -m 1 zugestellt /tmp/postfixstats.log|cut -f1 -d"z"
    UserParameter=postfix[weitergeleitet],grep -m 1 weitergeleitet /tmp/postfixstats.log|cut -f1 -d"w"
    UserParameter=postfix[zurueckgewiesen],grep -m 1 ckgewiesen /tmp/postfixstats.log|cut -f1 -d"z"
    UserParameter=postfix[zurueckgeworfen],grep -m 1 ckgeworfen /tmp/postfixstats.log|cut -f1 -d"z"
    UserParameter=postfix[abgelehnt],grep -m 1 abgelehnt /tmp/postfixstats.log|cut -f1 -d"a"
    UserParameter=postfix[Ablehnungswarnungen],grep -m 1 Ablehnungswarnungen /tmp/postfixstats.log|cut -f1 -d"A"
    UserParameter=postfix[wartend],grep -m 1 wartend /tmp/postfixstats.log|cut -f1 -d"w"
    UserParameter=postfix[verworfen],grep -m 1 verworfen /tmp/postfixstats.log|cut -f1 -d"v"
    UserParameter=postfix[byteszugestellt],grep -m 1 "bytes zugestellt" /tmp/postfixstats.log|cut -f1 -d"k"
    UserParameter=postfix[Empfaenger],grep -m 1 Empf /tmp/postfixstats.log|cut -f1 -d"E"
    --
    I grep stat data from postfixstats.log and extract numeric data

    best regards
    Vipo
  • mpeide
    Junior Member
    • Jul 2005
    • 21

    #2
    Postfix stats

    Vipo,

    Great stuff! Thanks for posting. I implemented your solution on my postfix boxes.

    Thanks for the samplwe config.

    Matt

    Comment

    • bbrendon
      Senior Member
      • Sep 2005
      • 870

      #3
      can someone translate to english?
      Unofficial Zabbix Expert
      Blog, Corporate Site

      Comment

      • SAT QPass
        Member
        • Oct 2005
        • 61

        #4
        Actually you do not need to translate... Just "read" (or run) the cuts on the log data with the Enlgish version and you will see what field is being cropped out. Since they are user parameters you can map them as you see fit.

        Comment

        • mpeide
          Junior Member
          • Jul 2005
          • 21

          #5
          translation request

          Here is an English sample. You can tailor for your environment. This is based of what I took from Vipo's example.


          For example I setup item with following key value "pfreceived".

          Then, I configured my agent to greps for first instance of something (ex. "recieved") and then returns text preceding search item. You can tailor for your environment.

          I use
          =zabbix_agentd.conf===============

          UserParameter=pfreceived,grep -m 1 received /tmp/postfixstats.log|cut -f1 -d"r"
          UserParameter=pfdelivered,grep -m 1 delivered /tmp/postfixstats.log|cut -f1 -d"d"
          UserParameter=pfforwarded,grep -m 1 forwarded /tmp/postfixstats.log|cut -f1 -d"f"
          UserParameter=pfdeferred,grep -m 1 deferred /tmp/postfixstats.log|cut -f1 -d"d"
          UserParameter=pfbounced,grep -m 1 bounced /tmp/postfixstats.log|cut -f1 -d"b"
          UserParameter=pfrejected,grep -m 1 rejected /tmp/postfixstats.log|cut -f1 -d"r"
          UserParameter=prejectedwarnings,grep -m 1 "rejected warnings" /tmp/postfixstats.log|cut -f1 -d"r"
          UserParameter=fpheld,grep -m 1 held /tmp/postfixstats.log|cut -f1 -d"h"
          UserParameter=pfdiscarded,grep -m 1 discarded /tmp/postfixstats.log|cut -f1 -d"d"
          UserParameter=pfbytesreceived,grep -m 1 "bytes recieved" /tmp/postfixstats.log|cut -f1 -d"b"
          UserParameter=pfbytesdelivered,grep -m 1 "bytes delivered" /tmp/postfixstats.log|cut -f1 -d"b"

          ================

          Later

          Comment

          • DiedX
            Senior Member
            • Oct 2004
            • 106

            #6
            First link is dead!
            https://www.diederik.nl

            Comment

            • edeus
              Senior Member
              • Aug 2005
              • 120

              #7
              If you looked closer it is obvious why it was broken.





              What non perl/log reporting option is there to monitor postfix? I cant figure out why there isnt an interface to some kind of internal Postfix counters.

              It is a waste to have to run a log file parsing utility just to find out how much MB is being sent.

              Comment

              • dminstrel
                Member
                • Apr 2005
                • 72

                #8
                Quick question about this: what's the best way to store values for these kinds of Items, "as is" or "delta"? I guess to obtain something similar to RRDTool graphs you'd use delta but then you'd lose the total number of e-mais (for instance) received, right?

                Cheers,

                Comment

                • SAT QPass
                  Member
                  • Oct 2005
                  • 61

                  #9
                  I am not sure why you would want total, it would just be a rising graph, not very useful in my opinion.

                  But if you did, you could just make two keys, one storing it as a delta, the other as a value.

                  Comment

                  • edeus
                    Senior Member
                    • Aug 2005
                    • 120

                    #10
                    Arrrgh!

                    I have been racking my brain trying to figure out a way I can bypass running a cronscript etc or some resident program to parse the stats.

                    All I want to do is get the mail sent, mail received or total mail transferred over a period of time. I thought I could do it with something like the following but cant find the exact way to cat/grep for specific times...

                    I.e. cat -time last1hour /var/log/maillog | awk '{print $9}' | awk add function
                    # awking for the size value in the maillog over the last hour, then add the values together.

                    This way I could have a simple line inside the agentd.conf. Am I going off on a tangent or is this possible? My Unix scripting is not great so if someone could help, it would be appreciated!

                    Thanks!

                    Comment

                    • bbrendon
                      Senior Member
                      • Sep 2005
                      • 870

                      #11
                      Hmm. I was going to do this, but decided I didn't need it bad enough right now.

                      A great solution for monitoring postfix with pflogsumm:
                      • Use logtail so your massive log files don't have to be read from the beginning each time
                      • Pipe the results from above into pflogsumm and save them
                      • Grep the data out and use zabbix sender to input it into zabbix
                      • Schedule the whole thing with cron to run with any interval you like!
                      • Create some cool graphs.
                      • Post the code and export the zabbix stuff into a template and post it all on the wiki


                      Wow, I'm good!!
                      Unofficial Zabbix Expert
                      Blog, Corporate Site

                      Comment

                      • bbrendon
                        Senior Member
                        • Sep 2005
                        • 870

                        #12
                        Ok. I gave in. So sue me.
                        http://www.zabbix.com/wiki/doku.php?...itoringpostfix
                        Unofficial Zabbix Expert
                        Blog, Corporate Site

                        Comment

                        Working...