1 |
I know this isn't a Gentoo specific problem, but since it's a server |
2 |
list I'm already subscribed to, I figured I would try here first. |
3 |
|
4 |
I'm running Postfix and I am trying to get snmp stats (net-snmp) to feed |
5 |
cacti (http://www.raxnet.net/products/cacti/). The best script I found |
6 |
that gets the sent and received emails was a set of perl scripts created |
7 |
for mrtg called mailstats (http://taz.net.au/postfix/mrtg/). |
8 |
Mailstats.pl works just fine. I modified it so that it should respond |
9 |
to snmp. That's: |
10 |
|
11 |
----script---- |
12 |
#!/usr/bin/perl |
13 |
|
14 |
# mailstats.pl |
15 |
# |
16 |
# Copyright Craig Sanders 1999 |
17 |
# |
18 |
# this script is licensed under the terms of the GNU GPL. |
19 |
|
20 |
use DB_File; |
21 |
|
22 |
$|=1; |
23 |
|
24 |
$stats_file = '/tmp/stats.db' ; |
25 |
|
26 |
tie(%foo, "DB_File", "$stats_file", O_RDONLY, 0666, $DB_HASH) || die |
27 |
("Cannot open $stats_file"); |
28 |
|
29 |
foreach (sort keys %foo) { |
30 |
if ($_ =~ "RECEIVED:smtp"){ |
31 |
print ".1.3.6.1.4.1.1021.56.1\n"; |
32 |
print "counter\n"; |
33 |
print "$foo{$_}\n" ; |
34 |
}else{ |
35 |
} |
36 |
} ; |
37 |
untie %foo; |
38 |
----end script---- |
39 |
|
40 |
Note: This script runs just fine from the command line. This file is |
41 |
called mailstats-r.pl for received mail. |
42 |
|
43 |
I modified snmpd.conf, and added these lines (.2 is for sent mail): |
44 |
|
45 |
pass .1.3.6.1.4.1.2021.56.1 /usr/bin/perl /usr/local/sbin/mailstats-r.pl |
46 |
pass .1.3.6.1.4.1.2021.56.2 /usr/bin/perl /usr/local/sbin/mailstats-s.pl |
47 |
|
48 |
I should now be able to get my mail stats via snmp, but this is what I |
49 |
get instead: |
50 |
|
51 |
user $ snmpget -v2c -c public mx.domain.tld .1.3.6.1.4.1.2021.56.1 |
52 |
UCD-SNMP-MIB::ucdavis.56.1 = No Such Object available on this agent at |
53 |
this OID |
54 |
|
55 |
I've been all over the snmpd.conf man page, but I just don't get it: |
56 |
(http://net-snmp.sourceforge.net/man/snmpd.conf.html). |
57 |
|
58 |
How are people graphing postfix statistics? I use to use ftp to |
59 |
transfer the stats to the cacti server, but I want to use SNMP since |
60 |
that's how all the other stats are collected. |