| | | Forum Newbie
       
Group: Forum Members Last Login: 4/17/2008 9:44:44 AM Posts: 8, Visits: 15 |
| | so after a few hours of reading documentation, i'm still confused as ever on how to create an active script. This is what i need to accomplish. i want a monitor in place to alert me via e-mail when my multilink starts spiking over 50%. i found the script for it but i'm having a hard time trying to implement it. here is the script that i have, it keeps giving me error messages. any help would be greatly appreciated. var oDb = Context.GetDB; if (null == oDb) { Context.SetResult( 1, " Problem creating the DB object"); } else { var nDeviceID = Context.GetProperty("DeviceID");
var nMaxUtilizationPercentage = 50; var sSql = "SELECT nPivotStatisticalMonitorTypeToDeviceID from PivotStatisticalMonitorTypeToDevice WHERE nDeviceID = " + nDeviceID; var oRs = oDb.Execute(sSql); var nPivotStatisticalMonitorTypeToDeviceID = oRs("nPivotStatisticalMonitorTypeToDeviceID"); 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"); } } } |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 4/17/2008 9:44:44 AM Posts: 8, Visits: 15 |
| | how do i implement this script?? |
| | | | Forum Member
       
Group: Forum Members Last Login: 5/14/2008 6:59:48 AM Posts: 32, Visits: 53 |
| No promises that this will work straight away for you, but here is the modified script which works fine for us // 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 {var oRs = new ActiveXObject("ADODB.Recordset"); // Get the device ID var nDeviceID=0; 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 bEnabled=1 AND nStatisticalMonitorTypeID = 1 AND nDeviceID = " + nDeviceID; var oRs = oDb.Execute(sSql); var nPivotStatisticalMonitorTypeToDeviceID = oRs("nPivotStatisticalMonitorTypeToDeviceID"); // Retrieve the nStatisticalInterfaceIdentificationID var sSql = "SELECT nStatisticalInterfaceIdentificationID from StatisticalInterfaceIdentification WHERE nIfInSpeedCustom > 0 AND nPivotStatisticalMonitorTypeToDeviceID = " + nPivotStatisticalMonitorTypeToDeviceID; var oRs = oDb.Execute(sSql); var nStatisticalInterfaceIdentificationID = oRs("nStatisticalInterfaceIdentificationID"); // Retrieve the data for the device var sSql3 = "SELECT nIfInOctets_AVG AS nInOctetsMax, nIfOutOctets_AVG AS nOutOctetsMax, nIfSpeedIn AS nIfSpeedInBps, nIfSpeedOut AS nIfSpeedOutBps FROM StatisticalInterfaceCache WHERE nStatisticalInterfaceIdentificationID = " + nStatisticalInterfaceIdentificationID; oRs = oDb.Execute(sSql3); oRs.moveFirst(); var nInPercentage = 0; var nOutPercentage = 0; while ( !oRs.EOF ) { var nIfSpeedIn = oRs("nIfSpeedInBps"); var nIfSpeedOut = oRs("nIfSpeedOutBps"); var nIfIn_Avg = oRs("nInOctetsMax"); var nIfOut_Avg = oRs("nOutOctetsMax"); if ( nIfSpeedIn > 0 ) { var nInPercentage = Math.round((nIfIn_Avg/(nIfSpeedIn / 10))*100); var nOutPercentage = Math.round((nIfOut_Avg/(nIfSpeedOut / 10))*100); } else { nInPercentage = 0; nOutPercentage = 0; } oRs.moveNext(); if ( nInPercentage > nMaxUtilizationPercentage || nOutPercentage > nMaxUtilizationPercentage) { var oDisplay; oDisplay = nDeviceID+" Failure: Interface "; oDisplay += " is running at "; oDisplay += nInPercentage; oDisplay += "%/" + nOutPercentage; oDisplay += "% utilization inbound/outbound (threshold is "; oDisplay += nMaxUtilizationPercentage + "%)."; Context.SetResult( 1, oDisplay); } else { Context.SetResult(0, nDeviceID+" Ok - Utilization Speed Normal" + nOutPercentage +"% / " + nInPercentage+"%"); } } oRs.Close(); }
|
| | | | Forum Newbie
       
Group: Forum Members Last Login: 4/17/2008 9:44:44 AM Posts: 8, Visits: 15 |
| | | | | Forum Newbie
       
Group: Forum Members Last Login: 4/17/2008 9:44:44 AM Posts: 8, Visits: 15 |
| | i'm getting this error message when i test it. Error: Source:'Microsoft OLE DB Provider for ODBC Drivers' Line:26 Char:2 Error:0 '[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '='.' -v (null)
|
| | | | Forum Member
       
Group: Forum Members Last Login: 5/14/2008 6:59:48 AM Posts: 32, Visits: 53 |
| | I honestly don't have a clue why this is not working for you. Can I just check that you do have a network interface performance monitor also on the device? |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 4/17/2008 9:44:44 AM Posts: 8, Visits: 15 |
| | i do. i'm not actually attaching the active monitor to a device yet. This is how i get that error. I create a new active script monitor in the active script monitor library, copy the script, select the script i just created and click the test button. it comes back with that error. |
| | | | Forum Member
       
Group: Forum Members Last Login: 5/14/2008 6:59:48 AM Posts: 32, Visits: 53 |
| | Right, I have tried the test button as well. If I select the device that has a performance monitor attached to it, everything works fine. However if I just select a random device with no performance monitor I get the same error as you. Can you make sure there is a performance monitor (SNMP interface traffic) on the device you are testing? This script only checks the values written to the DB by the performance monitor. |
| | | | Forum Newbie
       
Group: Forum Members
|
| |
|