aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/UserStatistics
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/UserStatistics')
-rw-r--r--OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs228
-rw-r--r--OpenSim/Region/UserStatistics/Clients_report.cs302
-rw-r--r--OpenSim/Region/UserStatistics/Default_Report.cs250
-rw-r--r--OpenSim/Region/UserStatistics/HTMLUtil.cs263
-rw-r--r--OpenSim/Region/UserStatistics/IStatsReport.cs38
-rw-r--r--OpenSim/Region/UserStatistics/LogLinesAJAX.cs130
-rw-r--r--OpenSim/Region/UserStatistics/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/UserStatistics/Prototype_distributor.cs65
-rw-r--r--OpenSim/Region/UserStatistics/Sessions_Report.cs283
-rw-r--r--OpenSim/Region/UserStatistics/SimStatsAJAX.cs223
-rw-r--r--OpenSim/Region/UserStatistics/Updater_distributor.cs66
-rw-r--r--OpenSim/Region/UserStatistics/WebStatsModule.cs1183
12 files changed, 0 insertions, 3064 deletions
diff --git a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
deleted file mode 100644
index 3243a9a..0000000
--- a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
+++ /dev/null
@@ -1,228 +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.Reflection;
32using System.Text;
33using Mono.Data.SqliteClient;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Framework.Monitoring;
38
39namespace OpenSim.Region.UserStatistics
40{
41 public class ActiveConnectionsAJAX : IStatsController
42 {
43 private Vector3 DefaultNeighborPosition = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 70);
44
45 #region IStatsController Members
46
47 public string ReportName
48 {
49 get { return ""; }
50 }
51
52 public Hashtable ProcessModel(Hashtable pParams)
53 {
54
55 List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
56
57 Hashtable nh = new Hashtable();
58 nh.Add("hdata", m_scene);
59
60 return nh;
61 }
62
63 public string RenderView(Hashtable pModelResult)
64 {
65 List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
66
67 StringBuilder output = new StringBuilder();
68 HTMLUtil.OL_O(ref output, "");
69 foreach (Scene scene in all_scenes)
70 {
71 HTMLUtil.LI_O(ref output, String.Empty);
72 output.Append(scene.RegionInfo.RegionName);
73 HTMLUtil.OL_O(ref output, String.Empty);
74 scene.ForEachScenePresence(delegate(ScenePresence av)
75 {
76 Dictionary<string, string> queues = new Dictionary<string, string>();
77 if (av.ControllingClient is IStatsCollector)
78 {
79 IStatsCollector isClient = (IStatsCollector)av.ControllingClient;
80 queues = decodeQueueReport(isClient.Report());
81 }
82 HTMLUtil.LI_O(ref output, String.Empty);
83 output.Append(av.Name);
84 output.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
85 output.Append((av.IsChildAgent ? "Child" : "Root"));
86 if (av.AbsolutePosition == DefaultNeighborPosition)
87 {
88 output.Append("<br />Position: ?");
89 }
90 else
91 {
92 output.Append(string.Format("<br /><NOBR>Position: <{0},{1},{2}></NOBR>", (int)av.AbsolutePosition.X,
93 (int)av.AbsolutePosition.Y,
94 (int)av.AbsolutePosition.Z));
95 }
96 Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
97
98 HTMLUtil.UL_O(ref output, String.Empty);
99
100 foreach (string throttlename in throttles.Keys)
101 {
102 HTMLUtil.LI_O(ref output, String.Empty);
103 output.Append(throttlename);
104 output.Append(":");
105 output.Append(throttles[throttlename].ToString());
106 if (queues.ContainsKey(throttlename))
107 {
108 output.Append("/");
109 output.Append(queues[throttlename]);
110 }
111 HTMLUtil.LI_C(ref output);
112 }
113 if (queues.ContainsKey("Incoming") && queues.ContainsKey("Outgoing"))
114 {
115 HTMLUtil.LI_O(ref output, "red");
116 output.Append("SEND:");
117 output.Append(queues["Outgoing"]);
118 output.Append("/");
119 output.Append(queues["Incoming"]);
120 HTMLUtil.LI_C(ref output);
121 }
122
123 HTMLUtil.UL_C(ref output);
124 HTMLUtil.LI_C(ref output);
125 });
126 HTMLUtil.OL_C(ref output);
127 }
128 HTMLUtil.OL_C(ref output);
129 return output.ToString();
130 }
131
132 public Dictionary<string, int> DecodeClientThrottles(byte[] throttle)
133 {
134 Dictionary<string, int> returndict = new Dictionary<string, int>();
135 // From mantis http://opensimulator.org/mantis/view.php?id=1374
136 // it appears that sometimes we are receiving empty throttle byte arrays.
137 // TODO: Investigate this behaviour
138 if (throttle.Length == 0)
139 {
140 return new Dictionary<string, int>();
141 }
142
143 int tResend = -1;
144 int tLand = -1;
145 int tWind = -1;
146 int tCloud = -1;
147 int tTask = -1;
148 int tTexture = -1;
149 int tAsset = -1;
150 int tall = -1;
151 const int singlefloat = 4;
152
153 //Agent Throttle Block contains 7 single floatingpoint values.
154 int j = 0;
155
156 // Some Systems may be big endian...
157 // it might be smart to do this check more often...
158 if (!BitConverter.IsLittleEndian)
159 for (int i = 0; i < 7; i++)
160 Array.Reverse(throttle, j + i * singlefloat, singlefloat);
161
162 // values gotten from OpenMetaverse.org/wiki/Throttle. Thanks MW_
163 // bytes
164 // Convert to integer, since.. the full fp space isn't used.
165 tResend = (int)BitConverter.ToSingle(throttle, j);
166 returndict.Add("Resend", tResend);
167 j += singlefloat;
168 tLand = (int)BitConverter.ToSingle(throttle, j);
169 returndict.Add("Land", tLand);
170 j += singlefloat;
171 tWind = (int)BitConverter.ToSingle(throttle, j);
172 returndict.Add("Wind", tWind);
173 j += singlefloat;
174 tCloud = (int)BitConverter.ToSingle(throttle, j);
175 returndict.Add("Cloud", tCloud);
176 j += singlefloat;
177 tTask = (int)BitConverter.ToSingle(throttle, j);
178 returndict.Add("Task", tTask);
179 j += singlefloat;
180 tTexture = (int)BitConverter.ToSingle(throttle, j);
181 returndict.Add("Texture", tTexture);
182 j += singlefloat;
183 tAsset = (int)BitConverter.ToSingle(throttle, j);
184 returndict.Add("Asset", tAsset);
185
186 tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset;
187 returndict.Add("All", tall);
188
189 return returndict;
190 }
191 public Dictionary<string,string> decodeQueueReport(string rep)
192 {
193 Dictionary<string, string> returndic = new Dictionary<string, string>();
194 if (rep.Length == 79)
195 {
196 int pos = 1;
197 returndic.Add("All", rep.Substring((6 * pos), 8)); pos++;
198 returndic.Add("Incoming", rep.Substring((7 * pos), 8)); pos++;
199 returndic.Add("Outgoing", rep.Substring((7 * pos) , 8)); pos++;
200 returndic.Add("Resend", rep.Substring((7 * pos) , 8)); pos++;
201 returndic.Add("Land", rep.Substring((7 * pos) , 8)); pos++;
202 returndic.Add("Wind", rep.Substring((7 * pos) , 8)); pos++;
203 returndic.Add("Cloud", rep.Substring((7 * pos) , 8)); pos++;
204 returndic.Add("Task", rep.Substring((7 * pos) , 8)); pos++;
205 returndic.Add("Texture", rep.Substring((7 * pos), 8)); pos++;
206 returndic.Add("Asset", rep.Substring((7 * pos), 8));
207 /*
208 * return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
209 SendQueue.Count(),
210 IncomingPacketQueue.Count,
211 OutgoingPacketQueue.Count,
212 ResendOutgoingPacketQueue.Count,
213 LandOutgoingPacketQueue.Count,
214 WindOutgoingPacketQueue.Count,
215 CloudOutgoingPacketQueue.Count,
216 TaskOutgoingPacketQueue.Count,
217 TextureOutgoingPacketQueue.Count,
218 AssetOutgoingPacketQueue.Count);
219 */
220 }
221
222
223
224 return returndic;
225 }
226 #endregion
227 }
228}
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}
diff --git a/OpenSim/Region/UserStatistics/Default_Report.cs b/OpenSim/Region/UserStatistics/Default_Report.cs
deleted file mode 100644
index cdc615c..0000000
--- a/OpenSim/Region/UserStatistics/Default_Report.cs
+++ /dev/null
@@ -1,250 +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.Reflection;
32using System.Text;
33using Mono.Data.SqliteClient;
34using OpenMetaverse;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Framework.Monitoring;
37
38
39namespace OpenSim.Region.UserStatistics
40{
41 public class Default_Report : IStatsController
42 {
43
44 public string ReportName
45 {
46 get { return "Home"; }
47 }
48
49 #region IStatsController Members
50
51 public Hashtable ProcessModel(Hashtable pParams)
52 {
53 SqliteConnection conn = (SqliteConnection)pParams["DatabaseConnection"];
54 List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
55
56 stats_default_page_values mData = rep_DefaultReport_data(conn, m_scene);
57 mData.sim_stat_data = (Dictionary<UUID,USimStatsData>)pParams["SimStats"];
58 mData.stats_reports = (Dictionary<string, IStatsController>) pParams["Reports"];
59
60 Hashtable nh = new Hashtable();
61 nh.Add("hdata", mData);
62 nh.Add("Reports", pParams["Reports"]);
63
64 return nh;
65 }
66
67 public string RenderView(Hashtable pModelResult)
68 {
69 stats_default_page_values mData = (stats_default_page_values) pModelResult["hdata"];
70 return rep_Default_report_view(mData);
71 }
72
73 #endregion
74
75 public string rep_Default_report_view(stats_default_page_values values)
76 {
77
78
79 StringBuilder output = new StringBuilder();
80
81
82
83 const string TableClass = "defaultr";
84 const string TRClass = "defaultr";
85 const string TDHeaderClass = "header";
86 const string TDDataClass = "content";
87 //const string TDDataClassRight = "contentright";
88 const string TDDataClassCenter = "contentcenter";
89
90 const string STYLESHEET =
91 @"
92<STYLE>
93body
94{
95 font-size:15px; font-family:Helvetica, Verdana; color:Black;
96}
97TABLE.defaultr { }
98TR.defaultr { padding: 5px; }
99TD.header { font-weight:bold; padding:5px; }
100TD.content {}
101TD.contentright { text-align: right; }
102TD.contentcenter { text-align: center; }
103TD.align_top { vertical-align: top; }
104</STYLE>
105";
106 HTMLUtil.HtmlHeaders_O(ref output);
107
108 HTMLUtil.InsertProtoTypeAJAX(ref output);
109 string[] ajaxUpdaterDivs = new string[3];
110 int[] ajaxUpdaterSeconds = new int[3];
111 string[] ajaxUpdaterReportFragments = new string[3];
112
113 ajaxUpdaterDivs[0] = "activeconnections";
114 ajaxUpdaterSeconds[0] = 10;
115 ajaxUpdaterReportFragments[0] = "activeconnectionsajax.html";
116
117 ajaxUpdaterDivs[1] = "activesimstats";
118 ajaxUpdaterSeconds[1] = 20;
119 ajaxUpdaterReportFragments[1] = "simstatsajax.html";
120
121 ajaxUpdaterDivs[2] = "activelog";
122 ajaxUpdaterSeconds[2] = 5;
123 ajaxUpdaterReportFragments[2] = "activelogajax.html";
124
125 HTMLUtil.InsertPeriodicUpdaters(ref output, ajaxUpdaterDivs, ajaxUpdaterSeconds, ajaxUpdaterReportFragments);
126
127 output.Append(STYLESHEET);
128 HTMLUtil.HtmlHeaders_C(ref output);
129 HTMLUtil.AddReportLinks(ref output, values.stats_reports, "");
130 HTMLUtil.TABLE_O(ref output, TableClass);
131 HTMLUtil.TR_O(ref output, TRClass);
132 HTMLUtil.TD_O(ref output, TDHeaderClass);
133 output.Append("# Users Total");
134 HTMLUtil.TD_C(ref output);
135 HTMLUtil.TD_O(ref output, TDHeaderClass);
136 output.Append("# Sessions Total");
137 HTMLUtil.TD_C(ref output);
138 HTMLUtil.TD_O(ref output, TDHeaderClass);
139 output.Append("Avg Client FPS");
140 HTMLUtil.TD_C(ref output);
141 HTMLUtil.TD_O(ref output, TDHeaderClass);
142 output.Append("Avg Client Mem Use");
143 HTMLUtil.TD_C(ref output);
144 HTMLUtil.TD_O(ref output, TDHeaderClass);
145 output.Append("Avg Sim FPS");
146 HTMLUtil.TD_C(ref output);
147 HTMLUtil.TD_O(ref output, TDHeaderClass);
148 output.Append("Avg Ping");
149 HTMLUtil.TD_C(ref output);
150 HTMLUtil.TD_O(ref output, TDHeaderClass);
151 output.Append("KB Out Total");
152 HTMLUtil.TD_C(ref output);
153 HTMLUtil.TD_O(ref output, TDHeaderClass);
154 output.Append("KB In Total");
155 HTMLUtil.TD_C(ref output);
156 HTMLUtil.TR_C(ref output);
157 HTMLUtil.TR_O(ref output, TRClass);
158 HTMLUtil.TD_O(ref output, TDDataClass);
159 output.Append(values.total_num_users);
160 HTMLUtil.TD_C(ref output);
161 HTMLUtil.TD_O(ref output, TDDataClass);
162 output.Append(values.total_num_sessions);
163 HTMLUtil.TD_C(ref output);
164 HTMLUtil.TD_O(ref output, TDDataClassCenter);
165 output.Append(values.avg_client_fps);
166 HTMLUtil.TD_C(ref output);
167 HTMLUtil.TD_O(ref output, TDDataClassCenter);
168 output.Append(values.avg_client_mem_use);
169 HTMLUtil.TD_C(ref output);
170 HTMLUtil.TD_O(ref output, TDDataClassCenter);
171 output.Append(values.avg_sim_fps);
172 HTMLUtil.TD_C(ref output);
173 HTMLUtil.TD_O(ref output, TDDataClassCenter);
174 output.Append(values.avg_ping);
175 HTMLUtil.TD_C(ref output);
176 HTMLUtil.TD_O(ref output, TDDataClassCenter);
177 output.Append(values.total_kb_out);
178 HTMLUtil.TD_C(ref output);
179 HTMLUtil.TD_O(ref output, TDDataClassCenter);
180 output.Append(values.total_kb_in);
181 HTMLUtil.TD_C(ref output);
182 HTMLUtil.TR_C(ref output);
183 HTMLUtil.TABLE_C(ref output);
184
185 HTMLUtil.HR(ref output, "");
186 HTMLUtil.TABLE_O(ref output, "");
187 HTMLUtil.TR_O(ref output, "");
188 HTMLUtil.TD_O(ref output, "align_top");
189 output.Append("<DIV id=\"activeconnections\">Active Connections loading...</DIV>");
190 HTMLUtil.TD_C(ref output);
191 HTMLUtil.TD_O(ref output, "align_top");
192 output.Append("<DIV id=\"activesimstats\">SimStats loading...</DIV>");
193 output.Append("<DIV id=\"activelog\">ActiveLog loading...</DIV>");
194 HTMLUtil.TD_C(ref output);
195 HTMLUtil.TR_C(ref output);
196 HTMLUtil.TABLE_C(ref output);
197 output.Append("</BODY></HTML>");
198 // TODO: FIXME: template
199 return output.ToString();
200 }
201
202
203
204 public stats_default_page_values rep_DefaultReport_data(SqliteConnection db, List<Scene> m_scene)
205 {
206 stats_default_page_values returnstruct = new stats_default_page_values();
207 returnstruct.all_scenes = m_scene.ToArray();
208 lock (db)
209 {
210 string SQL = @"SELECT COUNT(DISTINCT agent_id) as agents, COUNT(*) as sessions, AVG(avg_fps) as client_fps,
211 AVG(avg_sim_fps) as savg_sim_fps, AVG(avg_ping) as sav_ping, SUM(n_out_kb) as num_in_kb,
212 SUM(n_out_pk) as num_in_packets, SUM(n_in_kb) as num_out_kb, SUM(n_in_pk) as num_out_packets, AVG(mem_use) as sav_mem_use
213 FROM stats_session_data;";
214 SqliteCommand cmd = new SqliteCommand(SQL, db);
215 SqliteDataReader sdr = cmd.ExecuteReader();
216 if (sdr.HasRows)
217 {
218 sdr.Read();
219 returnstruct.total_num_users = Convert.ToInt32(sdr["agents"]);
220 returnstruct.total_num_sessions = Convert.ToInt32(sdr["sessions"]);
221 returnstruct.avg_client_fps = Convert.ToSingle(sdr["client_fps"]);
222 returnstruct.avg_sim_fps = Convert.ToSingle(sdr["savg_sim_fps"]);
223 returnstruct.avg_ping = Convert.ToSingle(sdr["sav_ping"]);
224 returnstruct.total_kb_out = Convert.ToSingle(sdr["num_out_kb"]);
225 returnstruct.total_kb_in = Convert.ToSingle(sdr["num_in_kb"]);
226 returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]);
227
228 }
229 }
230 return returnstruct;
231 }
232
233 }
234
235 public struct stats_default_page_values
236 {
237 public int total_num_users;
238 public int total_num_sessions;
239 public float avg_client_fps;
240 public float avg_client_mem_use;
241 public float avg_sim_fps;
242 public float avg_ping;
243 public float total_kb_out;
244 public float total_kb_in;
245 public float avg_client_resends;
246 public Scene[] all_scenes;
247 public Dictionary<UUID, USimStatsData> sim_stat_data;
248 public Dictionary<string, IStatsController> stats_reports;
249 }
250}
diff --git a/OpenSim/Region/UserStatistics/HTMLUtil.cs b/OpenSim/Region/UserStatistics/HTMLUtil.cs
deleted file mode 100644
index c07619f..0000000
--- a/OpenSim/Region/UserStatistics/HTMLUtil.cs
+++ /dev/null
@@ -1,263 +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.Generic;
30using System.Text;
31
32namespace OpenSim.Region.UserStatistics
33{
34 public static class HTMLUtil
35 {
36
37 public static void TR_O(ref StringBuilder o, string pclass)
38 {
39 o.Append("<tr");
40 if (pclass.Length > 0)
41 {
42 GenericClass(ref o, pclass);
43 }
44 o.Append(">\n\t");
45 }
46
47 public static void TR_C(ref StringBuilder o)
48 {
49 o.Append("</tr>\n");
50 }
51
52 public static void TD_O(ref StringBuilder o, string pclass)
53 {
54 TD_O(ref o, pclass, 0, 0);
55 }
56
57 public static void TD_O(ref StringBuilder o, string pclass, int rowspan, int colspan)
58 {
59 o.Append("<td");
60 if (pclass.Length > 0)
61 {
62 GenericClass(ref o, pclass);
63 }
64 if (rowspan > 1)
65 {
66 o.Append(" rowspan=\"");
67 o.Append(rowspan);
68 o.Append("\"");
69 }
70 if (colspan > 1)
71 {
72 o.Append(" colspan=\"");
73 o.Append(colspan);
74 o.Append("\"");
75 }
76 o.Append(">");
77 }
78
79 public static void TD_C(ref StringBuilder o)
80 {
81 o.Append("</td>");
82 }
83
84 public static void TABLE_O(ref StringBuilder o, string pclass)
85 {
86 o.Append("<table");
87 if (pclass.Length > 0)
88 {
89 GenericClass(ref o, pclass);
90 }
91 o.Append(">\n\t");
92 }
93
94 public static void TABLE_C(ref StringBuilder o)
95 {
96 o.Append("</table>\n");
97 }
98
99 public static void BLOCKQUOTE_O(ref StringBuilder o, string pclass)
100 {
101 o.Append("<blockquote");
102 if (pclass.Length > 0)
103 {
104 GenericClass(ref o, pclass);
105 }
106 o.Append(" />\n");
107 }
108
109 public static void BLOCKQUOTE_C(ref StringBuilder o)
110 {
111 o.Append("</blockquote>\n");
112 }
113
114 public static void BR(ref StringBuilder o)
115 {
116 o.Append("<br />\n");
117 }
118
119 public static void HR(ref StringBuilder o, string pclass)
120 {
121 o.Append("<hr");
122 if (pclass.Length > 0)
123 {
124 GenericClass(ref o, pclass);
125 }
126 o.Append(" />\n");
127 }
128
129 public static void UL_O(ref StringBuilder o, string pclass)
130 {
131 o.Append("<ul");
132 if (pclass.Length > 0)
133 {
134 GenericClass(ref o, pclass);
135 }
136 o.Append(" />\n");
137 }
138
139 public static void UL_C(ref StringBuilder o)
140 {
141 o.Append("</ul>\n");
142 }
143
144 public static void OL_O(ref StringBuilder o, string pclass)
145 {
146 o.Append("<ol");
147 if (pclass.Length > 0)
148 {
149 GenericClass(ref o, pclass);
150 }
151 o.Append(" />\n");
152 }
153
154 public static void OL_C(ref StringBuilder o)
155 {
156 o.Append("</ol>\n");
157 }
158
159 public static void LI_O(ref StringBuilder o, string pclass)
160 {
161 o.Append("<li");
162 if (pclass.Length > 0)
163 {
164 GenericClass(ref o, pclass);
165 }
166 o.Append(" />\n");
167 }
168
169 public static void LI_C(ref StringBuilder o)
170 {
171 o.Append("</li>\n");
172 }
173
174 public static void GenericClass(ref StringBuilder o, string pclass)
175 {
176 o.Append(" class=\"");
177 o.Append(pclass);
178 o.Append("\"");
179 }
180
181 public static void InsertProtoTypeAJAX(ref StringBuilder o)
182 {
183 o.Append("<script type=\"text/javascript\" src=\"prototype.js\"></script>\n");
184 o.Append("<script type=\"text/javascript\" src=\"updater.js\"></script>\n");
185 }
186
187 public static void InsertPeriodicUpdaters(ref StringBuilder o, string[] divID, int[] seconds, string[] reportfrag)
188 {
189 o.Append("<script type=\"text/javascript\">\n");
190 o.Append(
191 @"
192 // <![CDATA[
193 document.observe('dom:loaded', function() {
194 /*
195 first arg : div to update
196 second arg : interval to poll in seconds
197 third arg : file to get data
198 */
199");
200 for (int i = 0; i < divID.Length; i++)
201 {
202
203 o.Append("new updater('");
204 o.Append(divID[i]);
205 o.Append("', ");
206 o.Append(seconds[i]);
207 o.Append(", '");
208 o.Append(reportfrag[i]);
209 o.Append("');\n");
210 }
211
212 o.Append(@"
213 });
214 // ]]>
215 </script>");
216 }
217
218 public static void HtmlHeaders_O(ref StringBuilder o)
219 {
220 o.Append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
221 o.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"nl\">");
222 o.Append("<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />");
223 }
224
225 public static void HtmlHeaders_C(ref StringBuilder o)
226 {
227 o.Append("</HEAD>");
228 o.Append("<BODY>");
229 }
230
231 public static void AddReportLinks(ref StringBuilder o, Dictionary<string, IStatsController> reports, string pClass)
232 {
233 int repcount = 0;
234 foreach (string str in reports.Keys)
235 {
236 if (reports[str].ReportName.Length > 0)
237 {
238 if (repcount > 0)
239 {
240 o.Append("|&nbsp;&nbsp;");
241 }
242 A(ref o, reports[str].ReportName, str, pClass);
243 o.Append("&nbsp;&nbsp;");
244 repcount++;
245 }
246 }
247 }
248
249 public static void A(ref StringBuilder o, string linktext, string linkhref, string pClass)
250 {
251 o.Append("<A");
252 if (pClass.Length > 0)
253 {
254 GenericClass(ref o, pClass);
255 }
256 o.Append(" href=\"");
257 o.Append(linkhref);
258 o.Append("\">");
259 o.Append(linktext);
260 o.Append("</A>");
261 }
262 }
263}
diff --git a/OpenSim/Region/UserStatistics/IStatsReport.cs b/OpenSim/Region/UserStatistics/IStatsReport.cs
deleted file mode 100644
index e0ecce4..0000000
--- a/OpenSim/Region/UserStatistics/IStatsReport.cs
+++ /dev/null
@@ -1,38 +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.Collections;
29
30namespace OpenSim.Region.UserStatistics
31{
32 public interface IStatsController
33 {
34 string ReportName { get; }
35 Hashtable ProcessModel(Hashtable pParams);
36 string RenderView(Hashtable pModelResult);
37 }
38}
diff --git a/OpenSim/Region/UserStatistics/LogLinesAJAX.cs b/OpenSim/Region/UserStatistics/LogLinesAJAX.cs
deleted file mode 100644
index 74de46b..0000000
--- a/OpenSim/Region/UserStatistics/LogLinesAJAX.cs
+++ /dev/null
@@ -1,130 +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.Reflection;
32using System.Text;
33using System.Text.RegularExpressions;
34using Mono.Data.SqliteClient;
35using OpenMetaverse;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Framework.Monitoring;
38
39namespace OpenSim.Region.UserStatistics
40{
41 public class LogLinesAJAX : IStatsController
42 {
43 private Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline);
44
45 private Regex webFormat = new Regex(@"[^\s]*\s([^,]*),[^\s]*\s([A-Z]*)[^\s-][^\[]*\[([^\]]*)\]([^\n]*)",
46 RegexOptions.Singleline | RegexOptions.Compiled);
47 private Regex TitleColor = new Regex(@"[^\s]*\s(?:[^,]*),[^\s]*\s(?:[A-Z]*)[^\s-][^\[]*\[([^\]]*)\](?:[^\n]*)",
48 RegexOptions.Singleline | RegexOptions.Compiled);
49
50
51 #region IStatsController Members
52
53 public string ReportName
54 {
55 get { return ""; }
56 }
57
58 public Hashtable ProcessModel(Hashtable pParams)
59 {
60 Hashtable nh = new Hashtable();
61 nh.Add("loglines", pParams["LogLines"]);
62 return nh;
63 }
64
65 public string RenderView(Hashtable pModelResult)
66 {
67 StringBuilder output = new StringBuilder();
68
69 HTMLUtil.HR(ref output, "");
70 output.Append("<H3>ActiveLog</H3>\n");
71
72 string tmp = normalizeEndLines.Replace(pModelResult["loglines"].ToString(), "\n");
73
74 string[] result = Regex.Split(tmp, "\n");
75
76 string formatopen = "";
77 string formatclose = "";
78
79 for (int i = 0; i < result.Length; i++)
80 {
81 if (result[i].Length >= 30)
82 {
83 string logtype = result[i].Substring(24, 6);
84 switch (logtype)
85 {
86 case "WARN ":
87 formatopen = "<font color=\"#7D7C00\">";
88 formatclose = "</font>";
89 break;
90
91 case "ERROR ":
92 formatopen = "<font color=\"#FF0000\">";
93 formatclose = "</font>";
94 break;
95
96 default:
97 formatopen = "";
98 formatclose = "";
99 break;
100
101 }
102 }
103 StringBuilder replaceStr = new StringBuilder();
104 //string titlecolorresults =
105
106 string formatresult = Regex.Replace(TitleColor.Replace(result[i], "$1"), "[^ABCDEFabcdef0-9]", "");
107 if (formatresult.Length > 6)
108 {
109 formatresult = formatresult.Substring(0, 6);
110
111 }
112 for (int j = formatresult.Length; j <= 5; j++)
113 formatresult += "0";
114 replaceStr.Append("$1 - [<font color=\"#");
115 replaceStr.Append(formatresult);
116 replaceStr.Append("\">$3</font>] $4<br />");
117 string repstr = replaceStr.ToString();
118
119 output.Append(formatopen);
120 output.Append(webFormat.Replace(result[i], repstr));
121 output.Append(formatclose);
122 }
123
124
125 return output.ToString();
126 }
127
128 #endregion
129 }
130}
diff --git a/OpenSim/Region/UserStatistics/Properties/AssemblyInfo.cs b/OpenSim/Region/UserStatistics/Properties/AssemblyInfo.cs
deleted file mode 100644
index 100cf99..0000000
--- a/OpenSim/Region/UserStatistics/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Region.UserStatistics")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("http://opensimulator.org")]
12[assembly: AssemblyProduct("OpenSim")]
13[assembly: AssemblyCopyright("OpenSimulator developers")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("42b28288-5fdd-478f-8903-8dccbbb2d5f9")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32[assembly: AssemblyVersion("0.7.5.*")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/UserStatistics/Prototype_distributor.cs b/OpenSim/Region/UserStatistics/Prototype_distributor.cs
deleted file mode 100644
index 53ae557..0000000
--- a/OpenSim/Region/UserStatistics/Prototype_distributor.cs
+++ /dev/null
@@ -1,65 +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.IO;
30using System.Collections;
31using System.Collections.Generic;
32using System.Text;
33using OpenSim.Framework;
34
35namespace OpenSim.Region.UserStatistics
36{
37 public class Prototype_distributor : IStatsController
38 {
39 private string prototypejs=string.Empty;
40
41 public string ReportName
42 {
43 get { return ""; }
44 }
45 public Hashtable ProcessModel(Hashtable pParams)
46 {
47 Hashtable pResult = new Hashtable();
48 if (prototypejs.Length == 0)
49 {
50 StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/prototype.js", FileMode.Open));
51 prototypejs = fs.ReadToEnd();
52 fs.Close();
53 fs.Dispose();
54 }
55 pResult["js"] = prototypejs;
56 return pResult;
57 }
58
59 public string RenderView(Hashtable pModelResult)
60 {
61 return pModelResult["js"].ToString();
62 }
63
64 }
65}
diff --git a/OpenSim/Region/UserStatistics/Sessions_Report.cs b/OpenSim/Region/UserStatistics/Sessions_Report.cs
deleted file mode 100644
index 1a2d460..0000000
--- a/OpenSim/Region/UserStatistics/Sessions_Report.cs
+++ /dev/null
@@ -1,283 +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.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
57 string puserUUID = string.Empty;
58 string clientVersionString = string.Empty;
59 int queryparams = 0;
60
61 if (requestvars != null)
62 {
63 if (requestvars.ContainsKey("UserID"))
64 {
65 UUID testUUID = UUID.Zero;
66 if (UUID.TryParse(requestvars["UserID"].ToString(), out testUUID))
67 {
68 puserUUID = requestvars["UserID"].ToString();
69
70 }
71 }
72
73 if (requestvars.ContainsKey("VersionString"))
74 {
75 clientVersionString = requestvars["VersionString"].ToString();
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, b.start_time 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.start_time = Utils.UnixTimeToDateTime((uint)Convert.ToInt32(sdr["start_time"]));
140 ssd.session_id = UUID.Parse(sdr["session_id"].ToString());
141 ssd.client_version = sdr["client_version"].ToString();
142 activeSessionList.sessions.Add(ssd);
143
144 userUUID = activeSessionList.user_id;
145 }
146 }
147 sdr.Close();
148 sdr.Dispose();
149
150 }
151 modeldata["SessionData"] = lstSessions;
152 return modeldata;
153 }
154
155 public string RenderView(Hashtable pModelResult)
156 {
157 List<SessionList> lstSession = (List<SessionList>) pModelResult["SessionData"];
158 Dictionary<string, IStatsController> reports = (Dictionary<string, IStatsController>)pModelResult["Reports"];
159
160 const string STYLESHEET =
161 @"
162<STYLE>
163body
164{
165 font-size:15px; font-family:Helvetica, Verdana; color:Black;
166}
167TABLE.defaultr { }
168TR.defaultr { padding: 5px; }
169TD.header { font-weight:bold; padding:5px; }
170TD.content {}
171TD.contentright { text-align: right; }
172TD.contentcenter { text-align: center; }
173TD.align_top { vertical-align: top; }
174</STYLE>
175";
176
177 StringBuilder output = new StringBuilder();
178 HTMLUtil.HtmlHeaders_O(ref output);
179 output.Append(STYLESHEET);
180 HTMLUtil.HtmlHeaders_C(ref output);
181
182 HTMLUtil.AddReportLinks(ref output, reports, "");
183
184 HTMLUtil.TABLE_O(ref output, "defaultr");
185 HTMLUtil.TR_O(ref output, "defaultr");
186 HTMLUtil.TD_O(ref output, "header");
187 output.Append("FirstName");
188 HTMLUtil.TD_C(ref output);
189 HTMLUtil.TD_O(ref output, "header");
190 output.Append("LastName");
191 HTMLUtil.TD_C(ref output);
192 HTMLUtil.TD_O(ref output, "header");
193 output.Append("SessionEnd");
194 HTMLUtil.TD_C(ref output);
195 HTMLUtil.TD_O(ref output, "header");
196 output.Append("SessionLength");
197 HTMLUtil.TD_C(ref output);
198 HTMLUtil.TD_O(ref output, "header");
199 output.Append("Client");
200 HTMLUtil.TD_C(ref output);
201 HTMLUtil.TR_C(ref output);
202 if (lstSession.Count == 0)
203 {
204 HTMLUtil.TR_O(ref output, "");
205 HTMLUtil.TD_O(ref output, "align_top", 1, 5);
206 output.Append("No results for that query");
207 HTMLUtil.TD_C(ref output);
208 HTMLUtil.TR_C(ref output);
209 }
210 foreach (SessionList ssnlst in lstSession)
211 {
212 int cnt = 0;
213 foreach (ShortSessionData sesdata in ssnlst.sessions)
214 {
215 HTMLUtil.TR_O(ref output, "");
216 if (cnt++ == 0)
217 {
218 HTMLUtil.TD_O(ref output, "align_top", ssnlst.sessions.Count, 1);
219 output.Append(ssnlst.firstname);
220 HTMLUtil.TD_C(ref output);
221 HTMLUtil.TD_O(ref output, "align_top", ssnlst.sessions.Count, 1);
222 output.Append(ssnlst.lastname);
223 HTMLUtil.TD_C(ref output);
224 }
225 HTMLUtil.TD_O(ref output, "content");
226 output.Append(sesdata.last_update.ToShortDateString());
227 output.Append(" - ");
228 output.Append(sesdata.last_update.ToShortTimeString());
229 HTMLUtil.TD_C(ref output);
230 HTMLUtil.TD_O(ref output, "content");
231 TimeSpan dtlength = sesdata.last_update.Subtract(sesdata.start_time);
232 if (dtlength.Days > 0)
233 {
234 output.Append(dtlength.Days);
235 output.Append(" Days ");
236 }
237 if (dtlength.Hours > 0)
238 {
239 output.Append(dtlength.Hours);
240 output.Append(" Hours ");
241 }
242 if (dtlength.Minutes > 0)
243 {
244 output.Append(dtlength.Minutes);
245 output.Append(" Minutes");
246 }
247 HTMLUtil.TD_C(ref output);
248 HTMLUtil.TD_O(ref output, "content");
249 output.Append(sesdata.client_version);
250 HTMLUtil.TD_C(ref output);
251 HTMLUtil.TR_C(ref output);
252
253 }
254 HTMLUtil.TR_O(ref output, "");
255 HTMLUtil.TD_O(ref output, "align_top", 1, 5);
256 HTMLUtil.HR(ref output, "");
257 HTMLUtil.TD_C(ref output);
258 HTMLUtil.TR_C(ref output);
259 }
260 HTMLUtil.TABLE_C(ref output);
261 output.Append("</BODY>\n</HTML>");
262 return output.ToString();
263 }
264
265 public class SessionList
266 {
267 public string firstname;
268 public string lastname;
269 public UUID user_id;
270 public List<ShortSessionData> sessions;
271 }
272
273 public struct ShortSessionData
274 {
275 public UUID session_id;
276 public string client_version;
277 public DateTime last_update;
278 public DateTime start_time;
279 }
280
281 #endregion
282 }
283}
diff --git a/OpenSim/Region/UserStatistics/SimStatsAJAX.cs b/OpenSim/Region/UserStatistics/SimStatsAJAX.cs
deleted file mode 100644
index 28051fb..0000000
--- a/OpenSim/Region/UserStatistics/SimStatsAJAX.cs
+++ /dev/null
@@ -1,223 +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.Reflection;
32using System.Text;
33using Mono.Data.SqliteClient;
34using OpenMetaverse;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Framework.Monitoring;
37
38namespace OpenSim.Region.UserStatistics
39{
40 public class SimStatsAJAX : IStatsController
41 {
42 #region IStatsController Members
43
44 public string ReportName
45 {
46 get { return ""; }
47 }
48
49 public Hashtable ProcessModel(Hashtable pParams)
50 {
51 List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
52
53 Hashtable nh = new Hashtable();
54 nh.Add("hdata", m_scene);
55 nh.Add("simstats", pParams["SimStats"]);
56 return nh;
57 }
58
59 public string RenderView(Hashtable pModelResult)
60 {
61 StringBuilder output = new StringBuilder();
62 List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
63 Dictionary<UUID, USimStatsData> sdatadic = (Dictionary<UUID,USimStatsData>)pModelResult["simstats"];
64
65 const string TableClass = "defaultr";
66 const string TRClass = "defaultr";
67 const string TDHeaderClass = "header";
68 const string TDDataClass = "content";
69 //const string TDDataClassRight = "contentright";
70 const string TDDataClassCenter = "contentcenter";
71
72 foreach (USimStatsData sdata in sdatadic.Values)
73 {
74
75
76 foreach (Scene sn in all_scenes)
77 {
78 if (sn.RegionInfo.RegionID == sdata.RegionId)
79 {
80 output.Append("<H2>");
81 output.Append(sn.RegionInfo.RegionName);
82 output.Append("</H2>");
83 }
84 }
85 HTMLUtil.TABLE_O(ref output, TableClass);
86 HTMLUtil.TR_O(ref output, TRClass);
87 HTMLUtil.TD_O(ref output, TDHeaderClass);
88 output.Append("Dilatn");
89 HTMLUtil.TD_C(ref output);
90 HTMLUtil.TD_O(ref output, TDHeaderClass);
91 output.Append("SimFPS");
92 HTMLUtil.TD_C(ref output);
93 HTMLUtil.TD_O(ref output, TDHeaderClass);
94 output.Append("PhysFPS");
95 HTMLUtil.TD_C(ref output);
96 HTMLUtil.TD_O(ref output, TDHeaderClass);
97 output.Append("AgntUp");
98 HTMLUtil.TD_C(ref output);
99 HTMLUtil.TD_O(ref output, TDHeaderClass);
100 output.Append("RootAg");
101 HTMLUtil.TD_C(ref output);
102 HTMLUtil.TD_O(ref output, TDHeaderClass);
103 output.Append("ChldAg");
104 HTMLUtil.TD_C(ref output);
105 HTMLUtil.TD_O(ref output, TDHeaderClass);
106 output.Append("Prims");
107 HTMLUtil.TD_C(ref output);
108 HTMLUtil.TD_O(ref output, TDHeaderClass);
109 output.Append("ATvPrm");
110 HTMLUtil.TD_C(ref output);
111 HTMLUtil.TD_O(ref output, TDHeaderClass);
112 output.Append("AtvScr");
113 HTMLUtil.TD_C(ref output);
114 HTMLUtil.TD_O(ref output, TDHeaderClass);
115 output.Append("ScrLPS");
116 HTMLUtil.TD_C(ref output);
117 HTMLUtil.TR_C(ref output);
118 HTMLUtil.TR_O(ref output, TRClass);
119 HTMLUtil.TD_O(ref output, TDDataClass);
120 output.Append(sdata.TimeDilation);
121 HTMLUtil.TD_C(ref output);
122 HTMLUtil.TD_O(ref output, TDDataClass);
123 output.Append(sdata.SimFps);
124 HTMLUtil.TD_C(ref output);
125 HTMLUtil.TD_O(ref output, TDDataClassCenter);
126 output.Append(sdata.PhysicsFps);
127 HTMLUtil.TD_C(ref output);
128 HTMLUtil.TD_O(ref output, TDDataClassCenter);
129 output.Append(sdata.AgentUpdates);
130 HTMLUtil.TD_C(ref output);
131 HTMLUtil.TD_O(ref output, TDDataClassCenter);
132 output.Append(sdata.RootAgents);
133 HTMLUtil.TD_C(ref output);
134 HTMLUtil.TD_O(ref output, TDDataClassCenter);
135 output.Append(sdata.ChildAgents);
136 HTMLUtil.TD_C(ref output);
137 HTMLUtil.TD_O(ref output, TDDataClassCenter);
138 output.Append(sdata.TotalPrims);
139 HTMLUtil.TD_C(ref output);
140 HTMLUtil.TD_O(ref output, TDDataClassCenter);
141 output.Append(sdata.ActivePrims);
142 HTMLUtil.TD_C(ref output);
143 HTMLUtil.TD_O(ref output, TDDataClassCenter);
144 output.Append(sdata.ActiveScripts);
145 HTMLUtil.TD_C(ref output);
146 HTMLUtil.TD_O(ref output, TDDataClassCenter);
147 output.Append(sdata.ScriptLinesPerSecond);
148 HTMLUtil.TD_C(ref output);
149 HTMLUtil.TR_C(ref output);
150 HTMLUtil.TR_O(ref output, TRClass);
151 HTMLUtil.TD_O(ref output, TDHeaderClass);
152 output.Append("FrmMS");
153 HTMLUtil.TD_C(ref output);
154 HTMLUtil.TD_O(ref output, TDHeaderClass);
155 output.Append("AgtMS");
156 HTMLUtil.TD_C(ref output);
157 HTMLUtil.TD_O(ref output, TDHeaderClass);
158 output.Append("PhysMS");
159 HTMLUtil.TD_C(ref output);
160 HTMLUtil.TD_O(ref output, TDHeaderClass);
161 output.Append("OthrMS");
162 HTMLUtil.TD_C(ref output);
163 HTMLUtil.TD_O(ref output, TDHeaderClass);
164 output.Append("ScrLPS");
165 HTMLUtil.TD_C(ref output);
166 HTMLUtil.TD_O(ref output, TDHeaderClass);
167 output.Append("OutPPS");
168 HTMLUtil.TD_C(ref output);
169 HTMLUtil.TD_O(ref output, TDHeaderClass);
170 output.Append("InPPS");
171 HTMLUtil.TD_C(ref output);
172 HTMLUtil.TD_O(ref output, TDHeaderClass);
173 output.Append("NoAckKB");
174 HTMLUtil.TD_C(ref output);
175 HTMLUtil.TD_O(ref output, TDHeaderClass);
176 output.Append("PndDWN");
177 HTMLUtil.TD_C(ref output);
178 HTMLUtil.TD_O(ref output, TDHeaderClass);
179 output.Append("PndUP");
180 HTMLUtil.TD_C(ref output);
181 HTMLUtil.TR_C(ref output);
182 HTMLUtil.TR_O(ref output, TRClass);
183 HTMLUtil.TD_O(ref output, TDDataClass);
184 output.Append(sdata.TotalFrameTime);
185 HTMLUtil.TD_C(ref output);
186 HTMLUtil.TD_O(ref output, TDDataClass);
187 output.Append(sdata.AgentFrameTime);
188 HTMLUtil.TD_C(ref output);
189 HTMLUtil.TD_O(ref output, TDDataClassCenter);
190 output.Append(sdata.PhysicsFrameTime);
191 HTMLUtil.TD_C(ref output);
192 HTMLUtil.TD_O(ref output, TDDataClassCenter);
193 output.Append(sdata.OtherFrameTime);
194 HTMLUtil.TD_C(ref output);
195 HTMLUtil.TD_O(ref output, TDDataClassCenter);
196 output.Append(sdata.ScriptLinesPerSecond);
197 HTMLUtil.TD_C(ref output);
198 HTMLUtil.TD_O(ref output, TDDataClassCenter);
199 output.Append(sdata.OutPacketsPerSecond);
200 HTMLUtil.TD_C(ref output);
201 HTMLUtil.TD_O(ref output, TDDataClassCenter);
202 output.Append(sdata.InPacketsPerSecond);
203 HTMLUtil.TD_C(ref output);
204 HTMLUtil.TD_O(ref output, TDDataClassCenter);
205 output.Append(sdata.UnackedBytes);
206 HTMLUtil.TD_C(ref output);
207 HTMLUtil.TD_O(ref output, TDDataClassCenter);
208 output.Append(sdata.PendingDownloads);
209 HTMLUtil.TD_C(ref output);
210 HTMLUtil.TD_O(ref output, TDDataClassCenter);
211 output.Append(sdata.PendingUploads);
212 HTMLUtil.TD_C(ref output);
213 HTMLUtil.TR_C(ref output);
214 HTMLUtil.TABLE_C(ref output);
215
216 }
217
218 return output.ToString();
219 }
220
221 #endregion
222 }
223}
diff --git a/OpenSim/Region/UserStatistics/Updater_distributor.cs b/OpenSim/Region/UserStatistics/Updater_distributor.cs
deleted file mode 100644
index 9593cc9..0000000
--- a/OpenSim/Region/UserStatistics/Updater_distributor.cs
+++ /dev/null
@@ -1,66 +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.IO;
30using System.Collections;
31using System.Collections.Generic;
32using System.Text;
33using OpenSim.Framework;
34
35namespace OpenSim.Region.UserStatistics
36{
37 public class Updater_distributor : IStatsController
38 {
39 private string updaterjs = string.Empty;
40
41 public string ReportName
42 {
43 get { return ""; }
44 }
45
46 public Hashtable ProcessModel(Hashtable pParams)
47 {
48 Hashtable pResult = new Hashtable();
49 if (updaterjs.Length == 0)
50 {
51 StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/updater.js", FileMode.Open));
52 updaterjs = fs.ReadToEnd();
53 fs.Close();
54 fs.Dispose();
55 }
56 pResult["js"] = updaterjs;
57 return pResult;
58 }
59
60 public string RenderView(Hashtable pModelResult)
61 {
62 return pModelResult["js"].ToString();
63 }
64
65 }
66} \ No newline at end of file
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs
deleted file mode 100644
index 64cb577..0000000
--- a/OpenSim/Region/UserStatistics/WebStatsModule.cs
+++ /dev/null
@@ -1,1183 +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.IO;
32using System.Net; // to be used for REST-->Grid shortly
33using System.Reflection;
34using System.Text;
35using System.Threading;
36using log4net;
37using Nini.Config;
38using OpenMetaverse;
39using OpenMetaverse.StructuredData;
40using OpenSim.Framework;
41using OpenSim.Framework.Servers;
42using OpenSim.Framework.Servers.HttpServer;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes;
45using Mono.Data.SqliteClient;
46using Mono.Addins;
47
48using Caps = OpenSim.Framework.Capabilities.Caps;
49
50using OSD = OpenMetaverse.StructuredData.OSD;
51using OSDMap = OpenMetaverse.StructuredData.OSDMap;
52
53[assembly: Addin("WebStats", "1.0")]
54[assembly: AddinDependency("OpenSim", "0.5")]
55
56namespace OpenSim.Region.UserStatistics
57{
58 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebStatsModule")]
59 public class WebStatsModule : ISharedRegionModule
60 {
61 private static readonly ILog m_log =
62 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
63
64 private static SqliteConnection dbConn;
65
66 /// <summary>
67 /// User statistics sessions keyed by agent ID
68 /// </summary>
69 private Dictionary<UUID, UserSession> m_sessions = new Dictionary<UUID, UserSession>();
70
71 private List<Scene> m_scenes = new List<Scene>();
72 private Dictionary<string, IStatsController> reports = new Dictionary<string, IStatsController>();
73 private Dictionary<UUID, USimStatsData> m_simstatsCounters = new Dictionary<UUID, USimStatsData>();
74 private const int updateStatsMod = 6;
75 private int updateLogMod = 1;
76 private volatile int updateLogCounter = 0;
77 private volatile int concurrencyCounter = 0;
78 private bool enabled = false;
79 private string m_loglines = String.Empty;
80 private volatile int lastHit = 12000;
81
82 #region ISharedRegionModule
83
84 public virtual void Initialise(IConfigSource config)
85 {
86 IConfig cnfg = config.Configs["WebStats"];
87
88 if (cnfg != null)
89 enabled = cnfg.GetBoolean("enabled", false);
90 }
91
92 public virtual void PostInitialise()
93 {
94 if (!enabled)
95 return;
96
97 if (Util.IsWindows())
98 Util.LoadArchSpecificWindowsDll("sqlite3.dll");
99
100 //IConfig startupConfig = config.Configs["Startup"];
101
102 dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3");
103 dbConn.Open();
104 CreateTables(dbConn);
105
106 Prototype_distributor protodep = new Prototype_distributor();
107 Updater_distributor updatedep = new Updater_distributor();
108 ActiveConnectionsAJAX ajConnections = new ActiveConnectionsAJAX();
109 SimStatsAJAX ajSimStats = new SimStatsAJAX();
110 LogLinesAJAX ajLogLines = new LogLinesAJAX();
111 Default_Report defaultReport = new Default_Report();
112 Clients_report clientReport = new Clients_report();
113 Sessions_Report sessionsReport = new Sessions_Report();
114
115 reports.Add("prototype.js", protodep);
116 reports.Add("updater.js", updatedep);
117 reports.Add("activeconnectionsajax.html", ajConnections);
118 reports.Add("simstatsajax.html", ajSimStats);
119 reports.Add("activelogajax.html", ajLogLines);
120 reports.Add("default.report", defaultReport);
121 reports.Add("clients.report", clientReport);
122 reports.Add("sessions.report", sessionsReport);
123
124 ////
125 // Add Your own Reports here (Do Not Modify Lines here Devs!)
126 ////
127
128 ////
129 // End Own reports section
130 ////
131
132 MainServer.Instance.AddHTTPHandler("/SStats/", HandleStatsRequest);
133 MainServer.Instance.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest);
134 }
135
136 public virtual void AddRegion(Scene scene)
137 {
138 if (!enabled)
139 return;
140
141 lock (m_scenes)
142 {
143 m_scenes.Add(scene);
144 updateLogMod = m_scenes.Count * 2;
145
146 m_simstatsCounters.Add(scene.RegionInfo.RegionID, new USimStatsData(scene.RegionInfo.RegionID));
147
148 scene.EventManager.OnRegisterCaps += OnRegisterCaps;
149 scene.EventManager.OnDeregisterCaps += OnDeRegisterCaps;
150 scene.EventManager.OnClientClosed += OnClientClosed;
151 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
152 scene.StatsReporter.OnSendStatsResult += ReceiveClassicSimStatsPacket;
153 }
154 }
155
156 public void RegionLoaded(Scene scene)
157 {
158 }
159
160 public void RemoveRegion(Scene scene)
161 {
162 if (!enabled)
163 return;
164
165 lock (m_scenes)
166 {
167 m_scenes.Remove(scene);
168 updateLogMod = m_scenes.Count * 2;
169 m_simstatsCounters.Remove(scene.RegionInfo.RegionID);
170 }
171 }
172
173 public virtual void Close()
174 {
175 if (!enabled)
176 return;
177
178 dbConn.Close();
179 dbConn.Dispose();
180 m_sessions.Clear();
181 m_scenes.Clear();
182 reports.Clear();
183 m_simstatsCounters.Clear();
184 }
185
186 public virtual string Name
187 {
188 get { return "ViewerStatsModule"; }
189 }
190
191 public Type ReplaceableInterface
192 {
193 get { return null; }
194 }
195
196 #endregion
197
198 private void ReceiveClassicSimStatsPacket(SimStats stats)
199 {
200 if (!enabled)
201 return;
202
203 try
204 {
205 // Ignore the update if there's a report running right now
206 // ignore the update if there hasn't been a hit in 30 seconds.
207 if (concurrencyCounter > 0 || System.Environment.TickCount - lastHit > 30000)
208 return;
209
210 // We will conduct this under lock so that fields such as updateLogCounter do not potentially get
211 // confused if a scene is removed.
212 // XXX: Possibly the scope of this lock could be reduced though it's not critical.
213 lock (m_scenes)
214 {
215 if (updateLogMod != 0 && updateLogCounter++ % updateLogMod == 0)
216 {
217 m_loglines = readLogLines(10);
218
219 if (updateLogCounter > 10000)
220 updateLogCounter = 1;
221 }
222
223 USimStatsData ss = m_simstatsCounters[stats.RegionUUID];
224
225 if ((++ss.StatsCounter % updateStatsMod) == 0)
226 {
227 ss.ConsumeSimStats(stats);
228 }
229 }
230 }
231 catch (KeyNotFoundException)
232 {
233 }
234 }
235
236 private Hashtable HandleUnknownCAPSRequest(Hashtable request)
237 {
238 //string regpath = request["uri"].ToString();
239 int response_code = 200;
240 string contenttype = "text/html";
241 UpdateUserStats(ParseViewerStats(request["body"].ToString(), UUID.Zero), dbConn);
242 Hashtable responsedata = new Hashtable();
243
244 responsedata["int_response_code"] = response_code;
245 responsedata["content_type"] = contenttype;
246 responsedata["keepalive"] = false;
247 responsedata["str_response_string"] = string.Empty;
248 return responsedata;
249 }
250
251 private Hashtable HandleStatsRequest(Hashtable request)
252 {
253 lastHit = System.Environment.TickCount;
254 Hashtable responsedata = new Hashtable();
255 string regpath = request["uri"].ToString();
256 int response_code = 404;
257 string contenttype = "text/html";
258
259 string strOut = string.Empty;
260
261 regpath = regpath.Remove(0, 8);
262 if (regpath.Length == 0) regpath = "default.report";
263 if (reports.ContainsKey(regpath))
264 {
265 IStatsController rep = reports[regpath];
266 Hashtable repParams = new Hashtable();
267
268 if (request.ContainsKey("requestvars"))
269 repParams["RequestVars"] = request["requestvars"];
270 else
271 repParams["RequestVars"] = new Hashtable();
272
273 if (request.ContainsKey("querystringkeys"))
274 repParams["QueryStringKeys"] = request["querystringkeys"];
275 else
276 repParams["QueryStringKeys"] = new string[0];
277
278
279 repParams["DatabaseConnection"] = dbConn;
280 repParams["Scenes"] = m_scenes;
281 repParams["SimStats"] = m_simstatsCounters;
282 repParams["LogLines"] = m_loglines;
283 repParams["Reports"] = reports;
284
285 concurrencyCounter++;
286
287 strOut = rep.RenderView(rep.ProcessModel(repParams));
288
289 if (regpath.EndsWith("js"))
290 {
291 contenttype = "text/javascript";
292 }
293
294 concurrencyCounter--;
295
296 response_code = 200;
297 }
298 else
299 {
300 strOut = MainServer.Instance.GetHTTP404("");
301 }
302
303 responsedata["int_response_code"] = response_code;
304 responsedata["content_type"] = contenttype;
305 responsedata["keepalive"] = false;
306 responsedata["str_response_string"] = strOut;
307
308 return responsedata;
309 }
310
311 private void CreateTables(SqliteConnection db)
312 {
313 using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db))
314 {
315 createcmd.ExecuteNonQuery();
316 }
317 }
318
319 private void OnRegisterCaps(UUID agentID, Caps caps)
320 {
321// m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
322
323 string capsPath = "/CAPS/VS/" + UUID.Random();
324 caps.RegisterHandler(
325 "ViewerStats",
326 new RestStreamHandler(
327 "POST",
328 capsPath,
329 (request, path, param, httpRequest, httpResponse)
330 => ViewerStatsReport(request, path, param, agentID, caps),
331 "ViewerStats",
332 agentID.ToString()));
333 }
334
335 private void OnDeRegisterCaps(UUID agentID, Caps caps)
336 {
337 }
338
339 protected virtual void AddEventHandlers()
340 {
341 lock (m_scenes)
342 {
343 updateLogMod = m_scenes.Count * 2;
344 foreach (Scene scene in m_scenes)
345 {
346 scene.EventManager.OnRegisterCaps += OnRegisterCaps;
347 scene.EventManager.OnDeregisterCaps += OnDeRegisterCaps;
348 scene.EventManager.OnClientClosed += OnClientClosed;
349 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
350 }
351 }
352 }
353
354 private void OnMakeRootAgent(ScenePresence agent)
355 {
356// m_log.DebugFormat(
357// "[WEB STATS MODULE]: Looking for session {0} for {1} in {2}",
358// agent.ControllingClient.SessionId, agent.Name, agent.Scene.Name);
359
360 lock (m_sessions)
361 {
362 UserSession uid;
363
364 if (!m_sessions.ContainsKey(agent.UUID))
365 {
366 UserSessionData usd = UserSessionUtil.newUserSessionData();
367 uid = new UserSession();
368 uid.name_f = agent.Firstname;
369 uid.name_l = agent.Lastname;
370 uid.session_data = usd;
371
372 m_sessions.Add(agent.UUID, uid);
373 }
374 else
375 {
376 uid = m_sessions[agent.UUID];
377 }
378
379 uid.region_id = agent.Scene.RegionInfo.RegionID;
380 uid.session_id = agent.ControllingClient.SessionId;
381 }
382 }
383
384 private void OnClientClosed(UUID agentID, Scene scene)
385 {
386 lock (m_sessions)
387 {
388 if (m_sessions.ContainsKey(agentID) && m_sessions[agentID].region_id == scene.RegionInfo.RegionID)
389 {
390 m_sessions.Remove(agentID);
391 }
392 }
393 }
394
395 private string readLogLines(int amount)
396 {
397 Encoding encoding = Encoding.ASCII;
398 int sizeOfChar = encoding.GetByteCount("\n");
399 byte[] buffer = encoding.GetBytes("\n");
400 string logfile = Util.logDir() + "/" + "OpenSim.log";
401 FileStream fs = new FileStream(logfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
402 Int64 tokenCount = 0;
403 Int64 endPosition = fs.Length / sizeOfChar;
404
405 for (Int64 position = sizeOfChar; position < endPosition; position += sizeOfChar)
406 {
407 fs.Seek(-position, SeekOrigin.End);
408 fs.Read(buffer, 0, buffer.Length);
409
410 if (encoding.GetString(buffer) == "\n")
411 {
412 tokenCount++;
413 if (tokenCount == amount)
414 {
415 byte[] returnBuffer = new byte[fs.Length - fs.Position];
416 fs.Read(returnBuffer, 0, returnBuffer.Length);
417 fs.Close();
418 fs.Dispose();
419 return encoding.GetString(returnBuffer);
420 }
421 }
422 }
423
424 // handle case where number of tokens in file is less than numberOfTokens
425 fs.Seek(0, SeekOrigin.Begin);
426 buffer = new byte[fs.Length];
427 fs.Read(buffer, 0, buffer.Length);
428 fs.Close();
429 fs.Dispose();
430 return encoding.GetString(buffer);
431 }
432
433 /// <summary>
434 /// Callback for a viewerstats cap
435 /// </summary>
436 /// <param name="request"></param>
437 /// <param name="path"></param>
438 /// <param name="param"></param>
439 /// <param name="agentID"></param>
440 /// <param name="caps"></param>
441 /// <returns></returns>
442 private string ViewerStatsReport(string request, string path, string param,
443 UUID agentID, Caps caps)
444 {
445// m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID);
446
447 UpdateUserStats(ParseViewerStats(request, agentID), dbConn);
448
449 return String.Empty;
450 }
451
452 private UserSession ParseViewerStats(string request, UUID agentID)
453 {
454 UserSession uid = new UserSession();
455 UserSessionData usd;
456 OSD message = OSDParser.DeserializeLLSDXml(request);
457 OSDMap mmap;
458
459 lock (m_sessions)
460 {
461 if (agentID != UUID.Zero)
462 {
463 if (!m_sessions.ContainsKey(agentID))
464 {
465 m_log.WarnFormat("[WEB STATS MODULE]: no session for stat disclosure for agent {0}", agentID);
466 return new UserSession();
467 }
468
469 uid = m_sessions[agentID];
470
471// m_log.DebugFormat("[WEB STATS MODULE]: Got session {0} for {1}", uid.session_id, agentID);
472 }
473 else
474 {
475 // parse through the beginning to locate the session
476 if (message.Type != OSDType.Map)
477 return new UserSession();
478
479 mmap = (OSDMap)message;
480 {
481 UUID sessionID = mmap["session_id"].AsUUID();
482
483 if (sessionID == UUID.Zero)
484 return new UserSession();
485
486
487 // search through each session looking for the owner
488 foreach (UUID usersessionid in m_sessions.Keys)
489 {
490 // got it!
491 if (m_sessions[usersessionid].session_id == sessionID)
492 {
493 agentID = usersessionid;
494 uid = m_sessions[usersessionid];
495 break;
496 }
497
498 }
499
500 // can't find a session
501 if (agentID == UUID.Zero)
502 {
503 return new UserSession();
504 }
505 }
506 }
507 }
508
509 usd = uid.session_data;
510
511 if (message.Type != OSDType.Map)
512 return new UserSession();
513
514 mmap = (OSDMap)message;
515 {
516 if (mmap["agent"].Type != OSDType.Map)
517 return new UserSession();
518 OSDMap agent_map = (OSDMap)mmap["agent"];
519 usd.agent_id = agentID;
520 usd.name_f = uid.name_f;
521 usd.name_l = uid.name_l;
522 usd.region_id = uid.region_id;
523 usd.a_language = agent_map["language"].AsString();
524 usd.mem_use = (float)agent_map["mem_use"].AsReal();
525 usd.meters_traveled = (float)agent_map["meters_traveled"].AsReal();
526 usd.regions_visited = agent_map["regions_visited"].AsInteger();
527 usd.run_time = (float)agent_map["run_time"].AsReal();
528 usd.start_time = (float)agent_map["start_time"].AsReal();
529 usd.client_version = agent_map["version"].AsString();
530
531 UserSessionUtil.UpdateMultiItems(ref usd, agent_map["agents_in_view"].AsInteger(),
532 (float)agent_map["ping"].AsReal(),
533 (float)agent_map["sim_fps"].AsReal(),
534 (float)agent_map["fps"].AsReal());
535
536 if (mmap["downloads"].Type != OSDType.Map)
537 return new UserSession();
538 OSDMap downloads_map = (OSDMap)mmap["downloads"];
539 usd.d_object_kb = (float)downloads_map["object_kbytes"].AsReal();
540 usd.d_texture_kb = (float)downloads_map["texture_kbytes"].AsReal();
541 usd.d_world_kb = (float)downloads_map["workd_kbytes"].AsReal();
542
543// m_log.DebugFormat("[WEB STATS MODULE]: mmap[\"session_id\"] = [{0}]", mmap["session_id"].AsUUID());
544
545 usd.session_id = mmap["session_id"].AsUUID();
546
547 if (mmap["system"].Type != OSDType.Map)
548 return new UserSession();
549 OSDMap system_map = (OSDMap)mmap["system"];
550
551 usd.s_cpu = system_map["cpu"].AsString();
552 usd.s_gpu = system_map["gpu"].AsString();
553 usd.s_os = system_map["os"].AsString();
554 usd.s_ram = system_map["ram"].AsInteger();
555
556 if (mmap["stats"].Type != OSDType.Map)
557 return new UserSession();
558
559 OSDMap stats_map = (OSDMap)mmap["stats"];
560 {
561
562 if (stats_map["failures"].Type != OSDType.Map)
563 return new UserSession();
564 OSDMap stats_failures = (OSDMap)stats_map["failures"];
565 usd.f_dropped = stats_failures["dropped"].AsInteger();
566 usd.f_failed_resends = stats_failures["failed_resends"].AsInteger();
567 usd.f_invalid = stats_failures["invalid"].AsInteger();
568 usd.f_resent = stats_failures["resent"].AsInteger();
569 usd.f_send_packet = stats_failures["send_packet"].AsInteger();
570
571 if (stats_map["net"].Type != OSDType.Map)
572 return new UserSession();
573 OSDMap stats_net = (OSDMap)stats_map["net"];
574 {
575 if (stats_net["in"].Type != OSDType.Map)
576 return new UserSession();
577
578 OSDMap net_in = (OSDMap)stats_net["in"];
579 usd.n_in_kb = (float)net_in["kbytes"].AsReal();
580 usd.n_in_pk = net_in["packets"].AsInteger();
581
582 if (stats_net["out"].Type != OSDType.Map)
583 return new UserSession();
584 OSDMap net_out = (OSDMap)stats_net["out"];
585
586 usd.n_out_kb = (float)net_out["kbytes"].AsReal();
587 usd.n_out_pk = net_out["packets"].AsInteger();
588 }
589 }
590 }
591
592 uid.session_data = usd;
593 m_sessions[agentID] = uid;
594
595// m_log.DebugFormat(
596// "[WEB STATS MODULE]: Parse data for {0} {1}, session {2}", uid.name_f, uid.name_l, uid.session_id);
597
598 return uid;
599 }
600
601 private void UpdateUserStats(UserSession uid, SqliteConnection db)
602 {
603// m_log.DebugFormat(
604// "[WEB STATS MODULE]: Updating user stats for {0} {1}, session {2}", uid.name_f, uid.name_l, uid.session_id);
605
606 if (uid.session_id == UUID.Zero)
607 return;
608
609 lock (db)
610 {
611 using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_INSERT, db))
612 {
613 updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString()));
614 updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString()));
615 updatecmd.Parameters.Add(new SqliteParameter(":region_id", uid.session_data.region_id.ToString()));
616 updatecmd.Parameters.Add(new SqliteParameter(":last_updated", (int) uid.session_data.last_updated));
617 updatecmd.Parameters.Add(new SqliteParameter(":remote_ip", uid.session_data.remote_ip));
618 updatecmd.Parameters.Add(new SqliteParameter(":name_f", uid.session_data.name_f));
619 updatecmd.Parameters.Add(new SqliteParameter(":name_l", uid.session_data.name_l));
620 updatecmd.Parameters.Add(new SqliteParameter(":avg_agents_in_view", uid.session_data.avg_agents_in_view));
621 updatecmd.Parameters.Add(new SqliteParameter(":min_agents_in_view",
622 (int) uid.session_data.min_agents_in_view));
623 updatecmd.Parameters.Add(new SqliteParameter(":max_agents_in_view",
624 (int) uid.session_data.max_agents_in_view));
625 updatecmd.Parameters.Add(new SqliteParameter(":mode_agents_in_view",
626 (int) uid.session_data.mode_agents_in_view));
627 updatecmd.Parameters.Add(new SqliteParameter(":avg_fps", uid.session_data.avg_fps));
628 updatecmd.Parameters.Add(new SqliteParameter(":min_fps", uid.session_data.min_fps));
629 updatecmd.Parameters.Add(new SqliteParameter(":max_fps", uid.session_data.max_fps));
630 updatecmd.Parameters.Add(new SqliteParameter(":mode_fps", uid.session_data.mode_fps));
631 updatecmd.Parameters.Add(new SqliteParameter(":a_language", uid.session_data.a_language));
632 updatecmd.Parameters.Add(new SqliteParameter(":mem_use", uid.session_data.mem_use));
633 updatecmd.Parameters.Add(new SqliteParameter(":meters_traveled", uid.session_data.meters_traveled));
634 updatecmd.Parameters.Add(new SqliteParameter(":avg_ping", uid.session_data.avg_ping));
635 updatecmd.Parameters.Add(new SqliteParameter(":min_ping", uid.session_data.min_ping));
636 updatecmd.Parameters.Add(new SqliteParameter(":max_ping", uid.session_data.max_ping));
637 updatecmd.Parameters.Add(new SqliteParameter(":mode_ping", uid.session_data.mode_ping));
638 updatecmd.Parameters.Add(new SqliteParameter(":regions_visited", uid.session_data.regions_visited));
639 updatecmd.Parameters.Add(new SqliteParameter(":run_time", uid.session_data.run_time));
640 updatecmd.Parameters.Add(new SqliteParameter(":avg_sim_fps", uid.session_data.avg_sim_fps));
641 updatecmd.Parameters.Add(new SqliteParameter(":min_sim_fps", uid.session_data.min_sim_fps));
642 updatecmd.Parameters.Add(new SqliteParameter(":max_sim_fps", uid.session_data.max_sim_fps));
643 updatecmd.Parameters.Add(new SqliteParameter(":mode_sim_fps", uid.session_data.mode_sim_fps));
644 updatecmd.Parameters.Add(new SqliteParameter(":start_time", uid.session_data.start_time));
645 updatecmd.Parameters.Add(new SqliteParameter(":client_version", uid.session_data.client_version));
646 updatecmd.Parameters.Add(new SqliteParameter(":s_cpu", uid.session_data.s_cpu));
647 updatecmd.Parameters.Add(new SqliteParameter(":s_gpu", uid.session_data.s_gpu));
648 updatecmd.Parameters.Add(new SqliteParameter(":s_os", uid.session_data.s_os));
649 updatecmd.Parameters.Add(new SqliteParameter(":s_ram", uid.session_data.s_ram));
650 updatecmd.Parameters.Add(new SqliteParameter(":d_object_kb", uid.session_data.d_object_kb));
651 updatecmd.Parameters.Add(new SqliteParameter(":d_texture_kb", uid.session_data.d_texture_kb));
652 updatecmd.Parameters.Add(new SqliteParameter(":d_world_kb", uid.session_data.d_world_kb));
653 updatecmd.Parameters.Add(new SqliteParameter(":n_in_kb", uid.session_data.n_in_kb));
654 updatecmd.Parameters.Add(new SqliteParameter(":n_in_pk", uid.session_data.n_in_pk));
655 updatecmd.Parameters.Add(new SqliteParameter(":n_out_kb", uid.session_data.n_out_kb));
656 updatecmd.Parameters.Add(new SqliteParameter(":n_out_pk", uid.session_data.n_out_pk));
657 updatecmd.Parameters.Add(new SqliteParameter(":f_dropped", uid.session_data.f_dropped));
658 updatecmd.Parameters.Add(new SqliteParameter(":f_failed_resends", uid.session_data.f_failed_resends));
659 updatecmd.Parameters.Add(new SqliteParameter(":f_invalid", uid.session_data.f_invalid));
660 updatecmd.Parameters.Add(new SqliteParameter(":f_off_circuit", uid.session_data.f_off_circuit));
661 updatecmd.Parameters.Add(new SqliteParameter(":f_resent", uid.session_data.f_resent));
662 updatecmd.Parameters.Add(new SqliteParameter(":f_send_packet", uid.session_data.f_send_packet));
663
664// StringBuilder parameters = new StringBuilder();
665// SqliteParameterCollection spc = updatecmd.Parameters;
666// foreach (SqliteParameter sp in spc)
667// parameters.AppendFormat("{0}={1},", sp.ParameterName, sp.Value);
668//
669// m_log.DebugFormat("[WEB STATS MODULE]: Parameters {0}", parameters);
670
671// m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id);
672
673 updatecmd.ExecuteNonQuery();
674 }
675 }
676 }
677
678 #region SQL
679 private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE IF NOT EXISTS stats_session_data (
680 session_id VARCHAR(36) NOT NULL PRIMARY KEY,
681 agent_id VARCHAR(36) NOT NULL DEFAULT '',
682 region_id VARCHAR(36) NOT NULL DEFAULT '',
683 last_updated INT NOT NULL DEFAULT '0',
684 remote_ip VARCHAR(16) NOT NULL DEFAULT '',
685 name_f VARCHAR(50) NOT NULL DEFAULT '',
686 name_l VARCHAR(50) NOT NULL DEFAULT '',
687 avg_agents_in_view FLOAT NOT NULL DEFAULT '0',
688 min_agents_in_view INT NOT NULL DEFAULT '0',
689 max_agents_in_view INT NOT NULL DEFAULT '0',
690 mode_agents_in_view INT NOT NULL DEFAULT '0',
691 avg_fps FLOAT NOT NULL DEFAULT '0',
692 min_fps FLOAT NOT NULL DEFAULT '0',
693 max_fps FLOAT NOT NULL DEFAULT '0',
694 mode_fps FLOAT NOT NULL DEFAULT '0',
695 a_language VARCHAR(25) NOT NULL DEFAULT '',
696 mem_use FLOAT NOT NULL DEFAULT '0',
697 meters_traveled FLOAT NOT NULL DEFAULT '0',
698 avg_ping FLOAT NOT NULL DEFAULT '0',
699 min_ping FLOAT NOT NULL DEFAULT '0',
700 max_ping FLOAT NOT NULL DEFAULT '0',
701 mode_ping FLOAT NOT NULL DEFAULT '0',
702 regions_visited INT NOT NULL DEFAULT '0',
703 run_time FLOAT NOT NULL DEFAULT '0',
704 avg_sim_fps FLOAT NOT NULL DEFAULT '0',
705 min_sim_fps FLOAT NOT NULL DEFAULT '0',
706 max_sim_fps FLOAT NOT NULL DEFAULT '0',
707 mode_sim_fps FLOAT NOT NULL DEFAULT '0',
708 start_time FLOAT NOT NULL DEFAULT '0',
709 client_version VARCHAR(255) NOT NULL DEFAULT '',
710 s_cpu VARCHAR(255) NOT NULL DEFAULT '',
711 s_gpu VARCHAR(255) NOT NULL DEFAULT '',
712 s_os VARCHAR(2255) NOT NULL DEFAULT '',
713 s_ram INT NOT NULL DEFAULT '0',
714 d_object_kb FLOAT NOT NULL DEFAULT '0',
715 d_texture_kb FLOAT NOT NULL DEFAULT '0',
716 d_world_kb FLOAT NOT NULL DEFAULT '0',
717 n_in_kb FLOAT NOT NULL DEFAULT '0',
718 n_in_pk INT NOT NULL DEFAULT '0',
719 n_out_kb FLOAT NOT NULL DEFAULT '0',
720 n_out_pk INT NOT NULL DEFAULT '0',
721 f_dropped INT NOT NULL DEFAULT '0',
722 f_failed_resends INT NOT NULL DEFAULT '0',
723 f_invalid INT NOT NULL DEFAULT '0',
724 f_off_circuit INT NOT NULL DEFAULT '0',
725 f_resent INT NOT NULL DEFAULT '0',
726 f_send_packet INT NOT NULL DEFAULT '0'
727 );";
728
729 private const string SQL_STATS_TABLE_INSERT = @"INSERT OR REPLACE INTO stats_session_data (
730session_id, agent_id, region_id, last_updated, remote_ip, name_f, name_l, avg_agents_in_view, min_agents_in_view, max_agents_in_view,
731mode_agents_in_view, avg_fps, min_fps, max_fps, mode_fps, a_language, mem_use, meters_traveled, avg_ping, min_ping, max_ping, mode_ping,
732regions_visited, run_time, avg_sim_fps, min_sim_fps, max_sim_fps, mode_sim_fps, start_time, client_version, s_cpu, s_gpu, s_os, s_ram,
733d_object_kb, d_texture_kb, d_world_kb, n_in_kb, n_in_pk, n_out_kb, n_out_pk, f_dropped, f_failed_resends, f_invalid, f_off_circuit,
734f_resent, f_send_packet
735)
736VALUES
737(
738:session_id, :agent_id, :region_id, :last_updated, :remote_ip, :name_f, :name_l, :avg_agents_in_view, :min_agents_in_view, :max_agents_in_view,
739:mode_agents_in_view, :avg_fps, :min_fps, :max_fps, :mode_fps, :a_language, :mem_use, :meters_traveled, :avg_ping, :min_ping, :max_ping, :mode_ping,
740:regions_visited, :run_time, :avg_sim_fps, :min_sim_fps, :max_sim_fps, :mode_sim_fps, :start_time, :client_version, :s_cpu, :s_gpu, :s_os, :s_ram,
741:d_object_kb, :d_texture_kb, :d_world_kb, :n_in_kb, :n_in_pk, :n_out_kb, :n_out_pk, :f_dropped, :f_failed_resends, :f_invalid, :f_off_circuit,
742:f_resent, :f_send_packet
743)
744";
745
746 #endregion
747
748 }
749
750 public static class UserSessionUtil
751 {
752 public static UserSessionData newUserSessionData()
753 {
754 UserSessionData obj = ZeroSession(new UserSessionData());
755 return obj;
756 }
757
758 public static void UpdateMultiItems(ref UserSessionData s, int agents_in_view, float ping, float sim_fps, float fps)
759 {
760 // don't insert zero values here or it'll skew the statistics.
761 if (agents_in_view == 0 && fps == 0 && sim_fps == 0 && ping == 0)
762 return;
763 s._agents_in_view.Add(agents_in_view);
764 s._fps.Add(fps);
765 s._sim_fps.Add(sim_fps);
766 s._ping.Add(ping);
767
768 int[] __agents_in_view = s._agents_in_view.ToArray();
769
770 s.avg_agents_in_view = ArrayAvg_i(__agents_in_view);
771 s.min_agents_in_view = ArrayMin_i(__agents_in_view);
772 s.max_agents_in_view = ArrayMax_i(__agents_in_view);
773 s.mode_agents_in_view = ArrayMode_i(__agents_in_view);
774
775 float[] __fps = s._fps.ToArray();
776 s.avg_fps = ArrayAvg_f(__fps);
777 s.min_fps = ArrayMin_f(__fps);
778 s.max_fps = ArrayMax_f(__fps);
779 s.mode_fps = ArrayMode_f(__fps);
780
781 float[] __sim_fps = s._sim_fps.ToArray();
782 s.avg_sim_fps = ArrayAvg_f(__sim_fps);
783 s.min_sim_fps = ArrayMin_f(__sim_fps);
784 s.max_sim_fps = ArrayMax_f(__sim_fps);
785 s.mode_sim_fps = ArrayMode_f(__sim_fps);
786
787 float[] __ping = s._ping.ToArray();
788 s.avg_ping = ArrayAvg_f(__ping);
789 s.min_ping = ArrayMin_f(__ping);
790 s.max_ping = ArrayMax_f(__ping);
791 s.mode_ping = ArrayMode_f(__ping);
792 }
793
794 #region Statistics
795
796 public static int ArrayMin_i(int[] arr)
797 {
798 int cnt = arr.Length;
799 if (cnt == 0)
800 return 0;
801
802 Array.Sort(arr);
803 return arr[0];
804 }
805
806 public static int ArrayMax_i(int[] arr)
807 {
808 int cnt = arr.Length;
809 if (cnt == 0)
810 return 0;
811
812 Array.Sort(arr);
813 return arr[cnt-1];
814 }
815
816 public static float ArrayMin_f(float[] arr)
817 {
818 int cnt = arr.Length;
819 if (cnt == 0)
820 return 0;
821
822 Array.Sort(arr);
823 return arr[0];
824 }
825
826 public static float ArrayMax_f(float[] arr)
827 {
828 int cnt = arr.Length;
829 if (cnt == 0)
830 return 0;
831
832 Array.Sort(arr);
833 return arr[cnt - 1];
834 }
835
836 public static float ArrayAvg_i(int[] arr)
837 {
838 int cnt = arr.Length;
839
840 if (cnt == 0)
841 return 0;
842
843 float result = arr[0];
844
845 for (int i = 1; i < cnt; i++)
846 result += arr[i];
847
848 return result / cnt;
849 }
850
851 public static float ArrayAvg_f(float[] arr)
852 {
853 int cnt = arr.Length;
854
855 if (cnt == 0)
856 return 0;
857
858 float result = arr[0];
859
860 for (int i = 1; i < cnt; i++)
861 result += arr[i];
862
863 return result / cnt;
864 }
865
866 public static float ArrayMode_f(float[] arr)
867 {
868 List<float> mode = new List<float>();
869
870 float[] srtArr = new float[arr.Length];
871 float[,] freq = new float[arr.Length, 2];
872 Array.Copy(arr, srtArr, arr.Length);
873 Array.Sort(srtArr);
874
875 float tmp = srtArr[0];
876 int index = 0;
877 int i = 0;
878 while (i < srtArr.Length)
879 {
880 freq[index, 0] = tmp;
881
882 while (tmp == srtArr[i])
883 {
884 freq[index, 1]++;
885 i++;
886
887 if (i > srtArr.Length - 1)
888 break;
889 }
890
891 if (i < srtArr.Length)
892 {
893 tmp = srtArr[i];
894 index++;
895 }
896
897 }
898
899 Array.Clear(srtArr, 0, srtArr.Length);
900
901 for (i = 0; i < srtArr.Length; i++)
902 srtArr[i] = freq[i, 1];
903
904 Array.Sort(srtArr);
905
906 if ((srtArr[srtArr.Length - 1]) == 0 || (srtArr[srtArr.Length - 1]) == 1)
907 return 0;
908
909 float freqtest = (float)freq.Length / freq.Rank;
910
911 for (i = 0; i < freqtest; i++)
912 {
913 if (freq[i, 1] == srtArr[index])
914 mode.Add(freq[i, 0]);
915
916 }
917
918 return mode.ToArray()[0];
919 }
920
921 public static int ArrayMode_i(int[] arr)
922 {
923 List<int> mode = new List<int>();
924
925 int[] srtArr = new int[arr.Length];
926 int[,] freq = new int[arr.Length, 2];
927 Array.Copy(arr, srtArr, arr.Length);
928 Array.Sort(srtArr);
929
930 int tmp = srtArr[0];
931 int index = 0;
932 int i = 0;
933 while (i < srtArr.Length)
934 {
935 freq[index, 0] = tmp;
936
937 while (tmp == srtArr[i])
938 {
939 freq[index, 1]++;
940 i++;
941
942 if (i > srtArr.Length - 1)
943 break;
944 }
945
946 if (i < srtArr.Length)
947 {
948 tmp = srtArr[i];
949 index++;
950 }
951
952 }
953
954 Array.Clear(srtArr, 0, srtArr.Length);
955
956 for (i = 0; i < srtArr.Length; i++)
957 srtArr[i] = freq[i, 1];
958
959 Array.Sort(srtArr);
960
961 if ((srtArr[srtArr.Length - 1]) == 0 || (srtArr[srtArr.Length - 1]) == 1)
962 return 0;
963
964 float freqtest = (float)freq.Length / freq.Rank;
965
966 for (i = 0; i < freqtest; i++)
967 {
968 if (freq[i, 1] == srtArr[index])
969 mode.Add(freq[i, 0]);
970
971 }
972
973 return mode.ToArray()[0];
974 }
975
976 #endregion
977
978 private static UserSessionData ZeroSession(UserSessionData s)
979 {
980 s.session_id = UUID.Zero;
981 s.agent_id = UUID.Zero;
982 s.region_id = UUID.Zero;
983 s.last_updated = Util.UnixTimeSinceEpoch();
984 s.remote_ip = "";
985 s.name_f = "";
986 s.name_l = "";
987 s.avg_agents_in_view = 0;
988 s.min_agents_in_view = 0;
989 s.max_agents_in_view = 0;
990 s.mode_agents_in_view = 0;
991 s.avg_fps = 0;
992 s.min_fps = 0;
993 s.max_fps = 0;
994 s.mode_fps = 0;
995 s.a_language = "";
996 s.mem_use = 0;
997 s.meters_traveled = 0;
998 s.avg_ping = 0;
999 s.min_ping = 0;
1000 s.max_ping = 0;
1001 s.mode_ping = 0;
1002 s.regions_visited = 0;
1003 s.run_time = 0;
1004 s.avg_sim_fps = 0;
1005 s.min_sim_fps = 0;
1006 s.max_sim_fps = 0;
1007 s.mode_sim_fps = 0;
1008 s.start_time = 0;
1009 s.client_version = "";
1010 s.s_cpu = "";
1011 s.s_gpu = "";
1012 s.s_os = "";
1013 s.s_ram = 0;
1014 s.d_object_kb = 0;
1015 s.d_texture_kb = 0;
1016 s.d_world_kb = 0;
1017 s.n_in_kb = 0;
1018 s.n_in_pk = 0;
1019 s.n_out_kb = 0;
1020 s.n_out_pk = 0;
1021 s.f_dropped = 0;
1022 s.f_failed_resends = 0;
1023 s.f_invalid = 0;
1024 s.f_off_circuit = 0;
1025 s.f_resent = 0;
1026 s.f_send_packet = 0;
1027 s._ping = new List<float>();
1028 s._fps = new List<float>();
1029 s._sim_fps = new List<float>();
1030 s._agents_in_view = new List<int>();
1031 return s;
1032 }
1033 }
1034 #region structs
1035
1036 public class UserSession
1037 {
1038 public UUID session_id;
1039 public UUID region_id;
1040 public string name_f;
1041 public string name_l;
1042 public UserSessionData session_data;
1043 }
1044
1045 public struct UserSessionData
1046 {
1047 public UUID session_id;
1048 public UUID agent_id;
1049 public UUID region_id;
1050 public float last_updated;
1051 public string remote_ip;
1052 public string name_f;
1053 public string name_l;
1054 public float avg_agents_in_view;
1055 public float min_agents_in_view;
1056 public float max_agents_in_view;
1057 public float mode_agents_in_view;
1058 public float avg_fps;
1059 public float min_fps;
1060 public float max_fps;
1061 public float mode_fps;
1062 public string a_language;
1063 public float mem_use;
1064 public float meters_traveled;
1065 public float avg_ping;
1066 public float min_ping;
1067 public float max_ping;
1068 public float mode_ping;
1069 public int regions_visited;
1070 public float run_time;
1071 public float avg_sim_fps;
1072 public float min_sim_fps;
1073 public float max_sim_fps;
1074 public float mode_sim_fps;
1075 public float start_time;
1076 public string client_version;
1077 public string s_cpu;
1078 public string s_gpu;
1079 public string s_os;
1080 public int s_ram;
1081 public float d_object_kb;
1082 public float d_texture_kb;
1083 public float d_world_kb;
1084 public float n_in_kb;
1085 public int n_in_pk;
1086 public float n_out_kb;
1087 public int n_out_pk;
1088 public int f_dropped;
1089 public int f_failed_resends;
1090 public int f_invalid;
1091 public int f_off_circuit;
1092 public int f_resent;
1093 public int f_send_packet;
1094 public List<float> _ping;
1095 public List<float> _fps;
1096 public List<float> _sim_fps;
1097 public List<int> _agents_in_view;
1098 }
1099
1100 #endregion
1101
1102 public class USimStatsData
1103 {
1104 private UUID m_regionID = UUID.Zero;
1105 private volatile int m_statcounter = 0;
1106 private volatile float m_timeDilation;
1107 private volatile float m_simFps;
1108 private volatile float m_physicsFps;
1109 private volatile float m_agentUpdates;
1110 private volatile float m_rootAgents;
1111 private volatile float m_childAgents;
1112 private volatile float m_totalPrims;
1113 private volatile float m_activePrims;
1114 private volatile float m_totalFrameTime;
1115 private volatile float m_netFrameTime;
1116 private volatile float m_physicsFrameTime;
1117 private volatile float m_otherFrameTime;
1118 private volatile float m_imageFrameTime;
1119 private volatile float m_inPacketsPerSecond;
1120 private volatile float m_outPacketsPerSecond;
1121 private volatile float m_unackedBytes;
1122 private volatile float m_agentFrameTime;
1123 private volatile float m_pendingDownloads;
1124 private volatile float m_pendingUploads;
1125 private volatile float m_activeScripts;
1126 private volatile float m_scriptLinesPerSecond;
1127
1128 public UUID RegionId { get { return m_regionID; } }
1129 public int StatsCounter { get { return m_statcounter; } set { m_statcounter = value;}}
1130 public float TimeDilation { get { return m_timeDilation; } }
1131 public float SimFps { get { return m_simFps; } }
1132 public float PhysicsFps { get { return m_physicsFps; } }
1133 public float AgentUpdates { get { return m_agentUpdates; } }
1134 public float RootAgents { get { return m_rootAgents; } }
1135 public float ChildAgents { get { return m_childAgents; } }
1136 public float TotalPrims { get { return m_totalPrims; } }
1137 public float ActivePrims { get { return m_activePrims; } }
1138 public float TotalFrameTime { get { return m_totalFrameTime; } }
1139 public float NetFrameTime { get { return m_netFrameTime; } }
1140 public float PhysicsFrameTime { get { return m_physicsFrameTime; } }
1141 public float OtherFrameTime { get { return m_otherFrameTime; } }
1142 public float ImageFrameTime { get { return m_imageFrameTime; } }
1143 public float InPacketsPerSecond { get { return m_inPacketsPerSecond; } }
1144 public float OutPacketsPerSecond { get { return m_outPacketsPerSecond; } }
1145 public float UnackedBytes { get { return m_unackedBytes; } }
1146 public float AgentFrameTime { get { return m_agentFrameTime; } }
1147 public float PendingDownloads { get { return m_pendingDownloads; } }
1148 public float PendingUploads { get { return m_pendingUploads; } }
1149 public float ActiveScripts { get { return m_activeScripts; } }
1150 public float ScriptLinesPerSecond { get { return m_scriptLinesPerSecond; } }
1151
1152 public USimStatsData(UUID pRegionID)
1153 {
1154 m_regionID = pRegionID;
1155 }
1156
1157 public void ConsumeSimStats(SimStats stats)
1158 {
1159 m_regionID = stats.RegionUUID;
1160 m_timeDilation = stats.StatsBlock[0].StatValue;
1161 m_simFps = stats.StatsBlock[1].StatValue;
1162 m_physicsFps = stats.StatsBlock[2].StatValue;
1163 m_agentUpdates = stats.StatsBlock[3].StatValue;
1164 m_rootAgents = stats.StatsBlock[4].StatValue;
1165 m_childAgents = stats.StatsBlock[5].StatValue;
1166 m_totalPrims = stats.StatsBlock[6].StatValue;
1167 m_activePrims = stats.StatsBlock[7].StatValue;
1168 m_totalFrameTime = stats.StatsBlock[8].StatValue;
1169 m_netFrameTime = stats.StatsBlock[9].StatValue;
1170 m_physicsFrameTime = stats.StatsBlock[10].StatValue;
1171 m_otherFrameTime = stats.StatsBlock[11].StatValue;
1172 m_imageFrameTime = stats.StatsBlock[12].StatValue;
1173 m_inPacketsPerSecond = stats.StatsBlock[13].StatValue;
1174 m_outPacketsPerSecond = stats.StatsBlock[14].StatValue;
1175 m_unackedBytes = stats.StatsBlock[15].StatValue;
1176 m_agentFrameTime = stats.StatsBlock[16].StatValue;
1177 m_pendingDownloads = stats.StatsBlock[17].StatValue;
1178 m_pendingUploads = stats.StatsBlock[18].StatValue;
1179 m_activeScripts = stats.StatsBlock[19].StatValue;
1180 m_scriptLinesPerSecond = stats.StatsBlock[20].StatValue;
1181 }
1182 }
1183} \ No newline at end of file