Joel Staiman wrote: > > So to recap so that I can install the correct programs: > Which package should I install to get the stats? > =09 > I already get disk, memory, cpu stats, as well as smtp vs smtpd = > processes. > I would love to get mail throughput and # messages in queue pending. >
It sounds like you already have an SNMP agent and MRTG installed? If so then you just need the perl module and scripts here: http://taz.net.au/postfix/mrtg/ That should get you mail 'throughput' if you mean just incoming and outgoing connections. To get queue pending, try this: #!/usr/bin/perl -w @QUEUE = split(/\n{2}/, `/usr/bin/mailq`); $summary = pop @QUEUE; if ($ARGV[0]) { $summary =~ s/^.+Kbytes\sin\s(\d+).+$/$1/s; print scalar(@QUEUE), "\n", $summary, "\n\n"; } else { for (@QUEUE) { s/^.+?\s+(\d+)\s.+$/$1/s; $my_total += $_; } $my_kbytes = int($my_total/1000); $summary =~ s/^.+?\s(\d+).+$/$1/s; print "$my_kbytes\n$summary\n\n"; #print "$my_kbytes\n$my_kbytes\n\n"; } #EOF It didn't make sense to graph Kbytes vs. message count on the same chart, so my script just sanity checks mailq's own summary line. Hopefully they are the same (this seems not to be the case, I am always 20K lower for some reason): $ ./mqueue.pl 1945 1965 In case mailq decides to spit out in Mbytes or Gbytes, the first figure should still make sense to MRTG and the last line could be uncommented and replace the prior line (anyone know if mailq output line ever aggregates size to higher orders?). If you supply any arguments to the above script, it will output message count instead of bytes in the queue: $ ./mqueue.pl 1 344 344 There's potential for doing other interesting things with rrdtool. I'd like to see graphs summarizing rejects by blacklist, or incoming by top 10 domains / users etc. One important correction to something I wrote earlier: > 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 > < > My problem was only that I wasn't waiting long enough to get the output. No modifications were really necessary, and in fact by using mailstats.pl I was feeding MRTG a counter value but specifying it as gauge (graph got very impressive after a couple hours, since this config meant it could never go down!) Sometimes a graph is worth a thousand loglines, and my brain certainly parses it faster. Mike
