var oDb = Context.GetDB; if (null == oDb) { Context.SetResult( 1, " Problem creating the DB object"); } else { // Get the device ID var nDeviceID = Context.GetProperty("DeviceID"); // Definition of Maximum PING Latency in ms // Change this value to what you want to alarm at. var MaxRoundTripTime = 3000; // Retrieve the nPivotStatisticalMonitorTypeToDeviceID for Ping Response(Monitor Type=3), Refer to dboStatisticalMonitorType for ComponentType var sSql = "SELECT nPivotStatisticalMonitorTypeToDeviceID from PivotStatisticalMonitorTypeToDevice WHERE nStatisticalMonitorTypeID=3 and nDeviceID = " + nDeviceID; var oRs = oDb.Execute(sSql); var nPivotStatisticalMonitorTypeToDeviceID = oRs("nPivotStatisticalMonitorTypeToDeviceID"); // Retrieve the data for the device var sSql2 = "SELECT nRoundTripTime_Avg AS RoundTripTime_Avg, nRoundTripTime_Max AS RoundTripTime_Max,nNetworkInterfaceID AS NetworkInterfaceID FROM StatisticalPingCache WHERE nPivotStatisticalMonitorTypeToDeviceID = "+nPivotStatisticalMonitorTypeToDeviceID; oRs2 = oDb.Execute(sSql2); oRs2.moveFirst(); var nExceed = 0; var oDisplay="High Ping Response Time at\n\n "; while ( !oRs2.EOF ) { var RTTime = oRs2("RoundTripTime_Avg"); var IfMonID = oRs2("NetworkInterfaceID"); if ( RTTime > MaxRoundTripTime) { var sSql3 = "SELECT sNetworkAddress, sNetworkName FROM NetworkInterface WHERE nNetworkInterfaceID = " +IfMonID; var oRs3 = oDb.Execute(sSql3); var sNetworkAddress = oRs3("sNetworkAddress"); var sNetworkName = oRs3("sNetworkName"); nExceed += 1; oDisplay += "NetworkName : " + sNetworkName + " [ NetworkAddress : " + sNetworkAddress + " ], it is at "+ RTTime + "ms.\n\n"; } oRs2.moveNext(); } oDb.Close(); //Close database connection if ( nExceed > 0) { Context.SetResult( 1, oDisplay); } else { Context.SetResult(0, " Ok"); } }