SNMP4J- where is processPdu called in the program?

Hello Everyone,
I’ve made the simplest possible agent just to check if it can respond to the PDUs received from the manager. Although I’ve written the following code with the help of the SNMP4J tutorials, I have my doubt as to where is the processPdu function called in the program? I’ve written it fine, but I don’t see it being called. Thus, where is it that the PDU sent from the manager is actually received? Following is my code and the errors it generates. Please tell me where I’m going wrong. Also, since i'm working on Eclipse IDE, it seems quite confusing to me how to execute manager and agent together in order to create a communication session( just da way v do in socket programming). it seems that i can only run either of them at a time..
public class SNMP4J_AGENT extends Thread implements CommandResponder
* @param args
// Processes incoming Pdu
public synchronized void processPdu(CommandResponderEvent e)
System.out.println("Command");
ScopedPDU command;
if ( e.getPDU() instanceof ScopedPDU)
command = (ScopedPDU)e.getPDU();
else
command = (ScopedPDU)e.getPDU();
if (command != null)
//send reply
ScopedPDU cmd = (ScopedPDU)e.getPDU();
cmd.setType(ScopedPDU.RESPONSE);
cmd.setRequestID(command.getRequestID());
StatusInformation st=new StatusInformation(new VariableBinding(),
e.getStateReference().getContextName(),
e.getStateReference().getContextEngineID(),
new Integer32( e.getStateReference().getSecurityLevel()) );
StatusInformation statusInformation = new StatusInformation();
StateReference ref = e.getStateReference();
System.out.println(ref);
try
e.getMessageDispatcher().returnResponsePdu(e.getMessageProcessingModel(),
e.getSecurityModel(),
e.getSecurityName(),
e.getSecurityLevel(),
command,
e.getMaxSizeResponsePDU(),
ref,
st);
System.out.println("Response sent to manager....");
catch (MessageException e1)
e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates
@Override
public void run()
//InetAddress hostIp;
//int port_, version;
try
//Sets the snmp listener to port
TransportMapping transport = new DefaultUdpTransportMapping(new UdpAddress("udp:127.0.0.1/161"));
Snmp snmp = new Snmp(transport); //snmp.addCommandResponder(this);
MPv3 mpv3 = (MPv3)snmp.getMessageProcessingModel(MessageProcessingModel.MPv3);
System.out.println("in try");
//if (version == 3)
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.getUSM().addUser(new OctetString("MD5DES"),
new UsmUser(new OctetString("MD5DES"),
AuthMD5.ID,
new OctetString("MD5DESUserAuthPassword"),
PrivDES.ID ,
new OctetString("MD5DESUserPrivPassword")));
System.out.println("USM: "+ snmp.getUSM());
snmp.addCommandResponder(this);
//snmp.listen();
// md.addCommandResponder(this);
System.out.println("transportBinding..");
transport.listen();
// transport.listen();
System.out.print("SNMP Listener init: ");
Address a = transport.getListenAddress();
System.out.println(a.toString());
//snmp.processPdu(this);
/* try
snmp.processPdu(arg0);
catch(Exception ex)
ex.getMessage();
snmp.close();
catch (IOException e)
System.err.print("ERROR!!!!! "+e);
try
this.wait();
catch (InterruptedException ex)
Thread.currentThread().interrupt();
public static void main(String[] args)throws Exception
// TODO Auto-generated method stub
new SNMP4J_AGENT().start();
Errors:
Exception in thread "Thread-0" java.lang.IllegalArgumentException: udp:127.0.0.1/161
at org.snmp4j.smi.UdpAddress.<init>(UdpAddress.java:48)
at SNMP4J_AGENT.run(SNMP4J_AGENT.java:100)
Thanx a lot…..
Regards,
Nidhi Lohat,
Software Trainee,
Eminent Networks Pvt. Ltd.(HFCL Group)

Hello Everyone,
I’ve made the simplest possible agent just to check if it can respond to the PDUs received from the manager. Although I’ve written the following code with the help of the SNMP4J tutorials, I have my doubt as to where is the processPdu function called in the program? I’ve written it fine, but I don’t see it being called. Thus, where is it that the PDU sent from the manager is actually received? Following is my code and the errors it generates. Please tell me where I’m going wrong. Also, since i'm working on Eclipse IDE, it seems quite confusing to me how to execute manager and agent together in order to create a communication session( just da way v do in socket programming). it seems that i can only run either of them at a time..
public class SNMP4J_AGENT extends Thread implements CommandResponder
* @param args
// Processes incoming Pdu
public synchronized void processPdu(CommandResponderEvent e)
System.out.println("Command");
ScopedPDU command;
if ( e.getPDU() instanceof ScopedPDU)
command = (ScopedPDU)e.getPDU();
else
command = (ScopedPDU)e.getPDU();
if (command != null)
//send reply
ScopedPDU cmd = (ScopedPDU)e.getPDU();
cmd.setType(ScopedPDU.RESPONSE);
cmd.setRequestID(command.getRequestID());
StatusInformation st=new StatusInformation(new VariableBinding(),
e.getStateReference().getContextName(),
e.getStateReference().getContextEngineID(),
new Integer32( e.getStateReference().getSecurityLevel()) );
StatusInformation statusInformation = new StatusInformation();
StateReference ref = e.getStateReference();
System.out.println(ref);
try
e.getMessageDispatcher().returnResponsePdu(e.getMessageProcessingModel(),
e.getSecurityModel(),
e.getSecurityName(),
e.getSecurityLevel(),
command,
e.getMaxSizeResponsePDU(),
ref,
st);
System.out.println("Response sent to manager....");
catch (MessageException e1)
e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates
@Override
public void run()
//InetAddress hostIp;
//int port_, version;
try
//Sets the snmp listener to port
TransportMapping transport = new DefaultUdpTransportMapping(new UdpAddress("udp:127.0.0.1/161"));
Snmp snmp = new Snmp(transport); //snmp.addCommandResponder(this);
MPv3 mpv3 = (MPv3)snmp.getMessageProcessingModel(MessageProcessingModel.MPv3);
System.out.println("in try");
//if (version == 3)
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.getUSM().addUser(new OctetString("MD5DES"),
new UsmUser(new OctetString("MD5DES"),
AuthMD5.ID,
new OctetString("MD5DESUserAuthPassword"),
PrivDES.ID ,
new OctetString("MD5DESUserPrivPassword")));
System.out.println("USM: "+ snmp.getUSM());
snmp.addCommandResponder(this);
//snmp.listen();
// md.addCommandResponder(this);
System.out.println("transportBinding..");
transport.listen();
// transport.listen();
System.out.print("SNMP Listener init: ");
Address a = transport.getListenAddress();
System.out.println(a.toString());
//snmp.processPdu(this);
/* try
snmp.processPdu(arg0);
catch(Exception ex)
ex.getMessage();
snmp.close();
catch (IOException e)
System.err.print("ERROR!!!!! "+e);
try
this.wait();
catch (InterruptedException ex)
Thread.currentThread().interrupt();
public static void main(String[] args)throws Exception
// TODO Auto-generated method stub
new SNMP4J_AGENT().start();
Errors:
Exception in thread "Thread-0" java.lang.IllegalArgumentException: udp:127.0.0.1/161
at org.snmp4j.smi.UdpAddress.<init>(UdpAddress.java:48)
at SNMP4J_AGENT.run(SNMP4J_AGENT.java:100)
Thanx a lot…..
Regards,
Nidhi Lohat,
Software Trainee,
Eminent Networks Pvt. Ltd.(HFCL Group)

Similar Messages

  • Why would firefox be using so much memory that the application itself freezes to the point where I have to force the program to end?

    For the past few days, I've been doing research for a presentation that I am doing for college. As I've been using Firefox, the program freezes to the point where I have to force the program to terminate. I have a computer with 8 gigs of ram and an i5 quad core processor running at 2.8 ghz. There are no viruses or spyware on the system, and there isn't anything else running. There are no addons applied to my browser, and no personas. There should be no memory issues to the point where an internet browser would freeze this badly.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • NEED DEMO FOR APPLE TV AT HOME SITE......... HAVE ANY IDEA WHERE I DO CALL FOR THE SAME...........

    NEED DEMO FOR APPLE TV AT HOME SITE......... HAVE ANY IDEA WHERE I DO CALL FOR THE SAME...........

    This is a user forum. I suggest you call Apple or visit your local store to ask.

  • Where is a list of the programs included in my sub to the cloud, and what each does?

    I have subscribed to the cloud. I know what Photoshop and Lightroom and inDesign do for me. I'd like to learn more about the rest of the programs available. Which ones are available to me? What do they do? The name usually doesn't tell me what I need to know.
    How can I get more fonts available to use in InDesign and PhotoShop?

    Thanks John.
    From the Creative Cloud Apps page https://creative.adobe.com/apps you can click on the Learn More link for each product.
    Also the Training page is now available. Training by product is here http://helpx.adobe.com/creative-cloud/products.html.

  • My hard drive was replaced and could transfer CC or Lightroom.  I didn't see where or how to reinstall the programs.

    Where so I go to reinstall CC and Lightroom after the Hard drive is replaced?  Hope it is one of the easier processes.

    sign into your account and start your downloads, https://creative.adobe.com/

  • Where-used for FM somethimes colors the program in red- why?

    Hello,
    Small question for something that i've noticed:
    When i do Where-used for FM somethimes the program is colored in red- anyone knows why?
    Thanks,
    Moshe

    Hi,
    In a where-used list for a function module the programs coloured in pale red are inactive.
    Regards,
    Nick

  • Problems running bat file with calls to java programs (.jar)

    I created a bat file with calls to jar programs. In each line,
    I put a call to the programs with parameters, but bat only
    executes the first line and ends execution.
    All lines of my bat file must be executed.
    What should I do?
    Best Regards,
    Pedro Felipe
    [http://pedrofao.blogspot.com|http://pedrofao.blogspot.com]
    [http://viajantesmundo.blogspot.com/|http://viajantesmundo.blogspot.com/]

    user8730639 wrote:
    I realized that the problem isn`t my bat file. I made tests calling another jar files and then all the lines of the batch file were executed. So, the jar file called on my previous bat is finnishing the execution. I verified and the jar apps worked without error.
    I would like to know if exists any command in Java that can cause this effect (close a batch), to modify the open source code of the application.Not that I know of.
    Is prism a bat file?
    If you are invoking bat files from your bat file without using call that would explain it
    :: mymain.bat file
    :: call the first bat file
    call prism.bat arg1 arg2 arg3
    :: call the other bat file
    call prism.bat arg4 arg5 arg6
    ::

  • I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells, find the 10 lowest numbers, then get the average and after that multiply it by .96

    I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells in a column,  find the 10 lowest numbers, then get the average and after that multiply it by .96  I used to use Excel and the formula worked fine in that. Here is my Formula
    =(average(small(H201:H220,{1,2,3,4,5,6,7,8,9,10})))*.96
    This formula worked in Excel and when I converted my spreadsheet over to Numbers, this formula no longer works.
    The best that I have been able to do so far is use small in 10 different cells, then get the average of the 10 cells and finally multiply that average by .96  So instead of using 1 cell, I'm using 12 cells to get my answer.
    This is a formula that I will be using all the time. The next cell would be =(average(small(H202:H221,{1,2,3,4,5,6,7,8,9,10})))*.96
    Hoping I explain myself well enough and that someone can help me.
    Thanks

    You can still do it in one cell but it will be more unruly than the Excel array formula.
    =average(small(H201:H220,1),small(H201:H220,2),small(H201:H220,3),...,small(H201:H220,10))*0.96
    where you would, of course, replace the "..." with the remaining six SMALL functions.

  • Calling an external program (*.exe file) on the client

    Hi,
    I use 9iDS and I'd like to call an external program (*.exe file) on the client, but this exe file is located on the server not on the client.
    So it should be something like a mixture between host and client_host(webutil) command. Is it possible to use client_host where a virtual path is passed to?
    Regards Sören

    Are you saying you want to run on the exe on the client but its located on the server???
    In that case you would have to do a webutil file transfer to move it to the client before executing. Or, if you are calling a DLL, webutil will download it automatically from the server to the client (see the C API example on the webutil page).
    Regards
    Grant Ronald
    Forms Product Management

  • Where should i call the rfc function module? in xi or in r/3

    where should i call the rfc function module?
    for the synch scenario: file < -- >  xi <---> rfc
    i know the type of rfc is tcp/ip; but i'm not sure with the followings,
    and with some trials i can not even see any message via rwb even all the setting
    can be activated without errors.
    where should i create the rfc destination? in r/3 or xi
    where should i call the rfc via abap program? in r/3 or xi
    i guess the calling program should belong to the different server with the rfc itself....
    so confused....
    Thanks for your reply!!
    Jun

    if i create the destination in xi point to r/3, then i call the rfc use the destination in r/3 right ?
    The call doesnt use the destination in R3. XI has the RFC destination which is just used to connect to the R3 system
    but where i need to create the fm via se37? in xi or r/3 ?
    In R3
    Regards,
    Prateek

  • WHERE TO FIND THE Mac OS X to reinstall the programs?

    WHERE TO FIND THE Mac OS X to reinstall the programs?

    If you're talking about OS X 10.6 or earlier, iLife and other programs are on the application disk, usually the second disk of the set. If you need a set, you can call Apple Support to see if they are still available for sale for your system. The first disk is the operating system.
    If they don't have the original OS X disks for your system, you can buy OS X 10.6 from the online Apple store, via phone or online. And the iLife programs from vendors like hardcoremac.com and on Amazon.com. OS X 10.5 is no longer available from Apple and has to be bought from a vendor or used. If you buy used, buy a retail copy and not the gray-faced copies, as they are locked to the system type they are delivered with.
    If you're talking OS X 10.7 or later, those are loaded from the App store, as there are no disks included with those systems.

  • Lightroom refuses the correct serial number. Creative Suite stop working.  Adobe is treating people with total disrespect and does not even have a phone number where we could call. I will move soon to other software,

    Creative Suite stop working after backing up the program from Time Machine. Adobe is treating people with total disrespect and does not even have a phone number where we could call. I will move soon to other software. I paid for the software and it is totally abusive this behavior from Adobe.

    Trying to reinstall via transfer does not work.
    Phone support | Orders, returns exchanges
    http://helpx.adobe.com/x-productkb/global/phone-support-orders.html
    For the link below click the Still Need Help? option in the blue area at the bottom and choose the chat option...
    Serial number and activation chat support (non-CC)
    http://helpx.adobe.com/x-productkb/global/service1.html ( http://adobe.ly/1aYjbSC )

  • Where are the programs???

    im kinda new at these kinda computers and used to using microsoft pc's... where are the programs on these computers... i.e: typing programs, games, or anything of that nature,, thanks..

    Hi again ozzman, Programs are called applications or apps and they are in the applications folder. To find this open a 'Finder' window, (that square icon with a face in it on your dock). Text edit is a basic word processor, there is a more sophisticated one in Appleworks. If you're not sure what anything is, just double click it and it will open. (Single click from the dock) If it's not what you were looking for press 'Apple' + 'Q'. to close it. Unlike Windows just clicking on the red X doesn't quit the app, it just closes the window leaving the app running.
    Games are in the app folder too.
    Have fun!
    Adrian

  • How to get the program where the User exit is use

    Hi,
       Could anyone let me know how to get the program which is using the user exit
    EXIT_SAPLFMR4_002 .
    Thank you.
    Donny~

    You can do a where used on the functino module EXIT_SAPLFMR4_002 in SE37.
    In this case, you user exit is called from a function module FMRE_FI_BELEG_CHECK.  Which in my system, doesn't appear to be called directly. It could be called dynamically.
    Regards,
    RichHeilman

  • Not calling the event S-O-S while executing the program using T-Code

    Hi All,
    I've a strange problem here in my Quality environment.
    Well,
    The issue is when a program is getting executed from SA38/SE38, its working perfectly as expected. Whereas while calling the same program using the T-Code attached to that then the program is not getting executed.
    While looking at the code through debugger, the start of selection event is getting triggered while executing the program through SA38/SE38 where as the S-O-S event is not getting triggered if its through the T-Code. And this is happening ONLY with Quality environment.(In Dev and in Prod its working perfectly either through T-Code or thru SA38).
    I tried activating all the objects again for that program(Including the T-Code) through SE80, Still no luck.
    Please thow some light on it to eradicate this error in Quality Env.
    Thanks for all your help.
    Regards,
    -Shankar.

    Hi Shankar,
    please check the transaction definition and make sure you defined a [report transaction|http://help.sap.com/saphelp_nw73/helpdata/en/43/132f9803d76f40e10000000a422035/frameset.htm]
    If you noticed a difference between Quality, Dev and and Prod environment, probably the transaction definition or the program is not the same.
    Check version history for all objects involved.
    Regards,
    Clemens

Maybe you are looking for

  • Lookup in BI Transformations

    Hi Experts, My requirement is to write a lookup in transformations While loading data from DSO 1 to CUBE I need to perform a select statement on DSO A and with the results from select statement I need to again perform select on to a DSO B and get the

  • Text field spry validation over 2 table cells?

    Hello, This might be a real simple thing, but I can't figure it out. Can anyone  please help? I'm using DW CS3 and I'm building a contact form. I'm using DW's Spry  validation for my text field. It's an email field. I'd like to put the  label in one

  • Java Document Paragraph Colors

    Hi, I want to change Background color of Styled Document. I am able to change text color through StyleConstants.setForeground(styles, Color,RED); Its changing background color for text. If text ends at middle of line then color applied to half line o

  • Can restoring from an iTunes backup restore voicemails?

    I need to recover a voicemail that I very intentionally did NOT delete back in December 2012.  However, being as there is no way (at least that I am familiar with) to intentionally SAVE a voicemail on the iPhone, it no longer shows up on my VM list o

  • Outlook 2010 Client Makes RPC connection to WRONG CAS

    I have Outlook 2010 clients in Shanghai. Their mailbox server and CAS server is in Hong Kong.   I also have my main Mailbox servers and CAS server in Seattle. When the Outlook clients resolve the names in setting up the Outlook profile, they go to dw