#--------------------------------------------------- Target[aust.1.1.2]: 1.3.6.1.4.1.644.2.4.4.1.1.1.6.0.1.1.0&1.3.6.1.4.1.644.2.4.4. 1.3.1.6.0.1.1.0.1:[EMAIL PROTECTED] MaxBytes[aust.1.1.2]: 900 Title[aust.1.1.2]: Slot 1 Port 1 CUSTOMER PageTop[aust.1.1.2]: <H1>Bursty Errored Seconds on Slot 1 Port 1 BODYWORX</H1> Options[aust.1.1.2]: gauge, unknaszero, withzeroes, growright WithPeak[aust.1.1.2]: wmy YLegend[aust.1.1.2]: Seconds ShortLegend[aust.1.1.2]: Seconds LegendI[aust.1.1.2]: Current BES LegendO[aust.1.1.2]: Previous BES ThreshMinI[aust.1.1.2]: 3 ThreshMaxI[aust.1.1.2]: 9 ThreshProgI[aust.1.1.2]: /usr/local/bin/threshalarm ThreshProgOKI[aust.1.1.2]: /usr/local/bin/threshclear ThreshMinO[aust.1.1.2]: 10 ThreshMaxO[aust.1.1.2]: 30 ThreshProgO[aust.1.1.2]: /usr/local/bin/threshalarmprev ThreshProgOKO[aust.1.1.2]: /usr/local/bin/threshclearprev ThreshDesc[aust.1.1.2]: CUSTOMER
tcsh> cat /usr/local/bin/threshalarm #!/usr/bin/perl # # Establish initial parameters &initial; # Retreive parameters $target = $ARGV[0]; $threshold = $ARGV[1]; chomp($threshold); $current = $ARGV[2]; $comment = $ENV{"THRESH_DESC"}; $comment =~ s/\s+$//; $comment =~ s/\s+T1$/ T1/; # parse target info @target = split(/\./,$target); $city = $target[0]; $slot = $target[1]; $port = $target[2]; $event = $target[3]; # determine counter if ($event == 1) { $prm = "ES"; $parameter = "Errored Seconds"; } elsif ($event == 2) { $prm = "BES"; $parameter = "Bursty Errored Seconds"; } elsif ($event == 3) { $prm = "SES"; $parameter = "Severely Errored Seconds"; } elsif ($event == 4) { $prm = "UAS"; $parameter = "Unavailable Seconds"; } else { $prm = "UNK"; $parameter = "Unknown"; } # How were we called? if ($0 =~ /threshalarm$/) { if ($current >= $threshold) { $window = "current"; $severity = "alert"; $direction = "exceeded"; $delay++; $notify++; } else { $window = "current"; $severity = "info"; $direction = "cleared"; $delay++; } } elsif ($0 =~ /threshclear$/) { if ($current < $threshold) { $window = "current"; $severity = "alert"; $direction = "cleared"; $notify++; } else { $window = "current"; $severity = "info"; $direction = "exceeded"; } } elsif ($0 =~ /threshalarmprev/) { if ($current >= $threshold) { $window = "previous"; $severity = "alert"; $direction = "exceeded"; $delay++; $notify++; } else { $window = "previous"; $severity = "info"; $direction = "cleared"; $delay++; } } elsif ($0 =~ /threshclearprev/) { if ($current < $threshold) { $window = "previous"; $severity = "alert"; $direction = "cleared"; $notify++; } else { $window = "previous"; $severity = "info"; $direction = "exceeded"; } } else { $window = "unknown"; $direction = "unknown"; } ¬ify if ($notify); sleep 1 if ($delay); if ($log) { open(LOG,">>$log"); if ($comment) { print LOG "$months[$month] $mday $hour\:$min\:$sec dacs\-$city DACS Alarm $window $severity $prm $direction \[$current\/$threshold\] on $comment \n"; } else { print LOG "$months[$month] $mday $hour\:$min\:$sec dacs\-$city DACS Alarm $window $severity $prm $direction \[$current\/$threshold\] on slot $slot port $port\n"; } close(LOG); } sub notify { for ($a=0; $a<=$#recipients; $a++) { open(SENDMAIL,"|$sendmail $recipients[$a]"); print SENDMAIL "To: DACS Alarm Recipient \<$recipients[$a]\>\n"; print SENDMAIL "From: DACS Alarms \<[EMAIL PROTECTED]>\n"; print SENDMAIL "Subject: DACS Alarm $window $prm threshold $direction\n"; print SENDMAIL "\n"; print SENDMAIL "MRTG has detected that the level of $parameter\n"; print SENDMAIL "of the element $target has $direction its\n"; print SENDMAIL "$severity threshold of $threshold and has reached a level of $current\n"; print SENDMAIL "for the $window 15-minute interval.\n"; if ($comment) { print SENDMAIL "Description was $comment\n"; } close(SENDMAIL); } } sub initial { # initial parameters $log = "/var/log/router.log"; $sendmail = "/usr/sbin/sendmail"; @recipients = ( "[EMAIL PROTECTED]", ); # Get time @time = localtime(time); $hour = $time[2]; $min = $time[1]; $sec = $time[0]; $mday = $time[3]; $month = $time[4]; if ($hour == 0) { $hour = "00"; } elsif ($hour < 10) { $hour = "0".$hour; } if ($min == 0) { $min = "00"; } elsif ($min < 10) { $min = "0".$min; } if ($sec == 0) { $sec = "00"; } elsif ($sec < 10) { $sec = "0".$sec; } if ($mday == 0) { $mday = "00"; } elsif ($mday < 10) { $mday = "0".$mday; } @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); } Dmitry Chorine wrote: > Can someone show me an example of config file, where notificaiton by > email (thershold) is working? > > Thanks > > -- > Unsubscribe mailto:[EMAIL PROTECTED] > 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 > > -- Unsubscribe mailto:[EMAIL PROTECTED] 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