⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interface.jsp

📁 opennms得相关源码 请大家看看
💻 JSP
📖 第 1 页 / 共 2 页
字号:
<!--//// This file is part of the OpenNMS(R) Application.//// OpenNMS(R) is Copyright (C) 2002-2005 The OpenNMS Group, Inc.  All rights reserved.// OpenNMS(R) is a derivative work, containing both original code, included code and modified// code that was published under the GNU General Public License. Copyrights for modified // and included code are below.//// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.//// Modifications://// 2003 Oct 07: Corrected issue with selecting non-IP interface SNMP data.// 2003 Sep 25: Fixed SNMP Performance link issue.// 2003 Feb 07: Fixed URLEncoder issues.// 2003 Feb 01: Added response time link (Bug #684) and HTTP link (Bug #469).// 2002 Nov 26: Fixed breadcrumbs issue.// // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights reserved.//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program 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 General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//// For more information contact://      OpenNMS Licensing       <license@opennms.org>//      http://www.opennms.org///      http://www.opennms.com///--><%@page language="java" contentType="text/html" session="true" import="org.opennms.netmgt.config.PollerConfigFactory,org.opennms.web.element.*,java.util.*,org.opennms.web.event.*,org.opennms.web.performance.*,org.opennms.netmgt.utils.IfLabel,org.opennms.web.response.*" %><%!    protected int telnetServiceId;    protected int httpServiceId;    protected PerformanceModel perfModel;    protected ResponseTimeModel rtModel;        public void init() throws ServletException {        try {            this.telnetServiceId = NetworkElementFactory.getServiceIdFromName("Telnet");                    }        catch( Exception e ) {            throw new ServletException( "Could not determine the Telnet service ID", e );        }                try {            this.perfModel = new PerformanceModel( org.opennms.core.resource.Vault.getHomeDir() );        }        catch( Exception e ) {            throw new ServletException( "Could not initialize the PerformanceModel", e );        }                try {            this.httpServiceId = NetworkElementFactory.getServiceIdFromName("HTTP");        }        catch( Exception e ) {            throw new ServletException( "Could not determine the HTTP service ID", e );        }        try {            this.perfModel = new PerformanceModel( org.opennms.core.resource.Vault.getHomeDir() );        }        catch( Exception e ) {            throw new ServletException( "Could not initialize the PerformanceModel", e );        }        try {            this.rtModel = new ResponseTimeModel( org.opennms.core.resource.Vault.getHomeDir() );        }        catch( Exception e ) {            throw new ServletException( "Could not initialize the ResponseTimeModel", e );        }    }%><%    String nodeIdString = request.getParameter( "node" );    String ipAddr = request.getParameter( "intf" );    String ifindexString = request.getParameter( "ifindex" );        if( nodeIdString == null ) {        throw new org.opennms.web.MissingParameterException( "node", new String[] { "node", "intf", "ifindex?"} );    }    if( ipAddr == null ) {        throw new org.opennms.web.MissingParameterException( "intf", new String[] { "node", "intf", "ifindex?" } );    }    int nodeId = -1;    int ifindex = -1;        try {        nodeId = Integer.parseInt( nodeIdString );        if (ifindexString != null)             ifindex = Integer.parseInt( ifindexString );    }    catch( NumberFormatException e ) {        //throw new WrongParameterDataTypeException        throw new ServletException( "Wrong data type, should be integer", e );    }    Interface intf_db = null;        //see if we know the ifindex    if (ifindexString == null) {        intf_db = NetworkElementFactory.getInterface( nodeId, ipAddr );    }    else {        intf_db = NetworkElementFactory.getInterface( nodeId, ipAddr, ifindex );    }        if( intf_db == null ) {        //handle this WAY better, very awful        throw new ServletException( "No such interface in the database" );    }    Service[] services = NetworkElementFactory.getServicesOnInterface( nodeId, ipAddr );    if( services == null ) {        services = new Service[0];    }    String eventUrl = "event/list?filter=node%3D" + nodeId + "&filter=interface%3D" + ipAddr;        String telnetIp = null;    Service telnetService = NetworkElementFactory.getService(nodeId, ipAddr, this.telnetServiceId);        if( telnetService != null  ) {        telnetIp = ipAddr;    }        String httpIp = null;    Service httpService = NetworkElementFactory.getService(nodeId, ipAddr, this.httpServiceId);    if( httpService != null  ) {        httpIp = ipAddr;    }    PollerConfigFactory.init();    PollerConfigFactory pollerCfgFactory = PollerConfigFactory.getInstance();    pollerCfgFactory.rebuildPackageIpListMap();%><html><head>  <title><%=ipAddr%> | Interface | OpenNMS Web Console</title>  <base HREF="<%=org.opennms.web.Util.calculateUrlBase( request )%>" />  <link rel="stylesheet" type="text/css" href="includes/styles.css" /></head><% if (request.isUserInRole("OpenNMS Administrator")) { %><script language="Javascript" type="text/javascript" >function doDelete() {     if (confirm("Are you sure you want to proceed? This action will permanently delete this interface and cannot be undone."))     {         document.forms["delete"].submit();     }     return false;}</script><% } %><body marginwidth="0" marginheight="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0"><% String breadcrumb1 = "<a href='element/index.jsp'>Search</a>"; %><% String breadcrumb2 = "<a href='element/node.jsp?node=" + nodeId  + "'>Node</a>"; %><% String breadcrumb3 = "Interface"; %><jsp:include page="/includes/header.jsp" flush="false" >  <jsp:param name="title" value="Interface" />  <jsp:param name="breadcrumb" value="<%=breadcrumb1%>" />  <jsp:param name="breadcrumb" value="<%=breadcrumb2%>" />  <jsp:param name="breadcrumb" value="<%=breadcrumb3%>" /></jsp:include><br><!-- Body --><table width="100%" border="0" cellspacing="0" cellpadding="2" >  <tr>    <td>&nbsp;</td>    <td width="100%" valign="top" >      <h2>Interface: <%=intf_db.getIpAddress()%> <%=intf_db.getIpAddress().equals(intf_db.getHostname()) ? "" : "(" + intf_db.getHostname() + ")"%></h2>        <% if (request.isUserInRole("OpenNMS Administrator")) { %>      <form method="POST" name="delete" action="admin/deleteInterface">      <input type="hidden" name="node" value="<%=nodeId%>">      <input type="hidden" name="ifindex" value="<%=(ifindexString == null ? "" : ifindexString)%>">      <input type="hidden" name="intf" value="<%=ipAddr%>">      <% } %>      <p>        <a href="<%=eventUrl%>">View Events</a>        <% if( telnetIp != null ) { %>          &nbsp;&nbsp;&nbsp;<a href="telnet://<%=telnetIp%>">Telnet</a>        <% } %>                <% if( httpIp != null ) { %>          &nbsp;&nbsp;&nbsp;<a href="http://<%=httpIp%>">HTTP</a>        <% } %>                <% if(this.rtModel.isQueryableInterface(ipAddr)) { %>          &nbsp;&nbsp;&nbsp;<a href="response/addReportsToUrl?node=<%=nodeId%>&intf=<%=ipAddr%>&relativetime=lastday">Response Time</a>        <% } %>        <% if(hasSNMPData(intf_db) && ifindexString == null) { %>              <% String ifLabel = IfLabel.getIfLabel(nodeId, ipAddr); %>          <% if(ifLabel != null && this.perfModel.isQueryableInterface(nodeId, ifLabel)) { %>            &nbsp;&nbsp;&nbsp;<a href="performance/addReportsToUrl?node=<%=nodeId%>&intf=<%=ifLabel%>&relativetime=lastday">SNMP Performance</a>          <% } %>        <% } %>        <% if(hasSNMPData(intf_db) && ifindexString != null) { %>              <% String ifLabel = IfLabel.getIfLabelfromIfIndex(nodeId, ipAddr, ifindexString); %>          <% if(ifLabel != null && this.perfModel.isQueryableInterface(nodeId, ifLabel)) { %>            &nbsp;&nbsp;&nbsp;<a href="performance/addReportsToUrl?node=<%=nodeId%>&intf=<%=ifLabel%>&relativetime=lastday">SNMP Performance</a>          <% } %>        <% } %>                <% if (request.isUserInRole("OpenNMS Administrator")) { %>         &nbsp;&nbsp;&nbsp;<a href="admin/deleteInterface" onClick="return doDelete()">Delete</a>         <% } %>                 &nbsp;&nbsp;&nbsp;<a href="element/rescan.jsp?node=<%=nodeId%>&ipaddr=<%=ipAddr%>">Rescan</a>              <% if (request.isUserInRole("OpenNMS Administrator") && hasSNMPData(intf_db) && "P".equals(intf_db.getIsSnmpPrimary())) { %>         &nbsp;&nbsp;&nbsp;<a href="admin/updateSnmp.jsp?node=<%=nodeId%>&ipaddr=<%=ipAddr%>">Update SNMP</a>         <% } %>      </p>      <% if (request.isUserInRole("OpenNMS Administrator")) { %>      </form>      <% } %>      <table width="100%" border="0" cellspacing="0" cellpadding="0">        <tr>          <td valign="top" width="48%">            <!-- general info box -->            <table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolor="black" BGCOLOR="#cccccc">              <tr bgcolor="#999999">                <td colspan="2" ><b>General</b></td>               </tr>              <tr>                <td>Node</td>                 <td><a href="element/node.jsp?node=<%=intf_db.getNodeId()%>"><%=NetworkElementFactory.getNodeLabel(intf_db.getNodeId())%></a></td>              </tr>              <tr>                 <td>Polling Status</td>                <td><%=ElementUtil.getInterfaceStatusString(intf_db)%></td>              </tr>              <% if(ElementUtil.getInterfaceStatusString(intf_db).equals("Managed") && request.isUserInRole("OpenNMS Administrator")) {                  List inPkgs = pollerCfgFactory.getAllPackageMatches(ipAddr);                  Iterator pkgiter = inPkgs.iterator();                  while (pkgiter.hasNext()) { %>                      <tr>                          <td>Polling Package</td>                          <td><%= (String) pkgiter.next()%></td>                      </tr>                  <% } %>              <% } %>              <tr>                <td>Interface Index</td>                 <td>                  <% int ifIndex = intf_db.getIfIndex(); %>                  <% if( ifIndex > 0 ) {  %>                    <%=ifIndex%>                  <% } else { %>                    &nbsp;                  <% } %>                </td>              </tr>              <tr>                 <td>Last Service Scan</td>                <td><%=intf_db.getLastCapsdPoll()%></td>              </tr>              <tr>                <td>Physical Address</td>                        <td>                  <% String macAddr = intf_db.getPhysicalAddress(); %>                  <% if( macAddr != null && macAddr.trim().length() > 0 ) { %>                    <%=macAddr%>                  <% } else { %>                    &nbsp;                  <% } %>                </td>              </tr>            </table>            <br>                        <!-- SNMP box, if info available -->            <% if( hasSNMPData(intf_db) ) { %>                  <table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolor="black" bgcolor="#cccccc">                    <tr bgcolor="#999999">                      <td colspan="2"><b>SNMP Attributes</b></td>                     </tr>                    <tr>                       <td>Subnet Mask</td>                      <td>                        <%=(intf_db.getSnmpIpAdEntNetMask() == null) ? "&nbsp;" : intf_db.getSnmpIpAdEntNetMask()%>                                                          </td>                    </tr>                    <tr>                      <td>Interface Type</td>                      <td><%=IFTYPES[intf_db.getSnmpIfType()]%></td>                    </tr>                    <tr>                       <td>Status (Adm/Op)</td>                      <td>                        <% if( intf_db.getSnmpIfAdminStatus() < 1 || intf_db.getSnmpIfOperStatus() < 1 ) { %>                          &nbsp;                        <% } else { %>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -