diff options
author | Robert Adams | 2013-01-24 10:44:57 -0800 |
---|---|---|
committer | Robert Adams | 2013-01-24 10:44:57 -0800 |
commit | 427ab219b8ecf7f039d03ed3067e183db1434fb2 (patch) | |
tree | 520cdf2f0afb00fe8dbb28801d4fbf98902788dd /OpenSim/Region | |
parent | * Added in the manifold point dept on collision desc. In BulletSim engine Bul... (diff) | |
download | opensim-SC_OLD-427ab219b8ecf7f039d03ed3067e183db1434fb2.zip opensim-SC_OLD-427ab219b8ecf7f039d03ed3067e183db1434fb2.tar.gz opensim-SC_OLD-427ab219b8ecf7f039d03ed3067e183db1434fb2.tar.bz2 opensim-SC_OLD-427ab219b8ecf7f039d03ed3067e183db1434fb2.tar.xz |
Add JSONification of WebStats module. Adds a '?json' query parameter
to the fetch URL to return the data in JSON format. Also adds a simple
'sim.html' that uses JavaScript to display the JSON data. Not pretty
but an example.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs | 84 | ||||
-rw-r--r-- | OpenSim/Region/UserStatistics/Clients_report.cs | 27 | ||||
-rw-r--r-- | OpenSim/Region/UserStatistics/Default_Report.cs | 27 | ||||
-rw-r--r-- | OpenSim/Region/UserStatistics/IStatsReport.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/UserStatistics/LogLinesAJAX.cs | 29 | ||||
-rw-r--r-- | OpenSim/Region/UserStatistics/Prototype_distributor.cs | 31 | ||||
-rw-r--r-- | OpenSim/Region/UserStatistics/Sessions_Report.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/UserStatistics/SimStatsAJAX.cs | 59 | ||||
-rw-r--r-- | OpenSim/Region/UserStatistics/Updater_distributor.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/UserStatistics/WebStatsModule.cs | 25 |
10 files changed, 281 insertions, 11 deletions
diff --git a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs index 3243a9a..6a1112c 100644 --- a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs +++ b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs | |||
@@ -32,6 +32,7 @@ using System.Reflection; | |||
32 | using System.Text; | 32 | using System.Text; |
33 | using Mono.Data.SqliteClient; | 33 | using Mono.Data.SqliteClient; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenMetaverse.StructuredData; | ||
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Framework.Monitoring; | 38 | using OpenSim.Framework.Monitoring; |
@@ -51,7 +52,6 @@ namespace OpenSim.Region.UserStatistics | |||
51 | 52 | ||
52 | public Hashtable ProcessModel(Hashtable pParams) | 53 | public Hashtable ProcessModel(Hashtable pParams) |
53 | { | 54 | { |
54 | |||
55 | List<Scene> m_scene = (List<Scene>)pParams["Scenes"]; | 55 | List<Scene> m_scene = (List<Scene>)pParams["Scenes"]; |
56 | 56 | ||
57 | Hashtable nh = new Hashtable(); | 57 | Hashtable nh = new Hashtable(); |
@@ -129,6 +129,86 @@ namespace OpenSim.Region.UserStatistics | |||
129 | return output.ToString(); | 129 | return output.ToString(); |
130 | } | 130 | } |
131 | 131 | ||
132 | /// <summary> | ||
133 | /// Convert active connections information to JSON string. Returns a structure: | ||
134 | /// <pre> | ||
135 | /// {"regionName": { | ||
136 | /// "presenceName": { | ||
137 | /// "name": "presenceName", | ||
138 | /// "position": "<x,y,z>", | ||
139 | /// "isRoot": "false", | ||
140 | /// "throttle": { | ||
141 | /// }, | ||
142 | /// "queue": { | ||
143 | /// } | ||
144 | /// }, | ||
145 | /// ... // multiple presences in the scene | ||
146 | /// }, | ||
147 | /// ... // multiple regions in the sim | ||
148 | /// } | ||
149 | /// | ||
150 | /// </pre> | ||
151 | /// </summary> | ||
152 | /// <param name="pModelResult"></param> | ||
153 | /// <returns></returns> | ||
154 | public string RenderJson(Hashtable pModelResult) | ||
155 | { | ||
156 | List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"]; | ||
157 | |||
158 | OSDMap regionInfo = new OSDMap(); | ||
159 | foreach (Scene scene in all_scenes) | ||
160 | { | ||
161 | OSDMap sceneInfo = new OpenMetaverse.StructuredData.OSDMap(); | ||
162 | List<ScenePresence> avatarInScene = scene.GetScenePresences(); | ||
163 | foreach (ScenePresence av in avatarInScene) | ||
164 | { | ||
165 | OSDMap presenceInfo = new OSDMap(); | ||
166 | presenceInfo.Add("Name", new OSDString(av.Name)); | ||
167 | |||
168 | Dictionary<string,string> queues = new Dictionary<string, string>(); | ||
169 | if (av.ControllingClient is IStatsCollector) | ||
170 | { | ||
171 | IStatsCollector isClient = (IStatsCollector) av.ControllingClient; | ||
172 | queues = decodeQueueReport(isClient.Report()); | ||
173 | } | ||
174 | OSDMap queueInfo = new OpenMetaverse.StructuredData.OSDMap(); | ||
175 | foreach (KeyValuePair<string, string> kvp in queues) { | ||
176 | queueInfo.Add(kvp.Key, new OSDString(kvp.Value)); | ||
177 | } | ||
178 | sceneInfo.Add("queues", queueInfo); | ||
179 | |||
180 | if (av.IsChildAgent) | ||
181 | presenceInfo.Add("isRoot", new OSDString("false")); | ||
182 | else | ||
183 | presenceInfo.Add("isRoot", new OSDString("true")); | ||
184 | |||
185 | if (av.AbsolutePosition == DefaultNeighborPosition) | ||
186 | { | ||
187 | presenceInfo.Add("position", new OSDString("<0, 0, 0>")); | ||
188 | } | ||
189 | else | ||
190 | { | ||
191 | presenceInfo.Add("position", new OSDString(string.Format("<{0},{1},{2}>", | ||
192 | (int)av.AbsolutePosition.X, | ||
193 | (int) av.AbsolutePosition.Y, | ||
194 | (int) av.AbsolutePosition.Z)) ); | ||
195 | } | ||
196 | |||
197 | Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1)); | ||
198 | OSDMap throttleInfo = new OpenMetaverse.StructuredData.OSDMap(); | ||
199 | foreach (string throttlename in throttles.Keys) | ||
200 | { | ||
201 | throttleInfo.Add(throttlename, new OSDString(throttles[throttlename].ToString())); | ||
202 | } | ||
203 | presenceInfo.Add("throttle", throttleInfo); | ||
204 | |||
205 | sceneInfo.Add(av.Name, presenceInfo); | ||
206 | } | ||
207 | regionInfo.Add(scene.RegionInfo.RegionName, sceneInfo); | ||
208 | } | ||
209 | return regionInfo.ToString(); | ||
210 | } | ||
211 | |||
132 | public Dictionary<string, int> DecodeClientThrottles(byte[] throttle) | 212 | public Dictionary<string, int> DecodeClientThrottles(byte[] throttle) |
133 | { | 213 | { |
134 | Dictionary<string, int> returndict = new Dictionary<string, int>(); | 214 | Dictionary<string, int> returndict = new Dictionary<string, int>(); |
@@ -203,7 +283,7 @@ namespace OpenSim.Region.UserStatistics | |||
203 | returndic.Add("Cloud", rep.Substring((7 * pos) , 8)); pos++; | 283 | returndic.Add("Cloud", rep.Substring((7 * pos) , 8)); pos++; |
204 | returndic.Add("Task", rep.Substring((7 * pos) , 8)); pos++; | 284 | returndic.Add("Task", rep.Substring((7 * pos) , 8)); pos++; |
205 | returndic.Add("Texture", rep.Substring((7 * pos), 8)); pos++; | 285 | returndic.Add("Texture", rep.Substring((7 * pos), 8)); pos++; |
206 | returndic.Add("Asset", rep.Substring((7 * pos), 8)); | 286 | returndic.Add("Asset", rep.Substring((7 * pos), 8)); |
207 | /* | 287 | /* |
208 | * return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}", | 288 | * 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(), | 289 | SendQueue.Count(), |
diff --git a/OpenSim/Region/UserStatistics/Clients_report.cs b/OpenSim/Region/UserStatistics/Clients_report.cs index b2bb33b..4a6f7be 100644 --- a/OpenSim/Region/UserStatistics/Clients_report.cs +++ b/OpenSim/Region/UserStatistics/Clients_report.cs | |||
@@ -31,6 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Text; | 31 | using System.Text; |
32 | using Mono.Data.SqliteClient; | 32 | using Mono.Data.SqliteClient; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenMetaverse.StructuredData; | ||
34 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
35 | 36 | ||
36 | namespace OpenSim.Region.UserStatistics | 37 | namespace OpenSim.Region.UserStatistics |
@@ -44,6 +45,32 @@ namespace OpenSim.Region.UserStatistics | |||
44 | get { return "Client"; } | 45 | get { return "Client"; } |
45 | } | 46 | } |
46 | 47 | ||
48 | /// <summary> | ||
49 | /// Return summar information in the form: | ||
50 | /// <pre> | ||
51 | /// {"totalUsers": "34", | ||
52 | /// "totalSessions": "233", | ||
53 | /// ... | ||
54 | /// } | ||
55 | /// </pre> | ||
56 | /// </summary> | ||
57 | /// <param name="pModelResult"></param> | ||
58 | /// <returns></returns> | ||
59 | public string RenderJson(Hashtable pModelResult) { | ||
60 | stats_default_page_values values = (stats_default_page_values) pModelResult["hdata"]; | ||
61 | |||
62 | OSDMap summaryInfo = new OpenMetaverse.StructuredData.OSDMap(); | ||
63 | summaryInfo.Add("totalUsers", new OSDString(values.total_num_users.ToString())); | ||
64 | summaryInfo.Add("totalSessions", new OSDString(values.total_num_sessions.ToString())); | ||
65 | summaryInfo.Add("averageClientFPS", new OSDString(values.avg_client_fps.ToString())); | ||
66 | summaryInfo.Add("averageClientMem", new OSDString(values.avg_client_mem_use.ToString())); | ||
67 | summaryInfo.Add("averageSimFPS", new OSDString(values.avg_sim_fps.ToString())); | ||
68 | summaryInfo.Add("averagePingTime", new OSDString(values.avg_ping.ToString())); | ||
69 | summaryInfo.Add("totalKBOut", new OSDString(values.total_kb_out.ToString())); | ||
70 | summaryInfo.Add("totalKBIn", new OSDString(values.total_kb_in.ToString())); | ||
71 | return summaryInfo.ToString(); | ||
72 | } | ||
73 | |||
47 | public Hashtable ProcessModel(Hashtable pParams) | 74 | public Hashtable ProcessModel(Hashtable pParams) |
48 | { | 75 | { |
49 | SqliteConnection dbConn = (SqliteConnection)pParams["DatabaseConnection"]; | 76 | SqliteConnection dbConn = (SqliteConnection)pParams["DatabaseConnection"]; |
diff --git a/OpenSim/Region/UserStatistics/Default_Report.cs b/OpenSim/Region/UserStatistics/Default_Report.cs index cdc615c..fabe3d4 100644 --- a/OpenSim/Region/UserStatistics/Default_Report.cs +++ b/OpenSim/Region/UserStatistics/Default_Report.cs | |||
@@ -32,6 +32,7 @@ using System.Reflection; | |||
32 | using System.Text; | 32 | using System.Text; |
33 | using Mono.Data.SqliteClient; | 33 | using Mono.Data.SqliteClient; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenMetaverse.StructuredData; | ||
35 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Framework.Monitoring; | 37 | using OpenSim.Framework.Monitoring; |
37 | 38 | ||
@@ -230,6 +231,31 @@ TD.align_top { vertical-align: top; } | |||
230 | return returnstruct; | 231 | return returnstruct; |
231 | } | 232 | } |
232 | 233 | ||
234 | /// <summary> | ||
235 | /// Return summar information in the form: | ||
236 | /// <pre> | ||
237 | /// {"totalUsers": "34", | ||
238 | /// "totalSessions": "233", | ||
239 | /// ... | ||
240 | /// } | ||
241 | /// </pre> | ||
242 | /// </summary> | ||
243 | /// <param name="pModelResult"></param> | ||
244 | /// <returns></returns> | ||
245 | public string RenderJson(Hashtable pModelResult) { | ||
246 | stats_default_page_values values = (stats_default_page_values) pModelResult["hdata"]; | ||
247 | |||
248 | OSDMap summaryInfo = new OSDMap(); | ||
249 | summaryInfo.Add("totalUsers", new OSDString(values.total_num_users.ToString())); | ||
250 | summaryInfo.Add("totalSessions", new OSDString(values.total_num_sessions.ToString())); | ||
251 | summaryInfo.Add("averageClientFPS", new OSDString(values.avg_client_fps.ToString())); | ||
252 | summaryInfo.Add("averageClientMem", new OSDString(values.avg_client_mem_use.ToString())); | ||
253 | summaryInfo.Add("averageSimFPS", new OSDString(values.avg_sim_fps.ToString())); | ||
254 | summaryInfo.Add("averagePingTime", new OSDString(values.avg_ping.ToString())); | ||
255 | summaryInfo.Add("totalKBOut", new OSDString(values.total_kb_out.ToString())); | ||
256 | summaryInfo.Add("totalKBIn", new OSDString(values.total_kb_in.ToString())); | ||
257 | return summaryInfo.ToString(); | ||
258 | } | ||
233 | } | 259 | } |
234 | 260 | ||
235 | public struct stats_default_page_values | 261 | public struct stats_default_page_values |
@@ -247,4 +273,5 @@ TD.align_top { vertical-align: top; } | |||
247 | public Dictionary<UUID, USimStatsData> sim_stat_data; | 273 | public Dictionary<UUID, USimStatsData> sim_stat_data; |
248 | public Dictionary<string, IStatsController> stats_reports; | 274 | public Dictionary<string, IStatsController> stats_reports; |
249 | } | 275 | } |
276 | |||
250 | } | 277 | } |
diff --git a/OpenSim/Region/UserStatistics/IStatsReport.cs b/OpenSim/Region/UserStatistics/IStatsReport.cs index e0ecce4..80c4487 100644 --- a/OpenSim/Region/UserStatistics/IStatsReport.cs +++ b/OpenSim/Region/UserStatistics/IStatsReport.cs | |||
@@ -34,5 +34,6 @@ namespace OpenSim.Region.UserStatistics | |||
34 | string ReportName { get; } | 34 | string ReportName { get; } |
35 | Hashtable ProcessModel(Hashtable pParams); | 35 | Hashtable ProcessModel(Hashtable pParams); |
36 | string RenderView(Hashtable pModelResult); | 36 | string RenderView(Hashtable pModelResult); |
37 | string RenderJson(Hashtable pModelResult); | ||
37 | } | 38 | } |
38 | } | 39 | } |
diff --git a/OpenSim/Region/UserStatistics/LogLinesAJAX.cs b/OpenSim/Region/UserStatistics/LogLinesAJAX.cs index 74de46b..4d45b80 100644 --- a/OpenSim/Region/UserStatistics/LogLinesAJAX.cs +++ b/OpenSim/Region/UserStatistics/LogLinesAJAX.cs | |||
@@ -33,6 +33,7 @@ using System.Text; | |||
33 | using System.Text.RegularExpressions; | 33 | using System.Text.RegularExpressions; |
34 | using Mono.Data.SqliteClient; | 34 | using Mono.Data.SqliteClient; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenMetaverse.StructuredData; | ||
36 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Framework.Monitoring; | 38 | using OpenSim.Framework.Monitoring; |
38 | 39 | ||
@@ -125,6 +126,34 @@ namespace OpenSim.Region.UserStatistics | |||
125 | return output.ToString(); | 126 | return output.ToString(); |
126 | } | 127 | } |
127 | 128 | ||
129 | /// <summary> | ||
130 | /// Return the last log lines. Output in the format: | ||
131 | /// <pre> | ||
132 | /// {"logLines": [ | ||
133 | /// "line1", | ||
134 | /// "line2", | ||
135 | /// ... | ||
136 | /// ] | ||
137 | /// } | ||
138 | /// </pre> | ||
139 | /// </summary> | ||
140 | /// <param name="pModelResult"></param> | ||
141 | /// <returns></returns> | ||
142 | public string RenderJson(Hashtable pModelResult) | ||
143 | { | ||
144 | OSDMap logInfo = new OpenMetaverse.StructuredData.OSDMap(); | ||
145 | |||
146 | OSDArray logLines = new OpenMetaverse.StructuredData.OSDArray(); | ||
147 | string tmp = normalizeEndLines.Replace(pModelResult["loglines"].ToString(), "\n"); | ||
148 | string[] result = Regex.Split(tmp, "\n"); | ||
149 | for (int i = 0; i < result.Length; i++) | ||
150 | { | ||
151 | logLines.Add(new OSDString(result[i])); | ||
152 | } | ||
153 | logInfo.Add("logLines", logLines); | ||
154 | return logInfo.ToString(); | ||
155 | } | ||
156 | |||
128 | #endregion | 157 | #endregion |
129 | } | 158 | } |
130 | } | 159 | } |
diff --git a/OpenSim/Region/UserStatistics/Prototype_distributor.cs b/OpenSim/Region/UserStatistics/Prototype_distributor.cs index 53ae557..6f8b2aa 100644 --- a/OpenSim/Region/UserStatistics/Prototype_distributor.cs +++ b/OpenSim/Region/UserStatistics/Prototype_distributor.cs | |||
@@ -36,7 +36,18 @@ namespace OpenSim.Region.UserStatistics | |||
36 | { | 36 | { |
37 | public class Prototype_distributor : IStatsController | 37 | public class Prototype_distributor : IStatsController |
38 | { | 38 | { |
39 | private string prototypejs=string.Empty; | 39 | private string jsFileName = "prototype.js"; |
40 | private string prototypejs = string.Empty; | ||
41 | |||
42 | public Prototype_distributor() | ||
43 | { | ||
44 | jsFileName = "prototype.js"; | ||
45 | } | ||
46 | |||
47 | public Prototype_distributor(string jsName) | ||
48 | { | ||
49 | jsFileName = jsName; | ||
50 | } | ||
40 | 51 | ||
41 | public string ReportName | 52 | public string ReportName |
42 | { | 53 | { |
@@ -45,20 +56,24 @@ namespace OpenSim.Region.UserStatistics | |||
45 | public Hashtable ProcessModel(Hashtable pParams) | 56 | public Hashtable ProcessModel(Hashtable pParams) |
46 | { | 57 | { |
47 | Hashtable pResult = new Hashtable(); | 58 | Hashtable pResult = new Hashtable(); |
48 | if (prototypejs.Length == 0) | 59 | pResult["js"] = jsFileName; |
60 | return pResult; | ||
61 | } | ||
62 | |||
63 | public string RenderView(Hashtable pModelResult) | ||
64 | { | ||
65 | string fileName = (string)pModelResult["js"]; | ||
66 | using (StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/" + fileName, FileMode.Open))) | ||
49 | { | 67 | { |
50 | StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/prototype.js", FileMode.Open)); | ||
51 | prototypejs = fs.ReadToEnd(); | 68 | prototypejs = fs.ReadToEnd(); |
52 | fs.Close(); | 69 | fs.Close(); |
53 | fs.Dispose(); | ||
54 | } | 70 | } |
55 | pResult["js"] = prototypejs; | 71 | return prototypejs; |
56 | return pResult; | ||
57 | } | 72 | } |
58 | 73 | ||
59 | public string RenderView(Hashtable pModelResult) | 74 | public string RenderJson(Hashtable pModelResult) |
60 | { | 75 | { |
61 | return pModelResult["js"].ToString(); | 76 | return "{}"; |
62 | } | 77 | } |
63 | 78 | ||
64 | } | 79 | } |
diff --git a/OpenSim/Region/UserStatistics/Sessions_Report.cs b/OpenSim/Region/UserStatistics/Sessions_Report.cs index 1a2d460..0e94912 100644 --- a/OpenSim/Region/UserStatistics/Sessions_Report.cs +++ b/OpenSim/Region/UserStatistics/Sessions_Report.cs | |||
@@ -278,6 +278,11 @@ TD.align_top { vertical-align: top; } | |||
278 | public DateTime start_time; | 278 | public DateTime start_time; |
279 | } | 279 | } |
280 | 280 | ||
281 | public string RenderJson(Hashtable pModelResult) | ||
282 | { | ||
283 | return "{}"; | ||
284 | } | ||
281 | #endregion | 285 | #endregion |
282 | } | 286 | } |
287 | |||
283 | } | 288 | } |
diff --git a/OpenSim/Region/UserStatistics/SimStatsAJAX.cs b/OpenSim/Region/UserStatistics/SimStatsAJAX.cs index 28051fb..ad848a1 100644 --- a/OpenSim/Region/UserStatistics/SimStatsAJAX.cs +++ b/OpenSim/Region/UserStatistics/SimStatsAJAX.cs | |||
@@ -32,6 +32,7 @@ using System.Reflection; | |||
32 | using System.Text; | 32 | using System.Text; |
33 | using Mono.Data.SqliteClient; | 33 | using Mono.Data.SqliteClient; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenMetaverse.StructuredData; | ||
35 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Framework.Monitoring; | 37 | using OpenSim.Framework.Monitoring; |
37 | 38 | ||
@@ -218,6 +219,64 @@ namespace OpenSim.Region.UserStatistics | |||
218 | return output.ToString(); | 219 | return output.ToString(); |
219 | } | 220 | } |
220 | 221 | ||
222 | /// <summary> | ||
223 | /// Return stat information for all regions in the sim. Returns data of the form: | ||
224 | /// <pre> | ||
225 | /// {"REGIONNAME": { | ||
226 | /// "region": "REGIONNAME", | ||
227 | /// "timeDilation": "101", | ||
228 | /// ... // the rest of the stat info | ||
229 | /// }, | ||
230 | /// ... // entries for each region | ||
231 | /// } | ||
232 | /// </pre> | ||
233 | /// </summary> | ||
234 | /// <param name="pModelResult"></param> | ||
235 | /// <returns></returns> | ||
236 | public string RenderJson(Hashtable pModelResult) | ||
237 | { | ||
238 | List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"]; | ||
239 | Dictionary<UUID, USimStatsData> sdatadic = (Dictionary<UUID,USimStatsData>)pModelResult["simstats"]; | ||
240 | |||
241 | OSDMap allStatsInfo = new OpenMetaverse.StructuredData.OSDMap(); | ||
242 | foreach (USimStatsData sdata in sdatadic.Values) | ||
243 | { | ||
244 | OSDMap statsInfo = new OpenMetaverse.StructuredData.OSDMap(); | ||
245 | string regionName = "unknown"; | ||
246 | foreach (Scene sn in all_scenes) | ||
247 | { | ||
248 | if (sn.RegionInfo.RegionID == sdata.RegionId) | ||
249 | { | ||
250 | regionName = sn.RegionInfo.RegionName; | ||
251 | break; | ||
252 | } | ||
253 | } | ||
254 | statsInfo.Add("region", new OSDString(regionName)); | ||
255 | statsInfo.Add("timeDilation", new OSDString(sdata.TimeDilation.ToString())); | ||
256 | statsInfo.Add("simFPS", new OSDString(sdata.SimFps.ToString())); | ||
257 | statsInfo.Add("physicsFPS", new OSDString(sdata.PhysicsFps.ToString())); | ||
258 | statsInfo.Add("agentUpdates", new OSDString(sdata.AgentUpdates.ToString())); | ||
259 | statsInfo.Add("rootAgents", new OSDString(sdata.RootAgents.ToString())); | ||
260 | statsInfo.Add("childAgents", new OSDString(sdata.ChildAgents.ToString())); | ||
261 | statsInfo.Add("totalPrims", new OSDString(sdata.TotalPrims.ToString())); | ||
262 | statsInfo.Add("activePrims", new OSDString(sdata.ActivePrims.ToString())); | ||
263 | statsInfo.Add("activeScripts", new OSDString(sdata.ActiveScripts.ToString())); | ||
264 | statsInfo.Add("scriptLinesPerSec", new OSDString(sdata.ScriptLinesPerSecond.ToString())); | ||
265 | statsInfo.Add("totalFrameTime", new OSDString(sdata.TotalFrameTime.ToString())); | ||
266 | statsInfo.Add("agentFrameTime", new OSDString(sdata.AgentFrameTime.ToString())); | ||
267 | statsInfo.Add("physicsFrameTime", new OSDString(sdata.PhysicsFrameTime.ToString())); | ||
268 | statsInfo.Add("otherFrameTime", new OSDString(sdata.OtherFrameTime.ToString())); | ||
269 | statsInfo.Add("outPacketsPerSec", new OSDString(sdata.OutPacketsPerSecond.ToString())); | ||
270 | statsInfo.Add("inPacketsPerSec", new OSDString(sdata.InPacketsPerSecond.ToString())); | ||
271 | statsInfo.Add("unackedByptes", new OSDString(sdata.UnackedBytes.ToString())); | ||
272 | statsInfo.Add("pendingDownloads", new OSDString(sdata.PendingDownloads.ToString())); | ||
273 | statsInfo.Add("pendingUploads", new OSDString(sdata.PendingUploads.ToString())); | ||
274 | |||
275 | allStatsInfo.Add(regionName, statsInfo); | ||
276 | } | ||
277 | return allStatsInfo.ToString(); | ||
278 | } | ||
279 | |||
221 | #endregion | 280 | #endregion |
222 | } | 281 | } |
223 | } | 282 | } |
diff --git a/OpenSim/Region/UserStatistics/Updater_distributor.cs b/OpenSim/Region/UserStatistics/Updater_distributor.cs index 9593cc9..601e06b 100644 --- a/OpenSim/Region/UserStatistics/Updater_distributor.cs +++ b/OpenSim/Region/UserStatistics/Updater_distributor.cs | |||
@@ -62,5 +62,9 @@ namespace OpenSim.Region.UserStatistics | |||
62 | return pModelResult["js"].ToString(); | 62 | return pModelResult["js"].ToString(); |
63 | } | 63 | } |
64 | 64 | ||
65 | public string RenderJson(Hashtable pModelResult) { | ||
66 | return "{}"; | ||
67 | } | ||
68 | |||
65 | } | 69 | } |
66 | } \ No newline at end of file | 70 | } \ No newline at end of file |
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index 64cb577..438ef48 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs | |||
@@ -121,6 +121,10 @@ namespace OpenSim.Region.UserStatistics | |||
121 | reports.Add("clients.report", clientReport); | 121 | reports.Add("clients.report", clientReport); |
122 | reports.Add("sessions.report", sessionsReport); | 122 | reports.Add("sessions.report", sessionsReport); |
123 | 123 | ||
124 | reports.Add("sim.css", new Prototype_distributor("sim.css")); | ||
125 | reports.Add("sim.html", new Prototype_distributor("sim.html")); | ||
126 | reports.Add("jquery.js", new Prototype_distributor("jquery.js")); | ||
127 | |||
124 | //// | 128 | //// |
125 | // Add Your own Reports here (Do Not Modify Lines here Devs!) | 129 | // Add Your own Reports here (Do Not Modify Lines here Devs!) |
126 | //// | 130 | //// |
@@ -255,9 +259,12 @@ namespace OpenSim.Region.UserStatistics | |||
255 | string regpath = request["uri"].ToString(); | 259 | string regpath = request["uri"].ToString(); |
256 | int response_code = 404; | 260 | int response_code = 404; |
257 | string contenttype = "text/html"; | 261 | string contenttype = "text/html"; |
262 | bool jsonFormatOutput = false; | ||
258 | 263 | ||
259 | string strOut = string.Empty; | 264 | string strOut = string.Empty; |
260 | 265 | ||
266 | // The request patch should be "/SStats/reportName" where 'reportName' | ||
267 | // is one of the names added to the 'reports' hashmap. | ||
261 | regpath = regpath.Remove(0, 8); | 268 | regpath = regpath.Remove(0, 8); |
262 | if (regpath.Length == 0) regpath = "default.report"; | 269 | if (regpath.Length == 0) regpath = "default.report"; |
263 | if (reports.ContainsKey(regpath)) | 270 | if (reports.ContainsKey(regpath)) |
@@ -265,6 +272,9 @@ namespace OpenSim.Region.UserStatistics | |||
265 | IStatsController rep = reports[regpath]; | 272 | IStatsController rep = reports[regpath]; |
266 | Hashtable repParams = new Hashtable(); | 273 | Hashtable repParams = new Hashtable(); |
267 | 274 | ||
275 | if (request.ContainsKey("json")) | ||
276 | jsonFormatOutput = true; | ||
277 | |||
268 | if (request.ContainsKey("requestvars")) | 278 | if (request.ContainsKey("requestvars")) |
269 | repParams["RequestVars"] = request["requestvars"]; | 279 | repParams["RequestVars"] = request["requestvars"]; |
270 | else | 280 | else |
@@ -284,13 +294,26 @@ namespace OpenSim.Region.UserStatistics | |||
284 | 294 | ||
285 | concurrencyCounter++; | 295 | concurrencyCounter++; |
286 | 296 | ||
287 | strOut = rep.RenderView(rep.ProcessModel(repParams)); | 297 | if (jsonFormatOutput) |
298 | { | ||
299 | strOut = rep.RenderJson(rep.ProcessModel(repParams)); | ||
300 | contenttype = "text/json"; | ||
301 | } | ||
302 | else | ||
303 | { | ||
304 | strOut = rep.RenderView(rep.ProcessModel(repParams)); | ||
305 | } | ||
288 | 306 | ||
289 | if (regpath.EndsWith("js")) | 307 | if (regpath.EndsWith("js")) |
290 | { | 308 | { |
291 | contenttype = "text/javascript"; | 309 | contenttype = "text/javascript"; |
292 | } | 310 | } |
293 | 311 | ||
312 | if (regpath.EndsWith("css")) | ||
313 | { | ||
314 | contenttype = "text/css"; | ||
315 | } | ||
316 | |||
294 | concurrencyCounter--; | 317 | concurrencyCounter--; |
295 | 318 | ||
296 | response_code = 200; | 319 | response_code = 200; |