Mike Rockwell (Progress Software) asked a question.

Poll a reference variable and perform a calculation (example for SNMP System UpTime)

This is an example to use a Reference variable in an Active Script Performance monitor, poll the SNMP System UP time (in hundreths of a second) and perform a calculation to return it in hours.

 

  1. Create an Active Script Performance monitor
    1. Name: System Up Time
    2. Description: Tracks how long an SNMP enabled device has been Up in Hours
    3. Script Type: JScript
  2. Add New Reference Variable
    1. Name: RVsysUpTime
    2. Description: The time (in hundredths of a second) since the network management portion of the system was last re-initialized.
    3. Select: SNMP
    4. Counter: 1.3.6.1.2.1.1.3
    5. Instance: 0
    6. Save
  3. In the script block enter the below JScript
  1. // This script is a JScript that demonstrates how to use a reference variable in a script.  
  2. // The reference variable "RVsysUpTime" is an SNMP reference variable defined  
  3. // with an OID of 1.3.6.1.2.1.1.3 and instance of 0.  
  4.   
  5. // Poll reference variable RVsysUpTime  
  6. var RVsysUpTime = Context.GetReferenceVariable("RVsysUpTime");  
  7.   
  8. if (RVsysUpTime == null) {  
  9.     // Pass a non zero error code upon failure with an error message.  
  10.     // The error message will be logged in the Performance Monitor Error Log  
  11.     // and in the eventviewer.  
  12.     Context.SetResult(1, "Failed to poll the reference variable.");  
  13. }  
  14. else {  
  15.     // Success, use the polled value to convert sysUpTime in hours.  
  16.     // sysUpTime is an SNMP timestamp which is in hundredths of seconds:  
  17.     var sysUpTimeHours = RVsysUpTime / 3600 / 100;  
  18.     // Save the final value to graph:  
  19.     Context.SetValue(sysUpTimeHours);  
  20. }

This came from the v15 Help file