use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class NodeDaoHibernate method getHierarchy.
/** {@inheritDoc} */
@Override
public OnmsNode getHierarchy(Integer id) {
OnmsNode node = findUnique("select distinct n from OnmsNode as n " + "left join fetch n.assetRecord " + "where n.id = ?", id);
initialize(node.getIpInterfaces());
for (OnmsIpInterface i : node.getIpInterfaces()) {
initialize(i.getMonitoredServices());
}
initialize(node.getSnmpInterfaces());
for (OnmsSnmpInterface i : node.getSnmpInterfaces()) {
initialize(i.getIpInterfaces());
}
return node;
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class PollableSnmpInterface method setSnmpinterfaces.
/**
* <p>setSnmpinterfaces</p>
*
* @param snmpinterfaces a {@link java.util.List} object.
*/
public void setSnmpinterfaces(List<OnmsSnmpInterface> snmpinterfaces) {
if (snmpinterfaces == null) {
LOG.debug("setting snmpinterfaces: got null, thread instantiated but at moment no interface found");
return;
}
// ifIndex -> operstatus
final Map<Integer, Integer> oldStatuses = new HashMap<Integer, Integer>();
for (final Integer ifIndex : m_snmpinterfaces.keySet()) {
final OnmsSnmpInterface iface = m_snmpinterfaces.get(ifIndex);
if (iface != null && iface.getIfOperStatus() != null) {
oldStatuses.put(ifIndex, iface.getIfOperStatus());
}
}
m_snmpinterfaces.clear();
for (OnmsSnmpInterface iface : snmpinterfaces) {
LOG.debug("setting snmpinterface:", iface.toString());
if (iface != null && iface.getIfIndex() != null && iface.getIfIndex() > 0) {
final Integer oldStatus = oldStatuses.get(iface.getIfIndex());
LOG.debug("setting snmpinterface (oldStatus={}):{}", oldStatus, iface.toString());
// Note: If OpenNMS is restarted, the event is going to be sent no matter if it was sent before, if the current status of the interface is down.
m_snmpinterfaces.put(iface.getIfIndex(), iface);
if (iface.getIfAdminStatus() != null && iface.getIfAdminStatus().equals(SnmpMinimalPollInterface.IF_UP) && iface.getIfOperStatus() != null && iface.getIfOperStatus().equals(SnmpMinimalPollInterface.IF_DOWN) && (oldStatus == null || (iface.getIfOperStatus().intValue() != oldStatus.intValue()))) {
sendOperDownEvent(iface);
}
}
}
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class EnLinkdElementFactory method getFromCdpCacheDevicePort.
private OnmsSnmpInterface getFromCdpCacheDevicePort(Integer nodeid, String cdpCacheDevicePort) {
final CriteriaBuilder builder = new CriteriaBuilder(OnmsSnmpInterface.class);
builder.alias("node", "node", JoinType.LEFT_JOIN);
builder.sql("snmpifalias = '" + cdpCacheDevicePort + "' OR snmpifname = '" + cdpCacheDevicePort + "' OR snmpifdescr = '" + cdpCacheDevicePort + "'").eq("node.id", nodeid);
final List<OnmsSnmpInterface> nodes = m_snmpInterfaceDao.findMatching(builder.toCriteria());
if (nodes.size() == 1)
return nodes.get(0);
return null;
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class EnLinkdElementFactory method convertFromModel.
@Transactional
@SuppressWarnings("deprecation")
private CdpLinkNode convertFromModel(int nodeid, CdpLink link) {
CdpLinkNode linknode = new CdpLinkNode();
linknode.setCdpLocalPort(getPortString(link.getCdpCacheIfIndex(), link.getCdpInterfaceName(), null));
if (link.getCdpCacheIfIndex() != null)
linknode.setCdpLocalPortUrl(getSnmpInterfaceUrl(nodeid, link.getCdpCacheIfIndex()));
linknode.setCdpCacheAddressType(CiscoNetworkProtocolType.getTypeString(link.getCdpCacheAddressType().getValue()));
linknode.setCdpCacheAddress(link.getCdpCacheAddress());
linknode.setCdpCacheDeviceId(link.getCdpCacheDeviceId());
linknode.setCdpCacheDevicePlatform(link.getCdpCacheDevicePlatform());
linknode.setCdpCacheVersion(link.getCdpCacheVersion());
linknode.setCdpCacheDevicePort(link.getCdpCacheDevicePort());
CdpElement cdpCacheElement = m_cdpElementDao.findByGlobalDeviceId(link.getCdpCacheDeviceId());
if (cdpCacheElement != null) {
linknode.setCdpCacheDeviceUrl(getNodeUrl(cdpCacheElement.getNode().getId()));
OnmsSnmpInterface cdpcachesnmp = getFromCdpCacheDevicePort(cdpCacheElement.getNode().getId(), link.getCdpCacheDevicePort());
if (cdpcachesnmp != null) {
linknode.setCdpCacheDevicePort(getPortString(cdpcachesnmp.getIfIndex(), link.getCdpCacheDevicePort(), cdpcachesnmp.getIfAlias()));
linknode.setCdpCacheDevicePortUrl(getSnmpInterfaceUrl(cdpCacheElement.getNode().getId(), cdpcachesnmp.getIfIndex()));
}
}
linknode.setCdpCreateTime(Util.formatDateToUIString(link.getCdpLinkCreateTime()));
linknode.setCdpLastPollTime(Util.formatDateToUIString(link.getCdpLinkLastPollTime()));
return linknode;
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class EnLinkdElementFactory method getFromPhysAddress.
private OnmsSnmpInterface getFromPhysAddress(String physAddress) {
final CriteriaBuilder builder = new CriteriaBuilder(OnmsSnmpInterface.class);
builder.eq("physAddr", physAddress);
final List<OnmsSnmpInterface> nodes = m_snmpInterfaceDao.findMatching(builder.toCriteria());
if (nodes.size() == 1)
return nodes.get(0);
return null;
}
Aggregations