Commit ec9db647 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Initial version. JM-6


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1440 b35dd754-fafc-0310-a699-88a17e54d16e
parent f801747a
<%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 Jive Software. All rights reserved.
-
- This software is published under the terms of the GNU Public License (GPL),
- a copy of which is included in this distribution.
--%>
<%@ page import="org.jivesoftware.util.*,
java.util.*,
org.jivesoftware.messenger.*,
java.text.DateFormat,
java.text.NumberFormat,
org.jivesoftware.admin.*,
org.jivesoftware.messenger.user.User,
org.xmpp.packet.JID,
org.xmpp.packet.Presence,
java.net.URLEncoder,
org.jivesoftware.messenger.server.IncomingServerSession,
org.jivesoftware.messenger.server.OutgoingServerSession"
errorPage="error.jsp"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% // Get parameters
String hostname = ParamUtils.getParameter(request, "hostname");
// Handle a "go back" click:
if (request.getParameter("back") != null) {
response.sendRedirect("server-session-summary.jsp");
return;
}
// Get the session & address objects
SessionManager sessionManager = webManager.getSessionManager();
IncomingServerSession inSession = sessionManager.getIncomingServerSession(hostname);
OutgoingServerSession outSession = sessionManager.getOutgoingServerSession(hostname);
// Number dateFormatter for all numbers on this page:
NumberFormat numFormatter = NumberFormat.getNumberInstance();
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = LocaleUtils.getLocalizedString("server.session.details.title");
pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(LocaleUtils.getLocalizedString("global.main"), "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "server-session-details.jsp"));
pageinfo.setPageID("server-session-summary");
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
<p>
<fmt:message key="server.session.details.info">
<fmt:param value="<%= "<b>"+hostname+"</b>" %>" />
</fmt:message>
</p>
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th colspan="2">
<fmt:message key="server.session.details.title" />
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="c1">
<fmt:message key="server.session.label.connection" />
</td>
<td>
<% if (inSession != null && outSession == null) { %>
<img src="images/incoming_32x16.gif" width="32" height="16" border="0" title="<fmt:message key="server.session.connection.incoming" />">
<fmt:message key="server.session.connection.incoming" />
<% } else if (inSession == null && outSession != null) { %>
<img src="images/outgoing_32x16.gif" width="32" height="16" border="0" title="<fmt:message key="server.session.connection.outgoing" />">
<fmt:message key="server.session.connection.outgoing" />
<% } else { %>
<img src="images/both_32x16.gif" width="32" height="16" border="0" title="<fmt:message key="server.session.connection.both" />">
<fmt:message key="server.session.connection.both" />
<% } %>
</td>
</tr>
<tr>
<td class="c1">
<fmt:message key="server.session.details.hostname" />
</td>
<td>
<% if (inSession != null) { %>
<%= inSession.getConnection().getInetAddress().getHostAddress() %>
/
<%= inSession.getConnection().getInetAddress().getHostName() %>
<% } else if (outSession != null) { %>
<%= outSession.getConnection().getInetAddress().getHostAddress() %>
/
<%= outSession.getConnection().getInetAddress().getHostName() %>
<% } %>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<% // Show details of the incoming session
if (inSession != null) {
%>
<b><fmt:message key="server.session.details.incoming_session" /></b>
<div class="jive-table">
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr>
<th width="35%"><fmt:message key="server.session.details.streamid" /></th>
<th width="20%"><fmt:message key="server.session.label.creation" /></th>
<th width="20%"><fmt:message key="server.session.label.last_active" /></th>
<th width="25%" nowrap><fmt:message key="server.session.details.statistics" /></th>
</tr>
<tr>
<td><%= inSession.getStreamID()%></td>
<td align="center"><%= (System.currentTimeMillis() - inSession.getCreationDate().getTime() < 24*60*60*1000) ? JiveGlobals.formatTime(inSession.getCreationDate()) : JiveGlobals.formatDateTime(inSession.getCreationDate()) %></td>
<td align="center"><%= (System.currentTimeMillis() - inSession.getLastActiveDate().getTime() < 24*60*60*1000) ? JiveGlobals.formatTime(inSession.getLastActiveDate()) : JiveGlobals.formatDateTime(inSession.getLastActiveDate()) %></td>
<td align="center"><%= numFormatter.format(inSession.getNumClientPackets()) %>/<%= numFormatter.format(inSession.getNumServerPackets()) %></td>
</tr>
</table>
</div>
<br>
<% } %>
<% // Show details of the incoming session
if (outSession != null) {
%>
<b><fmt:message key="server.session.details.outgoing_session" /></b>
<div class="jive-table">
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr>
<th width="35%"><fmt:message key="server.session.details.streamid" /></th>
<th width="20%"><fmt:message key="server.session.label.creation" /></th>
<th width="20%"><fmt:message key="server.session.label.last_active" /></th>
<th width="25%" nowrap><fmt:message key="server.session.details.statistics" /></th>
</tr>
<tr>
<td><%= outSession.getStreamID()%></td>
<td align="center"><%= (System.currentTimeMillis() - outSession.getCreationDate().getTime() < 24*60*60*1000) ? JiveGlobals.formatTime(outSession.getCreationDate()) : JiveGlobals.formatDateTime(outSession.getCreationDate()) %></td>
<td align="center"><%= (System.currentTimeMillis() - outSession.getLastActiveDate().getTime() < 24*60*60*1000) ? JiveGlobals.formatTime(outSession.getLastActiveDate()) : JiveGlobals.formatDateTime(outSession.getLastActiveDate()) %></td>
<td align="center"><%= numFormatter.format(outSession.getNumClientPackets()) %>/<%= numFormatter.format(outSession.getNumServerPackets()) %></td>
</tr>
</table>
</div>
<br>
<% } %>
<br>
<form action="server-session-details.jsp">
<center>
<input type="submit" name="back" value="<fmt:message key="session.details.back_button" />">
</center>
</form>
<jsp:include page="bottom.jsp" flush="true" />
<%@ page import="org.jivesoftware.messenger.Session,
org.xmpp.packet.Presence,
java.net.URLEncoder,
org.jivesoftware.util.LocaleUtils,
org.jivesoftware.util.JiveGlobals,
java.util.Date"%>
<%--
- $RCSfile$
- $Revision$
- $Date$
--%>
<%--
- This page is meant to be included in other pages. It assumes 4 variables:
- * 'host', the name of the remote server
- * 'inSession', an IncomingServerSession object
- * 'outSession', an OutgoingServerSession object
- * 'count', an int representing the row number we're on.
--%>
<tr class="jive-<%= (((count % 2) == 0) ? "even" : "odd") %>">
<td width="1%" nowrap><%= count %></td>
<td width="47%" nowrap>
<a href="server-session-details.jsp?hostname=<%= URLEncoder.encode(host, "UTF-8") %>" title="<fmt:message key="session.row.cliked" />"><%= host %></a>
</td>
<% if (inSession != null && outSession == null) { %>
<td width="1%">
<img src="images/incoming_32x16.gif" width="32" height="16" border="0" title="<fmt:message key="server.session.connection.incoming" />">
</td>
<td width="10%"><fmt:message key="server.session.connection.incoming" /></td>
<% } else if (inSession == null && outSession != null) { %>
<td width="1%">
<img src="images/outgoing_32x16.gif" width="32" height="16" border="0" title="<fmt:message key="server.session.connection.outgoing" />">
</td>
<td width="10%"><fmt:message key="server.session.connection.outgoing" /></td>
<% } else { %>
<td width="1%">
<img src="images/both_32x16.gif" width="32" height="16" border="0" title="<fmt:message key="server.session.connection.both" />">
</td>
<td width="10%"><fmt:message key="server.session.connection.both" /></td>
<% } %>
<% Date creationDate = null;
Date lastActiveDate = null;
if (inSession != null && outSession == null) {
creationDate = inSession.getCreationDate();
lastActiveDate = inSession.getLastActiveDate();
}
else if (inSession == null && outSession != null) {
creationDate = outSession.getCreationDate();
lastActiveDate = outSession.getLastActiveDate();
}
else {
creationDate = inSession.getCreationDate().before(outSession.getCreationDate()) ? inSession.getCreationDate() : outSession.getCreationDate();
lastActiveDate = inSession.getLastActiveDate().after(outSession.getLastActiveDate()) ? inSession.getLastActiveDate() : outSession.getLastActiveDate();
}
long now = System.currentTimeMillis();
%>
<td align="center" width="20%" nowrap>
<%= (now - creationDate.getTime() < 24*60*60*1000) ? JiveGlobals.formatTime(creationDate) : JiveGlobals.formatDateTime(creationDate) %>
</td>
<td align="center" width="20%" nowrap>
<%= (now - lastActiveDate.getTime() < 24*60*60*1000) ? JiveGlobals.formatTime(lastActiveDate) : JiveGlobals.formatDateTime(lastActiveDate) %>
</td>
<td width="1%" nowrap align="center" style="border-right:1px #ccc solid;">
<a href="server-session-summary.jsp?hostname=<%= URLEncoder.encode(host, "UTF-8") %>&close=true"
title="<fmt:message key="session.row.cliked_kill_session" />"
onclick="return confirm('<fmt:message key="session.row.confirm_close" />');"
><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
</td>
</tr>
\ No newline at end of file
<%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 Jive Software. All rights reserved.
-
- This software is published under the terms of the GNU Public License (GPL),
- a copy of which is included in this distribution.
--%>
<%@ page import="org.jivesoftware.util.*,
java.util.*,
org.jivesoftware.messenger.*,
java.util.Date,
org.jivesoftware.admin.*,
java.text.DateFormat,
org.xmpp.packet.JID,
java.net.URLEncoder,
org.xmpp.packet.Presence,
org.jivesoftware.messenger.server.IncomingServerSession,
org.jivesoftware.messenger.server.OutgoingServerSession"
errorPage="error.jsp"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%!
final int DEFAULT_RANGE = 15;
final int[] RANGE_PRESETS = {15, 25, 50, 75, 100};
%>
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" />
<% admin.init(request, response, session, application, out ); %>
<% // Get parameters
int start = ParamUtils.getIntParameter(request,"start",0);
int range = ParamUtils.getIntParameter(request,"range",DEFAULT_RANGE);
boolean close = ParamUtils.getBooleanParameter(request,"close");
String hostname = ParamUtils.getParameter(request,"hostname");
// Get the user manager
SessionManager sessionManager = admin.getSessionManager();
Collection<String> hostnames = new TreeSet<String>();
// Get the incoming session hostnames
Collection<String> inHostnames = sessionManager.getIncomingServers();
hostnames.addAll(inHostnames);
// Get the outgoing session hostnames
Collection<String> outHostnames = sessionManager.getOutgoingServers();
hostnames.addAll(outHostnames);
// Get the session count
int sessionCount = hostnames.size();
// Close all connections related to the specified host
if (close) {
try {
Session sess = sessionManager.getIncomingServerSession(hostname);
if (sess != null) {
sess.getConnection().close();
}
sess = sessionManager.getOutgoingServerSession(hostname);
if (sess != null) {
sess.getConnection().close();
}
// wait one second
Thread.sleep(1000L);
}
catch (Exception ignored) {
// Session might have disappeared on its own
}
// redirect back to this page
response.sendRedirect("server-session-summary.jsp?close=success");
return;
}
// paginator vars
int numPages = (int)Math.ceil((double)sessionCount/(double)range);
int curPage = (start/range) + 1;
int maxIndex = (start+range <= sessionCount ? start+range : sessionCount);
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = LocaleUtils.getLocalizedString("server.session.summary.title");
pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(LocaleUtils.getLocalizedString("global.main"), "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "server-session-summary.jsp"));
pageinfo.setPageID("server-session-summary");
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
<% if ("success".equals(request.getParameter("close"))) { %>
<p class="jive-success-text">
<fmt:message key="server.session.summary.close" />
</p>
<% } %>
<fmt:message key="server.session.summary.active" />: <b><%= hostnames.size() %></b>
<% if (numPages > 1) { %>
- <fmt:message key="session.summary.showing" /> <%= (start+1) %>-<%= (start+range) %>
<% } %>
- <fmt:message key="server.session.summary.sessions_per_page" />:
<select size="1" onchange="location.href='server-session-summary.jsp?start=0&range=' + this.options[this.selectedIndex].value;">
<% for (int i=0; i<RANGE_PRESETS.length; i++) { %>
<option value="<%= RANGE_PRESETS[i] %>"
<%= (RANGE_PRESETS[i] == range ? "selected" : "") %>><%= RANGE_PRESETS[i] %></option>
<% } %>
</select>
</p>
<% if (numPages > 1) { %>
<p>
<fmt:message key="session.summary.page" />:
[
<% for (int i=0; i<numPages; i++) {
String sep = ((i+1)<numPages) ? " " : "";
boolean isCurrent = (i+1) == curPage;
%>
<a href="server-session-summary.jsp?start=<%= (i*range) %>"
class="<%= ((isCurrent) ? "jive-current" : "") %>"
><%= (i+1) %></a><%= sep %>
<% } %>
]
</p>
<% } %>
</p>
<p>
<fmt:message key="server.session.summary.info" />
</p>
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th>&nbsp;</th>
<th nowrap><fmt:message key="server.session.label.host" /></th>
<th nowrap colspan="2"><fmt:message key="server.session.label.connection" /></th>
<th nowrap><fmt:message key="server.session.label.creation" /></th>
<th nowrap><fmt:message key="server.session.label.last_active" /></th>
<th nowrap><fmt:message key="server.session.label.close_connect" /></th>
</tr>
</thead>
<tbody>
<% // Check if no out/in connection to/from a remote server exists
if (hostnames.isEmpty()) {
%>
<tr>
<td colspan="9">
<fmt:message key="server.session.summary.not_session" />
</td>
</tr>
<% } %>
<% int count = 0;
hostnames = new ArrayList<String>(hostnames).subList(start, maxIndex);
for (String host : hostnames) {
count++;
IncomingServerSession inSession = sessionManager.getIncomingServerSession(host);
OutgoingServerSession outSession = sessionManager.getOutgoingServerSession(host);
if (inSession == null && outSession == null) {
// If the connections were just closed then skip this host
continue;
}
%>
<%@ include file="server-session-row.jspf" %>
<% } %>
</tbody>
</table>
</div>
<% if (numPages > 1) { %>
<p>
<fmt:message key="session.summary.page" />:
[
<% for (int i=0; i<numPages; i++) {
String sep = ((i+1)<numPages) ? " " : "";
boolean isCurrent = (i+1) == curPage;
%>
<a href="server-session-summary.jsp?start=<%= (i*range) %>"
class="<%= ((isCurrent) ? "jive-current" : "") %>"
><%= (i+1) %></a><%= sep %>
<% } %>
]
</p>
<% } %>
<br>
<p>
<fmt:message key="server.session.summary.last_update" />: <%= JiveGlobals.formatDateTime(new Date()) %>
</p>
<jsp:include page="bottom.jsp" flush="true" />
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment