Ad Widget

Collapse

Postfix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frater
    Senior Member
    • Oct 2010
    • 340

    #1

    Postfix

    For monitoring Postfix I took a look at this script, but I had to alter some of the things. It doesn't come with a template, so I created one...

    http://www.zabbix.com/wiki/howto/mon...itoringpostfix
    Code:
    UserParameter=postfix.mailq,mailq | grep -v "Mail queue is empty" | grep -c '^[0-9A-Z]'
    Code:
    #!/bin/bash
    
    MAILLOG=/var/log/mail.log
    DAT1=/tmp/zabbix-postfix-offset.dat
    DAT2=$(mktemp)
    PFLOGSUMM=/usr/sbin/pflogsumm
    ZABBIX_CONF=/etc/zabbix/zabbix_agentd.conf
    DEBUG=1
    
    function zsend {
      key="postfix[`echo "$1" | tr ' -' '_' | tr '[A-Z]' '[a-z]' | tr -cd [a-z_]`]"
      value=`grep -m 1 "$1" $DAT2 | awk '{print $1}'`
      [ ${DEBUG} -ne 0 ] && echo "Send key \"${key}\" with value \"${value}\"" >&2
      /usr/bin/zabbix_sender -c $ZABBIX_CONF -k "${key}" -o "${value}" 2>&1 >/dev/null
    }
    
    /usr/sbin/logtail -f$MAILLOG -o$DAT1 | $PFLOGSUMM -h 0 -u 0 --no_bounce_detail --no_deferral_detail --no_reject_detail --no_no_msg_size --no_smtpd_warnings > $DAT2
    
    zsend received
    zsend delivered
    zsend forwarded
    zsend deferred
    zsend bounced
    zsend rejected
    zsend held
    zsend discarded
    zsend "reject warnings"
    zsend "bytes received"
    zsend "bytes delivered"
    zsend senders
    zsend recipients
    
    rm $DAT2
    Attached Files
    Last edited by frater; 25-10-2010, 13:23.
    Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP
  • bnaranjo
    Junior Member
    • Nov 2010
    • 9

    #2
    Postix template problem

    hi frater, i wonder if you can help me, i use your template and your script, but im unable to get the statistics in zabbix server, i've checked the logs and i couldn´t find anything to solve the problem, however if i run the script in the postfix server i can actually see the statitics, but i dont know the sender is not sending them to the zabbix server,

    first i had a problem running the agentd (i had an error “can not chdir(/var/spool/clientmqueue/): Permission denied. Program mode requires special privileges, e.g., root or TrustedUser.”) due to file permission but with a chmod -R 755 /var/spool/mqueue i'solved it, after i had an error that cannot create /tmp/zabbix-postfix-offset.dat same permissions issue, fixed after chmod -R 777 /tmp, im not very savy with linux centos, thats why i dont know what else to do to make this work.

    please help!!

    Thank you

    Comment

    • frater
      Senior Member
      • Oct 2010
      • 340

      #3
      Does the other zabbix stuff work?
      I mean, do you have an agent running on that machine and does it give you the other statistics?

      I did notice that the normal agent still works even if the hostname you entered in /etc/zabbix/zabbix_agentd.conf does not match with the hostname in your zabbix-server,
      When you use zabbix_sender it DOES need to match....

      Check this first
      Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

      Comment

      • bnaranjo
        Junior Member
        • Nov 2010
        • 9

        #4
        Monitoring Postfix

        Hi Frater, i've just checked the hostname (FQDN) in the agentd and its exactly the same as wrote it in the server even with case sensitive, i get the other statistics without a problem i´ve just realized that even the postfix items show as ACTIVE in the item configuration like the would be working fine, i just dont kown why they dont get any value nor appear in the latest data tab or anywhere else.

        there's is a way to monitor the zabbix sender or at least test it to see if its working???, by the way the item postfix.mailq just gives me the value of "0", all the time, i dont kown if this is correct..

        thank u 4 ur help frater.

        Comment

        • bnaranjo
          Junior Member
          • Nov 2010
          • 9

          #5
          Postfix Monitoring

          i've forgot to tell you that postfix.mailq is the only item that i do see in the latest data tab, the others just dont show anywhere... thanks

          Comment

          • frater
            Senior Member
            • Oct 2010
            • 340

            #6
            Originally posted by bnaranjo
            there's is a way to monitor the zabbix sender or at least test it to see if its working???, by the way the item postfix.mailq just gives me the value of "0", all the time, i dont kown if this is correct..

            thank u 4 ur help frater.
            It depends if your mailq is always empty or not...
            I'm using it on ISP mailservers which sends hundreds of mails. I don't know how many mails stay in your queue.

            Try to get an email in the queue which can't be delivered immediately..

            You could replace mailq with /usr/bin/mailq
            and maybe you need to add it to sudo with this line (first try the full path):
            Code:
            echo zabbix ALL = NOPASSWD: `which mailq` >> /etc/sudoers
            Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

            Comment

            • frater
              Senior Member
              • Oct 2010
              • 340

              #7
              You needed to read the original link too....

              Your system probably has these missing:

              logtail
              pflogsumm

              Code:
              apt-get install pflogsumm
              apt-get install logtail
              Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

              Comment

              • bnaranjo
                Junior Member
                • Nov 2010
                • 9

                #8
                Statistics seems fine in the server

                Hi Frater, sorry that i didnt get back at you sooner, i was out of town giving support in a branch office,

                i've already read the original link before i tried your script, and installed the other tools, that's why when i run the script with the zabbix user i get the statistics, as i attached them, i've also attached screenshots of logs in the zabbix server and postfix client, there are some errors of non supported items (due to the default linux template items), but nothing related to the postfix items, as you can see in the picture they seem ok in the config tab, but not showing info in the latest data tab. i tried the other command you told me /usr/bin/mailq and the queue is still 0, the volume of mails that i have is about 8000 per day (100k average)and i have a 1024mb uplink, i dont know if that is why i dont have mail in the queue.

                thanks for your help, once again
                Attached Files

                Comment

                • frater
                  Senior Member
                  • Oct 2010
                  • 340

                  #9
                  Versions > 1.8 of zabbix_sender will tell you if the server accepts the data you are providing.
                  I too had problems when I tried zabbix_sender for the first time.
                  The log of the zabbix server turned out to be useless, even when I set debug to high.

                  It's best to upgrade your sender if it's < 1.8

                  Use this line
                  Code:
                  /usr/bin/zabbix_sender -vv -c $ZABBIX_CONF -k "${key}" -o "${value}"
                  instead of
                  Code:
                  /usr/bin/zabbix_sender -c $ZABBIX_CONF -k "${key}" -o "${value}" 2>&1 >/dev/null
                  Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

                  Comment

                  • bnaranjo
                    Junior Member
                    • Nov 2010
                    • 9

                    #10
                    Zabbix Senders not sending data

                    Hi frater, i did what you told me and now i know the problem is in the comunication between the zabbix_sender and the zabbix_server, do you know where i can find any log that can tell what is actually the issue, because the other statistics are working just fine so its not a network problem, nor a firewall problem, both machine are in the same subnet and see each other directly

                    i attached the screenshots that i've got with the change that you suggested me,

                    i remembered also that you told me that zabbix sender wont work if its not the same hostname in the agentd and in the server so i put this screenshots too.

                    thanks and i really appreciate your help from far far away.
                    Attached Files

                    Comment

                    • bnaranjo
                      Junior Member
                      • Nov 2010
                      • 9

                      #11
                      this post, looks very similar to my problem:



                      they talk about especifiyng allowed hosts but i dont know where to do that if in the client or the server?...

                      do you think this is my problem??,

                      thx.

                      Comment

                      • bnaranjo
                        Junior Member
                        • Nov 2010
                        • 9

                        #12
                        Getting closer

                        Hi Frater, with the post that i told you i was able to get info in the zabbix server (i think), i attached the logs saying that i got the data, BUT in the frontend im still unable to watch the items.

                        am i correct?? am i getting the info in the zabbix server? or it is just ignoring it

                        thanks
                        Attached Files

                        Comment

                        • frater
                          Senior Member
                          • Oct 2010
                          • 340

                          #13
                          But how do you know it's not a firewall problem?

                          have you done a
                          Code:
                          telnet <server> 10051
                          Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

                          Comment

                          • bnaranjo
                            Junior Member
                            • Nov 2010
                            • 9

                            #14
                            yeah, i got connected to the port without the problem, as i said in the above post i think i got the data in the server, but if i run the script manually i still got the same problem
                            Attached Files

                            Comment

                            • bnaranjo
                              Junior Member
                              • Nov 2010
                              • 9

                              #15
                              At Last!!!!

                              Hi frater, i really appreciated your help, without you i dont think i would got this working, what was left was that de NAME field (not only hostname), must also match the hostname, with these and the post that i told you i got it working

                              thanks very much !!!!
                              Attached Files

                              Comment

                              Working...