public static List<SnmpValue> getColumns(final SnmpAgentConfig agentConfig, final String name, final SnmpObjId oid) throws InterruptedException { final List<SnmpValue> results = new ArrayList<>(); try(SnmpWalker walker=SnmpUtils.createWalker(agentConfig, name, new ColumnTracker(oid) { @Override protected void storeResult(SnmpResult res) { results.add(res.getValue()); } })) { walker.start(); walker.waitFor(); } return results; }
public SnmpValue[] generateRowStatusValues() { SnmpValueFactory vf = SnmpUtils.getValueFactory(); SnmpValue[] values = { vf.getInt32(m_ciscoPingEntryStatus) }; return values; }
public static SnmpV3TrapBuilder getV3TrapBuilder() { return getStrategy().getV3TrapBuilder(); }
public static SnmpWalker createWalker(SnmpAgentConfig agentConfig, String name, CollectionTracker... trackers) { return getStrategy().createWalker(agentConfig, name, createTooBigTracker(agentConfig, trackers)); }
public static String getLocalEngineID() { return getHexString(getStrategy().getLocalEngineID()); }
LOG.debug("OMSAStorageMonitor.poll: SnmpAgentConfig address: {}", agentConfig); SnmpObjId virtualDiskRollUpStatusSnmpObject = SnmpObjId.get(virtualDiskRollUpStatus + "." + virtualDiskNumber); SnmpValue virtualDiskRollUpStatus = SnmpUtils.get(agentConfig, virtualDiskRollUpStatusSnmpObject); Map<SnmpInstId,SnmpValue> arrayDisks = SnmpUtils.getOidValues(agentConfig, "OMSAStorageMonitor", arrayDiskLogicalConnectionVirtualDiskNumberSnmpObject); Map<SnmpInstId,SnmpValue> arrayDiskConnectionNumber = SnmpUtils.getOidValues(agentConfig,"OMSAStorageMonitor", arrayDiskLogicalConnectionArrayDiskNumberSnmpObject); SnmpValue diskValue = SnmpUtils.get(agentConfig,arrayDiskStateSnmpObject); SnmpValue nexusValue = SnmpUtils.get(agentConfig,arrayDiskNexusIDSnmpObject);
/** * <p>sendV2Trap</p> * * @throws java.lang.Exception if any. */ public void sendV2Trap() throws Exception { SnmpObjId enterpriseId = SnmpObjId.get(getEnterpriseId()); boolean isGeneric = false; SnmpObjId trapOID; if (SnmpObjId.get(".1.3.6.1.6.3.1.1.5").isPrefixOf(enterpriseId)) { isGeneric = true; trapOID = enterpriseId; } else { trapOID = SnmpObjId.get(enterpriseId, new SnmpInstId(getSpecificId())); // XXX or should it be this // trap OID = enterprise + ".0." + specific; } SnmpTrapBuilder pdu = SnmpUtils.getV2TrapBuilder(); pdu.addVarBind(SnmpObjId.get(".1.3.6.1.2.1.1.3.0"), SnmpUtils.getValueFactory().getTimeTicks(0)); pdu.addVarBind(SnmpObjId.get(".1.3.6.1.6.3.1.1.4.1.0"), SnmpUtils.getValueFactory().getObjectId(trapOID)); if (isGeneric) { pdu.addVarBind(SnmpObjId.get(".1.3.6.1.6.3.1.1.4.3.0"), SnmpUtils.getValueFactory().getObjectId(enterpriseId)); } pdu.addVarBind(SnmpObjId.get(".1.3.6.1.4.1.5813.20.1"), SnmpUtils.getValueFactory().getOctetString(getVarbind().getBytes())); pdu.send(InetAddressUtils.str(getHostInetAddress()), getPort(), getCommunity()); }
/** * <p>sendV1Trap</p> * * @throws java.lang.Exception if any. */ public void sendV1Trap() throws Exception { SnmpV1TrapBuilder pdu = SnmpUtils.getV1TrapBuilder(); pdu.setEnterprise(SnmpObjId.get(getEnterpriseId())); pdu.setGeneric(getGenericId()); pdu.setSpecific(getSpecificId()); pdu.setTimeStamp(0); InetAddress agentAddress = getHostInetAddress(); pdu.setAgentAddress(agentAddress); pdu.addVarBind(SnmpObjId.get(".1.3.6.1.4.1.5813.20.1"), SnmpUtils.getValueFactory().getOctetString(getVarbind().getBytes())); pdu.send(InetAddressUtils.str(agentAddress), getPort(), getCommunity()); }
configureAgentVersion(agentConfig); Map<SnmpInstId, SnmpValue> tagResults = SnmpUtils.getOidValues(agentConfig, "CiscoIpSlaDetector", SnmpObjId.get(RTT_ADMIN_TAG_OID)); if (tagResults == null) { LOG.warn("isServiceDetected: No admin tags received!"); Map<SnmpInstId, SnmpValue> operStateResults = SnmpUtils.getOidValues(agentConfig, "CiscoIpSlaDetector", SnmpObjId.get(RTT_OPER_STATE_OID)); if (operStateResults == null) { LOG.warn("isServiceDetected: No operational states received!");
/** * {@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 snmpObjectId = SnmpObjId.get(LOGICAL_BASE_OID + '.' + m_arrayNumber); SnmpValue value = SnmpUtils.get(agentConfig, snmpObjectId); if (value.toInt() != 2) { LOG.debug("PercMonitor.poll: Bad Disk Found. Log vol({}) degraded", m_arrayNumber); return false; } } catch (Throwable t) { throw new UndeclaredThrowableException(t); } return true; }
SnmpValue[] setResult = SnmpUtils.set(agentConfig, pingEntry.generateCreateOids(), pingEntry.generateCreateValues()); if (setResult == null) { LOG.warn("SNMP SET operation unsuccessful for proxy-ping entry for target {} -- {}", targetIpAddr, pingEntry); statusValues = SnmpUtils.get(agentConfig, pingEntry.generateResultsOids());
List<SnmpValue> results = SnmpUtils.getColumns(agentConfig, "snmpPoller", snmpObjectId); for(SnmpValue result : results) { reasonTemplate = "SNMP poll failed, addr=${ipaddr} oid=${oid}"; List<SnmpValue> results = SnmpUtils.getColumns(agentConfig, "snmpPoller", snmpObjectId); for(SnmpValue result : results) { if (result != null) { SnmpValue result = SnmpUtils.get(agentConfig, snmpObjectId);
public static Long getProtoCounter63Value(SnmpValue value) { Long retval = getProtoCounter63Value(value.getBytes()); if (retval != null && value.isDisplayable()) { LOG.info("Value '{}' is entirely displayable but still meets our other checks to be treated as a proto-Counter64. This may not be what you want.", new String(value.getBytes())); } return retval; }
public static String getStrategyClassName() { // Use SNMP4J as the default SNMP strategy return getConfig().getProperty("org.opennms.snmp.strategyClass", "org.opennms.netmgt.snmp.snmp4j.Snmp4JStrategy"); }
private static TooBigReportingAggregator createTooBigTracker(SnmpAgentConfig agentConfig, CollectionTracker tracker) { return createTooBigTracker(agentConfig, new CollectionTracker[] { tracker }); }
SnmpObjId laTableErrorSnmpObject = SnmpObjId.get(laTableErrorFlag); Map<SnmpInstId, SnmpValue> flagResults = SnmpUtils.getOidValues(agentConfig, "LaTableMonitor", laTableErrorSnmpObject); String LaErrorMsg = SnmpUtils.get(agentConfig,laTableErrorMsgSnmpObject).toDisplayString();
public static SnmpWalker createWalker(SnmpAgentConfig agentConfig, String name, CollectionTracker tracker) { return getStrategy().createWalker(agentConfig, name, createTooBigTracker(agentConfig, tracker)); }
Map<SnmpInstId, SnmpValue> nameResults = SnmpUtils.getOidValues(agentConfig, "HostResourceSwRunMonitor", SnmpObjId.get(getServiceNameOid()));
/** * <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(); } }
} else { Long value = SnmpUtils.getProtoCounter63Value(getValue()); if (value != null) { return value;