[SNMP4J] SNMP4J Questions

Frank Fock fock at agentpp.com
Sun Sep 19 22:41:29 CEST 2004


Hi Mathias,

Please find my answers inline in the below.

Mathias Bogaert wrote:

> Hi,
>
> I'm evaluating SNMP4J to migrate to from IReasoning SNMP. So far it 
> looks really good, and I have a couple of questions:
>
> - it would be easy if we could have a wrapped value in the Variable 
> classes where supported; eg.
>
> PDU response = snmp.sendPDU(requestPDU, target);
>         if (response.getErrorStatus() != 0)
>         for (int i = 0; response != null && i < response.size(); i++) {
>             VariableBinding vb = response.get(i);
>             if (vb.getOid().equals("1.3.6.1.4.1.9.9.116.1.4.1.1.3")) {
>                 sample.setTotalModems(((Integer32) 
> vb.getVariable()).getWrappedValue());
>             }
>         }
>
> Where getWrappedValue returns an Integer object (as opposed to int). 
> Reason is that by default, primitive types have a 0 value, and when 
> storing this in the database using Hibernate, one cannot distinguish 
> between an actual value of 0 or null (e.g. network element was down). 
> new Integer((((Integer32) vb.getVariable()).getValue())) looks so 
> verbose :)
>
I understand your reasoning for numeric values, but how would you like
to inbox (opposite of outboxing) an OctetString value? Using the native
String class would return wrong values for some values (because String
uses UTF-8). Another problematic value type is OID.

What about an utility class/interface for converting a Variable into a 
native
representation and vice versa (i.e. a ValueConverter class)?

> - what is the best practice when querying +10 000 cable modems every 
> 15 minutes? Should I create one Snmp instance for each poller thread 
> that goes and polls 200 modems? Can I reuse the same requestPDU time 
> after time, to avoid construction? Any other performance tips?

1. Avoid request burst, because that would increase the likelihood of
UDP buffer overflows. Thus, I would distribute the requests equally
over the 15min.
2. If you can open 200 transport sockets (= threads) then this would
provide best performance, but using only 1 transport socket in 
conjunction with
asynchronous requests and (1) will also provide a very good performance.
3. Yes, you can reuse the PDU object. Just call PDU.clear() to remove
all VBs and reset the request ID.

>
> - in PDU response = snmp.sendPDU(requestPDU, target); when will 
> response be null? Is there a difference between a null or IOException? 
> How can I detect a 'timeout'?
>
Response == null => a timeout occured. If any other problem
has been detected when trying to send the PDU, then an IOException
is thrown.

Hope this helps. Please let us know how your migration evolves!

Best regards,
Frank






More information about the SNMP4J mailing list