[ Main Index | HowTo Index ]

The Launch App functionality in ipSentry is quite simple in most cases.  Problems do arise however, when you are attempting to launch batch or command files (.BAT or .CMD) to perform various tasks for the alert sequence rather than just an executable.

Depending on your system environment configuration and security issues, you may be able to specify the batch file directly.  In other instances, you will need to specify the command interpreter as the application and the batch file as part of the command line.

We will also cover command line parameters in our example to familiarize you with the ipSentry Keyword functionality as it relates to this alert option.

In our example, we have a batch file  that performs a trace-route to the host and then performs some external logging function (not sure exactly what it does, but it needs to be executed) and then exits.  To accomplish the trace-route, we will need the IP Address of the server we are monitoring to be passed to the batch file.  We also need to know if the batch is being executed because of a failure or because the problem was corrected (alert recovery).  

Note: This example assumes we are running Windows NT.

The batch file we will execute is called ROUTELOG.BAT looks like this:

::Logs traceroute results to our temporary log file
::and then executes ptlog.exe.
::ptlog.exe is an in-house utility that parses the
::log file and stores important routing information
::in our proprietary database.
::The command line should contain the IP Address of
::the machine, and the state of the machine as OK or CRITICAL
::eg: routelog x.x.x.x OK


Set CurIP=%1
Set CurState=%2

If %CurState%!==OK! Goto SkipTrace

Tracert -d %CurIP%>PTLOG.DAT

:: ptlog takes the IP and State as parameters.
ptlog %CurIP% %CurState%



The only functionality of the above batch file that concerns us in this example is the fact that we need to pass the IP Address and the machine state on the command line.  The rest is merely batch processing and beyond the scope of this document.

If we are at a command prompt and wanted to start this process for a failed machine at IP, we would enter the command routelog.bat CRITICAL.

In order to accomplish this from ipSentry, we will need to execute the command interpreter (CMD.EXE) with a command line to start this batch process.  This would look something like this:

C:\WinNT\System32\CMD.EXE /CE:\ipSentry\Etc\RouteLog.BAT CRITICAL

Note:  If the path or file name contains spaces, you will need to enclose the command in quotes.
e.g. "C:\Winnt\System32\cmd.exe" /C"E:\ipSentry\etc\routelog.bat CRITICAL"

So, how do we get this into ipSentry so that the IP Address and state of the machine are sent on this command line?

  1. Starting in the Launch Application tab of the Alerts tab of the Entry Editor.

  2. Select Enabled in the Alert Status box.

  3. Select the Trigger on Recovery option so that it is checked.

  4. In the Command Line field, enter the following:
    "C:\Winnt\System32\cmd.exe" /C"E:\ipSentry\etc\routelog.bat %%mach.net.address%% %%mach.state%%"

  5. Set the Alert Schedule as desired.

Notice the use of %%mach.net.address%% and %%mach.state%% ?  These are ipSentry Keyword that will be converted to the IP Address and Machine State of the current device whenever this alert is triggered.  Use of these keys will depend on the type of system being monitored such that NT Service monitoring does not make use of the IP Address definition.

When ipSentry detects a failure, it will launch the above command while replacing %%mach.net.address%% with the IP Address of the current machine and replacing %%mach.state%% with CRITICAL.  If alert success is checked, this will again be executed when the problem has been corrected with %%mach.state%% replaced with "OK".

Within the command line, ipSentry keywords are replaced before any processing of the command is performed.  You can use keywords as part of file names thus causing ipSentry to launch differently named processes based on machine state.

For example, if you want to launch MYPROGCRITICAL.EXE when the alert is triggered due to failure, the command line could be simply MYPROG%%mach.state%%.EXE - And when the same alert was triggered due to the alert success feature, it would be converted to MYPROGOK.EXE. 


     If you require additional assistance, please visit our on-line support forum at http://forum.ipsentry.com.
  Copyright ┬ę1997-2018 by RGE, Inc. - All Rights Reserved
  ipSentry┬« is a registered trademark of RGE, Inc.
Web Site: https://ipsentry.com
Support Email: support@ipsentry.com