use of org.opennms.netmgt.snmp.SnmpObjId in project opennms by OpenNMS.
the class PercDetector method isServiceDetected.
/**
* {@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;
}
use of org.opennms.netmgt.snmp.SnmpObjId in project opennms by OpenNMS.
the class SnmpTrapNotificationStrategy method sendV2Trap.
/**
* <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());
}
use of org.opennms.netmgt.snmp.SnmpObjId in project opennms by OpenNMS.
the class SnmpPollInterfaceMonitor method poll.
/**
* <p>poll</p>
*
* @param agentConfig a {@link org.opennms.netmgt.snmp.SnmpAgentConfig} object.
* @param mifaces a {@link java.util.List} object.
* @return a {@link java.util.List} object.
*/
public List<SnmpMinimalPollInterface> poll(SnmpAgentConfig agentConfig, List<SnmpMinimalPollInterface> mifaces) {
if (mifaces == null) {
LOG.error("Null Interfaces passed to Monitor, exiting");
return null;
}
LOG.debug("Got {} interfaces to poll", mifaces.size());
//
if (agentConfig == null)
throw new RuntimeException("SnmpAgentConfig object not available");
SnmpObjId[] adminoids = new SnmpObjId[mifaces.size()];
SnmpObjId[] operooids = new SnmpObjId[mifaces.size()];
for (int i = 0; i < mifaces.size(); i++) {
SnmpMinimalPollInterface miface = mifaces.get(i);
miface.setStatus(PollStatus.unavailable());
adminoids[i] = SnmpObjId.get(IF_ADMIN_STATUS_OID + miface.getIfindex());
operooids[i] = SnmpObjId.get(IF_OPER_STATUS_OID + miface.getIfindex());
LOG.debug("Adding Admin/Oper oids: {}/{}", adminoids[i], operooids[i]);
}
SnmpValue[] adminresults = new SnmpValue[mifaces.size()];
SnmpValue[] operoresults = new SnmpValue[mifaces.size()];
LOG.debug("try to get admin statuses");
adminresults = SnmpUtils.get(agentConfig, adminoids);
LOG.debug("got admin status {} SnmpValues", adminresults.length);
if (adminresults.length != mifaces.size()) {
LOG.warn("Snmp Interface Admin statuses collection failed");
return mifaces;
}
LOG.debug("try to get operational statuses");
operoresults = SnmpUtils.get(agentConfig, operooids);
LOG.debug("got operational status {} SnmpValues", operoresults.length);
if (operoresults.length != mifaces.size()) {
LOG.warn("Snmp Interface Operational statuses collection failed");
return mifaces;
}
for (int i = 0; i < mifaces.size(); i++) {
SnmpMinimalPollInterface miface = mifaces.get(i);
if (adminresults[i] != null && operoresults[i] != null) {
try {
miface.setAdminstatus(adminresults[i].toInt());
miface.setOperstatus(operoresults[i].toInt());
miface.setStatus(PollStatus.up());
LOG.debug("SNMP Value is {} for oid: {}", adminresults[i].toInt(), adminoids[i]);
LOG.debug("SNMP Value is {} for oid: {}", operoresults[i].toInt(), operooids[i]);
} catch (Exception e) {
LOG.warn("SNMP Value is {} for oid: {}", adminresults[i].toDisplayString(), adminoids[i]);
LOG.warn("SNMP Value is {} for oid: {}", operoresults[i].toDisplayString(), operooids[i]);
}
} else {
LOG.info("SNMP Value is null for oid: {}/{}", adminoids[i], operooids[i]);
}
}
return mifaces;
}
use of org.opennms.netmgt.snmp.SnmpObjId in project opennms by OpenNMS.
the class OspfIpAddrTableGetter method get.
private List<SnmpValue> get(InetAddress addr) {
SnmpObjId instance = SnmpObjId.get(addr.getHostAddress());
List<SnmpObjId> oids = new ArrayList<>();
oids.add(SnmpObjId.get(IPADENT_IFINDEX, instance));
oids.add(SnmpObjId.get(IPADENT_NETMASK, instance));
return get(oids);
}
use of org.opennms.netmgt.snmp.SnmpObjId in project opennms by OpenNMS.
the class SnmpIfAdmin method getIfAdminStatus.
/**
* <p>
* Get desired admin interface status.
* </p>
*
* @param ifindex
* interface index to get
* @return The status of interface
* @throws SnmpBadConversionException
* Throw if returned code is not an integer
*/
public int getIfAdminStatus(int ifindex) {
SnmpObjId oid = SnmpObjId.get(snmpObjectId + "." + ifindex);
SnmpValue status = SnmpUtils.get(m_agent, oid);
return status.toInt();
}
Aggregations