The following table lists several active script performance monitor code examples that you can use to create useful performance monitors for your devices. To use these examples, select the text of the context and then copy and paste the code into the Script text box of the Add Active Script Performance Monitor dialog.
Note: You may need to remove the copyright information from the cut and paste if it appears when you copy from this help file.
Monitor |
Code |
Polling one reference variable and perform arithmetic calculation with it. |
/ this script is a jscript that demonstrates how to use a reference variable in a script. // Poll reference variable RVsysUpTime var RVsysUpTime = Context.GetReferenceVariable("RVsysUpTime"); if (RVsysUpTime == null) // Pass a non zero error code upon failure with an error message. // Save the final value to graph: |
Using SNMP "GetNext." |
// This scripts walks hrStorageType to find hard disks in the storage table. var hrStorageType = "1.3.6.1.2.1.25.2.3.1.2"; // Create and initialize the snmp object var arrIndexes = new Array(); // array containing the indexes of the disks we found // walk the column in the table: while (!oSnmpResponse.Failed && sOid < (hrStorageType + ".99999999999")) { oSnmpResponse = oSnmpRqst.GetNext(sOid); Context.LogMessage("Found disk indexes: " + arrIndexes.toString()); if (arrIndexes.length == 0) Context.SetResult(1, "No disk found"); // now that we have the indexes of the disks. Poll their utilization and units oSnmpResponse = oSnmpRqst.Get("1.3.6.1.2.1.25.2.3.1.5." + arrIndexes[i]) nTotalDiskSize += (nSize * nUnits); } // return the total size in gigabytes. |
Polling multiple reference variables. |
// This script is a Jscript that will allow you to graph the percentage of restransmitted TCP // For this script, we use two SNMP reference variables: var RVtcpOutSegs = parseInt(Context.GetReferenceVariable("RVtcpOutSegs")); // The second reference variable RVtcpRetransSegs is defined with OID 1.3.6.1.2.1.6.12 and instance 0. It polls var RVtcpRetransSegs = parseInt(Context.GetReferenceVariable("RVtcpRetransSegs")); if (isNaN(RVtcpRetransSegs) || isNaN(RVtcpOutSegs)) // Set the performance monitor value to graph |