geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akulshresh...@apache.org
Subject svn commit: r583343 - in /geronimo/sandbox/monitoring/client/client-war/src/main: java/org/apache/geronimo/plugins/monitoring/client/ webapp/WEB-INF/view/
Date Wed, 10 Oct 2007 02:38:03 GMT
Author: akulshreshtha
Date: Tue Oct  9 19:38:02 2007
New Revision: 583343

URL: http://svn.apache.org/viewvc?rev=583343&view=rev
Log:
GERONIMO-3526 Monitoring Client Patch by Erik B. Craig

Modified:
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MRCConnector.java
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/StatsGraph.java
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringPage.jsp

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java?rev=583343&r1=583342&r2=583343&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
Tue Oct  9 19:38:02 2007
@@ -288,9 +288,9 @@
                 e.printStackTrace();
             }
 
-            return (new StatsGraph(graph_id, graphName, rs
-                    .getString("description"), ServerIP + " - "
+            return (new StatsGraph(graph_id, ServerIP + " - "
                     + rs.getString("xlabel") + " - " + prettyTimeFrame, rs
+                    .getString("description"), "Time - " + prettyTimeFrame, rs
                     .getString("ylabel"), rs.getString("data1operation")
                     .charAt(0), DataList.get(graphName), rs
                     .getString("operation"), rs.getString("data2operation")

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MRCConnector.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MRCConnector.java?rev=583343&r1=583342&r2=583343&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MRCConnector.java
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MRCConnector.java
Tue Oct  9 19:38:02 2007
@@ -49,7 +49,7 @@
      * @throws Exception -
      *             If the connection to mrc-server fails
      */
-    MRCConnector(String ServerIP, String userName, String password)
+    public MRCConnector(String ServerIP, String userName, String password)
             throws Exception
     {
         JMXServiceURL serviceURL = new JMXServiceURL(
@@ -74,16 +74,8 @@
     {
         if (SnapshotDuration == 0)
         {
-            try
-            {
-                SnapshotDuration = (Long) mbServerConn.invoke(new ObjectName(
-                        PATH), "getSnapshotDuration", new Object[] {},
-                        new String[] {});
-            }
-            catch (Exception e)
-            {
-                e.printStackTrace();
-            }
+            SnapshotDuration = (Long) mbServerConn.invoke(new ObjectName(PATH),
+                    "getSnapshotDuration", new Object[] {}, new String[] {});
         }
         return SnapshotDuration;
     }
@@ -141,5 +133,44 @@
                         new Object[] { snapCount, skipCount }, new String[] {
                                 "java.lang.Integer", "java.lang.Integer" });
         return list;
+    }
+
+    /**
+     * @return - Returns a boolean indicating successful stop
+     * @throws Exception -
+     *             If the connection to the MRC-Server fails
+     */
+    public boolean stopSnapshotThread() throws Exception
+    {
+        mbServerConn.invoke(new ObjectName(PATH), "stopSnapshot",
+                new Object[] {}, new String[] {});
+        return true;
+    }
+
+    /**
+     * @return - Returns a boolean indicating successful stop
+     * @throws Exception -
+     *             If the connection to the MRC-Server fails
+     */
+    public boolean startSnapshotThread(long time) throws Exception
+    {
+        try
+        {
+            mbServerConn.invoke(new ObjectName(PATH), "startSnapshot",
+                    new Object[] { new Long(time) },
+                    new String[] { "java.lang.Long" });
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            return false;
+        }
+        return true;
+    }
+
+    public boolean isSnapshotRunning() throws Exception
+    {
+        return Boolean.TRUE.equals(mbServerConn.invoke(new ObjectName(PATH),
+                "isSnapshotRunning", new Object[] {}, new String[] {}));
     }
 }

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java?rev=583343&r1=583342&r2=583343&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java
Tue Oct  9 19:38:02 2007
@@ -17,6 +17,10 @@
 package org.apache.geronimo.plugins.monitoring.client;
 
 import java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -27,6 +31,8 @@
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 
+import org.apache.geronimo.plugins.monitoring.client.util.DBManager;
+
 /**
  * STATS
  */
@@ -72,6 +78,20 @@
             String view_id = actionRequest.getParameter("view_id");
             actionResponse.setRenderParameter("view_id", view_id);
         }
+        else if (action.equals("stopThread"))
+        {
+            String server_id = actionRequest.getParameter("server_id");
+            actionResponse.setRenderParameter("server_id", server_id);
+        }
+        else if (action.equals("startThread"))
+        {
+            String server_id = actionRequest.getParameter("server_id");
+            String snapshotDuration = actionRequest
+                    .getParameter("snapshotDuration");
+            actionResponse.setRenderParameter("server_id", server_id);
+            actionResponse.setRenderParameter("snapshotDuration",
+                    snapshotDuration);
+        }
     }
 
     @Override
@@ -86,6 +106,179 @@
             String view_id = request.getParameter("view_id");
             request.setAttribute("view_id", view_id);
             pageView.include(request, response);
+        }
+        else if (action.equals("stopThread"))
+        {
+            PreparedStatement pStmt = null;
+            ResultSet rs = null;
+            MRCConnector MRCConnection = null;
+            DBManager DBase = new DBManager();
+            Connection con = DBase.getConnection();
+            String server_id = request.getParameter("server_id");
+            String server_ip = null;
+            try
+            {
+                pStmt = con
+                        .prepareStatement("SELECT * FROM servers WHERE server_id="
+                                + server_id);
+                rs = pStmt.executeQuery();
+                if (!rs.next())
+                {
+                    request.setAttribute("message",
+                            "<font color='red'>DATABASE ERROR: Server id "
+                                    + server_id
+                                    + " not found in database</font>");
+                    normalView.include(request, response);
+                    return;
+                }
+            }
+            catch (SQLException e)
+            {
+                request.setAttribute("message",
+                        "<font color='red'>DATABASE ERROR: " + e.getMessage()
+                                + "</font>");
+                normalView.include(request, response);
+                return;
+            }
+            try
+            {
+                server_ip = rs.getString("ip");
+                MRCConnection = new MRCConnector(server_ip, rs
+                        .getString("username"), rs.getString("password"));
+            }
+            catch (Exception e)
+            {
+                request
+                        .setAttribute("message",
+                                "<font color='red'>MRC ERROR: Unable to connect to
server "
+                                        + server_ip + ": " + e.getMessage()
+                                        + "</font>");
+                normalView.include(request, response);
+                return;
+            }
+            try
+            {
+                if (MRCConnection.stopSnapshotThread())
+                {
+                    request.setAttribute("message",
+                            "<b>Snapshot thread stopped on server "
+                                    + rs.getString("name") + "</b>");
+                    normalView.include(request, response);
+                }
+                else
+                {
+                    request
+                            .setAttribute(
+                                    "message",
+                                    "<font color='red'>ERROR: Snapshot thread could
<b>NOT</b> be stopped on server "
+                                            + rs.getString("name") + "</font>");
+                    normalView.include(request, response);
+                    return;
+                }
+
+            }
+            catch (Exception e)
+            {
+                request
+                        .setAttribute(
+                                "message",
+                                "<font color='red'>MRC ERROR: Snapshot thread could
<b>NOT</b> be stopped on server "
+                                        + server_ip
+                                        + ": "
+                                        + e.getMessage()
+                                        + "</font>");
+                normalView.include(request, response);
+                return;
+            }
+
+        }
+        else if (action.equals("startThread"))
+        {
+            String server_id = request.getParameter("server_id");
+            Long snapshotDuration = java.lang.Long.parseLong(request
+                    .getParameter("snapshotDuration"));
+            PreparedStatement pStmt = null;
+            ResultSet rs = null;
+            MRCConnector MRCConnection = null;
+            DBManager DBase = new DBManager();
+            Connection con = DBase.getConnection();
+            String server_ip = null;
+            try
+            {
+                pStmt = con
+                        .prepareStatement("SELECT * FROM servers WHERE server_id="
+                                + server_id);
+                rs = pStmt.executeQuery();
+                if (!rs.next())
+                {
+                    request.setAttribute("message",
+                            "<font color='red'>DATABASE ERROR: Server id "
+                                    + server_id
+                                    + " not found in database</font>");
+                    normalView.include(request, response);
+                    return;
+                }
+            }
+            catch (SQLException e)
+            {
+                request.setAttribute("message",
+                        "<font color='red'>DATABASE ERROR: " + e.getMessage()
+                                + "</font>");
+                normalView.include(request, response);
+                return;
+            }
+            try
+            {
+                server_ip = rs.getString("ip");
+                MRCConnection = new MRCConnector(server_ip, rs
+                        .getString("username"), rs.getString("password"));
+            }
+            catch (Exception e)
+            {
+                request
+                        .setAttribute("message",
+                                "<font color='red'>MRC ERROR: Unable to connect to
server "
+                                        + server_ip + ": " + e.getMessage()
+                                        + "</font>");
+                normalView.include(request, response);
+                return;
+            }
+            try
+            {
+
+                if (MRCConnection.startSnapshotThread(new Long(10000)))
+                {
+                    request.setAttribute("message",
+                            "<b>Snapshot thread started on server "
+                                    + rs.getString("name") + "</b>");
+                    normalView.include(request, response);
+                }
+                else
+                {
+                    request
+                            .setAttribute(
+                                    "message",
+                                    "<font color='red'>ERROR: Snapshot thread could
<b>NOT</b> be started on server "
+                                            + rs.getString("name") + "</font>");
+                    normalView.include(request, response);
+                    return;
+                }
+
+            }
+            catch (Exception e)
+            {
+                request
+                        .setAttribute(
+                                "message",
+                                "<font color='red'>MRC ERROR: Snapshot thread could
<b>NOT</b> be started on server "
+                                        + server_ip
+                                        + ": "
+                                        + e.getMessage()
+                                        + "</font>");
+                normalView.include(request, response);
+                return;
+            }
+
         }
         else
         {

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/StatsGraph.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/StatsGraph.java?rev=583343&r1=583342&r2=583343&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/StatsGraph.java
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/StatsGraph.java
Tue Oct  9 19:38:02 2007
@@ -44,7 +44,7 @@
             float warninglevel1, float warninglevel2)
     {
 
-        DivName = graphName + "Container";
+        DivName = "graph" + graph_id + "Container";
         GraphName = graphName;
         Description = description;
         XAxisLabel = xAxisLabel;
@@ -55,13 +55,11 @@
         HexColor = hexColor;
 
         DivDefine = "#" + DivName + "\n" + "{\n" + "margin: 0px;\n"
-                + "background-color: #" + hexColor + "\n"
-                + "border: 1px solid #999;\n" + "width: 750px;\n"
-                + "height: 260px;\n" + "}";
+                + "width: 670px;\n" + "height: 240px;\n" + "}";
 
         DivImplement = "<div id=\"" + DivName + "\"></div>" + "\n";
 
-        GraphJS = "var " + graphName + "Data = \n" + "[\n";
+        GraphJS = "var " + "graph" + graph_id + "Data = \n" + "[\n";
 
         for (int i = 1; i < dataSet1.size(); i++)
         {
@@ -78,46 +76,50 @@
 
         GraphJS = GraphJS + "];\n";
 
-        GraphJS = GraphJS + "var " + graphName
+        GraphJS = GraphJS + "var " + "graph" + graph_id
                 + "Store = new dojo.collections.Store();\n";
-        GraphJS = GraphJS + graphName + "Store.setData(" + graphName
-                + "Data);\n";
-        GraphJS = GraphJS + graphName + "Max = 0;\n" + graphName + "Min = 0;\n"
-                + graphName + "Avg = 0;\n" + "for (var i = 0; i<" + graphName
-                + "Data.length; i++)\n" + "{\n" + graphName + "Max = Math.max("
-                + graphName + "Max," + graphName + "Data[i].value);\n"
-                + graphName + "Min = Math.min(" + graphName + "Min,"
-                + graphName + "Data[i].value);\n" + graphName + "Avg = ("
-                + graphName + "Avg + " + graphName + "Data[i].value);\n"
-                + "}\n" + graphName + "Avg = Math.round(" + graphName + "Avg/"
-                + graphName + "Data.length*10)/10;\n" + "if (" + graphName
-                + "Max == 0)\n" + graphName + "Max = 1;\n";
+        GraphJS = GraphJS + "graph" + graph_id + "Store.setData(" + "graph"
+                + graph_id + "Data);\n";
+        GraphJS = GraphJS + "graph" + graph_id + "Max = 0;\n" + "graph"
+                + graph_id + "Min = 0;\n" + "graph" + graph_id + "Avg = 0;\n"
+                + "for (var i = 0; i<" + "graph" + graph_id
+                + "Data.length; i++)\n" + "{\n" + "graph" + graph_id
+                + "Max = Math.max(" + "graph" + graph_id + "Max," + "graph"
+                + graph_id + "Data[i].value);\n" + "graph" + graph_id
+                + "Min = Math.min(" + "graph" + graph_id + "Min," + "graph"
+                + graph_id + "Data[i].value);\n" + "graph" + graph_id
+                + "Avg = (" + "graph" + graph_id + "Avg + " + "graph"
+                + graph_id + "Data[i].value);\n" + "}\n" + "graph" + graph_id
+                + "Avg = Math.round(" + "graph" + graph_id + "Avg/" + "graph"
+                + graph_id + "Data.length*10)/10;\n" + "if (" + "graph"
+                + graph_id + "Max == 0)\n" + "graph" + graph_id + "Max = 1;\n";
 
         // Setup the data series
-        GraphJS = GraphJS + "var " + graphName
+        GraphJS = GraphJS + "var " + "graph" + graph_id
                 + "Series = new dojo.charting.Series({\n";
-        GraphJS = GraphJS + "dataSource: " + graphName + "Store,\n";
+        GraphJS = GraphJS + "dataSource: " + "graph" + graph_id + "Store,\n";
         GraphJS = GraphJS + "bindings: { x: \"index\", y: \"value\" },\n";
-        GraphJS = GraphJS + "label: \"" + graphName + "\"\n";
+        GraphJS = GraphJS + "label: \"" + "graph" + graph_id + "\"\n";
         GraphJS = GraphJS + "});\n";
 
         // Define the x-axis
-        GraphJS = GraphJS + "var " + graphName
+        GraphJS = GraphJS + "var " + "graph" + graph_id
                 + "xAxis = new dojo.charting.Axis(); \n";
 
         // Set the upper and lower data range valuesprettyName
-        GraphJS = GraphJS + graphName + "xAxis.range = { lower: " + graphName
-                + "Data[0].index, upper: " + graphName + "Data[" + graphName
+        GraphJS = GraphJS + "graph" + graph_id + "xAxis.range = { lower: "
+                + "graph" + graph_id + "Data[0].index, upper: " + "graph"
+                + graph_id + "Data[" + "graph" + graph_id
                 + "Data.length-1].index };\n";
 
-        GraphJS = GraphJS + graphName + "xAxis.origin = \"" + graphName
-                + "Max\";\n";
-        GraphJS = GraphJS + graphName + "xAxis.showTicks = true;\n";
-        GraphJS = GraphJS + graphName + "xAxis.label = \"" + xAxisLabel
-                + "\";\n";
+        GraphJS = GraphJS + "graph" + graph_id + "xAxis.origin = \"" + "graph"
+                + graph_id + "Max\";\n";
+        GraphJS = GraphJS + "graph" + graph_id + "xAxis.showTicks = true;\n";
+        GraphJS = GraphJS + "graph" + graph_id + "xAxis.label = \""
+                + xAxisLabel + "\";\n";
 
         // Setup the x tick marks on the chart
-        GraphJS = GraphJS + graphName + "xAxis.labels = [ \n";
+        GraphJS = GraphJS + "graph" + graph_id + "xAxis.labels = [ \n";
         // timeFrame = ((int) ((Long)snapshotTimes.get(0) - (Long)snapshotTimes
         // .get(snapshotTimes.size() - 1)) / 60000);
         Format formatter = new SimpleDateFormat("HH:mm");
@@ -148,37 +150,39 @@
         }
         GraphJS = GraphJS + "];\n";
         // Define the y-axis
-        GraphJS = GraphJS + "var " + graphName
+        GraphJS = GraphJS + "var " + "graph" + graph_id
                 + "yAxis = new dojo.charting.Axis();\n";
-        GraphJS = GraphJS + graphName + "yAxis.range = { lower: " + graphName
-                + "Min, upper: " + graphName + "Max+(0.1*" + graphName
-                + "Max)};\n";
-        GraphJS = GraphJS + graphName + "yAxis.showLines = true;\n";
-        GraphJS = GraphJS + graphName + "yAxis.showTicks = true;\n";
-        GraphJS = GraphJS + graphName + "yAxis.label = \"" + yAxisLabel
-                + "\";\n";
+        GraphJS = GraphJS + "graph" + graph_id + "yAxis.range = { lower: "
+                + "graph" + graph_id + "Min, upper: " + "graph" + graph_id
+                + "Max+(0.1*" + "graph" + graph_id + "Max)};\n";
+        GraphJS = GraphJS + "graph" + graph_id + "yAxis.showLines = true;\n";
+        GraphJS = GraphJS + "graph" + graph_id + "yAxis.showTicks = true;\n";
+        GraphJS = GraphJS + "graph" + graph_id + "yAxis.label = \""
+                + yAxisLabel + "\";\n";
 
         // Setup the y tick marks on the chart
-        GraphJS = GraphJS + graphName + "yAxis.labels = [ \n";
-        GraphJS = GraphJS + "{ label: \"min - \"+" + graphName + "Min, value: "
-                + graphName + "Min },\n";
-        GraphJS = GraphJS + "{ label: \"avg - \"+" + graphName + "Avg, value: "
-                + graphName + "Avg },\n";
-        GraphJS = GraphJS + "{ label: \"max - \"+" + graphName + "Max, value: "
-                + graphName + "Max },\n";
-        GraphJS = GraphJS + "{ label: Math.round((" + graphName + "Max+(0.1*"
-                + graphName + "Max))), value: " + graphName + "Max+(0.1*"
-                + graphName + "Max) },\n";
+        GraphJS = GraphJS + "graph" + graph_id + "yAxis.labels = [ \n";
+        GraphJS = GraphJS + "{ label: \"min - \"+" + "graph" + graph_id
+                + "Min, value: " + "graph" + graph_id + "Min },\n";
+        GraphJS = GraphJS + "{ label: \"avg - \"+" + "graph" + graph_id
+                + "Avg, value: " + "graph" + graph_id + "Avg },\n";
+        GraphJS = GraphJS + "{ label: \"max - \"+" + "graph" + graph_id
+                + "Max, value: " + "graph" + graph_id + "Max },\n";
+        GraphJS = GraphJS + "{ label: Math.round((" + "graph" + graph_id
+                + "Max+(0.1*" + "graph" + graph_id + "Max))), value: "
+                + "graph" + graph_id + "Max+(0.1*" + "graph" + graph_id
+                + "Max) },\n";
         GraphJS = GraphJS + "];  \n";
 
         // Create the actual graph with the x and y axes defined above
-        GraphJS = GraphJS + "var " + graphName
+        GraphJS = GraphJS + "var " + "graph" + graph_id
                 + "chartPlotArea = new dojo.charting.PlotArea();\n";
-        GraphJS = GraphJS + "var " + graphName
-                + "chartPlot = new dojo.charting.Plot(" + graphName + "xAxis, "
-                + graphName + "yAxis);\n";
-        GraphJS = GraphJS + graphName + "chartPlotArea.initializePlot("
-                + graphName + "chartPlot);\n";
+        GraphJS = GraphJS + "var " + "graph" + graph_id
+                + "chartPlot = new dojo.charting.Plot(" + "graph" + graph_id
+                + "xAxis, " + "graph" + graph_id + "yAxis);\n";
+        GraphJS = GraphJS + "graph" + graph_id
+                + "chartPlotArea.initializePlot(" + "graph" + graph_id
+                + "chartPlot);\n";
         // graphOutput.add(graphName+"xAxis.initializeLabels();");
         // graphOutput.add(graphName+"xAxis.renderLabels("+graphName+"chartPlotArea,
         // "+graphName+"chartPlot, '200', '10', 'LABEL');");
@@ -189,41 +193,45 @@
         // Bar, HorizontalBar, Gantt, StackedArea, StackedCurvedArea,
         // HighLow, HighLowClose, HighLowOpenClose, Bubble,
         // DataBar, Line, CurvedLine, Area, CurvedArea, Scatter
-        GraphJS = GraphJS + graphName + "chartPlot.addSeries({ \n";
-        GraphJS = GraphJS + "data: " + graphName + "Series,\n";
+
+        GraphJS = GraphJS + "graph" + graph_id + "chartPlot.addSeries({ \n";
+        GraphJS = GraphJS + "data: " + "graph" + graph_id + "Series,\n";
         GraphJS = GraphJS + "plotter: dojo.charting.Plotters.CurvedArea\n";
         GraphJS = GraphJS + "});\n";
 
         // Define the plot area
 
-        GraphJS = GraphJS + graphName
+        GraphJS = GraphJS + "graph" + graph_id
                 + "chartPlotArea.size = { width: 650, height: 200 };\n";
         GraphJS = GraphJS
-                + graphName
-                + "chartPlotArea.padding = { top: 30, right: 20, bottom: 30, left: 80 };\n";
+                + "graph"
+                + graph_id
+                + "chartPlotArea.padding = { top: 10, right: 20, bottom: 30, left: 80 };\n";
 
         // Add the plot to the area
-        GraphJS = GraphJS + graphName + "chartPlotArea.plots.push(" + graphName
-                + "chartPlot);\n";
+        GraphJS = GraphJS + "graph" + graph_id + "chartPlotArea.plots.push("
+                + "graph" + graph_id + "chartPlot);\n";
         // Simply use the next available color when plotting the time series
         // plot
-        GraphJS = GraphJS + graphName + "Series.color = '#" + hexColor + "';\n";
+        GraphJS = GraphJS + "graph" + graph_id + "Series.color = '#" + hexColor
+                + "';\n";
 
         // Create the actual chart "canvas"
-        GraphJS = GraphJS + "var " + graphName
-                + "chart = new dojo.charting.Chart(null, \"" + graphName
+        GraphJS = GraphJS + "var " + "graph" + graph_id
+                + "chart = new dojo.charting.Chart(null, \"" + "graph"
+                + graph_id
                 + "\", \"This is the example chart description\");\n";
 
         // Add the plot area at an offset of 10 pixels from the top left
-        GraphJS = GraphJS + graphName + "chart.addPlotArea({ x: "
+        GraphJS = GraphJS + "graph" + graph_id + "chart.addPlotArea({ x: "
                 + dataSet1.size() + ", y: " + dataSet1.size() + ", plotArea: "
-                + graphName + "chartPlotArea });\n";
+                + "graph" + graph_id + "chartPlotArea });\n";
 
         // Setup the chart to be added to the DOM on load
-        GraphJS = GraphJS + "dojo.addOnLoad(function()\n{\n" + graphName
-                + "chart.node = dojo.byId(\"" + DivName + "\");";
+        GraphJS = GraphJS + "dojo.addOnLoad(function()\n{\n" + "graph"
+                + graph_id + "chart.node = dojo.byId(\"" + DivName + "\");";
 
-        GraphJS = GraphJS + graphName + "chart.render();\n});\n";
+        GraphJS = GraphJS + "graph" + graph_id + "chart.render();\n});\n";
 
     }
 

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp?rev=583343&r1=583342&r2=583343&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
Tue Oct  9 19:38:02 2007
@@ -21,19 +21,27 @@
 <%@ page import="java.sql.PreparedStatement" %>
 <%@ page import="java.sql.ResultSet" %>
 <%@ page import="java.sql.SQLException" %>
+<%@ page import="org.apache.geronimo.plugins.monitoring.client.MRCConnector" %>
 <%@ page import="org.apache.geronimo.plugins.monitoring.client.util.*" %>
 <%@ page import="org.apache.geronimo.console.util.PortletManager" %>
 <portlet:defineObjects/>
-
-<table width="100%">
+<%
+ String message = (String) request.getAttribute("message"); 
+ if (message != null)
+ {
+ %>
+<p><%=message %></p>
+<%} %>
+<br>
+<table width="100%" style="border-style: solid;
+border-width: 1px;">
  <thead align="center"><strong>Views</strong></thead>
  <tr>
-  <th width="20%">Name</th>
-  <th width="10%">Number of elements</th>
-  <th width="10%">Created</th>
-  <th width="10%">Modified</th>
-  <th width="10%"></th>
-  <th width="10%"></th>
+  <th class="DarkBackground" width="20%">Name</th>
+  <th class="DarkBackground" width="10%">Elements</th>
+  <th class="DarkBackground" width="10%">Created</th>
+  <th class="DarkBackground" width="10%">Modified</th>
+  <th class="DarkBackground" width="20%" colspan="2">Actions</th>
  </tr>
  <%
  DBManager DBase = new DBManager();
@@ -45,49 +53,118 @@
  {
      String view_id = rs.getString("view_id");
  %>
+ <c:set var="backgroundClass" value='MediumBackground'/>
+  <c:choose>
+      <c:when test="${backgroundClass == 'MediumBackground'}" >
+          <c:set var="backgroundClass" value='LightBackground'/>
+      </c:when>
+      <c:otherwise>
+          <c:set var="backgroundClass" value='MediumBackground'/>
+      </c:otherwise>
+  </c:choose>
  <tr>
-  <td align="center"><a href="<portlet:actionURL portletMode="view"><portlet:param
name="action" value="showView" /><portlet:param name="view_id" value="<%=rs.getString("view_id")%>"
/></portlet:actionURL>"><%=rs.getString("name")%></a></td>
-  <td align="center"><%=rs.getString("graph_count")%></td>
-  <td align="center"><%=rs.getString("added").substring(0,19)%></td>
-  <td align="center"><%=rs.getString("modified").substring(0,19)%></td>
-  <td align="center"><a href="#">Edit</a></td>
-  <td align="center"><a href="#">Delete</a></td>
+  <td class="${backgroundClass}" width="20%" align="center"><a href="<portlet:actionURL
portletMode="view"><portlet:param name="action" value="showView" /><portlet:param
name="view_id" value="<%=rs.getString("view_id")%>" /></portlet:actionURL>"><%=rs.getString("name")%></a></td>
+  <td class="${backgroundClass}" width="10%" align="center"><%=rs.getString("graph_count")%></td>
+  <td class="${backgroundClass}" width="10%" align="center"><%=rs.getString("added").substring(0,16)%></td>
+  <td class="${backgroundClass}" width="10%" align="center"><%=rs.getString("modified").substring(0,16)%></td>
+  <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="edit"><portlet:param name="action" value="showEditView" /><portlet:param
name="view_id" value="<%=rs.getString("view_id")%>" /></portlet:actionURL>">Edit</a></td>
+  <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="edit"><portlet:param name="action" value="doDeleteView" /><portlet:param
name="view_id" value="<%=rs.getString("view_id")%>" /></portlet:actionURL>">Delete</a></td>
  </tr>
  <%} %>
 </table>
-<hr>
-<table width="100%">
+<div align="right"><a href="#">Create View</a></div>
+<table width="100%" style="border-style: solid;
+border-width: 1px;">
  <thead align="center"><strong>Servers</strong></thead>
  <tr>
-  <th width="20%">Name</th>
-  <th width="10%">IP</th>
-  <th width="10%">Recent1</th>
-  <th width="10%">Recent2</th>
-  <th width="10%">Recent3</th>
-  <th width="10%">Recent4</th>
+  <th class="DarkBackground" width="20%">Name</th>
+  <th class="DarkBackground" width="10%">IP</th>
+  <th class="DarkBackground" width="10%">Status</th>
+  <th class="DarkBackground" width="10%">Stat. Query</th>
+  <th class="DarkBackground" width="20%" colspan="2">Actions</th>
  </tr>
  <%
  
- pStmt = con.prepareStatement("SELECT server_id, name, ip FROM servers");
+ pStmt = con.prepareStatement("SELECT * FROM servers WHERE enabled=1");
  rs = pStmt.executeQuery();
  while (rs.next())
  {
-
+     boolean online = false;
+     boolean collecting = false;
+     MRCConnector MRCConnection = null;
+     Long snapshotDuration = new Long(0);
+     try 
+     {
+         MRCConnection = new MRCConnector(rs.getString("ip"), rs
+             .getString("username"), rs.getString("password"));
+         online = true;
+     }    
+     catch (Exception e)
+     {
+         online = false;
+     }
+     try
+     {
+         snapshotDuration = MRCConnection.getSnapshotDuration();
+         if (MRCConnection.isSnapshotRunning())
+             collecting = true;
+         else
+             collecting = false;
+     }
+     catch (Exception e)
+     {
+         e.printStackTrace();
+         collecting = false;
+         online = false;
+     }
+     
 //     String server_name = rs.getString("server_name");
 //     String server_ip = rs.getString("server_ip");
 //     String username = rs.getString("username");
 //     String password = rs.getString("password");
 
-
  %>
+  <c:set var="backgroundClass" value='MediumBackground'/>
+  <c:choose>
+      <c:when test="${backgroundClass == 'MediumBackground'}" >
+          <c:set var="backgroundClass" value='LightBackground'/>
+      </c:when>
+      <c:otherwise>
+          <c:set var="backgroundClass" value='MediumBackground'/>
+      </c:otherwise>
+  </c:choose>
  <tr>
-  <td align="center"><a href="#"><%=rs.getString("name")%></a></td>
-  <td align="center"><a href="#"><%=rs.getString("ip")%></a></td>
-  <td align="center">??</td>
-  <td align="center">??</td>
-  <td align="center">??</td>
-  <td align="center">??</td>
+  <td class="${backgroundClass}" width="20%" align="center"><a href="<portlet:actionURL
portletMode="view"><portlet:param name="action" value="showServer" /><portlet:param
name="server_id" value="<%=rs.getString("server_id")%>" /></portlet:actionURL>"><%=rs.getString("name")%></a></td>
+  <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="view"><portlet:param name="action" value="showServer" /><portlet:param
name="server_id" value="<%=rs.getString("server_id")%>" /></portlet:actionURL>"><%=rs.getString("ip")%></a></td>
+<%
+if (online && collecting)
+{
+%>
+  <td class="${backgroundClass}" width="10%" align="center" bgcolor="green">Online</td>
+  <td class="${backgroundClass}" width="10%" align="center"><%=snapshotDuration/1000/60+"
min. (running)"%></td>
+  <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="edit"><portlet:param name="action" value="showEditServer" /><portlet:param
name="server_id" value="<%=rs.getString("server_id")%>" /></portlet:actionURL>">Edit</a></td>
+  <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="view"><portlet:param name="action" value="stopThread" /><portlet:param
name="server_id" value="<%=rs.getString("server_id")%>" /></portlet:actionURL>">Disable
Query</a></td>
+<%
+}
+else if (online && !collecting)
+{%>
+  <td class="${backgroundClass}" width="10%" align="center" bgcolor="green">Online</td>
+  <td class="${backgroundClass}" width="10%" align="center" bgcolor="red"><%=snapshotDuration/1000/60+"
min. (stopped)"%></td>
+  <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="edit"><portlet:param name="action" value="showEditServer" /><portlet:param
name="server_id" value="<%=rs.getString("server_id")%>" /></portlet:actionURL>">Edit
Server</a></td>
+  <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="view"><portlet:param name="action" value="startThread" /><portlet:param
name="server_id" value="<%=rs.getString("server_id")%>" /><portlet:param name="snapshotDuration"
value="<%=java.lang.Long.toString(snapshotDuration)%>" /></portlet:actionURL>">Enable
Query</a></td>
+<%
+}
+else if (!online)
+{%>
+<td class="${backgroundClass}" width="10%" align="center" bgcolor="red">Offline</td>
+<td class="${backgroundClass}" width="10%" align="center" bgcolor="red">(stopped)</td>
+<td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="edit"><portlet:param name="action" value="showEditServer" /><portlet:param
name="server_id" value="<%=rs.getString("server_id")%>" /></portlet:actionURL>">Edit
Server</a></td>
+<td class="${backgroundClass}" width="10%" align="center">Enable Query</td>
+<%
+}
+%>
  </tr>
  <%}
  con.close();%>
 </table>
+<div align="right"><a href="#">Add Server</a></div>

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringPage.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringPage.jsp?rev=583343&r1=583342&r2=583343&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringPage.jsp
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringPage.jsp
Tue Oct  9 19:38:02 2007
@@ -31,7 +31,6 @@
 
 <%
 
-//Set <String> trackedBeans = (Set<String>) request.getAttribute("trackedBeans");
 String view_id = (String) request.getAttribute("view_id"); 
 
 DBManager DBase = new DBManager();
@@ -65,6 +64,16 @@
     </style>
     <script type='text/javascript' src='/dojo/dojo.js'>
     </script>
+        <script type = "text/javascript">
+<!--
+function hide(x) {
+document.getElementById(x).style.display='none';
+}
+function show(x) {
+document.getElementById(x).style.display='';
+}
+//-->
+</script>
     <script type='text/javascript'>
     var dojoConfig =
     {
@@ -94,9 +103,10 @@
 <% for (StatsGraph graph : GraphVector) 
 {
 %>
-
+<p>
+<div id="<%=graph.getDivName()%>Head" "style="background-color: #f2f2f2; border-top:
1px solid #2581c7; margin: 0px; width: 670px; height: 10px;"><div align="left" style="background-color:
#f2f2f2; float:left; text-align:left; width:500px;"><%=graph.getName() %></div><div
align=right style="background-color: #f2f2f2; float:left; width:170px; text-align:right;"><a
href="#" onClick="hide('<%=graph.getDivName()%>')">_</a>&nbsp;<a href="#"
onClick="show('<%=graph.getDivName()%>')">+</a>&nbsp;<a href="#" onClick="hide('<%=graph.getDivName()%>');hide('<%=graph.getDivName()%>Head');">X</a></div></div>
 <%=graph.getDivImplement()%>
-
+</p>
 <%
 }
 %>
@@ -117,8 +127,10 @@
                 <tr>
                     <td bgcolor="#FFFFFF" nowrap>
                         &nbsp;<br />
-                        <a href="#">Add a graph to the current view</a><br
/>
-                        <a href="#">Modify the current view</a><br />
+                        <ul>
+                        <li><a href="#">Modify the current view</a></li>
+                        <li><a href="#">Create a new view</a></li>
+                        </ul>
                         &nbsp;<br />
                     </td>   
                 </tr>
@@ -134,6 +146,7 @@
     <tr>
         <!-- Body -->
         <td width="90%" align="left" valign="top">
+            <a HREF="javascript:history.go(-1)"><< Back</a>
             <p>
             <font face="Verdana" size="+1">
             View does not exist or is disabled
@@ -141,7 +154,32 @@
             </p>         
 
         </td>
+     
+         <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
+
+        <!-- Geronimo Links -->
+        <td valign="top">
+
+            <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolor="#000000">
+                <tr>
+                    <td class="DarkBackground" align="left" nowrap>
+                        <font face="Verdana" size="+1">Actions</font>
+                    </td>
+                </tr>
+                <tr>
+                    <td bgcolor="#FFFFFF" nowrap>
+                        &nbsp;<br />
+                        <ul>
+                        <li><a href="#">Create a new view</a></li>
+                        </ul>
+                        &nbsp;<br />
+                    </td>   
+                </tr>
+            </table>
+
+        </td>  
     </tr>
 </table>
     <%}%>
+
 



Mime
View raw message