salut toute le monde je veut lister un oid existant avec java ,j'ai le teste avec snmputil est coorect
voila le code java
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import snmp.*; 
import java.util.*; 
import java.math.*; 
import java.net.*; 
 
 
 
public class SNMPSample2 
{
 
    public static void main(String args[]) 
    {
 
        try 
        {
 
            InetAddress hostAddress = InetAddress.getByName("127.0.0.1");
            String community = "public"; 
            int version = 0;    // SNMPv1
 
            SNMPv1CommunicationInterface comInterface = new SNMPv1CommunicationInterface(version, hostAddress, community); 
 
 
            String itemID = ".1.3.6.1.2.1.1.1";
 
            System.out.println("Retrieving value corresponding to OID " + itemID);
 
           SNMPVarBindList newVars = comInterface.getMIBEntry(itemID);
 
 
            SNMPSequence pair = (SNMPSequence)(newVars.getSNMPObjectAt(0));
 
 
            SNMPObjectIdentifier snmpOID = (SNMPObjectIdentifier)pair.getSNMPObjectAt(0);
 
 
            SNMPObject snmpValue = pair.getSNMPObjectAt(1);
 
 
            System.out.println("Retrieved value: type " + snmpValue.getClass().getName() + ", value " + snmpValue.toString());
 
 
            byte[] javaByteArrayValue = (byte[])snmpValue.getValue(); 
 
 
            itemID = ".1.3.6.1.2.1.1.1";
 
            System.out.println("Retrieving value corresponding to OID " + itemID);
 
 
            newVars = comInterface.getMIBEntry(itemID);
 
 
            pair = (SNMPSequence)(newVars.getSNMPObjectAt(0));
 
 
            snmpOID = (SNMPObjectIdentifier)pair.getSNMPObjectAt(0);
 
 
            snmpValue = pair.getSNMPObjectAt(1);
 
 
            System.out.println("Retrieved value: type " + snmpValue.getClass().getName() + ", value " + snmpValue.toString());
        } 
        catch(Exception e) 
        { 
            System.out.println("Exception during SNMP operation:  " + e + "\n"); 
        }
 
    }
 
}
---------------------------------------------------------
Retrieving value corresponding to OID .1.3.6.1.2.1.1.1
Exception during SNMP operation:  snmp.SNMPGetException: OID .1.3.6.1.2.1.1.1 not available for retrieval