<%-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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. --%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%> <%@ page import="java.util.ArrayList" %> <%@ page import="java.sql.Connection" %> <%@ page import="java.sql.DatabaseMetaData" %> <%@ page import="java.sql.PreparedStatement" %> <%@ page import="java.sql.ResultSet" %> <%@ page import="java.sql.SQLException" %> <%@ page import="org.apache.geronimo.monitoring.console.MRCConnector" %> <%@ page import="org.apache.geronimo.monitoring.console.util.*" %> <% String message = (String) request.getAttribute("message"); if (message != null) { %>

<%= message %>

<% } %>
Views <% DBManager DBase = new DBManager(); Connection con = DBase.getConnection(); PreparedStatement pStmt = con.prepareStatement("SELECT view_id, name, description, graph_count, added, modified FROM views"); ResultSet rs = pStmt.executeQuery(); while (rs.next()) { String view_id = rs.getString("view_id"); %> <% } rs.close(); %>
Name Elements Created Modified Actions
" />"><%=rs.getString("name")%> <%=rs.getString("graph_count")%> <%=rs.getString("added").substring(0,16)%> <%=rs.getString("modified").substring(0,16)%> " />">Edit
">Create View
Servers <% pStmt = con.prepareStatement("SELECT * FROM servers"); rs = pStmt.executeQuery(); // data structure to store the server's info class ServerInfo { public String ip; public int port; public int protocol; public String username; public String password; public String server_id; public boolean enabled; public String name; } ArrayList serverInfos = new ArrayList(); // for each server, save the information locally while(rs.next()) { ServerInfo s = new ServerInfo(); s.ip = rs.getString("ip"); s.username = rs.getString("username"); s.password = rs.getString("password"); s.server_id = rs.getString("server_id"); s.name = rs.getString("name"); s.enabled = rs.getInt("enabled") == 1 ? true : false; s.port = rs.getInt("port"); s.protocol = rs.getInt("protocol"); serverInfos.add( s ); } // for each server, draw it for(int i = 0 ; i < serverInfos.size(); i++) { String ip = serverInfos.get(i).ip; int port = serverInfos.get(i).port; int protocol = serverInfos.get(i).protocol; String username = serverInfos.get(i).username; String password = serverInfos.get(i).password; String server_id = serverInfos.get(i).server_id; boolean enabled = serverInfos.get(i).enabled; String name = serverInfos.get(i).name; boolean online = false; Integer collecting = 0; MRCConnector mrc = null; Long snapshotDuration = new Long(0); if (enabled) { try { mrc = new MRCConnector(ip, username, password, port, protocol); online = true; } catch (Exception e) { online = false; } try { snapshotDuration = mrc.getSnapshotDuration(); collecting = mrc.isSnapshotRunning(); } catch (Exception e) { collecting = 0; online = false; } } %> <% if(enabled){ %> <% } else{ %> <% } if (online) { // online %> <% } else if(enabled){ // offline %> <% } else { // Disabled %> <% } if (collecting == 0) { // not collecting statistics %> <% if(enabled) { // enable the links %> <% } else { // do not provide links %> <% } %> <% } else if (collecting == -1) { // not collecting statistics %> <% if(enabled) { // enable the links %> <% } else { // do not provide links %> <% } %> <% } else { // collecting statistics if (enabled) { %> <% } else { %> <% } } if(enabled) { // enabled server %> <% } else { // disabled server %> <% } %> <%} %>
Name IP/Hostname Status Stat. Query Actions
"><%=name%> "><%=ip%><%=name%> <%=ip%>OnlineOfflineDisabled(stopped)">Enable QueryEnable Query">EditStopping...Disable QueryDisable Query">Edit<%=snapshotDuration/1000/60+" min. (running)"%> ">Disable Query ">EditStopped Disable Query ">Edit">Disable">Enable
">Add Server
Graphs <% pStmt = con.prepareStatement("SELECT * FROM graphs"); rs = pStmt.executeQuery(); // data structure to store the graph's info class GraphInfo { public String name; public String server_name; public String server_id; public String graph_id; public String timeframe; public String dataname1; public String operation; public String dataname2; public boolean enabled; } ArrayList graphInfo = new ArrayList(); // for each graph, save the information locally while(rs.next()) { pStmt = con.prepareStatement("SELECT name FROM servers WHERE server_id="+rs.getInt("server_id")); ResultSet rs2 = pStmt.executeQuery(); if (rs2.next()) { GraphInfo s = new GraphInfo(); s.server_name = rs2.getString("name"); s.name = rs.getString("name"); s.timeframe = rs.getString("timeframe"); s.dataname1 = rs.getString("dataname1"); s.operation = rs.getString("operation"); s.dataname2 = rs.getString("dataname2"); s.server_id = rs.getString("server_id"); s.graph_id = rs.getString("graph_id"); s.enabled = rs.getInt("enabled") == 1 ? true : false; graphInfo.add( s ); } rs2.close(); } // close connection con.close(); // for each graph, draw it for(int i = 0 ; i < graphInfo.size(); i++) { String name = graphInfo.get(i).name; String server_name = graphInfo.get(i).server_name; String timeframe = graphInfo.get(i).timeframe; String dataname1 = graphInfo.get(i).dataname1; String operation = graphInfo.get(i).operation; String dataname2 = graphInfo.get(i).dataname2; String server_id = graphInfo.get(i).server_id; String graph_id = graphInfo.get(i).graph_id; boolean enabled = graphInfo.get(i).enabled; %> <% if (enabled) { %> <%} else { %> <% }%> <%} %>
Name Server Timeframe Data Series Actions
<%=name %> "><%=server_name%> <%=timeframe%> <%=dataname1%><%if (operation != null && !operation.equals("null")){%><%=operation%><%}%><%if (dataname2 != null && !dataname2.equals("null")){%><%=dataname2%><%}%> ">Edit<%=name%> <%=server_name%> <%=timeframe%> <%=dataname1%><%if (operation != null && !operation.equals("null")){%><%=operation%><%}%><%if (dataname2 != null && !dataname2.equals("null")){%><%=dataname2%><%}%> Edit
">Add Graph