轮询参考变量并计算

<注意> 此范例仅供说明之用,本公司不提供技术支持。Ipswitch 为内容对象、SNMP API 和脚本环璄提供技术支持服务,但不对 JScript、VBScript,或活动脚本监控工具或操作的开发及侦错提供支持服务。如需此范例或自行编写脚本方面的协助,请造访 WhatsUp Gold 用户社群论坛

此性能监控工具会轮询参考变量,然后以返回值进行计算。

// 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);
}

另请参阅

活动脚本性能监控工具范例

以图形表示打印机墨水存量利用率

以图形表示温度监控工具

使用 SNMP GetNext

轮询多个参考变量