<%-- /******************************************************************************* * This file is part of OpenNMS(R). * * Copyright (C) 2002-2015 The OpenNMS Group, Inc. * OpenNMS(R) is Copyright (C) 1999-2015 The OpenNMS Group, Inc. * * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. * * OpenNMS(R) is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * OpenNMS(R) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with OpenNMS(R). If not, see: * http://www.gnu.org/licenses/ * * For more information contact: * OpenNMS(R) Licensing * http://www.opennms.org/ * http://www.opennms.com/ *******************************************************************************/ --%> <%@page import="org.opennms.web.enlinkd.LldpElementNode"%> <%@page import="org.opennms.web.enlinkd.CdpElementNode"%> <%@page import="org.opennms.web.enlinkd.OspfElementNode"%> <%@page import="org.opennms.web.enlinkd.IsisElementNode"%> <%@page import="org.opennms.web.enlinkd.BridgeElementNode"%> <%@page import="org.opennms.web.enlinkd.EnLinkdElementFactory"%> <%@page language="java" contentType="text/html" session="true" import=" java.util.*, java.net.*, java.sql.SQLException, org.opennms.core.soa.ServiceRegistry, org.opennms.core.utils.InetAddressUtils, org.opennms.core.utils.WebSecurityUtils, org.opennms.netmgt.config.PollOutagesConfigFactory, org.opennms.netmgt.config.poller.outages.Outage, org.opennms.netmgt.model.OnmsNode, org.opennms.netmgt.dao.hibernate.PathOutageManagerDaoImpl, org.opennms.web.api.Authentication, org.opennms.web.asset.Asset, org.opennms.web.asset.AssetModel, org.opennms.web.element.*, org.opennms.web.navigate.*, org.opennms.web.svclayer.api.ResourceService, org.springframework.util.StringUtils, org.springframework.web.context.WebApplicationContext, org.springframework.web.context.support.WebApplicationContextUtils" %> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <%!private int m_telnetServiceId; private int m_sshServiceId; private int m_httpServiceId; private int m_dellServiceId; private int m_rdpServiceId; private int m_snmpServiceId; private ResourceService m_resourceService; private AssetModel m_model = new AssetModel(); public void init() throws ServletException { try { m_telnetServiceId = NetworkElementFactory.getInstance(getServletContext()).getServiceIdFromName("Telnet"); } catch (Throwable e) { throw new ServletException("Could not determine the Telnet service ID", e); } try { m_sshServiceId = NetworkElementFactory.getInstance(getServletContext()).getServiceIdFromName("SSH"); } catch (Throwable e) { throw new ServletException("Could not determine the SSH service ID", e); } try { m_httpServiceId = NetworkElementFactory.getInstance(getServletContext()).getServiceIdFromName("HTTP"); } catch (Throwable e) { throw new ServletException("Could not determine the HTTP service ID", e); } try { m_dellServiceId = NetworkElementFactory.getInstance(getServletContext()).getServiceIdFromName("Dell-OpenManage"); } catch (Throwable e) { throw new ServletException("Could not determine the Dell-OpenManage service ID", e); } try { m_rdpServiceId = NetworkElementFactory.getInstance(getServletContext()).getServiceIdFromName("MS-RDP"); } catch (Throwable e) { throw new ServletException("Could not determine the Mirosoft Remote Desktop service ID", e); } try { m_snmpServiceId = NetworkElementFactory.getInstance(getServletContext()).getServiceIdFromName("SNMP"); } catch (Throwable e) { throw new ServletException("Could not determine the SNMP service ID", e); } final WebApplicationContext webAppContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); m_resourceService = (ResourceService) webAppContext.getBean("resourceService", ResourceService.class); } public static String getStatusStringWithDefault(OnmsNode node_db) { String status = ElementUtil.getNodeStatusString(node_db); if (status != null) { return status; } else { return "Unknown"; } } public static String findServiceAddress(int nodeId, int serviceId, ServletContext servletContext) throws SQLException, UnknownHostException { Service[] services = NetworkElementFactory.getInstance(servletContext).getServicesOnNode(nodeId, serviceId); if (services == null || services.length == 0) { return null; } List ips = new ArrayList(); for (Service service : services) { ips.add(InetAddressUtils.addr(service.getIpAddress())); } InetAddress lowest = InetAddressUtils.getLowestInetAddress(ips); if (lowest != null) { return lowest.getHostAddress(); } else { return null; } } public static Collection> createLinkForService(int nodeId, int serviceId, String linkText, String linkPrefix, String linkSuffix, ServletContext servletContext) throws SQLException, UnknownHostException { String ip = findServiceAddress(nodeId, serviceId, servletContext); if (ip == null) { return new ArrayList>(); } Map map = new HashMap(); map.put("text", linkText); map.put("url", linkPrefix + ip + linkSuffix); return Collections.singleton(map); }%> <% OnmsNode node_db = ElementUtil.getNodeByParams(request, getServletContext()); int nodeId = node_db.getId(); Map nodeModel = new TreeMap(); nodeModel.put("id", Integer.toString(nodeId)); nodeModel.put("label", node_db.getLabel()); nodeModel.put("foreignId", node_db.getForeignId()); nodeModel.put("foreignSource", node_db.getForeignSource()); List> links = new ArrayList>(); links.addAll(createLinkForService(nodeId, m_telnetServiceId, "Telnet", "telnet://", "", getServletContext())); links.addAll(createLinkForService(nodeId, m_sshServiceId, "SSH", "ssh://", "", getServletContext())); links.addAll(createLinkForService(nodeId, m_httpServiceId, "HTTP", "http://", "/", getServletContext())); links.addAll(createLinkForService(nodeId, m_dellServiceId, "OpenManage", "https://", ":1311", getServletContext())); links.addAll(createLinkForService(nodeId, m_rdpServiceId, "Microsoft RDP", "rdp://", ":3389", getServletContext())); nodeModel.put("links", links); Asset asset = m_model.getAsset(nodeId); nodeModel.put("asset", asset); if (asset != null && asset.getBuilding() != null && asset.getBuilding().length() > 0) { nodeModel.put("statusSite", WebSecurityUtils.sanitizeString(asset.getBuilding(),true)); } nodeModel.put("lldp", EnLinkdElementFactory.getInstance(getServletContext()).getLldpElement(nodeId)); nodeModel.put("cdp", EnLinkdElementFactory.getInstance(getServletContext()).getCdpElement(nodeId)); nodeModel.put("ospf", EnLinkdElementFactory.getInstance(getServletContext()).getOspfElement(nodeId)); nodeModel.put("isis", EnLinkdElementFactory.getInstance(getServletContext()).getIsisElement(nodeId)); nodeModel.put("bridges", EnLinkdElementFactory.getInstance(getServletContext()).getBridgeElements(nodeId)); nodeModel.put("resources", m_resourceService.findNodeChildResources(node_db)); nodeModel.put("criticalPath", PathOutageManagerDaoImpl.getInstance().getPrettyCriticalPath(nodeId)); nodeModel.put("noCriticalPath", PathOutageManagerDaoImpl.NO_CRITICAL_PATH); nodeModel.put("admin", request.isUserInRole(Authentication.ROLE_ADMIN)); // get the child interfaces Interface[] intfs = NetworkElementFactory.getInstance(getServletContext()).getActiveInterfacesOnNode(nodeId); if (intfs != null) { nodeModel.put("intfs", intfs); } else { nodeModel.put("intfs", new Interface[0]); } Service[] snmpServices = NetworkElementFactory.getInstance(getServletContext()).getServicesOnNode(nodeId, m_snmpServiceId); if (snmpServices != null && snmpServices.length > 0) { for (Interface intf : intfs) { if ("P".equals(intf.getIsSnmpPrimary())) { nodeModel.put("snmpPrimaryIntf", intf); break; } } } nodeModel.put("status", getStatusStringWithDefault(node_db)); nodeModel.put("showRancid","true".equalsIgnoreCase(Vault.getProperty("opennms.rancidIntegrationEnabled"))); nodeModel.put("node", node_db); nodeModel.put("sysName", WebSecurityUtils.sanitizeString(node_db.getSysName())); nodeModel.put("sysLocation", WebSecurityUtils.sanitizeString(node_db.getSysLocation())); nodeModel.put("sysContact", WebSecurityUtils.sanitizeString(node_db.getSysContact(), true)); nodeModel.put("sysDescription", WebSecurityUtils.sanitizeString(node_db.getSysDescription())); if(!(node_db.getForeignSource() == null) && !(node_db.getForeignId() == null)) { nodeModel.put("parentRes", node_db.getForeignSource() + ":" + node_db.getForeignId()); nodeModel.put("parentResType", "nodeSource"); } else { nodeModel.put("parentRes", Integer.toString(nodeId)); nodeModel.put("parentResType", "node"); } pageContext.setAttribute("model", nodeModel); final WebApplicationContext webAppContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); final ServiceRegistry registry = webAppContext.getBean(ServiceRegistry.class); final List renderedLinks = new ArrayList(); final Collection navLinks = registry.findProviders(ConditionalPageNavEntry.class, "(Page=node)"); for (final ConditionalPageNavEntry link : navLinks) { final DisplayStatus displayStatus = link.evaluate(request, node_db); if (displayStatus == null) continue; if (displayStatus == DisplayStatus.DISPLAY_NO_LINK) { renderedLinks.add(link.getName()); } else if (displayStatus == DisplayStatus.DISPLAY_LINK) { renderedLinks.add("" + link.getName() + ""); } } pageContext.setAttribute("navEntries", renderedLinks); final List schedOutages = new ArrayList(); PollOutagesConfigFactory f = PollOutagesConfigFactory.getInstance(); for (final Outage outage : f.getOutages()) { if (f.isCurTimeInOutage(outage)) { boolean inOutage = f.isNodeIdInOutage(nodeId, outage); if (!inOutage) { for (final Interface i : intfs) { if (f.isInterfaceInOutage(i.getIpAddress(), outage)) { inOutage = true; break; } } } if (inOutage) { final String name = outage.getName(); final String link = "" + name + ""; schedOutages.add(request.isUserInRole(Authentication.ROLE_ADMIN) ? link : name); } } } pageContext.setAttribute("schedOutages", schedOutages.isEmpty() ? null : StringUtils.collectionToDelimitedString(schedOutages, ", ")); %> <%@page import="org.opennms.core.resource.Vault"%>

Node: ${model.label}    ${model.id}  ${model.foreignSource}  ${model.foreignId}
Node: ${model.label}    ${model.id}

This node is currently affected by the following scheduled outages: ${schedOutages}
<% String showNodeStatusBar = System.getProperty("opennms.nodeStatusBar.show", "false"); if (Boolean.parseBoolean(showNodeStatusBar)) { %> <% } %>

Asset Information

Description ${model.asset.description}
Comments ${model.asset.comments}

SNMP Attributes

Name ${model.sysName}
sysObjectID ${model.node.sysObjectId}
Location ${model.sysLocation}
Contact ${model.sysContact}
Description ${model.sysDescription}

Path Outage - Critical Path

  • ${model.criticalPath}

Node Interfaces

VLAN Information

Vlan ID Vlan Name Vlan Type Vlan Status Status Last Poll Time
${vlan.vlanId} ${vlan.vlanName} ${vlan.vlanTypeString} ${vlan.vlanStatusString} ${vlan.statusString} ${vlan.lastPollTime}

LLDP Information

chassis id ${model.lldp.lldpChassisIdString}
sysname ${model.lldp.lldpSysName}
create time ${model.lldp.lldpCreateTime}
last poll time ${model.lldp.lldpLastPollTime}

CDP Information

global device id ${model.cdp.cdpGlobalDeviceId}
global device id format ${model.cdp.cdpGlobalDeviceIdFormat}
global run ${model.cdp.cdpGlobalRun}
create time ${model.cdp.cdpCreateTime}
last poll time ${model.cdp.cdpLastPollTime}

Bridge Information vlanid ${bridge.vlan} (${bridge.vlan})

Base Bridge Address ${bridge.baseBridgeAddress}
Base Number of Ports ${bridge.baseNumPorts}
Base Type ${bridge.baseType}
STP Protocol Specification ${bridge.stpProtocolSpecification}
STP Priority ${bridge.stpPriority}
STP Designated Root ${bridge.stpDesignatedRoot}
STP Root Cost ${bridge.stpRootCost}
STP Root Port ${bridge.stpRootPort}
Create Time ${bridge.bridgeNodeCreateTime}
Last Poll Time ${bridge.bridgeNodeLastPollTime}

OSPF Information

Router Id ${model.ospf.ospfRouterId}
Version Number ${model.ospf.ospfVersionNumber}
Admin Status ${model.ospf.ospfAdminStat}
create time ${model.ospf.ospfCreateTime}
last poll time ${model.ospf.ospfLastPollTime}

IS-IS Information

Sys ID ${model.isis.isisSysID}
Admin State ${model.isis.isisSysAdminState}
Create Time ${model.isis.isisCreateTime}
Last Poll Time ${model.isis.isisLastPollTime}