Ad Widget

Collapse

Postfix template for CentOS?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 0x570x690x6c0x6c
    Junior Member
    • Mar 2012
    • 13

    #1

    Postfix template for CentOS?

    I've noticed there are bunch of templates and cookbooks that require debian specific packages, but I don't see any for centos. Is there a way to monitor postfix with centos?

    I'd like to monitor the postfix queue along with how many messages, sent, etc. Is there a template for this?
  • Zaniwoop
    Senior Member
    • Jan 2010
    • 232

    #2
    This is what one of my guys set up on our postfix servers (running on Centos).

    There is a perl script: /etc/scripts/zbx_qshape.pl
    Code:
    #!/usr/bin/perl
    # qshape wrapper for zabbix
    # Usage: zbx_qshape <queuename> <minutes>
    # Returns the number of messages in <queuename> that have been in there for <minutes>
    # <minutes> must be one of T (all,default), 5,10,20,40,80,160,320,640,1280,1280+
    # $Id: zbx_qshape.pl 9 2007-08-27 14:54:33Z oli $
    
    use strict;
    
    my $queue= @ARGV[0];
    my $time = @ARGV[1];
    
    #qshape return values index
    my %timeindex = (
    'T' => 0,
    '5' => 1,
    '10' => 2,
    '20' => 3,
    '40' => 4,
    '80' => 5,
    '160' => 6,
    '320' => 7,
    '640' => 8,
    '1280' => 9,
    '1280+' => 10
    );
    my $index=$timeindex{$time};
    
    if(!$index){
    $index=0;
    }
    
    #awk starts at 1, not at 0, and we're not interested in the word TOTAL at the beginning
    $index=$index+2;
    
    #we need to set the PATH var as qshape does rely on the environment
    my $command = "/usr/bin/env PATH=\$PATH:/usr/sbin /usr/sbin/qshape $queue | grep TOTAL | awk {'print \$$index'}";
    my $result ="-1";
    
    #print $command."\n";
    $result = qx@$command@;
    chomp($result);
    print "$result\n";
    Then the following user parameters are used.

    Code:
    UserParameter=postfix.queue.active,sudo /etc/scripts/zbx_qshape.pl active T
    UserParameter=postfix.queue.deferred,sudo /etc/scripts/zbx_qshape.pl deferred T
    UserParameter=postfix.queue.hold,sudo /etc/scripts/zbx_qshape.pl hold T
    UserParameter=postfix.queue.incoming,sudo /etc/scripts/zbx_qshape.pl incoming T

    Comment

    • Vertical
      Junior Member
      • Mar 2012
      • 1

      #3
      Hi, thank you for posting your script and agent config. I was wondering if you consider posting your host config or template? I have been trying to get these stats imported into zabbix but am having zero luck.

      Thank you in advance!

      Comment

      • Zaniwoop
        Senior Member
        • Jan 2010
        • 232

        #4
        There is something I forgot to mention. Since the user parameter uses sudo, you need to add the following line to /etc/sudoers:

        Code:
        zabbix ALL = NOPASSWD: /etc/scripts/zbx_qshape.pl
        Attached Files

        Comment

        • Patjomkin
          Member
          • Nov 2012
          • 50

          #5
          Monitoring Zimbra (incoming, hold, active ...)

          Hi All!
          Please help me.
          It is necessary to monitoring zimbra by means of zabbix (active, hold, deferred, incoming). Zimbra is set on debian (squeed)
          I don't understand scripts. And this script doesn't work for me, he writes "zbx_qshape.pl: command not found"
          I changed sript for zimbra (possibly incorrectly)

          #!/usr/bin/perl
          # qshape wrapper for zabbix
          # Usage: zbx_qshape <queuename> <minutes>
          # Returns the number of messages in <queuename> that have been in there for <minutes>
          # <minutes> must be one of T (all,default), 5,10,20,40,80,160,320,640,1280,1280+
          # $Id: zbx_qshape.pl 9 2007-08-27 14:54:33Z oli $

          use strict;

          my $queue= @ARGV[0];
          my $time = @ARGV[1];

          #qshape return values index
          my %timeindex = (
          'T' => 0,
          '5' => 1,
          '10' => 2,
          '20' => 3,
          '40' => 4,
          '80' => 5,
          '160' => 6,
          '320' => 7,
          '640' => 8,
          '1280' => 9,
          '1280+' => 10
          );
          my $index=$timeindex{$time};

          if(!$index){
          $index=0;
          }

          #awk starts at 1, not at 0, and we're not interested in the word TOTAL at the beginning
          $index=$index+2;

          #we need to set the PATH var as qshape does rely on the environment
          my $command = "/usr/bin/env PATH=\$PATH:/opt/zimbra/bin /opt/zimbra/bin/qshape $queue | grep TOTAL | awk {'print \$$index'}";
          my $result ="-1";

          #print $command."\n";
          $result = qx@$command@;
          chomp($result);
          print "$result\n";

          Comment

          • petrogazz
            Junior Member
            • Mar 2015
            • 1

            #6
            Thanks for the script and template, saved me all lot of time...

            Cheers!

            Comment

            • aib
              Senior Member
              • Jan 2014
              • 1615

              #7
              Originally posted by Patjomkin
              Hi All!
              Please help me.
              It is necessary to monitoring zimbra by means of zabbix (active, hold, deferred, incoming). Zimbra is set on debian (squeed)
              I don't understand scripts. And this script doesn't work for me, he writes "zbx_qshape.pl: command not found"
              Did you give 'eXecutable' permission for script?
              Code:
              chmod +x zbx_qshape.pl
              Sincerely yours,
              Aleksey

              Comment

              Working...