<注意> 此范例仅供说明之用,本公司不提供技术支持。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);
}