This context object is available to the script programmer when scripts are executing. It delivers context aspects of the device that it is operating on. All methods and properties are retrieved using the "Context" namespace.
Note: This context object only applies to the script action plug-in.
Methods |
|
LogMessage(sText); |
This methods allows for a message to be written to the WhatsUp Gold debug log. Messages are displayed in the Event Viewer. Example: JScript
VBScript
|
SetResult(LONG nCode, sText); |
This method allows for a result code and result message to be set. This is how you can tell the WhatsUp Gold system if the action succeeded or not. Example: JScript
VBScript
|
NotifyProgress(sText); |
This method allows for a message to be written to the actions progress dialog. Messages are displayed in the Test dialog and Running Actions dialog. Example: JScript
VBScript
|
IsCancelled(); |
This method is used to test whether this action has been cancelled by the user. It is highly recommended that the script writer test this on a regular basis. If the return is true then you must terminate your script. A cancel can be issued by the user in the action progress dialog and by the WhatsUp Gold engine when shutting down. |
Properties |
|
GetProperty(bsPropertyName); |
|
"ActionTypeName" |
The action display name |
"Address" |
The IP Address of the device |
"Name" |
Network name of the device |
"DisplayName" |
Display name of the device |
"DeviceID" |
The device ID |
"ActionTypeID" |
The action type ID |
"TriggerCondition" |
The reason the action was fired. Trigger values: 1 Monitor changed from DOWN to
UP |
Examples:
JScript
var sAddress =
Context.GetProperty("Address");
var nDeviceID = Context.GetProperty("DeviceID");
get_GetDB;
This property returns an open connection to the WhatsUp PRO database.
Examples:
JScript
This examples gets the Open connection and reads some values out of the WhatsUp Gold Device table using the deviceID in context.
var oDb =
Context.GetDB;
if (null == oDb)
{
Context.SetResult( 1, " Problem creating the DB
object");
}
else
{
var oRs = new ActiveXObject("ADODB.Recordset");
// Get the device ID
var nDeviceID = Context.GetProperty("DeviceID");
var sSql = "SELECT * from Device WHERE nDeviceID = " +
nDeviceID;
oRs = oDb.Execute(sSql);
if ( !oRs.EOF )
{
var sDisplay;
sDisplay = "" + oRs("sDisplayName");
Context.LogMessage("Display Name=" +
sDisplay);
sDisplay = "" + oRs("nWorstStateID");
Context.LogMessage("WorstStateID=" +
sDisplay);
sDisplay = "" + oRs("sNote");
Context.LogMessage("Note=" + sDisplay);
sDisplay = "" + oRs("sStatus");
Context.LogMessage("Status=" +
sDisplay);
}
Context.SetResult( 0, " Ok");
}