[mrtg] Re: External application for thresholds

Brander, Eric Eric.Brander at ACS-INC.com
Tue Feb 25 14:17:50 MET 2003


When a threshold is breached, MRTG places an empty file in ThreshDir.  Then,
at the next polling interval if the error condition still exists, it will
check to see if its already been reported.  If it has (a file will already
be there) then it will skip executing ThreshProgO (or ThreshProgI).  If the
problem is resolved and no longer past the threshold, then MRTG will remove
the file it created and execute ThreshProgOKO (or ThreshProgOKI).  This
method prevents you from getting notified of a problem at every polling
cycle, letting you know when the threshold was crossed, and when it went
back to nominal.

Also, I'm running 2.9.25 on Win2k and my thresholds are working perfectly.

Here are the relevant settings in my configs:

### Global Config Options
HtmlDir: \mrtg\www
ImageDir: \mrtg\images
IconDir: \mrtg\images
LogDir: \mrtg\log
ThreshDir: \mrtg\thresh
ThreshProgO[_]: \mrtg\thresh\NotifyError.Bat
ThreshProgOKO[_]: \mrtg\thresh\NotifyOK.Bat
~snip~
ThreshMinO[server_diskC]: 15%
ThreshDesc[server_diskC]: "Disk C on server"
~snip~

And here's the batch files:

-NotifyError.bat
SET DEVICE=%1
SET THRESHOLD=%2
SET CURRENT_READING=%3
SET STATUS=Error
CSCRIPT ..\bin\SendEmail.vbs

-NotifyOK.bat
SET DEVICE=%1
SET THRESHOLD=%2
SET CURRENT_READING=%3
SET STATUS=OK
CSCRIPT ..\bin\SendEmail.vbs

The vbscript is simply to send the email to the help email address.
-SendEmail.vbs
Set WSHShell = WScript.CreateObject("WScript.Shell")
ThreshDesc = WSHShell.ExpandEnvironmentStrings("%THRESH_DESC%")
Device = WSHShell.ExpandEnvironmentStrings("%DEVICE%")
Threshold = WSHShell.ExpandEnvironmentStrings("%THRESHOLD%")
CurrentReading = WSHShell.ExpandEnvironmentStrings("%CURRENT_READING%")
Status = WSHShell.ExpandEnvironmentStrings("%STATUS%")

CreateEmail
Sub CreateEmail
     Set myOlApp = CreateObject("Outlook.Application")
     Set mail = myOlApp.CreateItem(olMailItem)
     mail.Subject = Status & " - " & ThreshDesc
     mail.Body = "Device: " & Device & vbCrlf & "Current Reading: " &
CurrentReading & vbCrlf & "Threshold: " & Threshold
     mail.To = "ISHelp"
     mail.Send
End Sub

Maybe this info can help you with your problem.  Don't give up, Thresholds
DO work in MRTG.


Eric Brander
ACS
Texas CHIP Account
Sr. Communications Engineer - Information Systems Department
512.336.3331
Eric dot Brander at acs-inc dot com


-----Original Message-----
From: Christophe Cornil [mailto:cco at clear2pay.com]
Sent: Tuesday, February 25, 2003 7:02 AM
To: mrtg at list.ee.ethz.ch
Subject: [mrtg] Re: External application for thresholds



Maybe I talked a little bit too fast.

Does someone knows what should be the exact way for the ThreshProgOKI to
be launched?

How MRTG knows, if the value is correct, that the previous one was not?
ThreshMinI is working , in my case, when HDD space goes under 200 Mb .
When I receive the alert, I delete some files to return above 200 Mb;
but the ThreshProgI never launch. 

Does MRTG create a file as flag or something, did I miss something? 

I don't think it's because of the program that should be launched
because I made a test with the same bat file for the ThreshMinI and
ThreshProgI (same path) and I have the same issue.

Thankks






Thanks guy for all the answers...
It works finally..

Apprently new version doesn't like to much Thresdir option.
Works if you do not pout this option and put the full path in the
threshprogI line.


Thanks for your support anyway.

-----Original Message-----
From: Christophe Cornil
Sent: Monday, February 24, 2003 9:08 AM
To: mrtg at list.ee.ethz.ch
Subject: [mrtg] External application for thresholds


Hi all,

My MRTG is almost working perfectly on Win2K Server.

MRTG version is 2.9.25

The only issue is : no application configured for ThreshProgI or works!

I create some batch files to send mail and create log when value of the
Hard disk Space pass under ThreshMinI.
Apparently, nothing that my .bat file should do is done. But if I look a
little bit closer, I can see a Dos prompt opening and closing very fast
(some milliseconds I guess) but, impossible to see what's going on.
I also have in my Thresholds directory (where my .bat files are) one
file appearing named: mrtg.cfg.servr_disk_e.minI   this file is empty.

Except that nothing happens. It looks like the application can't launch
another one.

I tried also with a test.bat with only a 'pause' command in there to see
my dos prompt staying on the screen but even that doesn't works.
Apparently it's not a problem about my file; but most a problem MRTG
have issue to call my .bat files.


This is the way I call my prog:

ThreshMinI[SERVER_DISK_E]: 6500
ThreshProgI[SERVER_DISK_E]: c:\mrtg\thresholds\under.bat



Note: I took the example of ThreshMinI, but, this is the same with
ThreshMaxI or ThreshMinO or ThreshMaxO,; I tried, still same issue.

Thanks for any help.

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

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

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

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