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    


Walkthrough on Postifx monitoring with Cacti
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
Mathieu



Joined: 13 Mar 2006
Posts: 12
Location: France

PostPosted: Thu Jul 13, 2006 4:42 am    Post subject: Reply with quote

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

MINRES < pooling period

Mathieu
Back to top
@ryaz



Joined: 31 May 2006
Posts: 14
Location: France

PostPosted: Thu Jul 13, 2006 4:50 pm    Post subject: Reply with quote

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
Back to top
nuber



Joined: 12 Jul 2006
Posts: 3

PostPosted: Fri Jul 14, 2006 6:38 pm    Post subject: Reply with quote

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



Joined: 21 Jun 2006
Posts: 21

PostPosted: Mon Jul 17, 2006 10:20 am    Post subject: Reply with quote

@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

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!
Back to top
@ryaz



Joined: 31 May 2006
Posts: 14
Location: France

PostPosted: Mon Jul 17, 2006 1:23 pm    Post subject: Reply with quote

Giorgio wrote:

Hi @riaz,

First sorry for my english, i try to improve it

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
Back to top
@ryaz



Joined: 31 May 2006
Posts: 14
Location: France

PostPosted: Tue Jul 18, 2006 3:09 pm    Post subject: Reply with quote

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:
# 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";
  }
}
Back to top
fozzy



Joined: 09 Jan 2006
Posts: 45
Location: SRN VOR 150/8

PostPosted: Wed Aug 30, 2006 3:38 am    Post subject: Reply with quote

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
Back to top
fozzy



Joined: 09 Jan 2006
Posts: 45
Location: SRN VOR 150/8

PostPosted: Thu Aug 31, 2006 5:16 am    Post subject: Reply with quote

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



Joined: 27 Sep 2006
Posts: 1

PostPosted: Wed Sep 27, 2006 2:41 am    Post subject: Problem getting it to work Reply with quote

Hi, I have been playing around, trying to get the script to work.

Quote:

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

Quote:

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:

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:

.1.3.6.1.4.1.2021.255.2
integer
0


In my snmpd.conf I have:

Code:

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:
ps aux | grep snmp
I get one extra running process in form of:
Code:
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?
Back to top
zagman76



Joined: 14 Nov 2006
Posts: 2

PostPosted: Tue Nov 14, 2006 7:06 pm    Post subject: Reply with quote

-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!

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:

#
# 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:

### 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"...?



fetch_mail_statistics.pl
 Description:
my current perl script

Download
 Filename:  fetch_mail_statistics.pl
 Filesize:  5.8 KB
 Downloaded:  408 Time(s)

Back to top
TheMuche



Joined: 24 Nov 2006
Posts: 1

PostPosted: Fri Nov 24, 2006 9:45 am    Post subject: Re: Problem getting it to work Reply with quote

idledk wrote:
Hi, I have been playing around, trying to get the script to work.

Quote:

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

Quote:

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:

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:

.1.3.6.1.4.1.2021.255.2
integer
0


In my snmpd.conf I have:

Code:

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:
ps aux | grep snmp
I get one extra running process in form of:
Code:
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
Back to top
rufinus



Joined: 05 Dec 2006
Posts: 1

PostPosted: Tue Dec 05, 2006 5:48 am    Post subject: Reply with quote

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
Back to top
cyberbobjr



Joined: 13 May 2007
Posts: 1

PostPosted: Sun May 13, 2007 11:28 am    Post subject: Reply with quote

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
Back to top
BG



Joined: 12 Sep 2007
Posts: 1

PostPosted: Wed Sep 12, 2007 11:08 am    Post subject: mailstat.db Reply with quote

Hi

check the rigths on the mailstat.db file.
I changed it to 766 and I got the rigth numbers.
bg.
Back to top
achoi



Joined: 25 Oct 2007
Posts: 1

PostPosted: Thu Oct 25, 2007 12:49 am    Post subject: Reply with quote

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!
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 Previous  1, 2, 3, 4, 5  Next
Page 4 of 5

 



Powered by phpBB © 2001, 2005 phpBB Group