java - Get the SNMP request message using adventnet/WebNMS in hex format -


i using webnms/adventnet , set snmp command on device.

i access programmatically request , response data printed in hex format when debug mode on.

import com.adventnet.snmp.snmp2.snmpapi; import com.adventnet.snmp.snmp2.snmpexception; import com.adventnet.snmp.snmp2.snmpoid; import com.adventnet.snmp.snmp2.snmppdu; import com.adventnet.snmp.snmp2.snmpsession; import com.adventnet.snmp.snmp2.udpprotocoloptions;  public class snmpwebnms {  //need both request , response in hex format  //it prints in log , request , response data in hex format     public static void main(string[] args) throws snmpexception {      snmpapi api=new snmpapi();     api.setdebug(true);     snmpsession session=new snmpsession(api);     session.open();     snmppdu pdu=new snmppdu();     udpprotocoloptions options=new udpprotocoloptions("192.168.0.1");     pdu.setprotocoloptions(options);     pdu.setcommunity("dummy");     pdu.setcommand(snmpapi.get_req_msg);     snmpoid oid=new snmpoid(".1.3.6.1.2.1.1.1.0");     pdu.addnull(oid);            snmppdu result=session.syncsend(pdu);     system.out.println("result = "+result.tostring());     session.close();    }   } 

i suggest instruction:

result.getvariablebindings().tostring(); 

to string value of oid.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -