Monitor Ping value in WUG


‘Whats Up Gold’ is one of my favorite monitoring tools. A big reason is that it allows me to create my own monitoring items.

One typical example is to monitor the ping round trip time to make sure the ISP service meets their SLA. 

I found the following Jscript somewhere in the Whatsup forum. And I added it to the Active Monitor module and change the MaxRoundTripTime value to what stated in the SLA. Once the round trip time is bigger than the value, a alarm will be triggered.

**********************************************************

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 = 235;

// 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”);
  }

}

**********************************************************

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s