Postfix Queues

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

Moderators: Moderators, Developers

Author
Message
valec
Posts: 5
Joined: Wed Aug 23, 2006 10:25 pm
Location: New Zealand

Postfix Queues

#1 Post by valec » Wed Oct 04, 2006 4:22 pm

Thought I'd upload a quick script with graph templates for postfix queue graphing.
Graphs: Active, Deferred, Incoming and Hold queues.

Not the most exciting graph, but maybe useful to someone. And there's probably a better way to do it. Suggestions welcome.

Code: Select all

#!/bin/bash

#getmailq.sh - written by Valec 2006. Steal and share.
#Get postfix queue lengths

#Place in /usr/local/bin/
#exec .1.3.6.1.4.1.2021.53.101.0 mailq /usr/local/bin/getmailq.sh

QUEUES="incoming active deferred hold"

for i in $QUEUES; do
        COUNT=`qshape $i | grep TOTAL | awk '{print $2}'`
        printf "$i:$COUNT "
done
Place in /usr/local/bin/
Add the following to /snmpd.conf:

Code: Select all

exec .1.3.6.1.4.1.2021.53.101.0 mailq /usr/local/bin/getmailq.sh
And on the Cacti host I have:

Code: Select all

#!/bin/bash
#/usr/share/cacti/site/scripts/postfixqueues.sh

output=`/usr/bin/snmpwalk -Oav -v2c -c syzygy $1 .1.3.6.1.4.1.2021.53.101.0.101.1 | cut -d '"' -f 2`
printf "$output"
echo
Graph template attached. If I've missed something let me know.

Image
Attachments
cacti_graph_template_postfix_queues.xml
(17.4 KiB) Downloaded 7414 times
Last edited by valec on Thu Oct 19, 2006 5:13 pm, edited 1 time in total.

masdani
Posts: 1
Joined: Wed Oct 11, 2006 3:56 am
Location: Indonesia
Contact:

#2 Post by masdani » Wed Oct 11, 2006 3:58 am

after try, i have problem. the graphic show nan, and manual running snmpwalk give info :

bash-3.00# snmpwalk -v1 -c gagak localhost .1.3.6.1.4.1.2021.53.101.0
UCD-SNMP-MIB::ucdavis.53.101.0.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.53.101.0.2.1 = STRING: "mailq"
UCD-SNMP-MIB::ucdavis.53.101.0.3.1 = STRING: "/usr/local/bin/getmailq.sh"
UCD-SNMP-MIB::ucdavis.53.101.0.100.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.53.101.0.101.1 = STRING: "/usr/local/bin/getmailq.sh: line 12: qshape: command not found"
UCD-SNMP-MIB::ucdavis.53.101.0.101.2 = STRING: "incoming: /usr/local/bin/getmailq.sh: line 12: qshape: command not found"
UCD-SNMP-MIB::ucdavis.53.101.0.101.3 = STRING: "active: /usr/local/bin/getmailq.sh: line 12: qshape: command not found"
UCD-SNMP-MIB::ucdavis.53.101.0.101.4 = STRING: "deferred: /usr/local/bin/getmailq.sh: line 12: qshape: command not found"
UCD-SNMP-MIB::ucdavis.53.101.0.101.5 = STRING: "hold: "
UCD-SNMP-MIB::ucdavis.53.101.0.102.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.53.101.0.103.1 = ""


and after run in command line, i have error like this :

./getmailq.sh
./getmailq.sh: line 12: qshape: command not found
incoming: ./getmailq.sh: line 12: qshape: command not found
active: ./getmailq.sh: line 12: qshape: command not found
deferred: ./getmailq.sh: line 12: qshape: command not found

i have running postfix postfix-2.2.10 in freebsd box

Keene44
Cacti User
Posts: 52
Joined: Thu Aug 17, 2006 10:49 am

#3 Post by Keene44 » Fri Oct 13, 2006 8:43 am

Looks like you don't have qshape installed on your postfix server.

I believe it comes installed in most postfix versions. It's just a perl file that you can find on the net.

sloop
Posts: 23
Joined: Tue Oct 17, 2006 10:09 am

#4 Post by sloop » Tue Oct 17, 2006 10:11 am

The data input method includes:

Code: Select all

/bin/bash <path_cacti>/scripts/postfixqueues.sh <Host_IP>
Can you please include this script? thanks :D

valec
Posts: 5
Joined: Wed Aug 23, 2006 10:25 pm
Location: New Zealand

#5 Post by valec » Thu Oct 19, 2006 5:11 pm

Ahh yeah, whoops. I'll do so now.

cscott
Posts: 2
Joined: Thu Oct 26, 2006 6:19 pm

What version

#6 Post by cscott » Thu Oct 26, 2006 6:21 pm

I am getting a "Error: XML: Hash version does not exist." when importing the graph template. What version of Cacti was this exported from? I am using 0.8.6i-1.

mdvz0r
Posts: 1
Joined: Fri Oct 27, 2006 9:00 am

#7 Post by mdvz0r » Fri Oct 27, 2006 9:03 am

Seems like this is not going to work for me.

Problem is that the snmp deamon (running as user snmp) doesn't have access to the /var/spool/postfix/.. directories. So qshape will generate errors. How did you guys solve this?

cscott
Posts: 2
Joined: Thu Oct 26, 2006 6:19 pm

postfix permissions

#8 Post by cscott » Fri Oct 27, 2006 1:45 pm

What is snmpd running as on your machine? Can't you fix it by using group permissions?

cviebrock
Posts: 3
Joined: Wed Dec 06, 2006 11:09 pm

#9 Post by cviebrock » Wed Dec 06, 2006 11:14 pm

I've got this problem too:

Code: Select all

# snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.53.101.0
UCD-SNMP-MIB::ucdavis.53.101.0.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.53.101.0.2.1 = STRING: "mailq"
UCD-SNMP-MIB::ucdavis.53.101.0.3.1 = STRING: "/usr/local/bin/getmailq.sh"
UCD-SNMP-MIB::ucdavis.53.101.0.100.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.53.101.0.101.1 = STRING: "Can't cd to incoming: Permission denied"
UCD-SNMP-MIB::ucdavis.53.101.0.101.2 = STRING: " at /usr/sbin/qshape line 286"
UCD-SNMP-MIB::ucdavis.53.101.0.101.3 = STRING: "incoming:0 Can't cd to active: Permission denied"
UCD-SNMP-MIB::ucdavis.53.101.0.101.4 = STRING: " at /usr/sbin/qshape line 286"
UCD-SNMP-MIB::ucdavis.53.101.0.101.5 = STRING: "active:0 Can't cd to deferred: Permission denied"
UCD-SNMP-MIB::ucdavis.53.101.0.101.6 = STRING: " at /usr/sbin/qshape line 286"
UCD-SNMP-MIB::ucdavis.53.101.0.101.7 = STRING: "deferred:0 Can't cd to hold: Permission denied"
UCD-SNMP-MIB::ucdavis.53.101.0.101.8 = STRING: " at /usr/sbin/qshape line 286"
UCD-SNMP-MIB::ucdavis.53.101.0.101.9 = STRING: "hold:0 "
UCD-SNMP-MIB::ucdavis.53.101.0.102.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.53.101.0.103.1 = ""
I tried adding the "snmp" user to the "postfix", the "adm" and even the "root" group, with no success.

The directories have the following perms:

Code: Select all

xxx:/var/spool/postfix/deferred# ls -las
total 72
4 drwx------  18 postfix root    4096 2006-07-20 00:09 .
4 drwxr-xr-x  19 root    root    4096 2006-11-08 11:33 ..
4 drwx------   2 postfix postfix 4096 2006-12-06 22:59 0
4 drwx------   2 postfix postfix 4096 2006-12-06 22:59 1
etc.
Any suggestions?[/code]

MoreDakka
Posts: 44
Joined: Wed Jul 04, 2007 12:57 pm

#10 Post by MoreDakka » Wed Jul 18, 2007 11:17 am

I am also having a problem with this script. If I enter the information in manually it works no problem and I've narrowed it down to "syzygy". I have no idea what that is. If it's a place holder is there any way to have the script grab the community from cacti rather than manually enter it?

zoemdoef
Posts: 1
Joined: Tue Jul 24, 2007 4:30 am

#11 Post by zoemdoef » Tue Jul 24, 2007 4:34 am

MoreDakka wrote:I am also having a problem with this script. If I enter the information in manually it works no problem and I've narrowed it down to "syzygy". I have no idea what that is. If it's a place holder is there any way to have the script grab the community from cacti rather than manually enter it?
syzygy is the snmp community name.

I am also stuggling with the permissions. Added user:snmp to postfix and root groups. When i run the getmailq.sh script it returns 0 values. When running the same script under root it works fine.

pologtijaune
Posts: 1
Joined: Mon Sep 17, 2007 2:08 pm

#12 Post by pologtijaune » Mon Sep 17, 2007 2:15 pm

Hi

I have somme problems with this scripts :

Code: Select all

# /usr/bin/snmpwalk -v2c -c COMUNITY IPADDRESS .1.3.6.1.4.1.2021.53.101.0
UCD-SNMP-MIB::ucdavis.53.101.0.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.53.101.0.2.1 = STRING: "mailq"
UCD-SNMP-MIB::ucdavis.53.101.0.3.1 = STRING: "/usr/local/bin/postfix_mailq.sh"
UCD-SNMP-MIB::ucdavis.53.101.0.100.1 = INTEGER: 0
Timeout: No Response from IPADDRESS
On the postfix server :

Code: Select all

# time /usr/local/bin/postfix_mailq.sh
incoming:0 active:34 deferred:2530 hold:0
real    0m4.431s
user    0m1.265s
sys     0m3.368s
What is the problem ?

pheezy
Cacti User
Posts: 59
Joined: Thu Oct 26, 2006 5:30 pm

#13 Post by pheezy » Mon Sep 24, 2007 4:24 pm

You need to prepend your entry in snmpd.conf with /bin/sh

jerome
Posts: 5
Joined: Mon Oct 29, 2007 10:06 am

#14 Post by jerome » Fri Nov 02, 2007 9:50 am

[edit]

Hi,

I've just added this script to my cacti system. The client side works fine. The postfixqueues.sh on cacti server give me correct results but result in cacti are false :

Code: Select all

 ./postfixqueues.sh mail_host
incoming:1 active:8 deferred:19564 hold:0
I'm using Cacti 0.8.6i on Debian Etch.


Any idea ?

Thanks
Jerome
Attachments
postfix_queue_daily.png
postfix_queue_daily.png (25.21 KiB) Viewed 77731 times

monachus
Posts: 42
Joined: Mon Sep 06, 2004 1:27 am
Location: New York, NY
Contact:

#15 Post by monachus » Mon Nov 05, 2007 9:37 pm

if using newer versions of net-snmp, you should use the extend directive instead of the exec directive, which will require some changes to the scripts:

in snmpd.conf:

Code: Select all

extend mailq /usr/local/bin/getmailq.sh

in postfixqueues.sh:

Code: Select all

/usr/bin/snmpget -Oqav -v2c -c<community> -t30 $1 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."mailq".1' | cut -d '"' -f 2
also, in newer versions of postfix, "qshape" has become "qshape.pl." check on your system for the updated version.
Adrian Goins - President / CEO
Arces Network, LLC
http://www.arces.net

Post Reply