Walkthrough on Postifx monitoring with Cacti

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

Moderators: Developers, Moderators

bjwi312
Posts: 3
Joined: Tue Mar 21, 2006 2:30 am

Can't get to the MIB

Post by bjwi312 »

Hey guys,
Just having a bit of trouble browsing to the correct MIB. I'm running a GENTOO box.


/ # snmpwalk -v 2c -c public [computername] .1.3.6.1.4.1.2021.255 UCD-SNMP-MIB::ucdavis.255 = No Such Object available on this agent at this OID

Have I made a mistake or is there an easy way to find out which branch I should be going to.

Cheers
Mathieu
Posts: 12
Joined: Mon Mar 13, 2006 5:40 am
Location: France

Post by Mathieu »

First of all, did you have restarted the snmpd daemon after adding the pass configuration line ?
Secondly, the OID is fixed by the pass configuration line :
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
Here the 1.3.6.1.4.1.2021.255 Oid will be assign to fetch script. You can walk the whole Net-SNMP dedicated tree .1.3.6.1.4.1.2021 if you are not sure of the configuration ![/i]
bjwi312
Posts: 3
Joined: Tue Mar 21, 2006 2:30 am

Post by bjwi312 »

The problem was in my version of the fetch_mail_statistics.pl script file, when I had pasted the txt into vi in the cvs comments the $ symbol was not commented out and this was what was causing the script and everything else not to work.

Thanks for all your help... and I will now walk away with head bowed and my tail between my legs.
dsmooth
Posts: 8
Joined: Fri Mar 17, 2006 2:01 pm

cacti & amavis

Post by dsmooth »

Mathieu, thanks for all the assistance. I finally got it working and in case anyone's interested using snmp to monitor amavis, see http://forums.cacti.net/viewtopic.php?t=3190
giovanni
Posts: 25
Joined: Sat May 20, 2006 8:06 pm

Post by giovanni »

Hi everyone!

Thanks for the perl script, i've changed to fetch also SPF information and seems to work very well.

But one question, the $MINRESET isnt supposed to be 300 seconds ? The time that cacti waits to get updated information ? Or the Data Source/Template is configured to fetch data at 50/50 seconds ?
giovanni
Posts: 25
Joined: Sat May 20, 2006 8:06 pm

Post by giovanni »

Ops! Sorry, i'd confused heartbeat parameter with Step parameter :)

PS: I had to insert the OIDs manually

BTW sorry, bad english! :lol:
sandcrawler
Posts: 1
Joined: Wed May 31, 2006 4:36 pm

No Graphs

Post by sandcrawler »

thought I'd mention this to elaborate on a problem I think Giovanni had.

I had mine up and running and I could use snmpwalk to verify stats were being collected. However, I was getting no graphs. If you meet those criteria, you probably need to go to the console, click on the data templates option, then for each option

Code: Select all

ucd/net - Postfix - Bad Header
ucd/net - Postfix - Banned Content
ETC, you need to manually enter the OID for each query. The OIDs are as follows... this applies to fetch_mail_statistics.pl,v 1.6 2004/11/07

Code: Select all

Bad Header - .1.3.6.1.4.1.2021.255.9  (This applied to bad headers passed and blocked)
Banned Content - .1.3.6.1.4.1.2021.255.10
Bounced - .1.3.6.1.4.1.2021.255.3
Clean - .1.3.6.1.4.1.2021.255.5
Deferred - .1.3.6.1.4.1.2021.255.2
Possible Spam - .1.3.6.1.4.1.2021.255.6
Received - .1.3.6.1.4.1.2021.255.0
Rejected - .1.3.6.1.4.1.2021.255.4
Sent - .1.3.6.1.4.1.2021.255.5.1
Spam - .1.3.6.1.4.1.2021.255.7
Virus - .1.3.6.1.4.1.2021.255.8
Do not check the box just below "oid" where is says Use Per-Data Source Value (Ignore this Value)

Hope this helps someone as much as it helped me :)
bjwi312
Posts: 3
Joined: Tue Mar 21, 2006 2:30 am

Problem with Potential Spam and Spam graphs

Post by bjwi312 »

Hey Guys,
I was having problems with possibly spam and spam being shown on the Mail filtering graph.

So I checked the header information and I realised that my "Hits" was not what my system was using in the X-Spam- header but actually score.

So I have modified the fetch_mail_statistics.pl file. Unfortunatley I really don't care about possible spam... As I rarely find that my setup gets false positives. But hey... no biggie just pass through all mail to my users that under a certain score but wrap it so I preface it that it may be spam. That should keep them happy.

Ok so what code did I change well I basically deleted the lines in the elsif that refer to spam and posible spam and added

elsif ( /score=([-+]?[0-9]*\.?[0-9]+)/) {
$hits = $1;
$num_clean++ if ($hits < $SPAMLVL);
$num_spam++ if ($hits >= $SPAMLVL);
}

That way the num clean increments and the number that spam increment.

If you want to check syntax on your own box or check certain things use this script

#! /usr/bin/perl -W

$temp = 0;
$SPAMLVL = 6.3;

print "opening file\n";
open (TEMP, "/var/log/amavis.log") or die "can't open file \n";

while ( <TEMP> ){

#print $_;

if( /score=([-+]?[0-9]*\.?[0-9]+)/) {
$temp++ if ($1 >= $SPAMLVL);
#print $2;

#print "\n";
#$temp = $temp + $0;
}
}
print $temp;

Just modify the if as need be and the componenets you want to search for. I have left a couple of test print statments in the loop just uncomment them as need be. Please also don't forget to change the log file that you are using.

Thanks for the great scripts and posts by everyone I have found it really helpful and currently have a fully working system that use Postfix, Amavis, ClamAV, DCC, pyzor, LDAP, MYSQL, Spamassasin and Cacti. I can now monitor both my Postfix and Amavis to see what is really going on in the system.

Hopefully before my contract is up I will be working on a per/domain monitoring system. If I get it to work in time I will post it.
@ryaz
Posts: 14
Joined: Wed May 31, 2006 3:34 pm
Location: France

[newbie with postfix]

Post by @ryaz »

Hello,

my MTA is postfix, but i don't find my /var/log/mailstats.db...
Where (or in which config file) do i find this file?

I found : /etc/postfix/access.db...

Regards,
Mathieu
Posts: 12
Joined: Mon Mar 13, 2006 5:40 am
Location: France

Post by Mathieu »

Hi ryaz, the mailstat.db file is created by the Perl script called fetch_mail_statistics.pl.

You must first call the script by hand to get the file created or configure snmpd with a line like the below example and then walk throught the OID thanks to snmpwalk.

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
Hope this will help you a little.

Mathieu[/b]
nuber
Posts: 3
Joined: Wed Jul 12, 2006 10:51 pm

Post by nuber »

I have followed Instigater's instructions, but have been unable to maintain the statistics in SNMP. The only way I've been able to get it to work is by first doing this on the mail server:

Code: Select all

/etc/snmp/fetch_mail_statistics.pl /var/log/mail.log /var/log/mailstats.db .1.3.6.1.4.1.2021.255 -g .1.3.6.1.4.1.2021.255
Upon running that piece of code, it shows the following in SNMP:

Code: Select all

snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.255
UCD-SNMP-MIB::ucdavis.255.0 = INTEGER: 5
UCD-SNMP-MIB::ucdavis.255.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.255.2 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.255.3 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.255.4 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.255.5 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.255.6 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.255.7 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.255.8 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.255.9 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.255.10 = INTEGER: 0
However, that information is quickly deleted for some reason (MINRESET?).

Therefore, after that information expires, the poller generates the following error which was documented earlier in this thread.

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.0

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
Anyone have some ideas on what I might be doing wrong?

Thanks ahead of time!
Mathieu
Posts: 12
Joined: Mon Mar 13, 2006 5:40 am
Location: France

Post by Mathieu »

You migth have done some modification on the fetch perl script. Could you attach your version of the script to a forum post ?

For your question on $MINRESET script variable, here is a brief description on how it is used in the script .

Begin Script

Compute TimeSinceLastUpdate
If TimeSinceLastUpdate > $MINRESET
Compute NewStatistics
Store NewStatistics Into Dbfile
End If

Load Statistics Out of Dbfile
Print Statistics

End Script


Mathieu
@ryaz
Posts: 14
Joined: Wed May 31, 2006 3:34 pm
Location: France

Post by @ryaz »

Hello, i have one question for you :

- the poller.php of cacti runs all 5 minutes, well what changement/modification to do in my fetch_mail_statistics.pl ?

thanks
Mathieu
Posts: 12
Joined: Mon Mar 13, 2006 5:40 am
Location: France

Post by Mathieu »

In my script MINRES = 50.
It means that is DbFile last modification date is past by more than 50s the statistics are recomputed.
@ryaz
Posts: 14
Joined: Wed May 31, 2006 3:34 pm
Location: France

Post by @ryaz »

thank you, and acoording to you what would be the best value for me?

I'am certainly stupid,the value must be 5*60?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest