aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/UserStatistics/Clients_report.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/UserStatistics/Clients_report.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/UserStatistics/Clients_report.cs')
-rw-r--r--OpenSim/Region/UserStatistics/Clients_report.cs302
1 files changed, 0 insertions, 302 deletions
diff --git a/OpenSim/Region/UserStatistics/Clients_report.cs b/OpenSim/Region/UserStatistics/Clients_report.cs
deleted file mode 100644
index b2bb33b..0000000
--- a/OpenSim/Region/UserStatistics/Clients_report.cs
+++ /dev/null
@@ -1,302 +0,0 @@
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.Region.Framework.Scenes;
35
36namespace OpenSim.Region.UserStatistics
37{
38 public class Clients_report : IStatsController
39 {
40 #region IStatsController Members
41
42 public string ReportName
43 {
44 get { return "Client"; }
45 }
46
47 public Hashtable ProcessModel(Hashtable pParams)
48 {
49 SqliteConnection dbConn = (SqliteConnection)pParams["DatabaseConnection"];
50
51
52 List<ClientVersionData> clidata = new List<ClientVersionData>();
53 List<ClientVersionData> cliRegData = new List<ClientVersionData>();
54 Hashtable regionTotals = new Hashtable();
55
56 Hashtable modeldata = new Hashtable();
57 modeldata.Add("Scenes", pParams["Scenes"]);
58 modeldata.Add("Reports", pParams["Reports"]);
59 int totalclients = 0;
60 int totalregions = 0;
61
62 lock (dbConn)
63 {
64 string sql = "select count(distinct region_id) as regcnt from stats_session_data";
65
66 SqliteCommand cmd = new SqliteCommand(sql, dbConn);
67 SqliteDataReader sdr = cmd.ExecuteReader();
68 if (sdr.HasRows)
69 {
70 sdr.Read();
71 totalregions = Convert.ToInt32(sdr["regcnt"]);
72 }
73
74 sdr.Close();
75 sdr.Dispose();
76
77 sql =
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;";
79
80 cmd = new SqliteCommand(sql, dbConn);
81 sdr = cmd.ExecuteReader();
82 if (sdr.HasRows)
83 {
84 while (sdr.Read())
85 {
86 ClientVersionData udata = new ClientVersionData();
87 udata.version = sdr["client_version"].ToString();
88 udata.count = Convert.ToInt32(sdr["cnt"]);
89 udata.fps = Convert.ToSingle(sdr["simfps"]);
90 clidata.Add(udata);
91 totalclients += udata.count;
92
93 }
94 }
95 sdr.Close();
96 sdr.Dispose();
97
98 if (totalregions > 1)
99 {
100 sql =
101 "select region_id, client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by region_id, client_version order by region_id, count(*) desc;";
102 cmd = new SqliteCommand(sql, dbConn);
103
104 sdr = cmd.ExecuteReader();
105
106 if (sdr.HasRows)
107 {
108 while (sdr.Read())
109 {
110 ClientVersionData udata = new ClientVersionData();
111 udata.version = sdr["client_version"].ToString();
112 udata.count = Convert.ToInt32(sdr["cnt"]);
113 udata.fps = Convert.ToSingle(sdr["simfps"]);
114 udata.region_id = UUID.Parse(sdr["region_id"].ToString());
115 cliRegData.Add(udata);
116 }
117 }
118 sdr.Close();
119 sdr.Dispose();
120
121
122 }
123
124 }
125
126 foreach (ClientVersionData cvd in cliRegData)
127 {
128
129 if (regionTotals.ContainsKey(cvd.region_id))
130 {
131 int regiontotal = (int)regionTotals[cvd.region_id];
132 regiontotal += cvd.count;
133 regionTotals[cvd.region_id] = regiontotal;
134 }
135 else
136 {
137 regionTotals.Add(cvd.region_id, cvd.count);
138 }
139
140
141
142 }
143
144 modeldata["ClientData"] = clidata;
145 modeldata["ClientRegionData"] = cliRegData;
146 modeldata["RegionTotals"] = regionTotals;
147 modeldata["Total"] = totalclients;
148
149 return modeldata;
150 }
151
152 public string RenderView(Hashtable pModelResult)
153 {
154 List<ClientVersionData> clidata = (List<ClientVersionData>) pModelResult["ClientData"];
155 int totalclients = (int)pModelResult["Total"];
156 Hashtable regionTotals = (Hashtable) pModelResult["RegionTotals"];
157 List<ClientVersionData> cliRegData = (List<ClientVersionData>) pModelResult["ClientRegionData"];
158 List<Scene> m_scenes = (List<Scene>)pModelResult["Scenes"];
159 Dictionary<string, IStatsController> reports = (Dictionary<string, IStatsController>)pModelResult["Reports"];
160
161 const string STYLESHEET =
162 @"
163<STYLE>
164body
165{
166 font-size:15px; font-family:Helvetica, Verdana; color:Black;
167}
168TABLE.defaultr { }
169TR.defaultr { padding: 5px; }
170TD.header { font-weight:bold; padding:5px; }
171TD.content {}
172TD.contentright { text-align: right; }
173TD.contentcenter { text-align: center; }
174TD.align_top { vertical-align: top; }
175</STYLE>
176";
177
178 StringBuilder output = new StringBuilder();
179 HTMLUtil.HtmlHeaders_O(ref output);
180 output.Append(STYLESHEET);
181 HTMLUtil.HtmlHeaders_C(ref output);
182
183 HTMLUtil.AddReportLinks(ref output, reports, "");
184
185 HTMLUtil.TABLE_O(ref output, "defaultr");
186 HTMLUtil.TR_O(ref output, "");
187 HTMLUtil.TD_O(ref output, "header");
188 output.Append("ClientVersion");
189 HTMLUtil.TD_C(ref output);
190 HTMLUtil.TD_O(ref output, "header");
191 output.Append("Count/%");
192 HTMLUtil.TD_C(ref output);
193 HTMLUtil.TD_O(ref output, "header");
194 output.Append("SimFPS");
195 HTMLUtil.TD_C(ref output);
196 HTMLUtil.TR_C(ref output);
197
198 foreach (ClientVersionData cvd in clidata)
199 {
200 HTMLUtil.TR_O(ref output, "");
201 HTMLUtil.TD_O(ref output, "content");
202 string linkhref = "sessions.report?VersionString=" + cvd.version;
203 HTMLUtil.A(ref output, cvd.version, linkhref, "");
204 HTMLUtil.TD_C(ref output);
205 HTMLUtil.TD_O(ref output, "content");
206 output.Append(cvd.count);
207 output.Append("/");
208 if (totalclients > 0)
209 output.Append((((float)cvd.count / (float)totalclients)*100).ToString());
210 else
211 output.Append(0);
212
213 output.Append("%");
214 HTMLUtil.TD_C(ref output);
215 HTMLUtil.TD_O(ref output, "content");
216 output.Append(cvd.fps);
217 HTMLUtil.TD_C(ref output);
218 HTMLUtil.TR_C(ref output);
219 }
220 HTMLUtil.TABLE_C(ref output);
221
222 if (cliRegData.Count > 0)
223 {
224 HTMLUtil.TABLE_O(ref output, "defaultr");
225 HTMLUtil.TR_O(ref output, "");
226 HTMLUtil.TD_O(ref output, "header");
227 output.Append("Region");
228 HTMLUtil.TD_C(ref output);
229 HTMLUtil.TD_O(ref output, "header");
230 output.Append("ClientVersion");
231 HTMLUtil.TD_C(ref output);
232 HTMLUtil.TD_O(ref output, "header");
233 output.Append("Count/%");
234 HTMLUtil.TD_C(ref output);
235 HTMLUtil.TD_O(ref output, "header");
236 output.Append("SimFPS");
237 HTMLUtil.TD_C(ref output);
238 HTMLUtil.TR_C(ref output);
239
240 foreach (ClientVersionData cvd in cliRegData)
241 {
242 HTMLUtil.TR_O(ref output, "");
243 HTMLUtil.TD_O(ref output, "content");
244 output.Append(regionNamefromUUID(m_scenes, cvd.region_id));
245 HTMLUtil.TD_C(ref output);
246 HTMLUtil.TD_O(ref output, "content");
247 output.Append(cvd.version);
248 HTMLUtil.TD_C(ref output);
249 HTMLUtil.TD_O(ref output, "content");
250 output.Append(cvd.count);
251 output.Append("/");
252 if ((int)regionTotals[cvd.region_id] > 0)
253 output.Append((((float)cvd.count / (float)((int)regionTotals[cvd.region_id])) * 100).ToString());
254 else
255 output.Append(0);
256
257 output.Append("%");
258 HTMLUtil.TD_C(ref output);
259 HTMLUtil.TD_O(ref output, "content");
260 output.Append(cvd.fps);
261 HTMLUtil.TD_C(ref output);
262 HTMLUtil.TR_C(ref output);
263 }
264 HTMLUtil.TABLE_C(ref output);
265
266 }
267
268 output.Append("</BODY>");
269 output.Append("</HTML>");
270 return output.ToString();
271 }
272 public string regionNamefromUUID(List<Scene> scenes, UUID region_id)
273 {
274 string returnstring = string.Empty;
275 foreach (Scene sn in scenes)
276 {
277 if (region_id == sn.RegionInfo.originRegionID)
278 {
279 returnstring = sn.RegionInfo.RegionName;
280 break;
281 }
282 }
283
284 if (returnstring.Length == 0)
285 {
286 returnstring = region_id.ToString();
287 }
288
289 return returnstring;
290 }
291
292 #endregion
293 }
294
295 public struct ClientVersionData
296 {
297 public UUID region_id;
298 public string version;
299 public int count;
300 public float fps;
301 }
302}