Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


Postfix Queues
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
valec



Joined: 23 Aug 2006
Posts: 5
Location: New Zealand

PostPosted: Wed Oct 04, 2006 4:22 pm    Post subject: Postfix Queues Reply with quote

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.




cacti_graph_template_postfix_queues.xml
 Description:

Download
 Filename:  cacti_graph_template_postfix_queues.xml
 Filesize:  17.4 KB
 Downloaded:  3314 Time(s)



Last edited by valec on Thu Oct 19, 2006 5:13 pm; edited 1 time in total
Back to top
masdani



Joined: 11 Oct 2006
Posts: 1
Location: Indonesia

PostPosted: Wed Oct 11, 2006 3:58 am    Post subject: Reply with quote

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
Back to top
Keene44
Cacti User


Joined: 17 Aug 2006
Posts: 52

PostPosted: Fri Oct 13, 2006 8:43 am    Post subject: Reply with quote

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.
Back to top
sloop



Joined: 17 Oct 2006
Posts: 14

PostPosted: Tue Oct 17, 2006 10:11 am    Post subject: Reply with quote

The data input method includes:

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


Can you please include this script? thanks
Back to top
valec



Joined: 23 Aug 2006
Posts: 5
Location: New Zealand

PostPosted: Thu Oct 19, 2006 5:11 pm    Post subject: Reply with quote

Ahh yeah, whoops. I'll do so now.
Back to top
cscott



Joined: 26 Oct 2006
Posts: 2

PostPosted: Thu Oct 26, 2006 6:21 pm    Post subject: What version Reply with quote

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.
Back to top
mdvz0r



Joined: 27 Oct 2006
Posts: 1

PostPosted: Fri Oct 27, 2006 9:03 am    Post subject: Reply with quote

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?
Back to top
cscott



Joined: 26 Oct 2006
Posts: 2

PostPosted: Fri Oct 27, 2006 1:45 pm    Post subject: postfix permissions Reply with quote

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



Joined: 06 Dec 2006
Posts: 3

PostPosted: Wed Dec 06, 2006 11:14 pm    Post subject: Reply with quote

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]
Back to top
MoreDakka



Joined: 04 Jul 2007
Posts: 31

PostPosted: Wed Jul 18, 2007 11:17 am    Post subject: Reply with quote

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?
Back to top
zoemdoef



Joined: 24 Jul 2007
Posts: 1

PostPosted: Tue Jul 24, 2007 4:34 am    Post subject: Reply with quote

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.
Back to top
pologtijaune



Joined: 17 Sep 2007
Posts: 1

PostPosted: Mon Sep 17, 2007 2:15 pm    Post subject: Reply with quote

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 ?
Back to top
pheezy
Cacti User


Joined: 26 Oct 2006
Posts: 54

PostPosted: Mon Sep 24, 2007 4:24 pm    Post subject: Reply with quote

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



Joined: 29 Oct 2007
Posts: 5

PostPosted: Fri Nov 02, 2007 9:50 am    Post subject: Reply with quote

[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



postfix_queue_daily.png
 Description:
 Filesize:  25.21 KB
 Viewed:  18420 Time(s)

postfix_queue_daily.png


Back to top
monachus



Joined: 06 Sep 2004
Posts: 30
Location: New York, NY

PostPosted: Mon Nov 05, 2007 9:37 pm    Post subject: Reply with quote

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.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 



Powered by phpBB © 2001, 2005 phpBB Group