Mike Lewinski wrote:

> If you install UCD-SNMP on the postfix host itself, I believe there is 
> an option to allow you to run any command and return the results. MRTG 
> supports directly querying an OID. I have never tried this, but don't 
> see any reason why it wouldn't work. 

I have now, and it will work. Here's basic config bits (sanitized):

$ cat /etc/snmpd.conf
rocommunity  a_hard_to_guess_snmp_RO_community 127.0.0.1
exec  .1.3.6.1.4.1.2021.50 mailstat /usr/local/bin/mailstats2.pl
#
# Change 127.0.0.1 to the IP of your MRTG machine and also change the
# community string to something unique that is not 'public' or 'private'


$ tail -n 10 /etc/mrtg.cfg
Target[postfix]: 
.1.3.6.1.4.1.2021.50.101.1&.1.3.6.1.4.1.2021.50.101.2:[EMAIL PROTECTED]:
MaxBytes[postfix]: 99999
Options[postfix]: gauge, growright
Title[postfix]: Postfix Statistics
PageTop[postfix]: <H1>Postfix Statistics</H1>
WithPeak[postfix]: dwmy
YLegend[postfix]: No. of messages
ShortLegend[postfix]: messages
LegendI[postfix]: &nbsp;Incoming:
LegendO[postfix]: &nbsp;Outgoing:
# Change community string above and 127.0.0.1 to your postfix
# server's snmp config.
#
# Note the author's example page leaves out required MaxBytes.
# Probably want to add nopercent to the options anyway....

I had some problems with the mrtg-mailstats.pl script. It was not 
outputting anything at all, and it was easier to modify mailstats.pl 
since it worked ok:

$ diff /usr/local/bin/mailstats2.pl /usr/local/bin/mailstats.pl
18c18
<       print "$foo{$_}\n" ;
---
 >       print "$_ $foo{$_}\n" ;
21d20
<

I also had some problems with the exec line not doing anything at all. 
As far as I can tell, there needs to be two spaces after the 'exec'. 
That was the only change I recall making when it suddently started to work.

It's also possible to graph the postfix machine's CPU and memory 
utilization. Below is sample config for that. Again you'll want to 
change the community and IP for each server (I recommend unique snmp 
strings on every device, unless you are managing hundreds)


Target[127.0.0.1_cpu]: 
.1.3.6.1.4.1.2021.11.9.0&.1.3.6.1.4.1.2021.11.10.0:[EMAIL PROTECTED]:
Options[127.0.0.1_cpu]: growright, gauge, nopercent
WithPeak[127.0.0.1_cpu]: ymw
MaxBytes[127.0.0.1_cpu]: 100
ShortLegend[127.0.0.1_cpu]: %
YLegend[127.0.0.1_cpu]: % Utilization
Legend1[127.0.0.1_cpu]: User time
Legend2[127.0.0.1_cpu]: System time
Legend3[127.0.0.1_cpu]: Max user
Legend4[127.0.0.1_cpu]: Max system
LegendI[127.0.0.1_cpu]: &nbsp;User:
LegendO[127.0.0.1_cpu]: &nbsp;Sys:
Title[127.0.0.1_cpu]: CPU utilization
PageTop[127.0.0.1_cpu]: <H1> CPU utilization</H1>

# Memory
Target[127.0.0.1_mem]: 
.1.3.6.1.4.1.2021.4.4.0&.1.3.6.1.4.1.2021.4.6.0:[EMAIL PROTECTED]:
Options[127.0.0.1_mem]: growright, gauge
MaxBytes1[127.0.0.1_mem]: 327264 # Change these to your real values
MaxBytes2[127.0.0.1_mem]: 298252 # Look at dmesg  for them?
ShortLegend[127.0.0.1_mem]: Bytes
YLegend[127.0.0.1_mem]: Bytes
Legend1[127.0.0.1_mem]: Swap available
Legend2[127.0.0.1_mem]: Real available
Legend3[127.0.0.1_mem]: Max swap
Legend4[127.0.0.1_mem]: Max real
LegendI[127.0.0.1_mem]: Swap
LegendO[127.0.0.1_mem]: Real
Title[127.0.0.1_mem]: Memory utilization
PageTop[127.0.0.1_mem]: <H1> Memory utilization</H1>


Mike
--
        Calling them "Freedom Fries" isn't patriotism, it's jingoism.
Sig stolen from a slashdot user


Reply via email to