Walkthrough on Postifx monitoring with Cacti
Moderators: Developers, Moderators
I had a look on fetch_mail_statistics.pl script:
Il looks for the above strings on maillog.
I searched above strings on mail.log, but there are no entries in file. I'm using amavis for email filtering.
Code: Select all
while( <LOGFILE> ) {
if ( / postfix\/smtpd/ && /client=/ && ! /127.0.0.1/ ) { $num_rec++; }
elsif ( /status=sent/ && ! /relay=(mailfilter|procmail|local|127.0.0.1)/ ) { $num_sent++; }
elsif ( /status=deferred/ ) { $num_deferred++; }
elsif ( /status=bounced/ ) { $num_bounced++; }
elsif ( /: NOQUEUE: reject: / ) { $num_reject++; }
elsif ( / Passed CLEAN/ ) { $num_clean++; }
elsif ( / Passed SPAM/ ) { $num_pspam++; }
elsif ( / Blocked SPAM/ ) { $num_spam++; }
elsif ( / Blocked INFECTED/ ) { $num_infected++; }
elsif ( / Passed BAD-HEADER/ ) { $num_header++; }
elsif ( / Blocked BAD-HEADER/ ) { $num_header++; }
elsif ( / Blocked BANNED/ ) { $num_banned++; }
I searched above strings on mail.log, but there are no entries in file. I'm using amavis for email filtering.
Hi there,
i made this script work for my configuration of Postfix/ClamAv/Amavisd-New/SpamAssasin this morning (i am using a Sarge Debian fully upgraded). I had to modify both amavisd logformat and fetch_mail_statistics.pl scripts. Here are my modifications :
/etc/amavisd/amavisd.conf
fetch_mail_statistics.pl
To use this modification, you must add at the beginning of the script a SPAMLVL variable with your local value. You can find this value in /etc/amavisd/amavisd.conf if you look for
Here is an exemple of such a line :
I hope this will help...
Mathieu
i made this script work for my configuration of Postfix/ClamAv/Amavisd-New/SpamAssasin this morning (i am using a Sarge Debian fully upgraded). I had to modify both amavisd logformat and fetch_mail_statistics.pl scripts. Here are my modifications :
/etc/amavisd/amavisd.conf
Code: Select all
$log_templ = '[?%#D|Not-Delivered|Passed] [? %#V |[? %#F |[? %#X |CLEAN|BAD-HEADER]|BANNED name/type (%F)]|INFECTED (%V)], #
[?%o|(?)|<%o>] -> [<%R>|,][? %i ||, quarantine %i], Message-ID: %m, Hits: %c';
Code: Select all
while( <LOGFILE> ) {
if ( / postfix\/smtpd/ && /client=/ && ! /127.0.0.1/ ) { $num_rec++; }
elsif ( /status=sent/ && ! /relay=(mailfilter|procmail|local|127.0.0.1)/ ) { $num_sent++; }
elsif ( /status=deferred/ ) { $num_deferred++; }
elsif ( /status=bounced/ ) { $num_bounced++; }
elsif ( /: NOQUEUE: reject: / ) { $num_reject++; }
elsif ( / Passed CLEAN/ && /Hits: ([-+]?[0-9]*\.?[0-9]+)/) {
$hits = $1;
$num_clean++ if ($hits < $tag_level);
$num_pspam++ if ($hits > $tag_level);
}
elsif ( / Not-Delivered CLEAN/ && /Hits: ([-+]?[0-9]*\.?[0-9]+)/) {
$hits = $1;
$num_clean++ if ($hits < $tag_level);
$num_spam++ if ($hits > $tag_level);
}
elsif ( / Passed INFECTED/ ) { $num_infected++; }
elsif ( / Not-Delivered INFECTED/ ) { $num_infected++; }
elsif ( / Passed BAD-HEADER/ ) { $num_header++; }
elsif ( / Not-Delivered BAD-HEADER/ ) { $num_header++; }
elsif ( / Blocked BANNED/ ) { $num_banned++; }
elsif ( / Not-Delivered BANNED/ ) { $num_banned++; }
}
To use this modification, you must add at the beginning of the script a SPAMLVL variable with your local value. You can find this value in /etc/amavisd/amavisd.conf if you look for
parameter.$tag2_level
Here is an exemple of such a line :
Code: Select all
$SPAMLVL = 2.0;
Mathieu
- Attachments
-
- fetch_mail_statistics.txt
- Here is my version of fetch_mail_statistics.pl script for Debian users. It relies on particular amavisd log configuration :
$log_templ = '[?%#D|Not-Delivered|Passed] [? %#V |[? %#F |[? %#X |CLEAN|BAD-HEADER]|BANNED name/type (%F)]|INFECTED (%V)], #
[?%o - (5.97 KiB) Downloaded 1695 times
Mathieu,Mathieu wrote: To use this modification, you must add at the beginning of the script a SPAMLVL variable with your local value. You can find this value in /etc/amavisd/amavisd.conf if you look forparameter.$tag2_level
Here is an exemple of such a line :MathieuCode: Select all
$SPAMLVL = 2.0;
thanks for your help, but I cannot find such value in my amavid.conf file.
could please attach your amavisd.conf file to let me compare mine?
merci,
a bientôt
Did you use SpamAssassin as anti spam software with amavisd ?
My post was not enougth detailed : it is the $sa_tag2_level_deflt parameter that you must look for.
Here is an extract of my configuration :
Mathieu
My post was not enougth detailed : it is the $sa_tag2_level_deflt parameter that you must look for.
Here is an extract of my configuration :
Code: Select all
# default values, can be overridden by more specific lookups, e.g. SQL
$sa_tag_level_deflt = -999; # add spam info headers if at, or above that level
$sa_tag2_level_deflt = 2.0; # add 'spam detected' headers at that level
fetch_mail_statistics.pl requires 5 parameters, but there are only 3 here. Any idea how to get it work? I tried your posted version as well...Instigater wrote:Fixed, tested, looks nice and right
Installation:
....
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
monitoring 2 instances of postfix on the same box?
Thanks for the PF monitoring with Cacti.
I had it working in a short time.
How can I monitor a 2nd instance of PF on the same box? I have 2 PF instance setups:
/etc/postfix
/etc/postfix-outbound
The *outbound* is for relay for outbound email only.
What changes are needed?
TIA
Dave
I had it working in a short time.
How can I monitor a 2nd instance of PF on the same box? I have 2 PF instance setups:
/etc/postfix
/etc/postfix-outbound
The *outbound* is for relay for outbound email only.
What changes are needed?
TIA
Dave
ack
so you got that perl script running already?! rats... i seem to be having trouble as the script demands 5 parameters, but the instructions only provide three! Maybe you could PM me any details or edits you had to make?
For your PF#2... you could have it log to a separate log file (e.g. /var/log/maillogOB) then parse it separately.
For your PF#2... you could have it log to a separate log file (e.g. /var/log/maillogOB) then parse it separately.
To monitor 2 Postfix Instance You will have to change the snmpd pass setting to use an alternative OID ( dont use the .255 one but the .254 for example).
You will have to change the DataSource template to pass the new snmp OID.
I see that someone complains about a wrong number of arguments with fetch_statistis Perl script: in my memory the 2 last argument are optional or passed by snmpd, i'll check this tomorrow and give you a full detailed answer with example extracted from my configuration.
You will have to change the DataSource template to pass the new snmp OID.
I see that someone complains about a wrong number of arguments with fetch_statistis Perl script: in my memory the 2 last argument are optional or passed by snmpd, i'll check this tomorrow and give you a full detailed answer with example extracted from my configuration.
I would really appreciate that; thank you...I see that someone complains about a wrong number of arguments with fetch_statistis Perl script: in my memory the 2 last argument are optional or passed by snmpd, i'll check this tomorrow and give you a full detailed answer with example extracted from my configuration.
Hi dsmooth,
On my snmpd pass configuration line, i only have 3 argument after the script name. Here is the extract :
As i thought, it is the snmpd daemon that pass the 2 more arguments to the script. Here is an extract of snmpd.conf manpage explaining the process:
Mathieu
On my snmpd pass configuration line, i only have 3 argument after the script name. Here is the extract :
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
As i thought, it is the snmpd daemon that pass the 2 more arguments to the script. Here is an extract of snmpd.conf manpage explaining the process:
You can simply check that the pass configuration line is working by executing the following command from a local or remote host ( note that you have to adjust it for your personnal snmpd authentication configuration is your are not using SNMP V1 Community Authentification):PASS-THROUGH CONTROL
pass MIBOID EXEC
(If you're writing perl scripts, please see the embedded perl
support information later in this manual page). Passes entire
control of MIBOID to the EXEC program. The EXEC program is
called in one of the following three ways:
EXEC -g MIBOID
EXEC -n MIBOID
These call lines match to SNMP get and getnext requests.
It is expected that the EXEC program will take the argu-
ments passed to it and return the appropriate response
through it's stdout.
Here is the result of such a command on my system :snmpwalk -v 1 -c public <host> .1.3.6.1.4.1.2021.255
On more test can be to call the fectch script as snmpd would :computer01:/home/math# snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.255
UCD-SNMP-MIB::ucdavis.255.0 = INTEGER: 21
UCD-SNMP-MIB::ucdavis.255.1 = INTEGER: 21
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: 21
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
I hope that will help !computer01:/usr/local/bin# ./fetch_mail_statistics.pl /var/log/mail.log /var/log/mailstats.db .1.3.6.1.4.1.2021.255 -n .1.3.6.1.4.1.2021.255.1
.1.3.6.1.4.1.2021.255.2
integer
0
Mathieu
ah! ok. I have the following values:Mathieu wrote:Did you use SpamAssassin as anti spam software with amavisd ?
My post was not enougth detailed : it is the $sa_tag2_level_deflt parameter that you must look for.
Here is an extract of my configuration :MathieuCode: Select all
# default values, can be overridden by more specific lookups, e.g. SQL $sa_tag_level_deflt = -999; # add spam info headers if at, or above that level $sa_tag2_level_deflt = 2.0; # add 'spam detected' headers at that level
Code: Select all
$sa_tag_level_deflt = 3.0; # add spam info headers if at, or above that level
$sa_tag2_level_deflt = 4.0; # add 'spam detected' headers at that level
You configuration mean that :
You just have to set $SPAMLVL = 4.0 ; and it must work. In fine, $SPAMLVL = ' the value of $sa_tag2_level_deflt in /etc/amavisd/amavisd.conf';
Hope this will help too.
Mathieu
- - mail with SpamAssasin hitscore below 3.0 will not be tagged as 'spam analyzed'
- mail with SpamAssasin hitscore between 3.0 and 4.0 will be tagged as 'spam analyzed'
- mail with SpamAssasin hitscore above 4.0 will be tagged as 'spam detected'
You just have to set $SPAMLVL = 4.0 ; and it must work. In fine, $SPAMLVL = ' the value of $sa_tag2_level_deflt in /etc/amavisd/amavisd.conf';
Hope this will help too.
Mathieu
Who is online
Users browsing this forum: No registered users and 0 guests