| | | Forum Newbie
       
Group: Forum Members Last Login: 6/23/2008 8:13:09 AM Posts: 9, Visits: 56 |
| Hello, I am trying to monitor the S0/0/0 interface sitting on my Cisco 2811. I would prefer to have an email sent out to my entire IT department as soon as this interface reaches more than 80%. I came across this script but I just don't know how to implement it correctly.
I hopped into WUG12 click on Configure and chose Action Library, clicked on New and selected Active Script Action Paste the text below into the script section then did the TEST, which came back successful. So where do I go from here?
// 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();
} |
| | | | Time Traveler
       
Group: Forum Members Last Login: 6/19/2008 4:58:30 PM Posts: 534, Visits: 1,874 |
| Firstly, the script was written for WUG11, it might not work for WUG12
Assuming it does :
1- change the following line to suit your need :
// Definition of Maximum allowable interface utilization percentage
// Change this value to what you want to alarm at. We use 80%.
var nMaxUtilizationPercentage = 80;
2- apply it to a device
3- set an action
Nothing out of ordinary, actually. |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 6/23/2008 8:13:09 AM Posts: 9, Visits: 56 |
| | So I added the script to one of my Cisco 2811's, but when applying an "Email Alert" I have to chose a state of condition. From what others have told me, is that the script is suppose to put the device in a Non responding condition (yellow DOWN 0 minutes) when it Utilizes more than 80%. Thats when you specify the Email Action to send as soon as it goes in a state condition of "DOWN". But what happens when it looses connection and goes in a state of "DOWN"? will I receive emails saying that it is currently "Utilizing more than 80%" when in fact, it's just loosing the connection. |
| | | | Time Traveler
       
Group: Forum Members Last Login: 6/19/2008 4:58:30 PM Posts: 534, Visits: 1,874 |
| this specific script won't fail, because it doesn't poll the device itself : it retrieve from the WUG DB values that were already polled from the device.
But yes, if you have other monitors that *does* poll the device, if the device gets completely down, each of these monitors will go down.
If you set action at the device level you will get only one alert, if you set actions at the monitor-level you will get multiple ones. |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 6/23/2008 8:13:09 AM Posts: 9, Visits: 56 |
| Here is the script that IPswitch sent me for WUGv12
' Definition of Maximum allowable interface utilization percentage
' Change this value to what you want to alarm at. We use 80%.
nMaxUtilizationPercentage = 80
' Get the Open DB connection from the Context NameSpace
Set oDb = Context.GetDB
If oDb Is Nothing Then
Context.SetResult 1, " Problem creating the DB object"
End If
' Get the device ID
nDeviceID = Context.GetProperty("DeviceID")
sSql = "Select sDisplayName from Device where nDeviceID = ' " & nDeviceID & " ' "
set oRsName = oDb.Execute(sSql)
Context.LogMessage "Checking Device " & oRsName("sDisplayName")
' Retrieve the nPivotStatisticalMonitorTypeToDeviceID
sSql = "SELECT nPivotStatisticalMonitorTypeToDeviceID from PivotStatisticalMonitorTypeToDevice WHERE nDeviceID = " & nDeviceID
set oRs = oDb.Execute(sSql)
nPivotStatisticalMonitorTypeToDeviceID = oRs("nPivotStatisticalMonitorTypeToDeviceID")
' Retrieve all interfaces for the device for the last 10 minutes
sSql3="SELECT " & _
"SI.dPollTime," & _
"SI.nIfInOctets_Max AS nInOctetsMax, " & _
"SI.nIfOutOctets_Max AS nOutOctetsMax, " & _
"SI.nIfSpeedIn AS nIfSpeedBps, " & _
"SII.sIfDescr AS sIfDescription " & _
"FROM StatisticalInterface as SI " & _
"Inner Join " & _
"StatisticalInterfaceIdentification as SII " & _
"ON (SII.nStatisticalInterfaceIdentificationID=SI.nStatisticalInterfaceIdentificationID) " & _
"where SI.dPollTime > dateadd(mi,-10,getdate()) " & _
"AND SII.nPivotStatisticalMonitorTypeToDeviceID=' " & nPivotStatisticalMonitorTypeToDeviceID & " ' " & _
"Order By sIfDescription, SI.dPollTime "
set oRs2 = oDb.Execute(sSql3)
oRs2.MoveFirst()
' Run the recordset
Do While Not oRs2.EOF
nIfSpeed = oRs2("nIfSpeedBps")
nIfIn_Avg = oRs2("nInOctetsMax")
nIfOut_Avg = oRs2("nOutOctetsMax")
nIfDescr = oRs2("sIfDescription")
Context.LogMessage "Checking Interface " & nIfDescr
If nIfSpeed > 0 Then
nInPercentage = Round((nIfIn_Avg / nIfSpeed * 100), 2)
nOutPercentage = Round((nIfOut_Avg / nIfSpeed * 100), 2)
Else
nInPercentage = 0
nOutPercentage = 0
End If
oRs2.moveNext()
Context.LogMessage "Utilization Out: " & nOutPercentage & "%"
Context.LogMessage "Utilization In: " & nInPercentage & "%"
If nInPercentage > nMaxUtilizationPercentage Or nOutPercentage > nMaxUtilizationPercentage Then
oDisplay = " Failure: Interface " & nIfDescr
oDisplay = oDisplay & " is running at "
oDisplay = oDisplay & nInPercentage
oDisplay = oDisplay & "%/" & nOutPercentage
oDisplay = oDisplay & "% utilization inbound/outbound (threshold is "
oDisplay = oDisplay & nMaxUtilizationPercentage & "%)."
Context.SetResult 1, oDisplay
Else
Context.SetResult 0, " Ok"
End If
Loop |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 5/16/2008 8:15:50 AM Posts: 5, Visits: 9 |
| | |
|
|