16.01.2013 Views

Ipswitch WhatsUp Gold User Guide - Ipswitch Documentation Server

Ipswitch WhatsUp Gold User Guide - Ipswitch Documentation Server

Ipswitch WhatsUp Gold User Guide - Ipswitch Documentation Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Ipswitch</strong> <strong>WhatsUp</strong> <strong>Gold</strong> <strong>User</strong> <strong>Guide</strong><br />

if (prtMarkerSuppliesMaxCapacity == null || prtMarkerSuppliesLevel == null) {<br />

}<br />

Context.SetResult(0, "Failed to poll printer ink levels.");<br />

else {<br />

Context.LogMessage("marker lever successfully retrieved");<br />

var nPercentMarkerUtilization = 100 * prtMarkerSuppliesLevel / prtMarkerSuppliesMaxCapacity;<br />

Context.LogMessage("Percent utilization=" + nPercentMarkerUtilization + "%");<br />

Context.SetValue(nPercentMarkerUtilization);<br />

Poll a reference variable and perform a calculation<br />

Note: This example is provided as an illustration only and is not supported. Technical support<br />

is available for the Context object, SNMP API, and scripting environment, but <strong>Ipswitch</strong> does<br />

not provide support for JScript, VBScript, or developing and debugging Active Script<br />

monitors or actions. For assistance with this example or with writing your own scripts, visit<br />

the <strong>WhatsUp</strong> <strong>Gold</strong> user community (http://www.whatsupgold.com/wugspace).<br />

This performance monitor polls a reference variable, and then performs an arithmetic<br />

calculation with the returned value.<br />

// This script is a JScript that demonstrates how to use a reference variable in a<br />

script.<br />

// The reference variable "RVsysUpTime" is an SNMP reference variable defined<br />

// with an OID of 1.3.6.1.2.1.1.3 and instance of 0.<br />

// Poll reference variable RVsysUpTime<br />

var RVsysUpTime = Context.GetReferenceVariable("RVsysUpTime");<br />

if (RVsysUpTime == null) {<br />

// Pass a non zero error code upon failure with an error message.<br />

// The error message will be logged in the Performance Monitor Error Log<br />

// and in the eventviewer.<br />

Context.SetResult(1, "Failed to poll the reference variable.");<br />

}<br />

else {<br />

// Success, use the polled value to convert sysUpTime in hours.<br />

// sysUpTime is an SNMP timestamp which is in hundredths of seconds:<br />

var sysUpTimeHours = RVsysUpTime / 3600 / 100;<br />

// Save the final value to graph:<br />

Context.SetValue(sysUpTimeHours);<br />

}<br />

932

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!