#!/usr/local/bin/perl # # Called when MRTG detects a threshold problem for a variable. # ARGV[0] = Parameter name, such as 'wanrouter.cpu'. # ARGV[1] = Threshold value which was breached, such as "99". # ARGV[2] = Actual current value of the parameter, such as "100". # # Command line looks like: # thisprogram wanrouter 99 100 # my($timestr, $param, $thresh, $value, $message, $logfile); $timestr = localtime(time); $param = $ARGV[0]; $thresh = $ARGV[1]; $value = $ARGV[2]; use Env qw(desc THRESH_DESC); #set the appropriate Interface description $param = $THRESH_DESC; # This will help us take care of our rounding problem use integer; $value = $value / 1; $logfile = "c:\\scripts\\errordisk.txt"; # # 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 time is $abovebelow its threshold of $thresh MB Free. The Current value is $value MB of free disk space"; print "$timestr $message\n"; # Log it open LOG, ">$logfile"; print LOG "$timestr $message\n\n You can go to\n\n http://van-mrtg02/routers2.cgi \n\n and check the latest data"; close(LOG); # Email it. #system("echo '$message' | $emailprog $emailuser"); exit(0);