InterfaceStatisticsListener

Document created by cdnadmin on Jan 25, 2014
Version 1Show Document
  • View in full screen mode
This document was generated from CDN thread

Created by: Jason Edelman on 10-10-2013 08:30:05 PM
Hi,

I've been thinking my code was causing errors in my application and not I'm not sure so figured I'd see if there were any known bugs specifically with retrieving interface statistics.
 1InterfaceStatListenerService interfaceListener = new InterfaceStatListenerService();
 2
 3InterfaceStatisticsFilter statsFilter = new InterfaceStatisticsFilter(InterfaceStatistics.InterfaceStatisticsParameter.ONEP_IF_STAT_INTERFACE_RESETS,OnepOperatorType.ONEP_OP_GE, 5,InterfaceStatisticsType.ONEP_INTERFACE_STATISTICS_TYPE_VALUE);
 4
 5statsFilter.setPollInterval(new Period(10, 0))  
 6def interfaces = getInterfaces(ne)
 7
 8for (NetworkInterface interf : interfaces)
 9{
10interf.addStatisticsListener(interfaceListener, statsFilter, null)
11}
Above is the code I use to add the stats listener on all interfaces.  It adds just fine and works as expected, but once I manually drive the "interface resets" up in order to trigger multiple events, the application usually disconnects to the device and has a long list of java errors usually starting with 'cannot write to output stream.'  The first few events work fine, but once I get 3 or 4 interfaces with 5 resets, the app pretty much crashes.

I reduced the statsFilter at one point to trigger above 1 reset instead of 5 and the app crashed right on the start b/c many of the IOL routers start at 1 reset...

For what it's worth, I am using the onePK runtime utility (ORU) and the 5star topology running IOL, so maybe it's the routers rejecting connections as well and not the app.  

Any ideas or thoughts are greatly appreciated.

Thanks,
Jason

Subject: RE: InterfaceStatisticsListener
Replied by: Joseph Clarke on 11-10-2013 12:30:02 AM
The first thing I notice is that you are using a value type for interface resets.  Since resets is a counter, you should be using increment (InterfaceStatisticsFilter.InterfaceStatisticsType.ONEP_INTERFACE_STATISTICS_TYPE_INCREMENT).  This way, you will only get an event if the value changes between polling cycles.  I have a small Swing app I wrote that uses this same interface, and it works quite well.

That said, the other thing in my case is that I'm using the 1.0 API with vIOS, not IOL.  I'm pretty sure I used this same app with 0.6, but it's been a long time, an I can't remember exactly.

Subject: RE: InterfaceStatisticsListener
Replied by: Jason Edelman on 11-10-2013 07:03:28 AM
Good info!  Thanks, Joe.

Think I saw you present at Cisco Live on NMS/programmability.  Hard to tell from your picture....job well done if that was you!  Thanks again and I'll try this later on tonight.

That said, even if it does trigger an event for each polling cycle, why should that cause a problem?

-Jason

Subject: RE: InterfaceStatisticsListener
Replied by: Joseph Clarke on 11-10-2013 10:36:45 AM
Thanks.  Likely could have been me.  I did present at CLUS on network programmability and NMS (with Jason Davis).  Yeah, that's a weird picture of me since I never wear a suit.

Likely the fact that you're triggering an event so frequently is the problem.  You're also using some old code.  We have fixed a lot of bugs in the 1.1 API and device layers.  Nonetheless, switching to increment will typically reduce the event frequency (unless you're getting a lot of resets).

Subject: RE: InterfaceStatisticsListener
Replied by: Joseph Clarke on 11-10-2013 11:28:37 AM
Joseph Clarke:
The first thing I notice is that you are using a value type for interface resets.  Since resets is a counter, you should be using increment (InterfaceStatisticsFilter.InterfaceStatisticsType.ONEP_INTERFACE_STATISTICS_TYPE_INCREMENT).  This way, you will only get an event if the value changes between polling cycles.  I have a small Swing app I wrote that uses this same interface, and it works quite well.

That said, the other thing in my case is that I'm using the 1.0 API with vIOS, not IOL.  I'm pretty sure I used this same app with 0.6, but it's been a long time, an I can't remember exactly.
I figured I'd attach my LiveInterface code as an example just to make sure everything is clear.

Outcomes