Using the context object with performance monitors

The context object provides an interface for your script to interact with WhatsUp Gold.

All methods and properties are retrieved using the Context namespace.

Note: You may have to remove the copyright information from the cut and paste if it appears when you copy from this help file.

Methods

Method description

LogMessage(sText);

This method allows for a message to be written to the WhatsUp Gold debug log.

Example

JScript

Context.LogMessage( "Checking Monitor name using Context.GetProperty()");

VBScript

Context.LogMessage "Checking Address using Context.GetProperty()"

PutProperty(sPropertyName);

This method allows you to store a value in the INMSerialize object. This value is retained across polls.

Example

JScript

var nCount = parselnt(nNum) +1;
Context.PutProperty("MyNumeric",nCount);

SetResult(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 monitor succeeds or fails.

Every script should call SetResult. If SetResult is not called, the script is always assumed to have succeeded.

Example

JScript

Context.SetResult(0, "Script completed successfully."); //Success
Context.SetResult(1, "An error occurred."); //Failure

VBScript

Context.SetResult 1, "An error occurred."

GetReferenceVariable(sRefVarName );

This method allows the code to grab a reference variable to be used in the monitor.

Example

JScript

Context.GetReferenceVariable("A")

A reference variable "A" would have had to have been created.

SetValue(nValue);

This method allows you to graph a value.

Example

JScript

Context.SetValue(245)

GetProperty(sPropertyName);

This method offers access to any of the device properties listed below. These names are case sensitive.

Property

Description

"ActiveMonitorTypeName"

The active monitor display name

"Address"

The IP address of the device

"DeviceID"

The device ID

"Mode"

1 =  doing discovery
2 =  polling
3 =  test

"ActiveMonitorTypeID"

The active monitor's type ID

"CredSnmpV1:ReadCommunity"

SNMP V1 Read community

"CredSnmpV1:WriteCommunity"

SNMP V1 Write community

"CredSnmpV2:ReadCommunity"

SNMP V2 Read community

"CredSnmpV2:WriteCommunity"

SNMP V2 Write community

"CredSnmpV3:Username"

SNMP V3 Username

"CredSnmpV3:Context"

SNMP V3 Context

"CredSnmpV3:AuthPassword"

SNMP V3 Authentication password

"CredSnmpV3:AuthProtocol"

SNMP V3 Authentication protocol

"CredSnmpV3:EncryptPassword"

SNMP V3 Encrypt password

"CredSnmpV3:EncryptProtocol"

SNMP V3 Encrypt protocol

"CredWindows:DomainAndUserid"

Windows NT Domain and User ID

"CredWindows:Password"

Windows NT Password

Example

JScript

var sAddress = Context.GetProperty("Address");
var sReadCommunity = Context.GetProperty("CredSnmpV1:ReadCommunity");
var nDeviceID = Context.GetProperty("DeviceID");

See Also

Scripting Performance Monitors

Example active script performance monitors