Changes in Mailiscanner-mrtg for Postfix

Eduardo Andre edu at ICARUS.COM.BR
Sat Sep 13 20:23:54 IST 2003


Attention!!!
I do this modifications for my personal use.
It´s experimental.

Good luck.

Ed Andre
---------------------------------------------------------------
STEP 1

Add in /usr/sbin/mailscanner-mrtg

line 57
if ($cmd eq "postfix")      { Postfix();            last SWITCH; };


In sub Mail,  replace all lines with /sendmail to this:

if (/postfix\/qmgr\[\d+\]/i) { $Total += $1 if /nrcpt=(\d+)/i; }


If you want, create a

sub BytesFromPostfix {
     if (/.+postfix\/nqmgr\[\d+\]:\s+\w+:\s+from=\S+,\s+size=(\d+),.+/i) {
       return $1;
     } else {
       return 0;
     }
   }


and add in sub MailBytes,  this lines.

} elsif (lc($Config{"calculatemailbytes"}) eq "postfix") {
        $Total += &BytesFromPostfix($_);


Creeate  the

sub Postfix{
  if ($debug) { Debug("Beginning sub Postfix") }

  @ps = `ps ax`;
  foreach $p (@ps) {
    if ($p =~ /smtpd/) {
      $Total ++;
    }
  }

  if ($debug) {
    Debug("Total", $Total);
    Debug("Leaving sub Postfix");
  }
}


I change the "sub InQueue" and  "sub OutQueue"
because Postfix use multiples spool subdirs.
You need install perl module File::Find::Rule.
Search in search.cpan.org

sub InQueue {
  if ($debug) { Debug("Beginning sub InQueue") }

  if ($Config{"incomingqueuedir"}) {
    use File::Find::Rule;
    my $filter = File::Find::Rule->new;
    if ($debug) { Debug ("use File::Find", "True") }

    $filter->file; # find only files
    push @results, $filter->in($Config{"incomingqueuedir"});
    foreach $line(@results){
        $Total++;
    }
  } else {
    die "ERROR: Incoming Queue Dir not specified in $configfile\n";
  }

  if ($debug) {
    Debug("Total", $Total);
    Debug("Leaving sub InQueue");
  }
}


and

sub OutQueue {
  if ($debug) { Debug("Beginning sub OutQueue") }

  if ($Config{"outgoingqueuedir"}) {
    use File::Find::Rule;
    my $filter = File::Find::Rule->new;
    if ($debug) { Debug ("use File::Find", "True") }

    $filter->file; # find only files
    push @results, $filter->in($Config{"outgoingqueuedir"});
    foreach $line(@results){
        $Total++;
    }
  } else {
    die "ERROR: Outgoing Queue Dir not specified in $configfile\n";
  }

  if ($debug) {
    Debug("Total", $Total);
    Debug("Leaving sub OutQueue");
  }
}





If you create a "sub BytesFromPostfix",
in mailscanner-mrtg.conf add this lines:
#Calculate MailBytes = Postfix


STEP 2

In mailscanner-mrtg.cfg add this lines.

Target[postfix]: `/usr/sbin/mailscanner-mrtg  postfix`
Title[postfix]: Copies Of POstfix Running
PageTop[postfix]: <H1>Copies Of Exim Running</H1>
Directory[postfix]: exim
MaxBytes[postfix]: 200
AbsMax[postfix]: 1000
YLegend[postfix]: Copies Running
ShortLegend[postfix]: &nbsp; &nbsp;
Legend1[postfix]: Average Copies
Legend2[postfix]:
Legend3[postfix]: Maximum Copies
Legend4[postfix]:
LegendI[postfix]: &nbsp;Copies:
LegendO[postfix]:

----------------------------------------------------



> -----Original Message-----
> From:   Eduardo Andre [mailto:edu at ICARUS.COM.BR]
> Sent:   Sat 9/13/2003 1:15 PM
> To:     MAILSCANNER at JISCMAIL.AC.UK
> Cc:
> Subject:        Re: Mailiscanner-mrtg
> I do this.
> If you want I send the modifications to you.
>
> Ed.
>
>> Anyone ever managed to modify the mailscanner-mrtg scripts for Postfix?
>> Is
>> it possible?
>>
>
> I would really appreciate... I looked at it, but I couldn't figure out how
> it worked.
>
> Thanks
>
> ugob at camo-route.com
>




More information about the MailScanner mailing list