[SNMP4J] Problem in installing SNMP4j
Hello Everyone, I'm working on developing an SNMPv3 based NMS software for a Licensed Band cellular Radio Backhaul, using SNMP4J. My major concern in this project is to do both, manager as well as the agent part. Being a beginner, I'm facing problem with the installation of the software itself. I downloaded snmp4j-agentx-1.3.1a , currently working on Windows XP platform and trying to execute them over the simple command prompt of Windows (Will be working over Eclipse IDE later). Since there was no online help available regarding the installation steps of this software, i tried n number of open forums which gave me the idea that certain .jar files were to be executed. However, no matter what i tried, all I got were Class Manifest errors. or, NoClassDef errors. This led to more confusion, resulting in multiple copies of the extracted snmp4j-agentx-1.3.1a folder at various locations. Also, is there a particular sequence in which these files are to be compiled/executed. I also made a simple test code that should make a PDU and sned it successfully. Since i can't execute and check it, i 'm a bit doubtful about it too. // checking for a simple request pdu and endinng it. import java.io.IOException; import java.util.List; import org.snmp4j.CommunityTarget; import org.snmp4j.scopedPDU; import org.snmp4j.Snmp; import org.snmp4j.event.ResponseEvent; import org.snmp4j.mp.SnmpConstants; import org.snmp4j.smi.Address; import org.snmp4j.smi.GenericAddress; import org.snmp4j.smi.OID; import org.snmp4j.smi.OctetString; import org.snmp4j.smi.VariableBinding; import org.snmp4j.transport.DefaultUdpTransportMapping; public class send { /** * @param args */ public static void main(String[] args) { //To setup a default SNMP session for UDP transport Address targetAddress = GenericAddress.parse("udp:127.0.0.1/161"); TransportMapping transport = new DefaultUdpTransportMapping(); snmp = new Snmp(transport); USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); SecurityModels.getInstance().addSecurityModel(usm); transport.listen(); // add 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"))); // create the target UserTarget target = new UserTarget(); target.setAddress(targetAddress); target.setRetries(1); target.setTimeout(5000); target.setVersion(SnmpConstants.version3); target.setSecurityLevel(SecurityLevel.AUTH_PRIV); target.setSecurityName(new OctetString("MD5DES")); // create the PDU PDU pdu = new ScopedPDU(); pdu.add(new VariableBinding(new OID("1.3.6"))); pdu.setType(PDU.GETNEXT); // send the PDU ResponseEvent response = snmp.send(pdu, target); if(response.getResponse()== NULL) { System.out.println("Request Timed out!!!"); exit(); } // extract the response PDU (could be null if timed out) PDU responsePDU = response.getResponse(); // extract the address used by the agent to send the response: Address peerAddress = response.getPeerAddress(); }} ___ SNMP4J mailing list SNMP4J@agentpp.org http://lists.agentpp.org/mailman/listinfo/snmp4j
Re: [SNMP4J] Some questions
Hi Andreas, i think you can take as examples the mibs in the "mib depot" page: http://www.mibdepot.com/index.shtml Regards On Thu, Aug 26, 2010 at 4:17 PM, Andreas Mayer wrote: > Hello everybody, > > I'm working on my bachelorthesis which is about information gathering from > remote virtualized systems. The information which should be retrieved are > related to hardware components and their energy consumption (CPU > temperature, CPU usage, HDD temperature and so on). So one of my tasks is > to > write an SNMPv3 agent which can be polled for these values. I worked > through > SampleAgent.java, but I am wondering how to write an MIB for SNMP4J which > is > able to provide these values. Is their any chance to do this without > AgenPro? Is there a documentation how to do this manually? Any help would > be > highly appreciated. Thank you in advance. > > Regards, > > Andy > ___ > SNMP4J mailing list > SNMP4J@agentpp.org > http://lists.agentpp.org/mailman/listinfo/snmp4j > ___ SNMP4J mailing list SNMP4J@agentpp.org http://lists.agentpp.org/mailman/listinfo/snmp4j
[SNMP4J] Some questions
Hello everybody, I'm working on my bachelorthesis which is about information gathering from remote virtualized systems. The information which should be retrieved are related to hardware components and their energy consumption (CPU temperature, CPU usage, HDD temperature and so on). So one of my tasks is to write an SNMPv3 agent which can be polled for these values. I worked through SampleAgent.java, but I am wondering how to write an MIB for SNMP4J which is able to provide these values. Is their any chance to do this without AgenPro? Is there a documentation how to do this manually? Any help would be highly appreciated. Thank you in advance. Regards, Andy ___ SNMP4J mailing list SNMP4J@agentpp.org http://lists.agentpp.org/mailman/listinfo/snmp4j
Re: [SNMP4J] Socket closed error in Windows 7
Hello Frank, After some more testing, we have decided to downgrade to snmp4j-1.9.1e as it is working fine..for now. Not sure yet if it has to do with the fastness of the latest version or with timing issues. I have also tested by sending a datagram packet for a large number of addresses without using snmp4j to see if this is happening with the JRE 1.6.* (32 and 64 bit) in Windows 7. I saw the same 'Socket closed' errors after a few seconds. Did the same test using Ruby on the same machine and is successful with no errors at all. So, not sure what is happening or if I'm doing something wrong. I appreciate any suggestions. Thanks, Varma From: varma datla To: Frank Fock Cc: "snmp4j@agentpp.org" Sent: Tue, August 17, 2010 2:07:47 PM Subject: Re: [SNMP4J] Socket closed error in Windows 7 Hello Frank, I apologize for that silly mistake and thanks for pointing it out. I've added a CountDownLatch so that the main() wouldn't exit unit all requests are being responded. Actually, we had this running in Tomcat..but just want to have a standalone program to reproduce the problem quicker. Please let me know if you want me to run any further tests on Windows 7. Code: package com.some; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; import java.util.LinkedHashSet; import java.util.Set; import java.util.concurrent.CountDownLatch; import org.apache.log4j.Logger; import org.snmp4j.CommunityTarget; import org.snmp4j.PDU; import org.snmp4j.Snmp; import org.snmp4j.TimeoutModel; import org.snmp4j.TransportMapping; import org.snmp4j.event.ResponseEvent; import org.snmp4j.event.ResponseListener; import org.snmp4j.mp.SnmpConstants; import org.snmp4j.smi.OID; import org.snmp4j.smi.UdpAddress; import org.snmp4j.smi.VariableBinding; import org.snmp4j.transport.DefaultUdpTransportMapping; public class Snmp4JUtil { private static final Logger LOGGER = Logger.getLogger( Snmp4JUtil.class ); private Snmp snmp; private final int [] oid = {1, 3, 6, 1, 4, 1 }; private final ResponseListener listener; public Snmp4JUtil( final ResponseListener listener ) { this.listener = listener; try { final TransportMapping transport = new DefaultUdpTransportMapping(); this.snmp = new Snmp( transport ); snmp.setTimeoutModel( getTimeoutModel( new int[]{ 500, 1000 } ) ); snmp.listen(); } catch (IOException e) { LOGGER.error( "Snmp4JUtil() Error: " + e.getMessage() ); } } public void close() { try { snmp.close(); } catch (IOException e) { LOGGER.error( "close() Error: " + e.getMessage() ); } } public void send( final CommunityTarget target ) { PDU pdu = new PDU(); pdu.setType( PDU.GETNEXT ); pdu.add( new VariableBinding( new OID( oid ) ) ); try { this.snmp.send( pdu, target, null, listener); } catch (IOException e) { LOGGER.error( "send( CommunityTarget ) - address:" + target.getAddress() + "; error:" + e.getMessage() ); e.printStackTrace(); } } private TimeoutModel getTimeoutModel( final int[] timeoutsRetries ) { return new TimeoutModel() { public long getRequestTimeout( final int totalNumberOfRetries, final long targetTimeout ) { long requestTimeout = 0; for ( int i : timeoutsRetries ) { requestTimeout += i; } return requestTimeout; } public long getRetryTimeout( final int retryCount, final int totalNumberOfRetries, final long targetTimeout ) { return timeoutsRetries[retryCount]; } }; } public static void main( final String args[] ) throws Exception { final StringBuilder responses = new StringBuilder(); // A few thousand addresses...just for testing final Set addresses = getAddresses( args[0] ); final CountDownLatch latch = new CountDownLatch( addresses.size() ); final ResponseListener listener = new ResponseListener() { public void onResponse( ResponseEvent event ) { //cancel event ((Snmp)event.getSource()).cancel(event.getRequest(), this); // output response here. responses.append( "Response: " + event.getResponse() ) .append( System.getProperty( "line.separator" ) ); latch.countDown(); System.out.println("countDown:" + latch.getCount());
Re: [SNMP4J] Work Out SNMP version
I've figured this out, if I connect with an SNMP version that the device doesn't support, I get an exception, so this is easy to handle, Thanks. -Original Message- From: snmp4j-boun...@agentpp.org [mailto:snmp4j-boun...@agentpp.org] On Behalf Of Osian Hughes Sent: Thursday, 26. August, 2010 10:51 To: snmp4j@agentpp.org Subject: [SNMP4J] Work Out SNMP version Hi, Is there any easy way to work out if a device is supporting either SNMPv1 or SNMPv2 (I'm not worried at the moment about v3), e.g. a specific OID i should ask for, etc. Thanks, Osian This email and any attachment may contain confidential information which is intended for use only by the addressee(s) named above. If you received this email by mistake, please notify the sender immediately, and delete the email from your system. You are prohibited from copying, disseminating or otherwise using the email or any attachment. ___ SNMP4J mailing list SNMP4J@agentpp.org http://lists.agentpp.org/mailman/listinfo/snmp4j This email and any attachment may contain confidential information which is intended for use only by the addressee(s) named above. If you received this email by mistake, please notify the sender immediately, and delete the email from your system. You are prohibited from copying, disseminating or otherwise using the email or any attachment. ___ SNMP4J mailing list SNMP4J@agentpp.org http://lists.agentpp.org/mailman/listinfo/snmp4j
[SNMP4J] Work Out SNMP version
Hi, Is there any easy way to work out if a device is supporting either SNMPv1 or SNMPv2 (I'm not worried at the moment about v3), e.g. a specific OID i should ask for, etc. Thanks, Osian This email and any attachment may contain confidential information which is intended for use only by the addressee(s) named above. If you received this email by mistake, please notify the sender immediately, and delete the email from your system. You are prohibited from copying, disseminating or otherwise using the email or any attachment. ___ SNMP4J mailing list SNMP4J@agentpp.org http://lists.agentpp.org/mailman/listinfo/snmp4j