[SNMP4J] Fedora disk OID
Frank Fock
fock at agentpp.com
Thu Apr 5 20:48:29 CEST 2007
Hello Roberto,
You are missing the index suffix which seems to be .1
in your case. Thus try
1.3.6.1.4.1.2021.9.1.2.1
instead of
1.3.6.1.4.1.2021.9.1.2
The NET-SNMP probably issues a GETNEXT after it gets a
noSuchInstance exception.
Best regards,
Frank
RobertoBouza at bayviewfinancial.com wrote:
> Hello everyone,
>
> Frank thanks for your help. I figure out the problem and it was this line
>
>
> pdu.setContextEngineID(new OctetString("0x80001f88803d4bf37386c41346"));
>
> I removed it, so it's using the default value and it works.
>
> Now I have another question. When I query systems OIDs (usign the
> snmp4j_tool not using my java class) it works perfect. Now when I use the
> Fedora custom OIDs like:
>
> 1.3.6.1.4.1.2021.9.1.2
>
> Which refers to the path of the disk 1 I get:
>
> 1.3.6.1.4.1.2021.9.1.2 = noSuchInstance
>
> If I use snmpget on linux I get:
>
> UCD-SNMP-MIB::dskPath.1 = STRING: /
>
> Do I need to do something special for this kind of OIDs?
>
> Thank you.
>
> ---
> Roberto Bouza
> Middle Tier Administrator II
> Bayview Financial, L.P.
> 4425 Ponce de Leon Blvd, 2nd Floor
> Coral Gables, FL 33146
> Ph. 305-644-2550
>
>
>
> Frank Fock <fock at agentpp.com>
> Sent by: snmp4j-bounces at agentpp.org
> 04/05/07 01:49 AM
>
> To
> RobertoBouza at bayviewfinancial.com
> cc
> snmp4j at agentpp.org
> Subject
> Re: [SNMP4J] (no subject) IpAddress vs. UdpAddress
>
>
>
>
>
>
> Hi,
>
> You cannot communicate with an IpAddress as communication
> endpoint. You need either an UdpAddress (default) or
> a TcpAddress. IP is a network protocol, whereas UDP and TCP
> are transport protocols.
>
> Best regards,
> Frank
>
> RobertoBouza at bayviewfinancial.com wrote:
>> Hello everyone,
>>
>> I'm getting this Exception:
>>
>> org.snmp4j.transport.UnsupportedAddressClassException: Unsupported
> address
>> class (transport mapping): org.snmp4j.smi.IpAddress
>>
>> I'm pretty new to SNMP and developing using SNMP4J. I just want to make
> a
>> SNMP get of an OID variable from a server and I get this error when the
>> send methos is called on the snmp class. Here is the code:
>>
>> Any help would be really appreciated.
>>
>> ###########
>>
>> public class GetMIBValue {
>>
>> public static void main(String arg[]) {
>>
>> try {
>>
>> TransportMapping transport = new
>> DefaultTcpTransportMapping();
>> Snmp snmp = new Snmp(transport);
>>
>> // Since we are using SNMPv3 we use authenticated users
>> this is handled by the UsmUser and USM class
>> UsmUser uu = new UsmUser(new OctetString("ssnmpreader"),
>
>> AuthMD5.ID, new OctetString("ssnmpread3r"), PrivDES.ID, new
>> OctetString("ssnmpread3r"));
>>
>> if (uu == null) {
>> System.out.println("Null UsmUser");
>> } else {
>> System.out.println("Valid UsmUser");
>> }
>>
>> USM usm = snmp.getUSM();
>>
>> if (usm == null) {
>> System.out.println("Null Usm");
>> } else {
>> usm = new USM(SecurityProtocols.getInstance(),
> new
>> OctetString(MPv3.createLocalEngineID()), 0);
>> usm.addUser(new OctetString("ssnmpreader"), uu);
>> System.out.println("Valid Usm");
>> }
>>
>> UserTarget target = new UserTarget();
>> IpAddress ipa = new IpAddress("10.10.32.201");
>> target.setAddress(ipa);
>>
>> if (target.getAddress().isValid()) {
>> System.out.println("Valid IP address");
>> } else {
>> System.out.println("Invalid IP address");
>> }
>>
>> target.setRetries(1);
>>
>> // set timeout to 500 milliseconds -> 2*500ms = 1s total
>
>> timeout
>> target.setTimeout(500);
>> target.setVersion(SnmpConstants.version3);
>> target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
>> target.setSecurityName(new OctetString("MD5DES"));
>>
>> // We create the basic PDU Unit
>> ScopedPDU pdu = new ScopedPDU();
>> pdu.add(new VariableBinding(new
> OID("1.3.6.1.2.1.1.1")));
>> pdu.setType(PDU.GET);
>>
>> // set non-default context engine ID (to use targets
>> authoritative engine ID
>> // use an empty (size == 0) octet string)
>> pdu.setContextEngineID(new
>> OctetString("0x80001f88803d4bf37386c41346"));
>>
>> ResponseEvent response = snmp.send(pdu, target);
>>
>> PDU responsePDU = response.getResponse();
>>
>> if (responsePDU == null) {
>> } else {
>> System.out.println("Received response from: "+
>> response.getPeerAddress());
>> System.out.println(responsePDU.toString());
>> }
>>
>> } catch (Exception exp) {
>> System.out.println(exp.toString());
>> System.out.println("-----------");
>> exp.printStackTrace();
>> }
>> }
>>
>> }
>>
>> ########################
>>
>>
>> ---
>> Roberto Bouza
>> Middle Tier Administrator II
>> Bayview Financial, L.P.
>> 4425 Ponce de Leon Blvd, 2nd Floor
>> Coral Gables, FL 33146
>> Ph. 305-644-2550
>> _______________________________________________
>> SNMP4J mailing list
>> SNMP4J at agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/snmp4j
>
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list