%--
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"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/CommonMsg.tld" prefix="CommonMsg"%>
<%@ page import="org.apache.geronimo.monitoring.console.StatsGraph" %>
<%@ page import="org.apache.geronimo.monitoring.console.GraphsBuilder" %>
<%@ page import="java.util.Set" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.TreeMap" %>
<%@ page import="java.lang.String" %>
<%@ 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.util.*" %>
<%@ page import="org.apache.geronimo.monitoring.console.MRCConnector" %>
<%@ page import="org.apache.geronimo.crypto.EncryptionManager" %>
<%
String server_id = (String) request.getAttribute("server_id");
String name = (String) request.getAttribute("name");
String ip = (String) request.getAttribute("ip");
String username = (String) request.getAttribute("username");
String password = (String) request.getAttribute("password");
String password2 = (String) request.getAttribute("password2");
String snapshot = (String) request.getAttribute("snapshot");
String retention = (String) request.getAttribute("retention");
String port = (String)request.getAttribute("port");
String protocol = (String) request.getAttribute("protocol");
if(name == null) name = "";
if(ip == null) ip = "";
if(username == null) username = "";
if(password == null) password = "";
if(password2 == null) password2 = "";
if(snapshot == null) snapshot = "";
if(retention == null) retention = "";
if(protocol == null) protocol = "";
if(protocol.equals("1"))
{
if(port == null) port = "1099";
}
else if(protocol.equals("2"))
{
if(port == null) port = "4201";
}
else
{
protocol = "1";
if(port == null) port = "1099";
}
DBManager DBase = new DBManager();
Connection con = DBase.getConnection();
PreparedStatement pStmt = con.prepareStatement("SELECT * FROM servers WHERE server_id="+server_id);
ResultSet rs = pStmt.executeQuery();
MRCConnector mrc = null;
boolean isOnline = true;
String added = "";
String modified = "";
String last_seen = "";
boolean enabled = true;
String dbPassword = "";
if (rs.next()) {
// name == "" when user has not submitted anything
if(name.equals("")) {
// store the information from db into the variables
name = rs.getString("name");
username = rs.getString("username");
ip = rs.getString("ip");
port = rs.getString("port");
protocol = rs.getString("protocol");
dbPassword = (String)EncryptionManager.decrypt(rs.getString("password"));
}
added = rs.getString("added");
modified = rs.getString("modified");
last_seen = rs.getString("last_seen");
enabled = rs.getInt("enabled") == 1 ? true : false;
try {
// close connection before using the MRCConnector
con.close();
mrc = new MRCConnector(ip, username, password, Integer.parseInt(port), Integer.parseInt(protocol));
} catch (Exception e) {
// the password supplied by the user doesn't work
try {
if(retention.equals("") || snapshot.equals("")) {
mrc = new MRCConnector(ip, username, dbPassword, Integer.parseInt(port), Integer.parseInt(protocol));
// get the snapshot on the first call or any subsequent valid connections
snapshot = snapshot == "" ? "" + mrc.getSnapshotDuration() / 1000 / 60 : snapshot;
// get the retention on the first call or any subsequent valid connection
retention = retention == "" ? "" + mrc.getSnapshotRetention() : retention;
}
} catch(Exception ee) {
// the password in the db does not work
isOnline = false;
}
}finally{
if(null != mrc){
mrc.dispose();
mrc = null;
}
}
%>
: <%=name%> (<%=ip%>)
|
|
|
<%
if(enabled) {
%>
- ">
<%
} else {
%>
- ">
<%
}
%>
- ">
- ">
|
|
<%
con.close();
}
else
{%>
<%
}
%>