Walkthrough on Postifx monitoring with Cacti

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

Moderators: Developers, Moderators

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

Post by Mathieu »

In my opinon, all the values for MINRES are good if they meet the following requierement :

MINRES < pooling period

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

Post by @ryaz »

hello, it's again me...sorry to bother you again :)

Well, i attentively read the perl script and i saw that the maillog file is cleanly scan with the perl fonctions tell() and seek() : $MINRES=50s means that the values collected are in the format : "msgs / 50s" instead of "msgs / 60s"?no?

With my cacti's config (polling all 5 minutes) :
-> I think the value of $MINRES must be exactly 5*60 = 300 secondes
-> And to have a format in "mgs/minutes" in the graphs i have to divise all the values by 6?no?

grrr! I can't make head or tail of it

EDIT: i think it's OK
To get a good estimation of "msgs/60s" i wrote :
$MINRES=60 (and the cacti's polling is always 5 minutes)



Thanks
Last edited by @ryaz on Sat Jul 15, 2006 5:35 am, edited 2 times in total.
nuber
Posts: 3
Joined: Wed Jul 12, 2006 10:51 pm

Post by nuber »

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

Mathieu
Mathieu, I have made no modification to the original script posted on this thread. For some reason, when I run the script manually, I can then do an snmpwalk to view the statistics. After the MINRESET expires, those statistics are no longer accessible via snmpwalk.

The problem I can't seem to solve is getting it to work in the snmpd.conf. I use the "pass" directive the way the instructions show, but for some reason everytime I do the snmpwalk to the OID, it doesn't give me any results.

Any ideas?
Giorgio
Posts: 21
Joined: Wed Jun 21, 2006 3:28 am

Post by Giorgio »

@ryaz wrote:hello, it's again me...sorry to bother you again :)

Well, i attentively read the perl script and i saw that the maillog file is cleanly scan with the perl fonctions tell() and seek() : $MINRES=50s means that the values collected are in the format : "msgs / 50s" instead of "msgs / 60s"?no?

With my cacti's config (polling all 5 minutes) :
-> I think the value of $MINRES must be exactly 5*60 = 300 secondes
-> And to have a format in "mgs/minutes" in the graphs i have to divise all the values by 6?no?

grrr! I can't make head or tail of it

EDIT: i think it's OK
To get a good estimation of "msgs/60s" i wrote :
$MINRES=60 (and the cacti's polling is always 5 minutes)



Thanks
Hi @riaz,

First sorry for my english, i try to improve it :D

I do a test. I install a simple postfix on a test environment. I put logs manually in postfix logs.

If you have 1 message sent in the first minute and 1 message sent in the last minute before cacti run the poll you will collecte 2 messages sent. So $MINRES don't occur.

But if you have 1 message sent in the first minute and you call the script (manually for example) you will collect 1 message sent during 50s (if you call the script few times in 50s).

So at the 2nd minutes you will have 0 message sent.

I don't know if you understand. I think it's the explication you can test it and send me an email to confirm this.

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

Post by @ryaz »

Giorgio wrote: Hi @riaz,

First sorry for my english, i try to improve it :D

I do a test. I install a simple postfix on a test environment. I put logs manually in postfix logs.

If you have 1 message sent in the first minute and 1 message sent in the last minute before cacti run the poll you will collecte 2 messages sent. So $MINRES don't occur.

But if you have 1 message sent in the first minute and you call the script (manually for example) you will collect 1 message sent during 50s (if you call the script few times in 50s).

So at the 2nd minutes you will have 0 message sent.

I don't know if you understand. I think it's the explication you can test it and send me an email to confirm this.

regards!
hello thanks for the reply giorgio!
i don't understand all you say... sorry.

my configuration is ok (for good) :
$MINRES= 298 (nearly 5 minutes like my cacti's polling)

in my graph the scale is simply : msgs / 5 minutes !

now i try to get, in the legend of the cacti's graph, the total of the messages (sent, receive, spam...) near current, average and maximum...i don't really see how to do...

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

Post by @ryaz »

Hello!
In fact, i think i don't really understand the end of the fetch_mail_statistics.pl script. Anyone could help me please?
thanks.

Code: Select all

# Return archived data.
open( DBFILE, $dbFile ) || die( "Cannot open db file `".$dbFile."'!" );
@data = ();
while( <DBFILE> ) { chomp; push @data, $_; }

$reqMethod = $ARGV[3];
$reqOid    = $ARGV[4];

if ( $reqMethod eq "-n" ) {
  # SNMP getNext request.
  if ( $reqOid eq $baseOid ) {
    print $baseOid.".0\ninteger\n".$data[1]."\n";
  } elsif ( $reqOid eq $baseOid.".0" ) {
    print $baseOid.".1\ninteger\n".$data[2]."\n";
  } elsif ( $reqOid eq $baseOid.".1" ) {
    print $baseOid.".2\ninteger\n".$data[3]."\n";
  } elsif ( $reqOid eq $baseOid.".2" ) {
    print $baseOid.".3\ninteger\n".$data[4]."\n";
  } elsif ( $reqOid eq $baseOid.".3" ) {
    print $baseOid.".4\ninteger\n".$data[5]."\n";
  } elsif ( $reqOid eq $baseOid.".4" ) {
    print $baseOid.".5\ninteger\n".$data[6]."\n";
  } elsif ( $reqOid eq $baseOid.".5" ) {
    print $baseOid.".6\ninteger\n".$data[7]."\n";
  } elsif ( $reqOid eq $baseOid.".6" ) {
    print $baseOid.".7\ninteger\n".$data[8]."\n";
  } elsif ( $reqOid eq $baseOid.".7" ) {
    print $baseOid.".8\ninteger\n".$data[9]."\n";
  } elsif ( $reqOid eq $baseOid.".8" ) {
    print $baseOid.".9\ninteger\n".$data[10]."\n";
  } elsif ( $reqOid eq $baseOid.".9" ) {
    print $baseOid.".10\ninteger\n".$data[11]."\n";
  }
} elsif ( $reqMethod eq "-g" ) {
  # SNMP get request.
  if ( $reqOid eq $baseOid || $reqOid eq $baseOid.".0" ) {
    print $baseOid.".0\ninteger\n".$data[1]."\n";
  } elsif( $reqOid eq $baseOid.".1" ) {
    print $baseOid.".1\ninteger\n".$data[2]."\n";
  } elsif( $reqOid eq $baseOid.".2" ) {
    print $baseOid.".2\ninteger\n".$data[3]."\n";
  } elsif( $reqOid eq $baseOid.".3" ) {
    print $baseOid.".3\ninteger\n".$data[4]."\n";
  } elsif( $reqOid eq $baseOid.".4" ) {
    print $baseOid.".4\ninteger\n".$data[5]."\n";
  } elsif( $reqOid eq $baseOid.".5" ) {
    print $baseOid.".5\ninteger\n".$data[6]."\n";
  } elsif( $reqOid eq $baseOid.".6" ) {
    print $baseOid.".6\ninteger\n".$data[7]."\n";
  } elsif( $reqOid eq $baseOid.".7" ) {
    print $baseOid.".7\ninteger\n".$data[8]."\n";
  } elsif( $reqOid eq $baseOid.".8" ) {
    print $baseOid.".8\ninteger\n".$data[9]."\n";
  } elsif( $reqOid eq $baseOid.".9" ) {
    print $baseOid.".9\ninteger\n".$data[10]."\n";
  } elsif( $reqOid eq $baseOid.".10" ) {
    print $baseOid.".10\ninteger\n".$data[11]."\n";
  }
}
fozzy
Cacti User
Posts: 54
Joined: Mon Jan 09, 2006 11:33 am
Location: SE of LIML
Contact:

Post by fozzy »

very nice got it working without too much problems... thanks.

Has anybody gotten this to work together with sophos pure message for unix to get spam and virus counts too?

Thank you, Luca
fozzy
Cacti User
Posts: 54
Joined: Mon Jan 09, 2006 11:33 am
Location: SE of LIML
Contact:

Post by fozzy »

has anybody made a SUM function to show the toal received / sent emails in the graph timeperiod? i tried starting from the |sum:auto:current:2:auto| which is used for bandwidth but it doesn't seem to work... i get very high numbers...

Thank you, Luca

EDIT: problem is it takes te value for each second so the total needs to be divided by 300. :)
idledk
Posts: 1
Joined: Wed Sep 27, 2006 2:15 am

Problem getting it to work

Post by idledk »

Hi, I have been playing around, trying to get the script to work.
snmpwalk -v 1 -c public <host> .1.3.6.1.4.1.2021.255
The funny thing is that is I do a snmpwalk I get en error:

snmpwalk -v 2c -c casalogic localhost .1.3.6.1.4.1.2021.255

UCD-SNMP-MIB::ucdavis.255 = No Such Instance currently exists at this OID
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
Now the funny thing comes to life. If I type:

Code: Select all

fetch_mail_stat.pl mail.log mailstats.db .1.3.6.1.4.1.2021.255 -n .1.3.6.1.4.1.2021.255.1
I get:

Code: Select all

.1.3.6.1.4.1.2021.255.2
integer
0
In my snmpd.conf I have:

Code: Select all

pass .1.3.6.1.4.1.2021.255 /var/cacti-mailgraph/fetch_mail_stat.pl /var/cacti-mailgraph/mail.log /var/cacti-mailgraph/mailstats.db .1.3.6.1.4.1.2021.255
also, every time I do an snmpwalk, and do a

Code: Select all

ps aux | grep snmp 
I get one extra running process in form of:

Code: Select all

snmp      9197  0.0  0.0      0     0 ?        Z    09:36   0:00 [fetch_mail_stat] <defunct>
Anybody have any sort of idear, of how to get any further?
zagman76
Posts: 2
Joined: Tue Nov 14, 2006 6:56 pm

Post by zagman76 »

-bump-

Hello - I have followed this thread, and have not been able to get the darn thing to work properly! :(

I am mostly new to linux, and am "less than new" to perl, so I am basically banging my head over here! :lol:

Can someone help me out?

Here is the issue; my postfix/amavisd-new/spamassassin/clamav is configured and works properly (has been for months). I want to do logging on the box, but my mailstats section is blank on Cacti (other graphs come in just fine - CPU/memory/load/etc).

I think that is has something to do with how amavisd writes the logs, but need some more experienced minds to help me out.

Here is the section of amavisd.conf that handles logging:

Code: Select all

#
# Section III - Logging
#

# true (e.g. 1) => syslog;  false (e.g. 0) => logging to file
$DO_SYSLOG = 1;                   # (defaults to 0)
$SYSLOG_LEVEL = 'mail.debug';     # (facility.priority, default 'mail.info')

# Log file (if not using syslog)
$LOGFILE = "$MYHOME/amavis.log";  # (defaults to empty, no log)

#NOTE: levels are not strictly observed and are somewhat arbitrary
# 0: startup/exit/failure messages, viruses detected
# 1: args passed from client, some more interesting messages
# 2: virus scanner output, timing
# 3: server, client
# 4: decompose parts
# 5: more debug details
$log_level = 5;		  # (defaults to 0)

# Customizable template for the most interesting log file entry (e.g. with
# $log_level=0) (take care to properly quote Perl special characters like '\')
# For a list of available macros see README.customize .

# $log_templ = undef;      # undef disables by-message level-0 log entries
# $log_recip_templ = undef;  # undef disables by-recipient level-0 log entries


# log both infected and noninfected messages (new default):
# (remove the leading '#' and a space in the following lines to activate)

# $log_templ = '
# [? [?%#D|#|Passed #
# [? [?%#V|1] |INFECTED (%V)|#
# [? [?%#F|1] |BANNED (%F)|#
# [? [? %2|1] |SPAM|#
# [? [?%#X|1] |BAD-HEADER|CLEAN]]]]#
# , [? %p ||%p ][?%a||[?%l||LOCAL ]\[%a\] ][?%e||\[%e\] ]<%o> -> [%D|,]#
# [? %q ||, quarantine: %q]#
# [? %Q ||, Queue-ID: %Q]#
# [? %m ||, Message-ID: %m]#
# [? %r ||, Resent-Message-ID: %r]#
# , mail_id: %i#
# , Hits: %c#
# #, size: %z#
# #[? %j ||, Subject: "%j"]#
# #[? %#T ||, Tests: \[[%T|,]]\]#
# , %y ms#
# ]
# [?%#O|#|Blocked #
# [? [?%#V|1] |INFECTED (%V)|#
# [? [?%#F|1] |BANNED (%F)|#
# [? [? %2|1] |SPAM|#
# [? [?%#X|1] |BAD-HEADER|CLEAN]]]]#
# , [? %p ||%p ][?%a||[?%l||LOCAL ]\[%a\] ][?%e||\[%e\] ]<%o> -> [%O|,]#
# [? %q ||, quarantine: %q]#
# [? %Q ||, Queue-ID: %Q]#
# [? %m ||, Message-ID: %m]#
# [? %r ||, Resent-Message-ID: %r]#
# , mail_id: %i#
# , Hits: %c#
# #, size: %z#
# #[? %j ||, Subject: "%j"]#
# #[? %#T ||, Tests: \[[%T|,]]\]#
# , %y ms#
# ]';

# log template compatible with amavisd-new-20030616-p10:
# $log_recip_templ = undef;
# $log_templ = '[? %#V |[? %#F |[?%#D|Not-Delivered|Passed]|BANNED name/type (%F)]|INFECTED (%V)], #
# <%o> -> [<%R>|,][? %q ||, quarantine %q], Message-ID: %m, Hits: %c';

$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';
Here is my snmpd.conf

Code: Select all

### Setup security names

com2sec local     	localhost		password
com2sec internalNet	1.1.1.1/128		password

### Map groups to security names

group ROGroup	any	local
group ROGroup	any	internalNet

view viewEverything    included  .1	80

### grant groups access to the view

access ROGroup ""      any       noauth    exact  viewEverything    none   none
pass .1.3.6.1.4.1.2021.255 /usr/local/sbin/fetch_mail_statistics.pl /var/log/mail.log /var/log/mailstats.db .1.3.6.1.4.1.2021.255
(attached is the pl script I use)

please help!!!

if you need anything else posted, please let me know.

thanks!

-edit- someone mentioned earlier in the thread that the perl script ignores "local" messages - how do i know if my amavis is doing things "locally"...?
Attachments
fetch_mail_statistics.pl
my current perl script
(5.8 KiB) Downloaded 1061 times
TheMuche
Posts: 1
Joined: Fri Nov 24, 2006 9:40 am

Re: Problem getting it to work

Post by TheMuche »

idledk wrote:Hi, I have been playing around, trying to get the script to work.
snmpwalk -v 1 -c public <host> .1.3.6.1.4.1.2021.255
The funny thing is that is I do a snmpwalk I get en error:

snmpwalk -v 2c -c casalogic localhost .1.3.6.1.4.1.2021.255

UCD-SNMP-MIB::ucdavis.255 = No Such Instance currently exists at this OID
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
Now the funny thing comes to life. If I type:

Code: Select all

fetch_mail_stat.pl mail.log mailstats.db .1.3.6.1.4.1.2021.255 -n .1.3.6.1.4.1.2021.255.1
I get:

Code: Select all

.1.3.6.1.4.1.2021.255.2
integer
0
In my snmpd.conf I have:

Code: Select all

pass .1.3.6.1.4.1.2021.255 /var/cacti-mailgraph/fetch_mail_stat.pl /var/cacti-mailgraph/mail.log /var/cacti-mailgraph/mailstats.db .1.3.6.1.4.1.2021.255
also, every time I do an snmpwalk, and do a

Code: Select all

ps aux | grep snmp 
I get one extra running process in form of:

Code: Select all

snmp      9197  0.0  0.0      0     0 ?        Z    09:36   0:00 [fetch_mail_stat] <defunct>
Anybody have any sort of idear, of how to get any further?
Hello,
I have the same problem and I've found the solution.

You need to change the rights on the file Fetch_Mail_Statistics.pl
I've used the following command

chmod 777 fetch_mail_statistics.pl

Now it's OK

server:/usr/local/bin # snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.255
UCD-SNMP-MIB::ucdavis.255.0 = INTEGER: 58
UCD-SNMP-MIB::ucdavis.255.1 = INTEGER: 20
UCD-SNMP-MIB::ucdavis.255.2 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.255.3 = INTEGER: 16
UCD-SNMP-MIB::ucdavis.255.4 = INTEGER: 229
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


Bye
rufinus
Posts: 1
Joined: Tue Dec 05, 2006 5:44 am

Post by rufinus »

Hi,

i followed the thread an set it all up.

# snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.255
UCD-SNMP-MIB::ucdavis.255.0 = INTEGER: 83
UCD-SNMP-MIB::ucdavis.255.1 = INTEGER: 5
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

put if the poller runs i got
CMDPHP: Host[1] DS[10] WARNING: Result from SNMP not valid. Partial Result

if i use directly fetch_mail_statistics.pl:

# /usr/local/bin/fetch_mail_statistics.pl /var/log/amavis.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


anyone an idea whats wrong ?
TIA
Rufinus
cyberbobjr
Posts: 1
Joined: Sun May 13, 2007 11:26 am

Post by cyberbobjr »

hi all,
sorry to bump, but i have the same problem, does someone resolve it ?
Thanks for your help.
regards
Cyb
rufinus wrote:Hi,

i followed the thread an set it all up.

# snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.255
UCD-SNMP-MIB::ucdavis.255.0 = INTEGER: 83
UCD-SNMP-MIB::ucdavis.255.1 = INTEGER: 5
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

put if the poller runs i got
CMDPHP: Host[1] DS[10] WARNING: Result from SNMP not valid. Partial Result

if i use directly fetch_mail_statistics.pl:

# /usr/local/bin/fetch_mail_statistics.pl /var/log/amavis.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


anyone an idea whats wrong ?
TIA
Rufinus
BG
Posts: 1
Joined: Wed Sep 12, 2007 11:03 am

mailstat.db

Post by BG »

Hi

check the rigths on the mailstat.db file.
I changed it to 766 and I got the rigth numbers.
bg.
achoi
Posts: 1
Joined: Thu Oct 25, 2007 12:47 am

Post by achoi »

Hi,

I am a problem trying to show data that is over 1024. I have already changed to the maximum value in the data template to 100000, but my graph still won't graph anything higher than 1000.

Please help. thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests