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