aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/UserStatistics
diff options
context:
space:
mode:
authorTeravus Ovares2009-01-07 23:20:23 +0000
committerTeravus Ovares2009-01-07 23:20:23 +0000
commit95984e05876136cee464b3ecdc66d3cf36aac353 (patch)
tree53625792d2f8b5fcd629079bc0b460efcc2ff560 /OpenSim/Region/UserStatistics
parent* refactor: Make some direct IClientAPI calls go through the dialog module in... (diff)
downloadopensim-SC_OLD-95984e05876136cee464b3ecdc66d3cf36aac353.zip
opensim-SC_OLD-95984e05876136cee464b3ecdc66d3cf36aac353.tar.gz
opensim-SC_OLD-95984e05876136cee464b3ecdc66d3cf36aac353.tar.bz2
opensim-SC_OLD-95984e05876136cee464b3ecdc66d3cf36aac353.tar.xz
* Added session report.
** Full or two criteria. UserID, or VersionString * Added link to session report from client report.
Diffstat (limited to 'OpenSim/Region/UserStatistics')
-rw-r--r--OpenSim/Region/UserStatistics/Clients_report.cs5
-rw-r--r--OpenSim/Region/UserStatistics/HTMLUtil.cs44
-rw-r--r--OpenSim/Region/UserStatistics/Sessions_Report.cs260
-rw-r--r--OpenSim/Region/UserStatistics/WebStatsModule.cs16
4 files changed, 312 insertions, 13 deletions
diff --git a/OpenSim/Region/UserStatistics/Clients_report.cs b/OpenSim/Region/UserStatistics/Clients_report.cs
index bc43e18..69514fb 100644
--- a/OpenSim/Region/UserStatistics/Clients_report.cs
+++ b/OpenSim/Region/UserStatistics/Clients_report.cs
@@ -71,6 +71,8 @@ namespace OpenSim.Region.UserStatistics
71 totalregions = Convert.ToInt32(sdr["regcnt"]); 71 totalregions = Convert.ToInt32(sdr["regcnt"]);
72 } 72 }
73 73
74 sdr.Close();
75 sdr.Dispose();
74 76
75 sql = 77 sql =
76 "select client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by client_version order by count(*) desc LIMIT 10;"; 78 "select client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by client_version order by count(*) desc LIMIT 10;";
@@ -197,7 +199,8 @@ TD.align_top { vertical-align: top; }
197 { 199 {
198 HTMLUtil.TR_O(ref output, ""); 200 HTMLUtil.TR_O(ref output, "");
199 HTMLUtil.TD_O(ref output, "content"); 201 HTMLUtil.TD_O(ref output, "content");
200 output.Append(cvd.version); 202 string linkhref = "sessions.report?VersionString=" + cvd.version;
203 HTMLUtil.A(ref output, cvd.version, linkhref, "");
201 HTMLUtil.TD_C(ref output); 204 HTMLUtil.TD_C(ref output);
202 HTMLUtil.TD_O(ref output, "content"); 205 HTMLUtil.TD_O(ref output, "content");
203 output.Append(cvd.count); 206 output.Append(cvd.count);
diff --git a/OpenSim/Region/UserStatistics/HTMLUtil.cs b/OpenSim/Region/UserStatistics/HTMLUtil.cs
index 173f75e..bd0c74a 100644
--- a/OpenSim/Region/UserStatistics/HTMLUtil.cs
+++ b/OpenSim/Region/UserStatistics/HTMLUtil.cs
@@ -50,11 +50,27 @@ namespace OpenSim.Region.UserStatistics
50 50
51 public static void TD_O(ref StringBuilder o, string pclass) 51 public static void TD_O(ref StringBuilder o, string pclass)
52 { 52 {
53 TD_O(ref o, pclass, 0, 0);
54 }
55 public static void TD_O(ref StringBuilder o, string pclass, int rowspan, int colspan)
56 {
53 o.Append("<td"); 57 o.Append("<td");
54 if (pclass.Length > 0) 58 if (pclass.Length > 0)
55 { 59 {
56 GenericClass(ref o, pclass); 60 GenericClass(ref o, pclass);
57 } 61 }
62 if (rowspan > 1)
63 {
64 o.Append(" rowspan=\"");
65 o.Append(rowspan);
66 o.Append("\"");
67 }
68 if (colspan > 1)
69 {
70 o.Append(" colspan=\"");
71 o.Append(colspan);
72 o.Append("\"");
73 }
58 o.Append(">"); 74 o.Append(">");
59 } 75 }
60 public static void TD_C(ref StringBuilder o) 76 public static void TD_C(ref StringBuilder o)
@@ -220,21 +236,25 @@ namespace OpenSim.Region.UserStatistics
220 { 236 {
221 o.Append("|&nbsp;&nbsp;"); 237 o.Append("|&nbsp;&nbsp;");
222 } 238 }
223 239 A(ref o, reports[str].ReportName, str, pClass);
224 o.Append("<A"); 240 o.Append("&nbsp;&nbsp;");
225 if (pClass.Length > 0)
226 {
227 GenericClass(ref o, pClass);
228
229 }
230 o.Append(" href=\"");
231 o.Append(str);
232 o.Append("\">");
233 o.Append(reports[str].ReportName);
234 o.Append("</A>&nbsp;&nbsp;");
235 repcount++; 241 repcount++;
236 } 242 }
237 } 243 }
238 } 244 }
245 public static void A( ref StringBuilder o, string linktext, string linkhref, string pClass)
246 {
247 o.Append("<A");
248 if (pClass.Length > 0)
249 {
250 GenericClass(ref o, pClass);
251 }
252 o.Append(" href=\"");
253 o.Append(linkhref);
254 o.Append("\">");
255 o.Append(linktext);
256 o.Append("</A>");
257
258 }
239 } 259 }
240} 260}
diff --git a/OpenSim/Region/UserStatistics/Sessions_Report.cs b/OpenSim/Region/UserStatistics/Sessions_Report.cs
new file mode 100644
index 0000000..2eeb90d
--- /dev/null
+++ b/OpenSim/Region/UserStatistics/Sessions_Report.cs
@@ -0,0 +1,260 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using Mono.Data.SqliteClient;
33using OpenMetaverse;
34using OpenSim.Framework;
35
36namespace OpenSim.Region.UserStatistics
37{
38 public class Sessions_Report : IStatsController
39 {
40 #region IStatsController Members
41
42 public string ReportName
43 {
44 get { return "Sessions"; }
45 }
46
47 public Hashtable ProcessModel(Hashtable pParams)
48 {
49 Hashtable modeldata = new Hashtable();
50 modeldata.Add("Scenes", pParams["Scenes"]);
51 modeldata.Add("Reports", pParams["Reports"]);
52 SqliteConnection dbConn = (SqliteConnection)pParams["DatabaseConnection"];
53 List<SessionList> lstSessions = new List<SessionList>();
54 Hashtable requestvars = (Hashtable) pParams["RequestVars"];
55
56 string puserUUID = string.Empty;
57 string clientVersionString = string.Empty;
58 int queryparams = 0;
59
60 if (requestvars.ContainsKey("UserID"))
61 {
62 UUID testUUID = UUID.Zero;
63 if (UUID.TryParse(requestvars["UserID"].ToString(), out testUUID))
64 {
65 puserUUID = requestvars["UserID"].ToString();
66
67 }
68 }
69
70 if (requestvars.ContainsKey("VersionString"))
71 {
72 UUID testUUID = UUID.Zero;
73
74 clientVersionString = requestvars["VersionString"].ToString();
75
76
77 }
78
79 lock (dbConn)
80 {
81 string sql =
82 "SELECT distinct a.name_f, a.name_l, a.Agent_ID, b.Session_ID, b.client_version, b.last_updated FROM stats_session_data a LEFT OUTER JOIN stats_session_data b ON a.Agent_ID = b.Agent_ID";
83
84 if (puserUUID.Length > 0)
85 {
86 if (queryparams == 0)
87 sql += " WHERE";
88 else
89 sql += " AND";
90
91 sql += " b.agent_id=:agent_id";
92 queryparams++;
93 }
94
95 if (clientVersionString.Length > 0)
96 {
97 if (queryparams == 0)
98 sql += " WHERE";
99 else
100 sql += " AND";
101
102 sql += " b.client_version=:client_version";
103 queryparams++;
104 }
105
106 sql += " ORDER BY a.name_f, a.name_l, b.last_updated;";
107
108 SqliteCommand cmd = new SqliteCommand(sql, dbConn);
109
110 if (puserUUID.Length > 0)
111 cmd.Parameters.Add(new SqliteParameter(":agent_id", puserUUID));
112 if (clientVersionString.Length > 0)
113 cmd.Parameters.Add(new SqliteParameter(":client_version", clientVersionString));
114
115 SqliteDataReader sdr = cmd.ExecuteReader();
116
117 if (sdr.HasRows)
118 {
119 UUID userUUID = UUID.Zero;
120
121 SessionList activeSessionList = new SessionList();
122 activeSessionList.user_id=UUID.Random();
123 while(sdr.Read())
124 {
125 UUID readUUID = UUID.Parse(sdr["agent_id"].ToString());
126 if (readUUID != userUUID)
127 {
128 activeSessionList = new SessionList();
129 activeSessionList.user_id = readUUID;
130 activeSessionList.firstname = sdr["name_f"].ToString();
131 activeSessionList.lastname = sdr["name_l"].ToString();
132 activeSessionList.sessions = new List<ShortSessionData>();
133 lstSessions.Add(activeSessionList);
134 }
135
136 ShortSessionData ssd = new ShortSessionData();
137
138 ssd.last_update = Utils.UnixTimeToDateTime((uint)Convert.ToInt32(sdr["last_updated"]));
139 ssd.session_id = UUID.Parse(sdr["session_id"].ToString());
140 ssd.client_version = sdr["client_version"].ToString();
141 activeSessionList.sessions.Add(ssd);
142
143 userUUID = activeSessionList.user_id;
144 }
145 }
146 sdr.Close();
147 sdr.Dispose();
148
149 }
150 modeldata["SessionData"] = lstSessions;
151 return modeldata;
152 }
153
154 public string RenderView(Hashtable pModelResult)
155 {
156 List<SessionList> lstSession = (List<SessionList>) pModelResult["SessionData"];
157 Dictionary<string, IStatsController> reports = (Dictionary<string, IStatsController>)pModelResult["Reports"];
158
159 const string STYLESHEET =
160 @"
161<STYLE>
162body
163{
164 font-size:15px; font-family:Helvetica, Verdana; color:Black;
165}
166TABLE.defaultr { }
167TR.defaultr { padding: 5px; }
168TD.header { font-weight:bold; padding:5px; }
169TD.content {}
170TD.contentright { text-align: right; }
171TD.contentcenter { text-align: center; }
172TD.align_top { vertical-align: top; }
173</STYLE>
174";
175
176 StringBuilder output = new StringBuilder();
177 HTMLUtil.HtmlHeaders_O(ref output);
178 output.Append(STYLESHEET);
179 HTMLUtil.HtmlHeaders_C(ref output);
180
181 HTMLUtil.AddReportLinks(ref output, reports, "");
182
183 HTMLUtil.TABLE_O(ref output, "defaultr");
184 HTMLUtil.TR_O(ref output, "defaultr");
185 HTMLUtil.TD_O(ref output, "header");
186 output.Append("FirstName");
187 HTMLUtil.TD_C(ref output);
188 HTMLUtil.TD_O(ref output, "header");
189 output.Append("LastName");
190 HTMLUtil.TD_C(ref output);
191 HTMLUtil.TD_O(ref output, "header");
192 output.Append("SessionEnd");
193 HTMLUtil.TD_C(ref output);
194 HTMLUtil.TD_O(ref output, "header");
195 output.Append("Client");
196 HTMLUtil.TD_C(ref output);
197 HTMLUtil.TR_C(ref output);
198 if (lstSession.Count == 0)
199 {
200 HTMLUtil.TR_O(ref output, "");
201 HTMLUtil.TD_O(ref output, "align_top", 1, 4);
202 output.Append("No results for that query");
203 HTMLUtil.TD_C(ref output);
204 HTMLUtil.TR_C(ref output);
205 }
206 foreach (SessionList ssnlst in lstSession)
207 {
208 int cnt = 0;
209 foreach (ShortSessionData sesdata in ssnlst.sessions)
210 {
211 HTMLUtil.TR_O(ref output, "");
212 if (cnt++ == 0)
213 {
214 HTMLUtil.TD_O(ref output, "align_top", ssnlst.sessions.Count, 1);
215 output.Append(ssnlst.firstname);
216 HTMLUtil.TD_C(ref output);
217 HTMLUtil.TD_O(ref output, "align_top", ssnlst.sessions.Count, 1);
218 output.Append(ssnlst.lastname);
219 HTMLUtil.TD_C(ref output);
220 }
221 HTMLUtil.TD_O(ref output, "content");
222 output.Append(sesdata.last_update.ToShortDateString());
223 output.Append(" - ");
224 output.Append(sesdata.last_update.ToShortTimeString());
225 HTMLUtil.TD_C(ref output);
226 HTMLUtil.TD_O(ref output, "content");
227 output.Append(sesdata.client_version);
228 HTMLUtil.TD_C(ref output);
229 HTMLUtil.TR_C(ref output);
230
231 }
232 HTMLUtil.TR_O(ref output, "");
233 HTMLUtil.TD_O(ref output, "align_top", 1, 4);
234 HTMLUtil.HR(ref output, "");
235 HTMLUtil.TD_C(ref output);
236 HTMLUtil.TR_C(ref output);
237 }
238 HTMLUtil.TABLE_C(ref output);
239 output.Append("</BODY>\n</HTML>");
240 return output.ToString();
241 }
242
243 public class SessionList
244 {
245 public string firstname;
246 public string lastname;
247 public UUID user_id;
248 public List<ShortSessionData> sessions;
249 }
250
251 public struct ShortSessionData
252 {
253 public UUID session_id;
254 public string client_version;
255 public DateTime last_update;
256 }
257
258 #endregion
259 }
260}
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs
index 8a640d0..efea515 100644
--- a/OpenSim/Region/UserStatistics/WebStatsModule.cs
+++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs
@@ -106,6 +106,7 @@ namespace OpenSim.Region.UserStatistics
106 SimStatsAJAX ajSimStats = new SimStatsAJAX(); 106 SimStatsAJAX ajSimStats = new SimStatsAJAX();
107 LogLinesAJAX ajLogLines = new LogLinesAJAX(); 107 LogLinesAJAX ajLogLines = new LogLinesAJAX();
108 Clients_report clientReport = new Clients_report(); 108 Clients_report clientReport = new Clients_report();
109 Sessions_Report sessionsReport = new Sessions_Report();
109 110
110 reports.Add("", rep); 111 reports.Add("", rep);
111 reports.Add("prototype.js", protodep); 112 reports.Add("prototype.js", protodep);
@@ -114,6 +115,18 @@ namespace OpenSim.Region.UserStatistics
114 reports.Add("simstatsajax.ajax", ajSimStats); 115 reports.Add("simstatsajax.ajax", ajSimStats);
115 reports.Add("activelogajax.ajax", ajLogLines); 116 reports.Add("activelogajax.ajax", ajLogLines);
116 reports.Add("clients.report", clientReport); 117 reports.Add("clients.report", clientReport);
118 reports.Add("sessions.report", sessionsReport);
119
120
121
122 ////
123 // Add Your own Reports here (Do Not Modify Lines here Devs!)
124 ////
125
126 ////
127 // End Own reports section
128 ////
129
117 130
118 scene.CommsManager.HttpServer.AddHTTPHandler("/SStats/", HandleStatsRequest); 131 scene.CommsManager.HttpServer.AddHTTPHandler("/SStats/", HandleStatsRequest);
119 scene.CommsManager.HttpServer.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest); 132 scene.CommsManager.HttpServer.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest);
@@ -190,6 +203,9 @@ namespace OpenSim.Region.UserStatistics
190 IStatsController rep = reports[regpath]; 203 IStatsController rep = reports[regpath];
191 Hashtable repParams = new Hashtable(); 204 Hashtable repParams = new Hashtable();
192 205
206 repParams["RequestVars"] = request["requestvars"];
207 repParams["QueryStringKeys"] = request["querystringkeys"];
208
193 repParams["DatabaseConnection"] = dbConn; 209 repParams["DatabaseConnection"] = dbConn;
194 repParams["Scenes"] = m_scene; 210 repParams["Scenes"] = m_scene;
195 repParams["SimStats"] = m_simstatsCounters; 211 repParams["SimStats"] = m_simstatsCounters;