title: Getting device name and model via snmp
body: <p>I am trying to get switches device and model name through snmp. When I try to get Nortell or Juniper switch, it works fine but Cisco switches cause a problem. I use this oid value: ".1.3.6.1.2.1.1.1.0" ,  but I tried "1.3.6.1.2.1.1.1"  also. And return value is null. 
  Here is my code:</p>
  
  <pre><code>package list;
  
  public class DeviceInfo {
      private static String ipAddress = "10.20.X.XX";
  
      private static String port = "161";
  
      private static String oidValue = ".1.3.6.1.2.1.1.1";
  
      private static int snmpVersion = SnmpConstants.version1; // or version2c
  
      private static String community = "myreadcommunity";
  
      public static void main(String[] args) throws Exception {
  
          TransportMapping transport = new DefaultUdpTransportMapping();
          transport.listen();
  
          CommunityTarget comtarget = new CommunityTarget();
          comtarget.setCommunity(new OctetString(community));
          comtarget.setVersion(snmpVersion);
          comtarget.setAddress(new UdpAddress(ipAddress + "/" + port));
          comtarget.setRetries(2);
          comtarget.setTimeout(1000);
  
          PDU pdu = new PDU();
          pdu.add(new VariableBinding(new OID(oidValue)));
          pdu.setType(PDU.GET);
          pdu.setRequestID(new Integer32(1));
  
          Snmp snmp = new Snmp(transport);
  
          System.out.println("Sending request.");
          ResponseEvent response = snmp.get(pdu, comtarget);
  
          if (response != null) {
  
              System.out.println("Got results.");
              PDU responsePDU = response.getResponse();
  
              if (responsePDU != null) {
                  int errorStatus = responsePDU.getErrorStatus();
                  int errorIndex = responsePDU.getErrorIndex();
                  String errorStatusText = responsePDU.getErrorStatusText();
  
                  if (errorStatus == PDU.noError) {
                      System.out.println("Switch Name: = " + responsePDU.getVariableBindings());
                      System.out.println(responsePDU.size());
                  } else {
                      System.out.println("Error");
                      System.out.println("Error code: " + errorStatus);
                      System.out.println("Error Name: " + errorStatusText);
                  }
              } else {
                  System.out.println("NULL");
              }
          } else {
              System.out.println("Error: Timeout ");
          }
          snmp.close();
      }
  }
  </code></pre>