[mrtg] Re: Thresholds

Thomas Muggli - NSM mugglit at cscoe.ac.com
Mon Jul 26 21:02:53 MEST 1999


Hopefully this will help the people who want to use Thresholds...

I'm using Thresholds to send notifications when the disk space on NT partitions reach a certain level (95%).  Here's the relevant parts for a server called "mpclm1005":

WorkDir: /usr/mrtg/www-docs/mpclm1005
ThreshDir: /usr/mrtg/mrtg-thresh

Target[mpclm1005.disk0]: 1.3.6.1.4.1.232.11.2.4.1.1.5.0&1.3.6.1.4.1.232.11.2.4.1.1.5.0:public at mpclm1005
MaxBytes[mpclm1005.disk0]: 100
Title[mpclm1005.disk0]: mpclm1005 - Disk Space Used (%) for Drive C: [NTFS]
PageTop[mpclm1005.disk0]: <H2>mpclm1005 - Disk Space Used (%) for Drive C: [NTFS]</H2>
YLegend[mpclm1005.disk0]: Percent Full (C:)
ShortLegend[mpclm1005.disk0]: % Full
Legend2[mpclm1005.disk0]: Disk Usage
LegendO[mpclm1005.disk0]: &nbsp;Usage:
Options[mpclm1005.disk0]: growright, nopercent, gauge
ThreshMaxI[mpclm1005.disk0]: 95
ThreshProgI[mpclm1005.disk0]: /usr/mrtg/bin/threshold.mrtg
ThreshProgOKI[mpclm1005.disk0]: /usr/mrtg/bin/thresholdOK.mrtg


I use very similar programs for ThreshProgOKI and ThreshProgI.  Here is the ThresholdProgI Program (make sure it has execute permissions set):


#!/usr/local/bin/perl
#
#       Called when MRTG detects a threshold problem for a variable.
#       ARGV[0] = Parameter name, such as 'mpclm1005.disk0'.
#       ARGV[1] = Threshold value which was breached, such as "95".
#       ARGV[2] = Actual current value of the parameter, such as "100".
#
#       From the command line, it would look like:
#
#               thisprogram mpclm1005 95 100
#
my($timestr, $param, $thresh, $value, $message, $logfile);
$timestr = localtime(time);
$param = $ARGV[0];
$thresh = $ARGV[1];
$value = $ARGV[2];

$logfile = "/tmp/mrtgthresh.log";
$emailprog = "/usr/ucb/mail -s 'MRTG Thresh'";
$emailuser = "mugglit";

#
#       Do something meaningful with the information.
#       Send an email message, log to a file, execute some script...
#

if ($thresh > $value) { $abovebelow = "below"; }
                 else { $abovebelow = "above"; }
$message .= "$param ($value) is $abovebelow threshold ($thresh)";

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

# Email it.
system("echo '$message' | $emailprog $emailuser");

exit(0);


I hope that helps.  Feel free to use that code as a base, but you might want to customize it for your site.

Tom

> Is anyone using Thresholds?  I am trying to use thresholds and the
> ThreshProgOK program is run everytime that MRTG is run.  It is my
> understanding that this should only run when a threshold was crossed
> the time before and is now OK.  Would someone please share an example
> of a working config?  

--
* To unsubscribe from the mrtg mailing list, send a message with the
  subject: unsubscribe to mrtg-request at list.ee.ethz.ch
* The mailing list archive is at http://www.ee.ethz.ch/~slist/mrtg


More information about the mrtg mailing list