[mrtg] Re: Can mrtg set to send out a alert email when Max In tra

Rich Sena ras at thick.net
Wed Dec 10 15:39:37 MET 2003


You can do this with Threshold variables set...

We do this with the following globals set in the config...

ThreshProgI[_]: /var/www/html/mrtg/scripts/mail.pl
ThreshProgO[_]: /var/www/html/mrtg/scripts/mail.pl
ThreshMaxI[_]: 90%
ThreshMaxO[_]: 90%

mail.pl is a small perl script for handling the email gateway...

I hacked this up with some insight from some other peoples efforts...

There is also a filter further into the script below that filters out alerts from Ethernet interfaces.


<begin script>

#!/usr/bin/perl
# file thresh.pl
use Mail::Internet;

my($timestr, $param, $thresh, $value, $logfile, $now, $result, $in_name, 
$link_name);
  $timestr = localtime(time);
  $param = $ARGV[0];
  $thresh = $ARGV[1];
  $value = $ARGV[2];
  $thdesc = $ENV{'THRESH_DESC'};
  $logfile = "/tmp/mrtgthresh.log";
  $now = `date`;
  $result = $value * 8 / 1024;


my $head = Mail::Header->new;
$head->add(From => 'ThreshMAN <net-lists at lists.thick.net>');
$head->add(ReplyTo => 'Netgroups <net-lists at lists.thick.net>');
$head->add(To   => 'Netgroups <net-lists at lists.thick.net>');
$head->add(Subject => "THRESHOLD ALERT:  $thdesc ($param) is above $thresh 
bandwidth threshold");

my $body = <<END;
Device          : $thdesc ($param)
Threshold Value : $thresh
Current Value   : $result kbps
Date/Time       : $now

--
THICKNET Consulting

This was auto-generated on mbnet12 by /var/www/html/mrtg/scripts/mail.pl

END


$mail = Mail::Internet->new(Header => $head,
                            Body   => [$body],
                            Modify => 1);

# Mail it.
if ($thdesc !~ /(thernet)/) { print $mail->send('sendmail'); }

# Log it.
if ($thresh > $value) { $abovebelow = "below"; }
                 else { $abovebelow = "above"; }

$message .= "$thdesc ($param) ($result kbps) is $abovebelow threshold 
($thresh)";

open(LOG, ">>$logfile");
print LOG "$timestr $message\n";
close(LOG);


exit(0);

<end script>


On Dec 8, 2003 avinash phogat spake:

> hi all
> 
> anyone have  a script that can set mrtg to send out a alert email when "Max
> In"traffice over 80%?, pls provide it to me iam very thankfull to u
> 
> Thank you in advance.
> 
> Avinash Phogat
> 
> _________________________________________________________________
> Discover India. Celebrate her diversity. 
> http://server1.msn.co.in/features/tourism/  Come, fall in love!
> 
> --
> Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
> Archive     http://www.ee.ethz.ch/~slist/mrtg
> FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
> WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi
> 

-- 
Rich Sena - ras at thick.net
ThickNET Consulting
"On the way to understanding; you understand, and forget."


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list