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

}<br />

//nFinalTemp = (nFinalTemp - 32) * 5 / 9;<br />

Context.SetValue(nFinalTemp);<br />

Use SNMP GetNext.<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 walks the hrStorageType MIB to find hard disks in the storage<br />

table. After a hard disk is found, it obtains indexes of it and polls new objects (the storage size<br />

and units).<br />

// This scripts walks hrStorageType to find hard disks in the storage table.<br />

// A hard disk as a hrStorageType of "1.3.6.1.2.1.25.2.1.4" (hrStorageFixedDisk).<br />

// Then it gets the indexes of the hard disk in that table and for each index, it polls<br />

two new<br />

// objects in that table, the storage size and the units of that entry.<br />

// It adds everything up and converts it in Gigabytes.<br />

var hrStorageType = "1.3.6.1.2.1.25.2.3.1.2";<br />

// Create and initialize the snmp object<br />

var oSnmpRqst = new ActiveXObject("CoreAsp.SnmpRqst");<br />

var nDeviceID = Context.GetProperty("DeviceID");<br />

var oResult = oSnmpRqst.Initialize(nDeviceID);<br />

var arrIndexes = new Array(); // array containing the indexes of the disks we found<br />

// walk the column in the table:<br />

var oSnmpResponse = oSnmpRqst.GetNext(hrStorageType);<br />

if (oSnmpResponse.Failed) Context.SetResult(1, oSnmpResponse.GetPayload);<br />

var sOid = String(oSnmpResponse.GetOid);<br />

var sPayload = String(oSnmpResponse.GetPayload);<br />

while (!oSnmpResponse.Failed && sOid < (hrStorageType + ".99999999999"))<br />

{<br />

if (sPayload == "1.3.6.1.2.1.25.2.1.4") {<br />

// This storage entry is a disk, add the index to the table.<br />

// the index is the last element of the OID:<br />

var arrOid = sOid.split(".");<br />

arrIndexes.push(arrOid[arrOid.length - 1]);<br />

}<br />

}<br />

oSnmpResponse = oSnmpRqst.GetNext(sOid);<br />

if (oSnmpResponse.Failed) Context.SetResult(1, oSnmpResponse.GetPayload);<br />

sOid = String(oSnmpResponse.GetOid);<br />

sPayload = String(oSnmpResponse.GetPayload);<br />

934

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

Saved successfully!

Ooh no, something went wrong!