29 using System.Collections;
30 using System.Collections.Generic;
32 using Mono.Data.SqliteClient;
34 using OpenMetaverse.StructuredData;
35 using OpenSim.Region.Framework.Scenes;
37 namespace OpenSim.
Region.UserStatistics
41 #region IStatsController Members
43 public string ReportName
45 get {
return "Client"; }
62 OSDMap summaryInfo =
new OpenMetaverse.StructuredData.OSDMap();
63 summaryInfo.Add(
"totalUsers",
new OSDString(values.
total_num_users.ToString()));
65 summaryInfo.Add(
"averageClientFPS",
new OSDString(values.
avg_client_fps.ToString()));
66 summaryInfo.Add(
"averageClientMem",
new OSDString(values.
avg_client_mem_use.ToString()));
67 summaryInfo.Add(
"averageSimFPS",
new OSDString(values.
avg_sim_fps.ToString()));
68 summaryInfo.Add(
"averagePingTime",
new OSDString(values.
avg_ping.ToString()));
69 summaryInfo.Add(
"totalKBOut",
new OSDString(values.
total_kb_out.ToString()));
70 summaryInfo.Add(
"totalKBIn",
new OSDString(values.
total_kb_in.ToString()));
71 return summaryInfo.ToString();
76 SqliteConnection dbConn = (SqliteConnection)pParams[
"DatabaseConnection"];
79 List<ClientVersionData> clidata =
new List<ClientVersionData>();
80 List<ClientVersionData> cliRegData =
new List<ClientVersionData>();
81 Hashtable regionTotals =
new Hashtable();
83 Hashtable modeldata =
new Hashtable();
84 modeldata.Add(
"Scenes", pParams[
"Scenes"]);
85 modeldata.Add(
"Reports", pParams[
"Reports"]);
91 string sql =
"select count(distinct region_id) as regcnt from stats_session_data";
93 SqliteCommand cmd =
new SqliteCommand(sql, dbConn);
94 SqliteDataReader sdr = cmd.ExecuteReader();
98 totalregions = Convert.ToInt32(sdr[
"regcnt"]);
105 "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;";
107 cmd =
new SqliteCommand(sql, dbConn);
108 sdr = cmd.ExecuteReader();
114 udata.version = sdr[
"client_version"].ToString();
115 udata.count = Convert.ToInt32(sdr[
"cnt"]);
116 udata.fps = Convert.ToSingle(sdr[
"simfps"]);
118 totalclients += udata.count;
125 if (totalregions > 1)
128 "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;";
129 cmd =
new SqliteCommand(sql, dbConn);
131 sdr = cmd.ExecuteReader();
138 udata.version = sdr[
"client_version"].ToString();
139 udata.count = Convert.ToInt32(sdr[
"cnt"]);
140 udata.fps = Convert.ToSingle(sdr[
"simfps"]);
141 udata.region_id = UUID.Parse(sdr[
"region_id"].ToString());
142 cliRegData.Add(udata);
156 if (regionTotals.ContainsKey(cvd.
region_id))
158 int regiontotal = (int)regionTotals[cvd.
region_id];
159 regiontotal += cvd.
count;
160 regionTotals[cvd.
region_id] = regiontotal;
164 regionTotals.Add(cvd.region_id, cvd.count);
171 modeldata[
"ClientData"] = clidata;
172 modeldata[
"ClientRegionData"] = cliRegData;
173 modeldata[
"RegionTotals"] = regionTotals;
174 modeldata[
"Total"] = totalclients;
181 List<ClientVersionData> clidata = (List<ClientVersionData>) pModelResult[
"ClientData"];
182 int totalclients = (int)pModelResult[
"Total"];
183 Hashtable regionTotals = (Hashtable) pModelResult[
"RegionTotals"];
184 List<ClientVersionData> cliRegData = (List<ClientVersionData>) pModelResult[
"ClientRegionData"];
185 List<Scene> m_scenes = (List<Scene>)pModelResult[
"Scenes"];
186 Dictionary<string, IStatsController> reports = (Dictionary<string, IStatsController>)pModelResult[
"Reports"];
188 const string STYLESHEET =
193 font-size:15px; font-family:Helvetica, Verdana; color:Black;
196 TR.defaultr { padding: 5px; }
197 TD.header { font-weight:bold; padding:5px; }
199 TD.contentright { text-align: right; }
200 TD.contentcenter { text-align: center; }
201 TD.align_top { vertical-align: top; }
205 StringBuilder output =
new StringBuilder();
206 HTMLUtil.HtmlHeaders_O(ref output);
207 output.Append(STYLESHEET);
208 HTMLUtil.HtmlHeaders_C(ref output);
210 HTMLUtil.AddReportLinks(ref output, reports,
"");
212 HTMLUtil.TABLE_O(ref output,
"defaultr");
213 HTMLUtil.TR_O(ref output,
"");
214 HTMLUtil.TD_O(ref output,
"header");
215 output.Append(
"ClientVersion");
216 HTMLUtil.TD_C(ref output);
217 HTMLUtil.TD_O(ref output,
"header");
218 output.Append(
"Count/%");
219 HTMLUtil.TD_C(ref output);
220 HTMLUtil.TD_O(ref output,
"header");
221 output.Append(
"SimFPS");
222 HTMLUtil.TD_C(ref output);
223 HTMLUtil.TR_C(ref output);
227 HTMLUtil.TR_O(ref output,
"");
228 HTMLUtil.TD_O(ref output,
"content");
229 string linkhref =
"sessions.report?VersionString=" + cvd.version;
230 HTMLUtil.A(ref output, cvd.version, linkhref,
"");
231 HTMLUtil.TD_C(ref output);
232 HTMLUtil.TD_O(ref output,
"content");
233 output.Append(cvd.count);
235 if (totalclients > 0)
236 output.Append((((float)cvd.
count / (
float)totalclients)*100).ToString());
241 HTMLUtil.TD_C(ref output);
242 HTMLUtil.TD_O(ref output,
"content");
243 output.Append(cvd.fps);
244 HTMLUtil.TD_C(ref output);
245 HTMLUtil.TR_C(ref output);
247 HTMLUtil.TABLE_C(ref output);
249 if (cliRegData.Count > 0)
251 HTMLUtil.TABLE_O(ref output,
"defaultr");
252 HTMLUtil.TR_O(ref output,
"");
253 HTMLUtil.TD_O(ref output,
"header");
254 output.Append(
"Region");
255 HTMLUtil.TD_C(ref output);
256 HTMLUtil.TD_O(ref output,
"header");
257 output.Append(
"ClientVersion");
258 HTMLUtil.TD_C(ref output);
259 HTMLUtil.TD_O(ref output,
"header");
260 output.Append(
"Count/%");
261 HTMLUtil.TD_C(ref output);
262 HTMLUtil.TD_O(ref output,
"header");
263 output.Append(
"SimFPS");
264 HTMLUtil.TD_C(ref output);
265 HTMLUtil.TR_C(ref output);
269 HTMLUtil.TR_O(ref output,
"");
270 HTMLUtil.TD_O(ref output,
"content");
271 output.Append(regionNamefromUUID(m_scenes, cvd.
region_id));
272 HTMLUtil.TD_C(ref output);
273 HTMLUtil.TD_O(ref output,
"content");
274 output.Append(cvd.version);
275 HTMLUtil.TD_C(ref output);
276 HTMLUtil.TD_O(ref output,
"content");
277 output.Append(cvd.count);
279 if ((
int)regionTotals[cvd.region_id] > 0)
280 output.Append((((
float)cvd.
count / (
float)((
int)regionTotals[cvd.
region_id])) * 100).ToString());
285 HTMLUtil.TD_C(ref output);
286 HTMLUtil.TD_O(ref output,
"content");
287 output.Append(cvd.fps);
288 HTMLUtil.TD_C(ref output);
289 HTMLUtil.TR_C(ref output);
291 HTMLUtil.TABLE_C(ref output);
295 output.Append(
"</BODY>");
296 output.Append(
"</HTML>");
297 return output.ToString();
301 string returnstring = string.Empty;
302 foreach (
Scene sn
in scenes)
304 if (region_id == sn.
RegionInfo.originRegionID)
306 returnstring = sn.RegionInfo.RegionName;
311 if (returnstring.Length == 0)
313 returnstring = region_id.ToString();
string RenderJson(Hashtable pModelResult)
Return summar information in the form:
OpenMetaverse.StructuredData.OSDMap OSDMap
string regionNamefromUUID(List< Scene > scenes, UUID region_id)
Hashtable ProcessModel(Hashtable pParams)
string RenderView(Hashtable pModelResult)
virtual RegionInfo RegionInfo