private String formatValue(SnmpValue value) { return value.isNull() ? null : value.toString().replaceAll("\"", ""); }
@Override public SnmpValue get(final SnmpAgentConfig agentConfig, final SnmpObjId oid) { final PropertyOidContainer oidContainer = getOidContainer(agentConfig); if (oidContainer == null) return null; SnmpValue val = oidContainer.findValueForOid(oid); if (val.isNull()) { return null; } return val; }
public OspfLink get(OspfLink link) { //use point to point by default link.setOspfIpMask(InetAddressUtils.addr("255.255.255.252")); List<SnmpValue> val = get(link.getOspfIpAddr()); if (val != null && val.size() == 2 ) { if (!val.get(0).isNull() && val.get(0).isNumeric() ) link.setOspfIfIndex(val.get(0).toInt()); if (!val.get(1).isNull() && !val.get(1).isError()) { try { link.setOspfIpMask(val.get(1).toInetAddress()); } catch (IllegalArgumentException e) { } } } return link; }
public OspfElement get(OspfElement element) { //loopback mask by default element.setOspfRouterIdNetmask(InetAddressUtils.addr("255.255.255.255")); //-1 ifindex by default element.setOspfRouterIdIfindex(-1); List<SnmpValue> val = get(element.getOspfRouterId()); if (val != null && val.size() == 2) { if (!val.get(0).isNull() && val.get(0).isNumeric()) element.setOspfRouterIdIfindex(val.get(0).toInt()); if (!val.get(1).isNull() && !val.get(1).isError()) { try { element.setOspfRouterIdNetmask(val.get(1).toInetAddress()); } catch (IllegalArgumentException e) { } } } return element; }
/** {@inheritDoc} */ @Override protected void storeResult(SnmpResult res) { if(res.getBase().toString().equals(AbstractSnmpCollector.IFALIAS_OID) && (res.getValue().isNull() || res.getValue().toDisplayString() == null || res.getValue().toDisplayString().equals(""))) { LOG.debug("Skipping storeResult. Null or zero length ifAlias"); return; } SNMPCollectorEntry entry = m_results.get(res.getInstance()); if (entry == null) { LOG.debug("Creating new SNMPCollectorEntry entry"); entry = new SNMPCollectorEntry(m_objList, m_collectionSet); m_results.put(res.getInstance(), entry); } entry.storeResult(res); }
/** * <p>getValue</p> * * @param agentConfig a {@link org.opennms.netmgt.snmp.SnmpAgentConfig} object. * @param oid a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ protected static String getValue(SnmpAgentConfig agentConfig, String oid, boolean hex) { SnmpValue val = SnmpUtils.get(agentConfig, SnmpObjId.get(oid)); if (val == null || val.isNull() || val.isEndOfMib() || val.isError()) { return null; } else { return hex ? val.toHexString() : val.toString(); } }
/** * {@inheritDoc} * * Returns true if the protocol defined by this plugin is supported. If * the protocol is not supported then a false value is returned to the * caller. The qualifier map passed to the method is used by the plugin to * return additional information by key-name. These key-value pairs can be * added to service events if needed. */ @Override public boolean isServiceDetected(final InetAddress address, final SnmpAgentConfig agentConfig) { try { configureAgentPTR(agentConfig); configureAgentVersion(agentConfig); SnmpObjId virtualDiskRollUpStatusSnmpObject = SnmpObjId.get(virtualDiskRollUpStatus + '.' + m_virtualDiskNumber); SnmpValue virtualDiskRollUpStatus = SnmpUtils.get(agentConfig, virtualDiskRollUpStatusSnmpObject); if (virtualDiskRollUpStatus == null || virtualDiskRollUpStatus.isNull()) { LOG.debug("SNMP poll failed: no results, addr={} oid={}", agentConfig.getAddress(), virtualDiskRollUpStatusSnmpObject); return false; } if (virtualDiskRollUpStatus.toInt() != 3) { // 3 means Online LOG.debug("OMSAStorageMonitor.poll: Bad Disk Found. Log vol({}) degraded", m_virtualDiskNumber); return false; } } catch (Throwable t) { throw new UndeclaredThrowableException(t); } return true; }
SnmpValue virtualDiskRollUpStatus = SnmpUtils.get(agentConfig, virtualDiskRollUpStatusSnmpObject); if(virtualDiskRollUpStatus == null || virtualDiskRollUpStatus.isNull()) { LOG.debug("SNMP poll failed: no results, addr={} oid={}", hostAddress, virtualDiskRollUpStatusSnmpObject); return PollStatus.unavailable();