コード例 #1
0
 private String getPhysAddr() {
   final SnmpValue value = getValue(IF_PHYS_ADDR);
   String hexString = value == null ? null : value.toHexString();
   String displayString = value == null ? null : value.toDisplayString();
   // See ifTableEntry: NMS-4902 (revision cee964fe979e6465aeb4e2efd4772e50ebc54831)
   try {
     if (hexString != null && hexString.length() == 12) {
       // If the hex string is 12 characters long, than the agent is kinda weird and
       // is returning the value as a raw binary value that is 6 bytes in length.
       // But that's OK, as long as we can convert it into a string, that's fine.
       return hexString;
     } else {
       // This is the normal case that most agents conform to: the value is an ASCII
       // string representing the colon-separated MAC address. We just need to reformat
       // it to remove the colons and convert it into a 12-character string.
       return displayString == null || displayString.trim().isEmpty()
           ? null
           : InetAddressUtils.normalizeMacAddress(displayString);
     }
   } catch (IllegalArgumentException e) {
     LOG.warn(e.getMessage(), e);
     return displayString;
   }
 }
コード例 #2
0
 @Test
 public void testAgent() throws Exception {
   SnmpValue snmpValue = SnmpUtils.get(snmpAgentConfig, SnmpObjId.get(".1.3.6.1.2.1.1.1.0"));
   Assert.assertEquals("Mock Juniper TCA Device", snmpValue.toDisplayString());
 }
コード例 #3
0
 private String getIfDescr() {
   final SnmpValue value = getValue(IF_DESCR);
   return value == null ? null : value.toDisplayString();
 }
コード例 #4
0
 private String getIfAlias() {
   final SnmpValue value = getValue(IF_ALIAS);
   return value == null ? null : value.toDisplayString();
 }
コード例 #5
0
 private String getIfName() {
   final SnmpValue value = getValue(IF_NAME);
   return value == null ? null : value.toDisplayString();
 }