%@ page contentType="text/html; charset=UTF-8" %>
<%--
-
- Copyright (C) 2004-2008 Jive Software, 2016-2024 Ignite Realtime Foundation. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--%>
<%@ page import="java.text.*"
errorPage="error.jsp"
%>
<%@ page import="org.jivesoftware.database.DbConnectionManager"%>
<%@ page import="org.jivesoftware.util.JiveGlobals"%>
<%@ page import="org.jivesoftware.database.ProfiledConnection"%>
<%@ page import="org.jivesoftware.database.ProfiledConnectionEntry"%>
<%@ page import="org.jivesoftware.util.ParamUtils"%>
<%@ page import="org.jivesoftware.util.CookieUtils"%>
<%@ page import="org.jivesoftware.util.LocaleUtils"%>
<%@ page import="org.jivesoftware.util.StringUtils"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="admin" prefix="admin" %>
<% webManager.init(request, response, session, application, out ); %>
<%! // Global methods, vars
// Default refresh values
static final int[] REFRESHES = {10,30,60,90};
%>
<%
// Get parameters
boolean doClear = request.getParameter("doClear") != null;
String enableStats = ParamUtils.getParameter(request,"enableStats");
int refresh = ParamUtils.getIntParameter(request,"refresh", -1);
boolean doSortByTime = ParamUtils.getBooleanParameter(request,"doSortByTime");
Cookie csrfCookie = CookieUtils.getCookie(request, "csrf");
String csrfParam = ParamUtils.getParameter(request, "csrf");
boolean csrf_check = true;
if (csrfCookie == null || csrfParam == null || !csrfCookie.getValue().equals(csrfParam)) {
csrf_check = false;
doClear = false;
}
csrfParam = StringUtils.randomString(16);
CookieUtils.setCookie(request, response, "csrf", csrfParam, -1);
pageContext.setAttribute("csrf", csrfParam);
// Var for the alternating colors
int rowColor = 0;
// Clear the statistics
if (doClear) {
ProfiledConnection.resetStatistics();
// Reload the page without params.
response.sendRedirect("server-db-stats.jsp");
}
if (csrf_check) {
// Enable/disable stats
if ("true".equals(enableStats) && ! DbConnectionManager.isProfilingEnabled()) {
DbConnectionManager.setProfilingEnabled(true);
// Log the event
webManager.logEvent("enabled db profiling", null);
}
else if ("false".equals(enableStats) && DbConnectionManager.isProfilingEnabled()) {
DbConnectionManager.setProfilingEnabled(false);
// Log the event
webManager.logEvent("disabled db profiling", null);
}
}
// Number intFormat for pretty printing of large number values and decimals:
NumberFormat intFormat = NumberFormat.getInstance(JiveGlobals.getLocale());
DecimalFormat decFormat = new DecimalFormat("#,##0.00");
pageContext.setAttribute("refresh", refresh);
pageContext.setAttribute("profilingEnabled", DbConnectionManager.isProfilingEnabled());
pageContext.setAttribute("selectList", ProfiledConnection.getSortedQueries(ProfiledConnection.Type.select, doSortByTime));
pageContext.setAttribute("insertList", ProfiledConnection.getSortedQueries(ProfiledConnection.Type.insert, doSortByTime));
pageContext.setAttribute("updateList", ProfiledConnection.getSortedQueries(ProfiledConnection.Type.update, doSortByTime));
pageContext.setAttribute("deleteList", ProfiledConnection.getSortedQueries(ProfiledConnection.Type.delete, doSortByTime));
%>
<% // Enable refreshing if specified
if (refresh >= 10) {
%>
<% } %>
|
<%= intFormat.format(ProfiledConnection.getQueryCount(ProfiledConnection.Type.select)) %> |
|
<%= intFormat.format(ProfiledConnection.getTotalQueryTime(ProfiledConnection.Type.select).toMillis()) %> |
|
<%= decFormat.format(ProfiledConnection.getAverageQueryTime(ProfiledConnection.Type.select).toMillis()) %> |
|
<%= decFormat.format(ProfiledConnection.getQueriesPerSecond(ProfiledConnection.Type.select)) %> |
|
|
|
|
<%= intFormat.format(ProfiledConnection.getQueryCount(ProfiledConnection.Type.insert)) %> |
|
<%= intFormat.format(ProfiledConnection.getTotalQueryTime(ProfiledConnection.Type.insert).toMillis()) %> |
|
<%= decFormat.format(ProfiledConnection.getAverageQueryTime(ProfiledConnection.Type.insert).toMillis()) %> |
|
<%= decFormat.format(ProfiledConnection.getQueriesPerSecond(ProfiledConnection.Type.insert)) %> |
|
|
|
|
<%= intFormat.format(ProfiledConnection.getQueryCount(ProfiledConnection.Type.update)) %> |
|
<%= intFormat.format(ProfiledConnection.getTotalQueryTime(ProfiledConnection.Type.update).toMillis()) %> |
|
<%= decFormat.format(ProfiledConnection.getAverageQueryTime(ProfiledConnection.Type.update).toMillis()) %> |
|
<%= decFormat.format(ProfiledConnection.getQueriesPerSecond(ProfiledConnection.Type.update)) %> |
|
|
|
|
<%= intFormat.format(ProfiledConnection.getQueryCount(ProfiledConnection.Type.delete)) %> |
|
<%= intFormat.format(ProfiledConnection.getTotalQueryTime(ProfiledConnection.Type.delete).toMillis()) %> |
|
<%= decFormat.format(ProfiledConnection.getAverageQueryTime(ProfiledConnection.Type.delete).toMillis()) %> |
|
<%= decFormat.format(ProfiledConnection.getQueriesPerSecond(ProfiledConnection.Type.delete)) %> |
|
|
|