How to get the number of items in a MTA's queue remotly

Templates, scripts for templates, scripts and requests for templates.

Moderators: Moderators, Developers

Post Reply
Author
Message
falcon10
Posts: 11
Joined: Fri Dec 19, 2003 3:16 am

How to get the number of items in a MTA's queue remotly

#1 Post by falcon10 » Sun Sep 19, 2004 4:43 am

Just my perl version of the bash script that you can find on this website:

Code: Select all

#!/usr/bin/perl -w
use strict;

my $mailqbin = '/usr/bin/mailq';

open(MAILQ, "$mailqbin|");

while (<MAILQ>) {
    if ($_ =~ m/^.*Kbytes.*Requests.*$/) {
        my @temp = split(/ /, $_);
        print $temp[4];
    }
}
Should work with postfix's/sendmail's syntax.

add the following line to your snmpd.conf:

Code: Select all

exec .1.3.6.1.4.1.2021.53.101.0 mailq /usr/local/sbin/getmailq.pl
and now you can do a SNMP query using this OID and you'll get the number of items currently on the queue.

Guest

#2 Post by Guest » Wed Sep 22, 2004 4:01 pm

Hello,

You have tamplete to graph mailq?


Thanks.

HellBoy

falcon10
Posts: 11
Joined: Fri Dec 19, 2003 3:16 am

#3 Post by falcon10 » Sat Sep 25, 2004 7:46 am

Anonymous wrote:Hello,

You have tamplete to graph mailq?


Thanks.

HellBoy
actually, I do. I will post it tomorrow

falcon10
Posts: 11
Joined: Fri Dec 19, 2003 3:16 am

#4 Post by falcon10 » Sun Sep 26, 2004 3:43 am

falcon10 wrote:
Anonymous wrote:Hello,

You have tamplete to graph mailq?


Thanks.

HellBoy
actually, I do. I will post it tomorrow
OK, here is the templates.

by the way, i forgot a small elsif there, so this is the right script:

Code: Select all

#!/usr/bin/perl -w
use strict;

my $mailqbin = '/usr/bin/mailq';

open(MAILQ, "$mailqbin|");

while (<MAILQ>) {
    if ($_ =~ m/^.*Kbytes.*Requests.*$/) {
        my @temp = split(/ /, $_);
        print $temp[4];
    } elsif ($_ =~ m/^Mail queue is empty$/) {
    print 0;
    }
}
Attachments
cacti_data_template_postfix_queue.xml
(5.51 KiB) Downloaded 2816 times
cacti_graph_template_postfix_queue.xml
(9.37 KiB) Downloaded 3419 times

rblecher
Posts: 1
Joined: Tue May 19, 2009 10:12 am

#5 Post by rblecher » Tue May 19, 2009 10:13 am

Newer versions of Net-SNMP no longer support "exec." Has anyone gotten this to work with "extend"? If so, what changes do I have to make to get this working?

davideb
Posts: 6
Joined: Mon Aug 17, 2009 10:14 am
Location: Amsterdam - The Netherland

extend is the same as exec

#6 Post by davideb » Thu Aug 20, 2009 5:23 am

Just replace 'exec' with 'extend':

extend .1.3.6.1.4.1.2021.53.101.1 mailq /usr/local/bin/mailq.pl

derkiely
Posts: 1
Joined: Mon May 17, 2010 6:57 am

Where to find bash script

#7 Post by derkiely » Mon May 17, 2010 7:00 am

Hello, can you tell me where to find the bash script you mentioned in your post below

"Just my perl version of the bash script that you can find on this website: "

Thanks for your help

Regards
DK

User avatar
hbokh
Posts: 40
Joined: Thu Feb 24, 2005 4:29 pm
Location: Groningen, NL

Re: How to get the number of items in a MTA's queue remotly

#8 Post by hbokh » Fri Jan 28, 2011 10:41 am

OID .1.3.6.1.4.1.2021.53.101.0.101.1 seems wrong:

Code: Select all

# snmpwalk -c foobar -v 2c 192.168.0.x .1.3.6.1.4.1.2021.53.101.0.101.1
UCD-SNMP-MIB::ucdavis.53.101.0.101.1 = No Such Object available on this agent at this OID
OID ucdavis.53.101.1.4.1.2.5.109.97.105.108.113.1 seems right:

Code: Select all

# snmpwalk -c foobar -v 2c 192.168.0.x ucdavis.53.101.1.4.1.2.5.109.97.105.108.113.1
UCD-SNMP-MIB::ucdavis.53.101.1.4.1.2.5.109.97.105.108.113.1 = STRING: "7"
Any clues / thoughts? In the end it creates graphs with the last one...
This is my sick nature...

Post Reply