Chuck Black | 15 Dec 2012 00:02

sending SNMP requests from multiple source IP's through the same NIC

Does anybody know if it is possible to send SNMP requests from multiple IP
addresses on a single system, through a single NIC?  In other words, the
physical link to my system is actually trunked (link aggregation), and I
have multiple static IP addresses configured on my system through this one
NIC (interface card).  And I want to send SNMP requests out, using my
different source IP addresses on different requests.

I believe you can do this if you are using the normal Java socket class,
and so I'm hoping that you can do this through the SNMP APIs as well.  I'm
brand new to using snmp4j and don't have any other developers handy to ask,
so if you know the answer or have any ideas and could let me know, that'd
be great.

Thanks!
--- chuck black
Norberto R. de Goes Jr. | 14 Dec 2012 19:08
Picon

Virtual table

How are you doing?
I am using the SNMP4J in my agent implementation. The agent must provide a
long size table, then i am using the virtual table instrumentation.

But i am having difficult to understand the iterative process.

For each "tailIterator" do i have to create a new instance of iterator ?
When the process starts (trigger)? When the process stops?

Please, could you help me with a example ?

Thank you very much.

--

-- 
Norberto R. de Goes Jr.
CPqD - DRC
Tel.: +55 19 3705-4241 / Fax: +55 19 3705-6125
norberto@... <sperissi@...>
www.cpqd.com.br
Frank Fock | 7 Dec 2012 21:15
Favicon

Re: log4J in SNMP4J

Hi Akshay,

You do not need to write an adapter for log4j. Instead write a 
LogAdapter and LogFactory
subclass for the logging framework you are using and then register your 
factory as shown
by my last email.

Best regards,
Frank

Am 07.12.2012 16:18, schrieb Ballarpure, Akshay (NSN - IN/Hyderabad):
> log4J in SNMP4J
>
> Hi Frank,
>
> Thanks for your quick help.
>
> I have written adapter for Log4J but somehow I am not getting snmp4j 
> logs in my application. Instead MLog is using log4j.
>
> [2012-12-07 20:26:41,588] 
> INFO-main-com.motorola.nsm.common.fm.Snmp4jLog4jLogger ->logging with 
> log4j
>
> [2012-12-07 20:27:29,618] INFO-main-com.mchange.v2.log.MLog ->MLog 
> clients using log4j logging.
>
> [2012-12-07 20:27:30,362] INFO-main-com.mchange.v2.c3p0.C3P0Registry 
> ->Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; 
(Continue reading)

Frank Fock | 6 Dec 2012 18:49
Favicon

Re: log4J in SNMP4J

Hi,
Simply call

static {
   LogFactory.setLogFactory(new Log4jLogFactory());
}

in your main class.

Best regards,
Frank

Am 06.12.2012 15:19, schrieb Ballarpure, Akshay (NSN - IN/Hyderabad):
> log4J in SNMP4J
>
> Can someone help me how to use log4j in snmp4j.. any sample code if 
> available would help.
>
> Urgent reply is appreciated...
>
> --
>
> With Thanks & Regards,
>
> ***Akshay Ballarpure*
>
> (Office: +91-40-4472-***4112*
>

--

-- 
(Continue reading)

Wayne T | 29 Nov 2012 02:06
Picon
Favicon

snmp.inform question


The javadoc states the following for SNMP.inform(...)
Returns:the received response encapsulated in a ResponseEvent
    instance. To obtain the received response PDU call
    ResponseEvent.getResponse(). If the request timed out,
    that method will return null.
Throws:
java.io.IOException - if the inform request could not be send to the specified target.
The
 snmp.inform command always seems to return a resposeEvent with 
responseEvent.getResponse() == null.  It doesn't matter if I send to a 
IP Address that does not exist in the network, or on a port that is not 
listened on.  It also does not throw IOException.  

In fact, when
 I send an inform PDU using SnmpRequest with args "-v 2c -p INFORM", the
 following code is called but the response is always set to null.
      long startTime = System.nanoTime();
      responseEvent = snmp.send(request, target);
      if (responseEvent != null) {
        response = responseEvent.getResponse();
        System.out.println("Received response after "+
                           (System.nanoTime()-startTime)/1000000+" milliseconds");
      }

In what case does inform throw an IOException?

Is there something that needs to be initialized so that responseEvent.getResponse() will return
something other than null?

(Continue reading)

Jerome Callaghan | 26 Nov 2012 18:20
Favicon

v2 PDU in v1 message


Hello,

We have some devices which send traps in a v2 PDU but in a v1 message.  snmp4j discards these.  I've come up with a
source code change which looks ahead in v1 message processing to see if it's a v2 PDU and creates a v2 PDU
instead of a v1 PDU if so.  I've tested and it's working well.  Is there someone to talk to about getting this
into the source baseline for snmp4j?

Thank you,
Jerome
Li, Hoiying | 21 Nov 2012 20:20

Does snmp4j allow disabling v3 trap authentication?

Hi,

I implemented a simple snmp4j trap listener a while ago which has been receiving SNMPv1 and SNMPv2c traps
without any issue. Recently I noticed that my trap listener is not receiving v3 traps. According to the
following snmp4j documentation, to receive v3 traps, I have to add the highlighted code with the v3 USM
configured. My system allows various v3 credentials to be configured on the agents and the v3 credentials
are not naturally known to the trap listener. I'm wondering if snmp4j allows disabling v3 trap
authentication in some way so that my current trap listener code can also receive v3 traps without having
to configure USM?

Example for Receiving SNMP Messages
import org.snmp4j.*;
import org.snmp4j.smi.*;
import org.snmp4j.mp.SnmpConstants;
...
TransportMapping transport =
    new DefaultUdpTransportMapping(new UdpAddress("0.0.0.0/161"));
Snmp snmp = new Snmp(transport);
if (version == SnmpConstants.version3) {
    byte[] localEngineID =
        ((MPv3)snmp.getMessageProcessingModel(MessageProcessingModel.MPv3)).createLocalEngineID();
    USM usm = new USM(SecurityProtocols.getInstance(),
                      new OctetString(localEngineID), 0);
    SecurityModels.getInstance().addSecurityModel(usm);
    snmp.setLocalEngine(localEngineID, 0, 0);
    // Add the configured user to the USM
    ...
}
snmp.addCommandResponder(this);
snmp.listen();
(Continue reading)

Baskar Bharadwaj J | 21 Nov 2012 12:18
Picon

java.nio.BufferOverflowException on 64-bit

Hi Frank,
First of all many thanks for the direction provided by you.
We were using JDK 7 u1 where we had the issue, & after updating to JDK
7 u9 we do not see the issue (or at-least the application has been
running stable for 8 hours).
We are using single instance of 'Snmp' where again the issue gets
reproduced in JDK 7 u1.(but not in u9)

From Java release notes, I'am trying to trace which of the Java issues
between u1 & u9 that causes this problem, but could not find anything
very relevant. Kindly share if you are already in possesion of the
issue number/the root cause JVM bug.
(Again, this happens only on multi-threaded application, 64-bit processor/OS)

Also, do you have any suggestions on the recommended Java version
considering SNMP4j library? (i.e., works stable across 32-bit, 64-bit,
different OS'). Though we observed in JDK 7, could the older versions
5/6 also be vulnerable?

Alternately, will increasing the socket buffer size avoid the problem
totally irrespective of the JDK version? Since NIO channels are being
used inside SNMP4j, how is it recommended to increase the send buffer
size on windows? what value may be good enough (Application may use
upto 15 threads to send SNMP Get sub tree at a time)

Thanks in advance.
Baskar
Baskar Bharadwaj J | 20 Nov 2012 06:48
Picon

java.nio.BufferOverflowException on 64-bit Windows 2008

Hi,
We get an exception in our multi-threaded application that uses SNMP4j
2.0.3. Application sends get requests periodically to different agents
using SNMP4j, & suddenly the below exception arises (mostly between 30
min to 1 hr of starting the application). Once the below exception is
seen no further SNMP requests are getting processed (all requests fail
with the below exception).

Below exception is peculiarly observed only in Windows 2008 64-bit
platform. Same runs well for days on Windows 7 32-bit platform.

java.nio.BufferOverflowException
        at java.nio.Buffer.nextPutIndex(Unknown Source)
        at java.nio.HeapByteBuffer.put(Unknown Source)
        at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:63)
        at org.snmp4j.asn1.BER.encodeHeader(BER.java:118)
        at org.snmp4j.smi.Null.encodeBER(Null.java:95)
        at org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:180)
        at org.snmp4j.PDU.encodeBER(PDU.java:573)
        at org.snmp4j.mp.MPv1.prepareOutgoingMessage(MPv1.java:128)
        at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:472)
        at org.snmp4j.Snmp.sendMessage(Snmp.java:1005)
        at org.snmp4j.Snmp.send(Snmp.java:898)
        at org.snmp4j.Snmp.send(Snmp.java:878)
        at org.snmp4j.Snmp.send(Snmp.java:843)
        at org.snmp4j.Snmp.get(Snmp.java:555)

Has anybody else come across this problem?

Please share any pointers regarding the root cause of the observed
(Continue reading)

Binh Le | 16 Oct 2012 19:28
Picon

localEngineID and enterpriseID

Greetings,

I notice that the enterpriseID is hardcoded with the value 4976 in
org/snmp4j/mp/MPv3.java and the localEngineID is also created based on
that enterpriseID plus the host's IP address.

What can I do in order to create the localEngineID in a different
formula? I was thinking of subclass MPv3 and setting a new
localEngineID at agent startup from the new class. However, I also see
that MPv3 is statically referred in several places in the stack, so I
am afraid that SNMPv3 will not work if I subclass MPv3 like that that.

Would you please throw some suggestions?

Thanks a lot in advance,
Binh
Prema Upot | 2 Oct 2012 19:30

SNMP messages are not being send out

Hi,

We are encountering a situation where some SNMP messages are not going out of the machine where our
application(with snmp4j) is running. I see snmp4j debug logs that shows messages are being sent out but
wireshark dump does not have this message. We matched the request id in snmp4j logs to wireshark dump to
make sure the message is not there.

Eg: request id : 1200561071
2012-10-02 08:58:42,370 DEBUG  [ pool-1-thread-3           ] Running pending sync request with handle
PduHandle[1200561071] and retry count left 0
2012-10-02 08:58:42,370 DEBUG  [ pool-1-thread-3           ] Sending message to 192.168.30.161/161 with length
63: 30 3d 02 01 01 04 06 70 75 62 6c 69 63 a0 30 02 04 47 8f 1b af 02 01 00 02 01 00 30 22 30 12 06 0e 2b 06 01 04 01 81 bb 56 04 05
01 13 01 01 05 00 30 0c 06 08 2b 06 01 02 01 01 05 00 05 00

And after the 8 second timeout I see a log that this pending request was removed(but I don't see a
corresponding "Request timed out" log).

2012-10-02 08:58:50,370 DEBUG  [ pool-1-thread-3           ] Removed pending request with handle: PduHandle[1200561071]

I can see that the request previous to this one (id: 1200561070) and the next request (id: 1200561072) went
through fine.

Ours is a multi threaded application. Our snmp4j wrapper code is very similar to console.SnmpRequest but
we use Snmp object as a singleton. A different PDU is created every time we send a request.

Has someone come across such an issue before ? Can someone point to possible causes?

Thanks,
Prema
(Continue reading)


Gmane