// Get the Open DB connection from the Context NameSpace 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 allowable interface utilization percentage // Change this value to what you want to alarm at. We use 80%. var nMaxUtilizationPercentage = 80; // Retrieve the nPivotStatisticalMonitorTypeToDeviceID var sSql = "SELECT nPivotStatisticalMonitorTypeToDeviceID from PivotStatisticalMonitorTypeToDevice WHERE nDeviceID = " + nDeviceID; var oRs = oDb.Execute(sSql); var nPivotStatisticalMonitorTypeToDeviceID = oRs("nPivotStatisticalMonitorTypeToDeviceID"); // Retrieve the data for the device var sSql3 = "SELECT nIfInOctets_Max AS nInOctetsMax, nIfOutOctets_Max AS nOutOctetsMax, nIfSpeed AS nIfSpeedBps, sIfDescr FROM StatisticalInterface WHERE nPivotStatisticalMonitorTypeToDeviceID = " + nPivotStatisticalMonitorTypeToDeviceID; oRs2 = oDb.Execute(sSql3); oRs2.moveFirst(); while ( !oRs2.EOF ) { var nIfSpeed = oRs2("nIfSpeedBps"); var nIfIn_Avg = oRs2("nInOctetsMax"); var nIfOut_Avg = oRs2("nOutOctetsMax"); var nIfDescr = oRs2("sIfDescr"); if ( nIfSpeed > 0 ) { var nInPercentage = Math.round((nIfIn_Avg / nIfSpeed * 100)); var nOutPercentage = Math.round((nIfOut_Avg / nIfSpeed * 100)); } else { var nInPercentage = 0; var nOutPercentage = 0; } oRs2.moveNext(); if ( nInPercentage > nMaxUtilizationPercentage || nOutPercentage > nMaxUtilizationPercentage) { var oDisplay; oDisplay = " Failure: Interface " + nIfDescr; oDisplay += " is running at "; oDisplay += nInPercentage; oDisplay += "%/" + nOutPercentage; oDisplay += "% utilization inbound/outbound (threshold is "; oDisplay += nMaxUtilizationPercentage + "%)."; Context.SetResult( 1, oDisplay); } else { Context.SetResult(0, " Ok"); } } }