[SNMP4J] Statistics about number of retries and snmp request times

MichaƂ Steiner mist at mist.pl
Fri Jan 22 10:05:54 CET 2016


Hi,

I'm looking for  a way to gather detailed statistics about SNMP
communication (number of retries and exact times).
SNMP4j supports  re-sending request if response didn't come within timeout
limit which is very useful feature but it can mask some issues existing in
the network. For example when there is a lot of retries because we are
loosing some pockets, it will not be obviously visible. To find out how
many retries was required you need to measure time between send request and
getting response then depending on your TimeOutModel you need make some
calculations.

This approach is not very useful because:
- calculations may not be accurate  because we measure time of whole
message handling not sending single PDU
- you will need to modify all places in your code where you calling SNMP4j
send method. It could be many of them.

Much better would be have possibility to get such info from Snmp class. For
example you could add request  listener to the Snmp, and  in
 PendingRequest#responseReceived() method notify it about received
response, something like this:

public void responseReceived() {

requestListener.onResponseReceived(
target.getAddress(), //ip address
pdu.getType(),  //get get-next etc
pdu.size(),  //how many oids
(System.nanoTime() - startedInNano) /
SnmpConstants.MILLISECOND_TO_NANOSECOND ,  //how many ms was from creation
of thiss PendingRequest till getting response
target.getRetries() - retryCount);//how many retries

this.responseReceived = true;
...

  public interface RequestListener{
    void onResponseReceived(Address address,int type, int size, long
durationInMs, int retries);
  }



Passing this request listener would be optional. It would be useful to have
also info about request without response and cancelled.

Do you think it is good approach ?

Maybe you have other ideas how to gather such data?

Best Regards
Michal



More information about the SNMP4J mailing list