aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs
diff options
context:
space:
mode:
authorRobert Adams2015-09-08 04:54:16 -0700
committerRobert Adams2015-09-08 04:54:16 -0700
commite5367d822be9b05e74c859afe2d2956a3e95aa33 (patch)
treee904050a30715df587aa527d7f313755177726a7 /OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs
parentadd lost admin_reset_land method (diff)
parentDeleted access control spec from [LoginService] section of standalone config.... (diff)
downloadopensim-SC-e5367d822be9b05e74c859afe2d2956a3e95aa33.zip
opensim-SC-e5367d822be9b05e74c859afe2d2956a3e95aa33.tar.gz
opensim-SC-e5367d822be9b05e74c859afe2d2956a3e95aa33.tar.bz2
opensim-SC-e5367d822be9b05e74c859afe2d2956a3e95aa33.tar.xz
Merge of ubitworkvarnew with opensim/master as of 20150905.
This integrates the OpenSim refactoring to make physics, etc into modules. AVN physics hasn't been moved to new location. Does not compile yet. Merge branch 'osmaster' into mbworknew1
Diffstat (limited to 'OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs')
-rw-r--r--OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs276
1 files changed, 276 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs b/OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs
new file mode 100644
index 0000000..06d9e91
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs
@@ -0,0 +1,276 @@
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 OpenMetaverse.StructuredData;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Framework.Monitoring;
38
39namespace OpenSim.Region.UserStatistics
40{
41 public class SimStatsAJAX : IStatsController
42 {
43 #region IStatsController Members
44
45 public string ReportName
46 {
47 get { return ""; }
48 }
49
50 public Hashtable ProcessModel(Hashtable pParams)
51 {
52 List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
53
54 Hashtable nh = new Hashtable();
55 nh.Add("hdata", m_scene);
56 nh.Add("simstats", pParams["SimStats"]);
57 return nh;
58 }
59
60 public string RenderView(Hashtable pModelResult)
61 {
62 StringBuilder output = new StringBuilder();
63 List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
64 Dictionary<UUID, USimStatsData> sdatadic = (Dictionary<UUID,USimStatsData>)pModelResult["simstats"];
65
66 const string TableClass = "defaultr";
67 const string TRClass = "defaultr";
68 const string TDHeaderClass = "header";
69 const string TDDataClass = "content";
70 //const string TDDataClassRight = "contentright";
71 const string TDDataClassCenter = "contentcenter";
72
73 foreach (USimStatsData sdata in sdatadic.Values)
74 {
75
76
77 foreach (Scene sn in all_scenes)
78 {
79 if (sn.RegionInfo.RegionID == sdata.RegionId)
80 {
81 output.Append("<H2>");
82 output.Append(sn.RegionInfo.RegionName);
83 output.Append("</H2>");
84 }
85 }
86 HTMLUtil.TABLE_O(ref output, TableClass);
87 HTMLUtil.TR_O(ref output, TRClass);
88 HTMLUtil.TD_O(ref output, TDHeaderClass);
89 output.Append("Dilatn");
90 HTMLUtil.TD_C(ref output);
91 HTMLUtil.TD_O(ref output, TDHeaderClass);
92 output.Append("SimFPS");
93 HTMLUtil.TD_C(ref output);
94 HTMLUtil.TD_O(ref output, TDHeaderClass);
95 output.Append("PhysFPS");
96 HTMLUtil.TD_C(ref output);
97 HTMLUtil.TD_O(ref output, TDHeaderClass);
98 output.Append("AgntUp");
99 HTMLUtil.TD_C(ref output);
100 HTMLUtil.TD_O(ref output, TDHeaderClass);
101 output.Append("RootAg");
102 HTMLUtil.TD_C(ref output);
103 HTMLUtil.TD_O(ref output, TDHeaderClass);
104 output.Append("ChldAg");
105 HTMLUtil.TD_C(ref output);
106 HTMLUtil.TD_O(ref output, TDHeaderClass);
107 output.Append("Prims");
108 HTMLUtil.TD_C(ref output);
109 HTMLUtil.TD_O(ref output, TDHeaderClass);
110 output.Append("ATvPrm");
111 HTMLUtil.TD_C(ref output);
112 HTMLUtil.TD_O(ref output, TDHeaderClass);
113 output.Append("AtvScr");
114 HTMLUtil.TD_C(ref output);
115 HTMLUtil.TD_O(ref output, TDHeaderClass);
116 output.Append("ScrLPS");
117 HTMLUtil.TD_C(ref output);
118 HTMLUtil.TR_C(ref output);
119 HTMLUtil.TR_O(ref output, TRClass);
120 HTMLUtil.TD_O(ref output, TDDataClass);
121 output.Append(sdata.TimeDilation);
122 HTMLUtil.TD_C(ref output);
123 HTMLUtil.TD_O(ref output, TDDataClass);
124 output.Append(sdata.SimFps);
125 HTMLUtil.TD_C(ref output);
126 HTMLUtil.TD_O(ref output, TDDataClassCenter);
127 output.Append(sdata.PhysicsFps);
128 HTMLUtil.TD_C(ref output);
129 HTMLUtil.TD_O(ref output, TDDataClassCenter);
130 output.Append(sdata.AgentUpdates);
131 HTMLUtil.TD_C(ref output);
132 HTMLUtil.TD_O(ref output, TDDataClassCenter);
133 output.Append(sdata.RootAgents);
134 HTMLUtil.TD_C(ref output);
135 HTMLUtil.TD_O(ref output, TDDataClassCenter);
136 output.Append(sdata.ChildAgents);
137 HTMLUtil.TD_C(ref output);
138 HTMLUtil.TD_O(ref output, TDDataClassCenter);
139 output.Append(sdata.TotalPrims);
140 HTMLUtil.TD_C(ref output);
141 HTMLUtil.TD_O(ref output, TDDataClassCenter);
142 output.Append(sdata.ActivePrims);
143 HTMLUtil.TD_C(ref output);
144 HTMLUtil.TD_O(ref output, TDDataClassCenter);
145 output.Append(sdata.ActiveScripts);
146 HTMLUtil.TD_C(ref output);
147 HTMLUtil.TD_O(ref output, TDDataClassCenter);
148 output.Append(sdata.ScriptLinesPerSecond);
149 HTMLUtil.TD_C(ref output);
150 HTMLUtil.TR_C(ref output);
151 HTMLUtil.TR_O(ref output, TRClass);
152 HTMLUtil.TD_O(ref output, TDHeaderClass);
153 output.Append("FrmMS");
154 HTMLUtil.TD_C(ref output);
155 HTMLUtil.TD_O(ref output, TDHeaderClass);
156 output.Append("AgtMS");
157 HTMLUtil.TD_C(ref output);
158 HTMLUtil.TD_O(ref output, TDHeaderClass);
159 output.Append("PhysMS");
160 HTMLUtil.TD_C(ref output);
161 HTMLUtil.TD_O(ref output, TDHeaderClass);
162 output.Append("OthrMS");
163 HTMLUtil.TD_C(ref output);
164 HTMLUtil.TD_O(ref output, TDHeaderClass);
165 output.Append("OutPPS");
166 HTMLUtil.TD_C(ref output);
167 HTMLUtil.TD_O(ref output, TDHeaderClass);
168 output.Append("InPPS");
169 HTMLUtil.TD_C(ref output);
170 HTMLUtil.TD_O(ref output, TDHeaderClass);
171 output.Append("NoAckKB");
172 HTMLUtil.TD_C(ref output);
173 HTMLUtil.TD_O(ref output, TDHeaderClass);
174 output.Append("PndDWN");
175 HTMLUtil.TD_C(ref output);
176 HTMLUtil.TD_O(ref output, TDHeaderClass);
177 output.Append("PndUP");
178 HTMLUtil.TD_C(ref output);
179 HTMLUtil.TR_C(ref output);
180 HTMLUtil.TR_O(ref output, TRClass);
181 HTMLUtil.TD_O(ref output, TDDataClass);
182 output.Append(sdata.TotalFrameTime);
183 HTMLUtil.TD_C(ref output);
184 HTMLUtil.TD_O(ref output, TDDataClass);
185 output.Append(sdata.AgentFrameTime);
186 HTMLUtil.TD_C(ref output);
187 HTMLUtil.TD_O(ref output, TDDataClassCenter);
188 output.Append(sdata.PhysicsFrameTime);
189 HTMLUtil.TD_C(ref output);
190 HTMLUtil.TD_O(ref output, TDDataClassCenter);
191 output.Append(sdata.OtherFrameTime);
192 HTMLUtil.TD_C(ref output);
193 HTMLUtil.TD_O(ref output, TDDataClassCenter);
194 output.Append(sdata.OutPacketsPerSecond);
195 HTMLUtil.TD_C(ref output);
196 HTMLUtil.TD_O(ref output, TDDataClassCenter);
197 output.Append(sdata.InPacketsPerSecond);
198 HTMLUtil.TD_C(ref output);
199 HTMLUtil.TD_O(ref output, TDDataClassCenter);
200 output.Append(sdata.UnackedBytes);
201 HTMLUtil.TD_C(ref output);
202 HTMLUtil.TD_O(ref output, TDDataClassCenter);
203 output.Append(sdata.PendingDownloads);
204 HTMLUtil.TD_C(ref output);
205 HTMLUtil.TD_O(ref output, TDDataClassCenter);
206 output.Append(sdata.PendingUploads);
207 HTMLUtil.TD_C(ref output);
208 HTMLUtil.TR_C(ref output);
209 HTMLUtil.TABLE_C(ref output);
210
211 }
212
213 return output.ToString();
214 }
215
216 /// <summary>
217 /// Return stat information for all regions in the sim. Returns data of the form:
218 /// <pre>
219 /// {"REGIONNAME": {
220 /// "region": "REGIONNAME",
221 /// "timeDilation": "101",
222 /// ... // the rest of the stat info
223 /// },
224 /// ... // entries for each region
225 /// }
226 /// </pre>
227 /// </summary>
228 /// <param name="pModelResult"></param>
229 /// <returns></returns>
230 public string RenderJson(Hashtable pModelResult)
231 {
232 List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
233 Dictionary<UUID, USimStatsData> sdatadic = (Dictionary<UUID,USimStatsData>)pModelResult["simstats"];
234
235 OSDMap allStatsInfo = new OpenMetaverse.StructuredData.OSDMap();
236 foreach (USimStatsData sdata in sdatadic.Values)
237 {
238 OSDMap statsInfo = new OpenMetaverse.StructuredData.OSDMap();
239 string regionName = "unknown";
240 foreach (Scene sn in all_scenes)
241 {
242 if (sn.RegionInfo.RegionID == sdata.RegionId)
243 {
244 regionName = sn.RegionInfo.RegionName;
245 break;
246 }
247 }
248 statsInfo.Add("region", new OSDString(regionName));
249 statsInfo.Add("timeDilation", new OSDString(sdata.TimeDilation.ToString()));
250 statsInfo.Add("simFPS", new OSDString(sdata.SimFps.ToString()));
251 statsInfo.Add("physicsFPS", new OSDString(sdata.PhysicsFps.ToString()));
252 statsInfo.Add("agentUpdates", new OSDString(sdata.AgentUpdates.ToString()));
253 statsInfo.Add("rootAgents", new OSDString(sdata.RootAgents.ToString()));
254 statsInfo.Add("childAgents", new OSDString(sdata.ChildAgents.ToString()));
255 statsInfo.Add("totalPrims", new OSDString(sdata.TotalPrims.ToString()));
256 statsInfo.Add("activePrims", new OSDString(sdata.ActivePrims.ToString()));
257 statsInfo.Add("activeScripts", new OSDString(sdata.ActiveScripts.ToString()));
258 statsInfo.Add("scriptLinesPerSec", new OSDString(sdata.ScriptLinesPerSecond.ToString()));
259 statsInfo.Add("totalFrameTime", new OSDString(sdata.TotalFrameTime.ToString()));
260 statsInfo.Add("agentFrameTime", new OSDString(sdata.AgentFrameTime.ToString()));
261 statsInfo.Add("physicsFrameTime", new OSDString(sdata.PhysicsFrameTime.ToString()));
262 statsInfo.Add("otherFrameTime", new OSDString(sdata.OtherFrameTime.ToString()));
263 statsInfo.Add("outPacketsPerSec", new OSDString(sdata.OutPacketsPerSecond.ToString()));
264 statsInfo.Add("inPacketsPerSec", new OSDString(sdata.InPacketsPerSecond.ToString()));
265 statsInfo.Add("unackedByptes", new OSDString(sdata.UnackedBytes.ToString()));
266 statsInfo.Add("pendingDownloads", new OSDString(sdata.PendingDownloads.ToString()));
267 statsInfo.Add("pendingUploads", new OSDString(sdata.PendingUploads.ToString()));
268
269 allStatsInfo.Add(regionName, statsInfo);
270 }
271 return allStatsInfo.ToString();
272 }
273
274 #endregion
275 }
276}