use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class ThresholdingVisitorIT method createSnmpIfData.
private static SnmpIfData createSnmpIfData(String ipAddress, String ifName, Long ifSpeed, Integer ifIndex, boolean collectionEnabled) {
OnmsNode node = new OnmsNode();
node.setId(1);
node.setLabel("testNode");
OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(node, ifIndex);
snmpIface.setIfDescr(ifName);
snmpIface.setIfName(ifName);
snmpIface.setIfAlias(ifName);
snmpIface.setIfSpeed(ifSpeed);
// If the SNMP interface doesn't have collection enable, threshold processing will be ignored for the interface
snmpIface.setCollectionEnabled(collectionEnabled);
return new SnmpIfData(snmpIface);
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class MockNodeDao method findObsoleteSnmpInterfaces.
public List<OnmsSnmpInterface> findObsoleteSnmpInterfaces(final Integer nodeId, final Date scanStamp) {
final List<OnmsSnmpInterface> ifaces = new ArrayList<>();
final OnmsNode node = get(nodeId);
if (node == null)
return ifaces;
for (final OnmsSnmpInterface iface : node.getSnmpInterfaces()) {
if (truncateMillis(iface.getLastCapsdPoll()) < truncateMillis(scanStamp)) {
LOG.debug("findObsoleteSnmpInterfaces: {} < {}", truncateMillis(iface.getLastCapsdPoll()), truncateMillis(scanStamp));
ifaces.add(iface);
}
}
return ifaces;
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class DefaultCollectionAgentService method getSnmpInterfaceData.
/* (non-Javadoc)
* @see org.opennms.netmgt.collectd.CollectionAgent#getSnmpInterfaceInfo(org.opennms.netmgt.collectd.IfResourceType)
*/
/**
* <p>getSnmpInterfaceData</p>
*
* @return a {@link java.util.Set} object.
*/
@Override
public Set<SnmpIfData> getSnmpInterfaceData() {
Set<OnmsSnmpInterface> snmpIfs = getSnmpInterfaces();
Set<SnmpIfData> ifData = new LinkedHashSet<SnmpIfData>(snmpIfs.size());
for (OnmsSnmpInterface snmpIface : snmpIfs) {
logInitializeSnmpIf(snmpIface);
SnmpIfData snmpIfData = new SnmpIfData(snmpIface);
ifData.add(snmpIfData);
//ifInfos.add(new IfInfo(type, agent, snmpIfData));
}
return ifData;
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class DefaultCollectionAgentService method getSnmpInterfaces.
private Set<OnmsSnmpInterface> getSnmpInterfaces() {
OnmsNode node = getNode();
Set<OnmsSnmpInterface> snmpIfs = node.getSnmpInterfaces();
if (snmpIfs.size() == 0) {
LOG.debug("no known SNMP interfaces for node {}", node);
}
return snmpIfs;
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class EnLinkdElementFactory method convertFromModel.
@Transactional
@SuppressWarnings("deprecation")
private NodeLinkBridge convertFromModel(String mac, SharedSegment segment, String port) {
final NodeLinkBridge linknode = new NodeLinkBridge();
linknode.setNodeLocalPort(port);
for (BridgePort link : segment.getBridgePortsOnSegment()) {
final BridgeLinkRemoteNode remlinknode = new BridgeLinkRemoteNode();
final Integer rempnodeId = link.getNode().getId();
final Integer rembridgePortIfIndex = link.getBridgePortIfIndex();
remlinknode.setBridgeRemoteNode(link.getNode().getLabel());
remlinknode.setBridgeRemoteUrl(getNodeUrl(rempnodeId));
final OnmsSnmpInterface remiface = rembridgePortIfIndex == null ? null : m_snmpInterfaceDao.findByNodeIdAndIfIndex(rempnodeId, rembridgePortIfIndex);
if (remiface != null) {
remlinknode.setBridgeRemotePort(getPortString(rembridgePortIfIndex, remiface.getIfName(), remiface.getIfAlias()));
} else {
remlinknode.setBridgeRemotePort(getPortString(rembridgePortIfIndex, null, null));
}
remlinknode.setBridgeRemotePortUrl(getSnmpInterfaceUrl(rempnodeId, rembridgePortIfIndex));
remlinknode.setBridgeRemoteVlan(link.getVlan());
linknode.getBridgeLinkRemoteNodes().add(remlinknode);
}
for (BridgeMacLink link : segment.getBridgeMacLinks()) {
if (link.getMacAddress().equals(mac)) {
linknode.setBridgeLinkCreateTime(Util.formatDateToUIString(link.getBridgeMacLinkCreateTime()));
linknode.setBridgeLinkLastPollTime(Util.formatDateToUIString(link.getBridgeMacLinkLastPollTime()));
break;
}
}
Map<String, List<IpNetToMedia>> sharedmacs = new HashMap<String, List<IpNetToMedia>>();
for (String shredmac : segment.getMacsOnSegment()) {
if (shredmac.equals(mac))
continue;
sharedmacs.put(shredmac, new ArrayList<IpNetToMedia>());
sharedmacs.get(shredmac).addAll(m_ipNetToMediaDao.findByPhysAddress(shredmac));
}
Map<String, List<OnmsIpInterface>> sharedhosts = new HashMap<String, List<OnmsIpInterface>>();
for (String shredmac : sharedmacs.keySet()) {
if (sharedmacs.get(shredmac).isEmpty()) {
BridgeLinkSharedHost remlinknode = new BridgeLinkSharedHost();
OnmsSnmpInterface snmp = getFromPhysAddress(shredmac);
if (snmp == null) {
remlinknode.setSharedHost(shredmac + " No ip address found");
} else {
remlinknode.setSharedHost(snmp.getNode().getLabel());
remlinknode.setSharedHostUrl(getNodeUrl(snmp.getNode().getId()));
remlinknode.setSharedHostPort(getPortString(snmp.getIfIndex(), snmp.getIfName(), snmp.getIfAlias()));
remlinknode.setSharedHostPortUrl(getSnmpInterfaceUrl(snmp.getNode().getId(), snmp.getIfIndex()));
}
linknode.getBridgeLinkSharedHost().add(remlinknode);
continue;
}
sharedhosts.put(shredmac, new ArrayList<OnmsIpInterface>());
for (IpNetToMedia ipnettomedia : sharedmacs.get(shredmac)) sharedhosts.get(shredmac).addAll(m_ipInterfaceDao.findByIpAddress(ipnettomedia.getNetAddress().getHostAddress()));
}
for (String shredmac : sharedhosts.keySet()) {
BridgeLinkSharedHost remlinknode = new BridgeLinkSharedHost();
Set<InetAddress> ips = new HashSet<InetAddress>();
if (sharedhosts.get(shredmac).isEmpty()) {
for (IpNetToMedia ipnettomedia : sharedmacs.get(shredmac)) {
ips.add(ipnettomedia.getNetAddress());
}
remlinknode.setSharedHost(getNodePortString(ips, shredmac) + " No node found");
linknode.getBridgeLinkSharedHost().add(remlinknode);
continue;
}
OnmsIpInterface first = null;
boolean multiplenodeids = false;
for (OnmsIpInterface ip : sharedhosts.get(shredmac)) {
if (first == null)
first = ip;
if (first.getNode().getId().intValue() != ip.getNode().getId().intValue())
multiplenodeids = true;
ips.add(ip.getIpAddress());
}
if (multiplenodeids) {
remlinknode.setSharedHost(getNodePortString(ips, shredmac) + " duplicated ip multiple node associated in db");
} else {
remlinknode.setSharedHost(first.getNode().getLabel());
remlinknode.setSharedHostUrl(getNodeUrl(first.getNode().getId()));
}
remlinknode.setSharedHostPort(getNodePortString(ips, shredmac));
if (ips.size() == 1) {
remlinknode.setSharedHostPortUrl(getIpInterfaceUrl(first));
}
linknode.getBridgeLinkSharedHost().add(remlinknode);
}
return linknode;
}
Aggregations