Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Sat May 25, 2019 12:35 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Postfix Queues
PostPosted: Wed Oct 04, 2006 4:22 pm 
Offline

Joined: Wed Aug 23, 2006 10:25 pm
Posts: 5
Location: New Zealand
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:
#!/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:
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:
#!/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 7375 times


Last edited by valec on Thu Oct 19, 2006 5:13 pm, edited 1 time in total.
Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 11, 2006 3:58 am 
Offline

Joined: Wed Oct 11, 2006 3:56 am
Posts: 1
Location: Indonesia
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 8:43 am 
Offline
Cacti User

Joined: Thu Aug 17, 2006 10:49 am
Posts: 52
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 10:11 am 
Offline

Joined: Tue Oct 17, 2006 10:09 am
Posts: 23
The data input method includes:

Code:
/bin/bash <path_cacti>/scripts/postfixqueues.sh <Host_IP>


Can you please include this script? thanks :D


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 5:11 pm 
Offline

Joined: Wed Aug 23, 2006 10:25 pm
Posts: 5
Location: New Zealand
Ahh yeah, whoops. I'll do so now.


Top
 Profile  
 
 Post subject: What version
PostPosted: Thu Oct 26, 2006 6:21 pm 
Offline

Joined: Thu Oct 26, 2006 6:19 pm
Posts: 2
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.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 27, 2006 9:03 am 
Offline

Joined: Fri Oct 27, 2006 9:00 am
Posts: 1
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?


Top
 Profile  
 
 Post subject: postfix permissions
PostPosted: Fri Oct 27, 2006 1:45 pm 
Offline

Joined: Thu Oct 26, 2006 6:19 pm
Posts: 2
What is snmpd running as on your machine? Can't you fix it by using group permissions?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 06, 2006 11:14 pm 
Offline

Joined: Wed Dec 06, 2006 11:09 pm
Posts: 3
I've got this problem too:
Code:
# 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:
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]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 18, 2007 11:17 am 
Offline

Joined: Wed Jul 04, 2007 12:57 pm
Posts: 44
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?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 24, 2007 4:34 am 
Offline

Joined: Tue Jul 24, 2007 4:30 am
Posts: 1
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 17, 2007 2:15 pm 
Offline

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

I have somme problems with this scripts :

Code:
# /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:
# 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 ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 24, 2007 4:24 pm 
Offline
Cacti User

Joined: Thu Oct 26, 2006 5:30 pm
Posts: 59
You need to prepend your entry in snmpd.conf with /bin/sh


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 02, 2007 9:50 am 
Offline

Joined: Mon Oct 29, 2007 10:06 am
Posts: 5
[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:
./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 76987 times ]
Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 05, 2007 9:37 pm 
Offline

Joined: Mon Sep 06, 2004 1:27 am
Posts: 42
Location: New York, NY
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:
extend mailq /usr/local/bin/getmailq.sh



in postfixqueues.sh:
Code:
/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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group