[mrtg] Delayed Threshold Actions

dan.lowry at attbi.com dan.lowry at attbi.com
Wed Jun 18 16:53:43 MEST 2003


Here's a batch file that seems to work for Windows 2k.
It looks at inbound link utilization for 20 minutes, and if it's over
threshold for 20 minutes, an email gets sent.
Thanks to the group at windowsshellscripting.com  for providing this usefull
script !
It has provisions to get past an issue with threshprogok where
if you enable threshdir which is needed for threshprogok to kick off,
then you no longer kick off threshprogx every 5 minutes (Only
every hour)
This batch file when run will create  a timestamp, and if the last time the 
file was updated was > 7 minutes ago, will set the count variable back to 1.
that way if you have a couple of threshold breaches, and then it goes back to 
normal, you won't leave stale values in the temp file and get a premature email 
next time. 

No guarantee, but it seems to work for me. It will also have an issue at the 
end of the year boundry , if anyone can fix that it would be appreciated.

Otherwise, Here you go, it works for me on windows 2k server. 

Dan
-----------------------------------------------------------
:link_util_out_20min.BAT

SET PARM1=%1
SET PARM2=%2 
SET PARM3=%3
SET /A PARM2=%PARM2% * 8
SET /A PARM3=%PARM3% * 8


ECHO MRTG THRESHOLD ALERT > e:\mrtg\thresholds\%PARM1%_out_email.TXT
ECHO. >> e:\mrtg\thresholds\%PARM1%_out_email.TXT
ECHO Current Inbound %THRESH_DESC% Is Greater than %PARM2% Bits Per Second >> 
e:\mrtg\thresholds\%PARM1%_out_email.TXT
ECHO Please Call Network Services on Call. >> e:\mrtg\thresholds\%PARM1%
_out_email.TXT
ECHO Next Message will be sent in 20 Minutes. >> e:\mrtg\thresholds\%PARM1%
_out_email.TXT
ECHO. >> %PARM1%_out_email.TXT
ECHO Questions/Comments: Please send email to bozo at clown.com >> 
e:\mrtg\thresholds\%PARM1%_out_email.TXT

FOR /F "TOKENS=2-4 DELIMS=/ " %%F IN ('DATE /T') DO (SET DTTM=%%H%%F%%G)
SET DTTM=%DTTM:~3%
FOR /F "TOKENS=5-6 DELIMS=: " %%F IN ('ECHO.^|TIME') DO (SET DTTM=%DTTM%%%F%%G)

IF EXIST e:\mrtg\thresholds\%PARM1%_out_counter.TXT (
 FOR /F "TOKENS=1-2" %%F IN (e:\mrtg\thresholds\%PARM1%_out_counter.TXT) DO (
  SET Counter=%%F
  SET LastDTTM=%%G 
 )
) ELSE (
 SET Counter=1
 GOTO WriteIt
)

SET /A LastDTTM=%LastDTTM% + 7
IF %DTTM% GTR %LastDTTM% (
 SET COUNTER=1
 GOTO WriteIt
)

SET /A COUNTER=%COUNTER% + 1
IF %COUNTER% GEQ 5 (
 e:\mrtg\sendmail\blat.exe e:\mrtg\thresholds\%PARM1%_out_email.TXT -s "Inbound 
%THRESH_DESC% has been greater than %PARM2% Bits Per Second for 20 minutes!" -
bozo at clown.com 
 DEL e:\mrtg\thresholds\%PARM1%_out_email.TXT
 DEL e:\mrtg\thresholds\%PARM1%_out_counter.TXT
GOTO :EOF
)
:WriteIt
ECHO %COUNTER% %DTTM%> e:\mrtg\thresholds\%PARM1%_out_counter.TXT
:: -----link_util_out_20min.BAT-------
-------------------------------------------------------------------------
Here's a snip from the the config file

ThreshDesc[bla_bla]: Utilization on Miller ATM1/70 6 Meg IMA Port
ThreshMaxO[bla_bla]: 625000
ThreshProgO[bla_bla]:e:\mrtg\thresholds\link_util_out_20min.bat

Good luck !


--
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