Walkthrough on Postifx monitoring with Cacti

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

Moderators: Moderators, Developers

Author
Message
nduda78
Cacti User
Posts: 106
Joined: Tue Mar 01, 2005 11:26 am
Contact:

Walkthrough on Postifx monitoring with Cacti

#1 Post by nduda78 » Wed Mar 02, 2005 2:29 pm

Can someone post a step by step walk through on getting Postfix info (over SNMP perhaps?) to a cacti server and graph it. This should be for recieved, sent, bounced....etc

A search on the forums and google/news gives nothing on how to accompkish this in a step by step.

Thanks,
Nick

User avatar
Instigater
Cacti User
Posts: 141
Joined: Mon Dec 13, 2004 5:14 pm
Location: Jurmala, Latvia

#2 Post by Instigater » Thu Dec 15, 2005 9:24 am

I could make templates but I don't know which OIDs should be used better. I made script that reports:
received
sent
clean
viruses
bounced
deffered
rejected
through SNMP. I don't know which would be the best place to mount this data in SNMP tree that does not conflict with other data.

User avatar
gandalf
Developer
Posts: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

#3 Post by gandalf » Fri Dec 16, 2005 12:39 pm

Moved to Scripts and Templates
Reinhard

User avatar
Instigater
Cacti User
Posts: 141
Joined: Mon Dec 13, 2004 5:14 pm
Location: Jurmala, Latvia

#4 Post by Instigater » Mon Dec 19, 2005 3:40 am

Almost done, found some bugs, fixing and testing right away.

User avatar
Instigater
Cacti User
Posts: 141
Joined: Mon Dec 13, 2004 5:14 pm
Location: Jurmala, Latvia

#5 Post by Instigater » Mon Dec 19, 2005 8:22 am

Fixed, tested, looks nice and right :D

Installation:
1) Configure SNMP agent on Mail server and make sure it is set up right.
2) Unzip fetch_mail_statistics.pl script in place of your choice. (I used /usr/local/bin)
3) Check that your perl path in script points to perl executable
4) Add following line in snmpd.conf file

Code: Select all

pass .1.3.6.1.4.1.2021.255 /usr/local/bin/fetch_mail_statistics.pl /var/log/mail.log /var/log/mailstats.db .1.3.6.1.4.1.2021.255
5) Adjust your maillog filename and path corresponding to your system. mailstats.db are used for internal script data storage, place it anywhere.
6) Import template in cacti.

Script proudly stolen from
http://netilium.org/~mad/technotes/postfixstat/
some code ideas inspired from
http://people.ee.ethz.ch/~dws/software/mailgraph/

NB! Script is based on one minute polling interval, adjustments must be made to run on default Cacti installation. This template also updates Yearly (1 day average) RRA, so be careful.
Attachments
postfix_mailserver.tar.gz
Download this, the first one had some bugs in perl.
(7.11 KiB) Downloaded 10850 times
Last edited by Instigater on Mon Jun 19, 2006 7:32 am, edited 1 time in total.

typera
Posts: 1
Joined: Mon Jan 02, 2006 1:18 pm

#6 Post by typera » Mon Jan 02, 2006 1:20 pm

Instigater wrote:Fixed, tested, looks nice and right :D

Installation:
1) Configure SNMP agent on Mail server and make sure it is set up right.
2) Unzip fetch_mail_statistics.pl script in place of your choice. (I used /usr/local/bin)
3) Check that your perl path in script points to perl executable
4) Add following line in snmpd.conf file

Code: Select all

pass .1.3.6.1.4.1.2021.255 /usr/local/bin/fetch_mail_statistics.pl /var/log/mail.log /var/log/mailstats.db .1.3.6.1.4.1.2021.255
5) Adjust your maillog filename and path corresponding to your system. mailstats.db are used for internal script data storage, place it anywhere.
6) Import template in cacti.

Script proudly stolen from
http://netilium.org/~mad/technotes/postfixstat/
some code ideas inspired from
http://people.ee.ethz.ch/~dws/software/mailgraph/

NB! Script is based on one minute polling interval, adjustments must be made to run on default Cacti installation. This template also updates Yearly (1 day average) RRA, so be careful.
Hi Instigater,

thank you for posting this. As being a novice to the cacti/rrdtool could you please let me know what exactly I need to change to make this suitable for a 5 min refresh intervals. ?

Cheers,
Max

epoch
Posts: 2
Joined: Wed Jan 18, 2006 11:58 am

error when importing xml template

#7 Post by epoch » Wed Jan 18, 2006 4:53 pm

When trying to import cacti_host_template_postfix_mailserver.xml I get the following error:

Code: Select all

Notice: Only variable references should be returned by reference in /var/www/localhost/htdocs/cacti/lib/import.php on line 44

Warning: Cannot modify header information - headers already sent by (output started at /var/www/localhost/htdocs/cacti/lib/import.php:44) in /var/www/localhost/htdocs/cacti/templates_import.php on line 67
Anyone have any ideas on what can be done to fix this? I am using cacti 0.8.6f on Gentoo.

Thanks Much!

davidwoo
Posts: 7
Joined: Fri Oct 07, 2005 12:42 pm

#8 Post by davidwoo » Thu Jan 26, 2006 10:43 pm

Dear typera

Can you create one item? DISCARD

Thank you so much.

epoch
Posts: 2
Joined: Wed Jan 18, 2006 11:58 am

Re: error when importing xml template

#9 Post by epoch » Wed Feb 01, 2006 4:33 pm

I was able to get the template to import once I upgraded to the latest version of Cacti. I am now running into another issue. The postfix graphs do not seem to be updating properly. I get partial lines drawn for sent messages. Basically, the sent graph line will appear in segments across the graph. Anyone have any ideas as to why this is happening?
epoch wrote:When trying to import cacti_host_template_postfix_mailserver.xml I get the following error:

Code: Select all

Notice: Only variable references should be returned by reference in /var/www/localhost/htdocs/cacti/lib/import.php on line 44

Warning: Cannot modify header information - headers already sent by (output started at /var/www/localhost/htdocs/cacti/lib/import.php:44) in /var/www/localhost/htdocs/cacti/templates_import.php on line 67
Anyone have any ideas on what can be done to fix this? I am using cacti 0.8.6f on Gentoo.

Thanks Much!

rfuller
Posts: 5
Joined: Fri Feb 03, 2006 12:42 pm

#10 Post by rfuller » Thu Feb 09, 2006 1:38 pm

EDIT: Never mind it was because I had amavis changed to do everything local and the script filters out localhost.

I had everything up and working great...then I installed syslog-ng and only filtering shows up now. Anyone have any ideas? using postfix/amavis/clamd/spamassassin.
Here is the maillog portion of my syslog-ng.conf:

destination d_mail { file("/var/log/maillog" sync(10)); };
source s_local { internal(); file("/proc/kmsg" log_prefix("kernel: ")); unix-dgram("/dev/log"); };
filter f_filter4 { facility(mail); };
log { source(s_local); filter(f_filter4); destination(d_mail); };

francismcphail
Posts: 2
Joined: Mon May 10, 2004 1:21 am

#11 Post by francismcphail » Sun Feb 12, 2006 11:16 pm

I've gone though the steps as listed above, and have the following error when I manually run the poller.

Anyone have any ideas?

Code: Select all

Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: .1.3.6.1.4.1.2021.255.3

Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: .1.3.6.1.4.1.2021.255.2

OK u:0.00 s:0.00 r:0.01
OK u:0.00 s:0.00 r:0.01
OK u:0.00 s:0.00 r:0.01
OK u:0.00 s:0.00 r:0.01
OK u:0.00 s:0.00 r:0.01
OK u:0.00 s:0.00 r:0.01
OK u:0.00 s:0.00 r:0.01
OK u:0.00 s:0.00 r:0.01
OK u:0.00 s:0.00 r:0.01
OK u:0.00 s:0.00 r:0.01
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: .1.3.6.1.4.1.2021.255.0

OK u:0.00 s:0.00 r:0.06
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: .1.3.6.1.4.1.2021.255.4

Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: .1.3.6.1.4.1.2021.255.1

Content-type: text/html
X-Powered-By: PHP/4.3.2

02/13/2006 03:12:50 PM - SYSTEM STATS: Time:2.1098 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:18 RRDsProcessed:14
OK u:0.00 s:0.00 r:1.08
OK u:0.00 s:0.00 r:1.08
OK u:0.00 s:0.00 r:1.08

User avatar
Instigater
Cacti User
Posts: 141
Joined: Mon Dec 13, 2004 5:14 pm
Location: Jurmala, Latvia

#12 Post by Instigater » Mon Feb 13, 2006 8:58 am

Did you configure SNMP agent on mailserver?
Does perl script have right permisions?

User avatar
Instigater
Cacti User
Posts: 141
Joined: Mon Dec 13, 2004 5:14 pm
Location: Jurmala, Latvia

Re: error when importing xml template

#13 Post by Instigater » Mon Feb 13, 2006 9:00 am

epoch wrote:I was able to get the template to import once I upgraded to the latest version of Cacti. I am now running into another issue. The postfix graphs do not seem to be updating properly. I get partial lines drawn for sent messages. Basically, the sent graph line will appear in segments across the graph. Anyone have any ideas as to why this is happening?
...
Your mailserver is not busy enough. ;-) Only mailservers of ISPs or popular webmail servers will have enough mail traffic to generate lines.

kharford
Cacti User
Posts: 50
Joined: Thu Jul 07, 2005 11:53 am
Location: Mass, USA

Any Ideas??

#14 Post by kharford » Wed Feb 15, 2006 2:36 pm

I am having problems displaying data in Cacti for Postfix Mailstats.

I am using the fetch_mail_statistics.pl script and grabbing the data via SNMP. I am using a loghost to log all my postfix mail data. I am running the fetch script on the loghost.

Here is the output of my logfile:

02/15/2006 01:20:05 PM - CMDPHP: Poller[0] Host[2] DS[41] SNMP: v1: loghost3, dsname: postfix_sent, oid: .1.3.6.1.4.1.2021.255.1, output: 84004
02/15/2006 01:20:05 PM - CMDPHP: Poller[0] Host[2] DS[40] SNMP: v1: loghost3, dsname: postfix_reject, oid: .1.3.6.1.4.1.2021.255.4, output: 0
02/15/2006 01:20:05 PM - CMDPHP: Poller[0] Host[2] DS[39] SNMP: v1: loghost3, dsname: postfix_recv, oid: .1.3.6.1.4.1.2021.255.0, output: 0
02/15/2006 01:20:05 PM - CMDPHP: Poller[0] Host[2] DS[38] SNMP: v1: loghost3, dsname: postfix_deferred, oid: .1.3.6.1.4.1.2021.255.2, output: 14062
02/15/2006 01:20:05 PM - CMDPHP: Poller[0] Host[2] DS[37] SNMP: v1: loghost3, dsname: postfix_bounced, oid: .1.3.6.1.4.1.2021.255.3, output: 4076




This data never makes it to my graph.

Any ideas??

Ken
Attachments
Mail-Stats.JPG
Mail-Stats.JPG (82 KiB) Viewed 104125 times

vinx
Posts: 18
Joined: Mon Mar 06, 2006 12:02 pm

#15 Post by vinx » Mon Mar 06, 2006 12:05 pm

Hello,
I tried to import template but I got the following error:

Error: XML: Hash version does not exist

I run Cacti 0.8.6c on Debian Sarge.

Post Reply