SimStatsAJAX.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Reflection;
  31. using System.Text;
  32. using Mono.Data.SqliteClient;
  33. using OpenMetaverse;
  34. using OpenSim.Region.Framework.Scenes;
  35. using OpenSim.Framework.Statistics;
  36. namespace OpenSim.Region.UserStatistics
  37. {
  38. public class SimStatsAJAX : IStatsController
  39. {
  40. #region IStatsController Members
  41. public string ReportName
  42. {
  43. get { return ""; }
  44. }
  45. public Hashtable ProcessModel(Hashtable pParams)
  46. {
  47. List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
  48. Hashtable nh = new Hashtable();
  49. nh.Add("hdata", m_scene);
  50. nh.Add("simstats", pParams["SimStats"]);
  51. return nh;
  52. }
  53. public string RenderView(Hashtable pModelResult)
  54. {
  55. StringBuilder output = new StringBuilder();
  56. List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
  57. Dictionary<UUID, USimStatsData> sdatadic = (Dictionary<UUID,USimStatsData>)pModelResult["simstats"];
  58. const string TableClass = "defaultr";
  59. const string TRClass = "defaultr";
  60. const string TDHeaderClass = "header";
  61. const string TDDataClass = "content";
  62. //const string TDDataClassRight = "contentright";
  63. const string TDDataClassCenter = "contentcenter";
  64. foreach (USimStatsData sdata in sdatadic.Values)
  65. {
  66. foreach (Scene sn in all_scenes)
  67. {
  68. if (sn.RegionInfo.RegionID == sdata.RegionId)
  69. {
  70. output.Append("<H2>");
  71. output.Append(sn.RegionInfo.RegionName);
  72. output.Append("</H2>");
  73. }
  74. }
  75. HTMLUtil.TABLE_O(ref output, TableClass);
  76. HTMLUtil.TR_O(ref output, TRClass);
  77. HTMLUtil.TD_O(ref output, TDHeaderClass);
  78. output.Append("Dilatn");
  79. HTMLUtil.TD_C(ref output);
  80. HTMLUtil.TD_O(ref output, TDHeaderClass);
  81. output.Append("SimFPS");
  82. HTMLUtil.TD_C(ref output);
  83. HTMLUtil.TD_O(ref output, TDHeaderClass);
  84. output.Append("PhysFPS");
  85. HTMLUtil.TD_C(ref output);
  86. HTMLUtil.TD_O(ref output, TDHeaderClass);
  87. output.Append("AgntUp");
  88. HTMLUtil.TD_C(ref output);
  89. HTMLUtil.TD_O(ref output, TDHeaderClass);
  90. output.Append("RootAg");
  91. HTMLUtil.TD_C(ref output);
  92. HTMLUtil.TD_O(ref output, TDHeaderClass);
  93. output.Append("ChldAg");
  94. HTMLUtil.TD_C(ref output);
  95. HTMLUtil.TD_O(ref output, TDHeaderClass);
  96. output.Append("Prims");
  97. HTMLUtil.TD_C(ref output);
  98. HTMLUtil.TD_O(ref output, TDHeaderClass);
  99. output.Append("ATvPrm");
  100. HTMLUtil.TD_C(ref output);
  101. HTMLUtil.TD_O(ref output, TDHeaderClass);
  102. output.Append("AtvScr");
  103. HTMLUtil.TD_C(ref output);
  104. HTMLUtil.TD_O(ref output, TDHeaderClass);
  105. output.Append("ScrLPS");
  106. HTMLUtil.TD_C(ref output);
  107. HTMLUtil.TR_C(ref output);
  108. HTMLUtil.TR_O(ref output, TRClass);
  109. HTMLUtil.TD_O(ref output, TDDataClass);
  110. output.Append(sdata.TimeDilation);
  111. HTMLUtil.TD_C(ref output);
  112. HTMLUtil.TD_O(ref output, TDDataClass);
  113. output.Append(sdata.SimFps);
  114. HTMLUtil.TD_C(ref output);
  115. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  116. output.Append(sdata.PhysicsFps);
  117. HTMLUtil.TD_C(ref output);
  118. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  119. output.Append(sdata.AgentUpdates);
  120. HTMLUtil.TD_C(ref output);
  121. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  122. output.Append(sdata.RootAgents);
  123. HTMLUtil.TD_C(ref output);
  124. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  125. output.Append(sdata.ChildAgents);
  126. HTMLUtil.TD_C(ref output);
  127. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  128. output.Append(sdata.TotalPrims);
  129. HTMLUtil.TD_C(ref output);
  130. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  131. output.Append(sdata.ActivePrims);
  132. HTMLUtil.TD_C(ref output);
  133. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  134. output.Append(sdata.ActiveScripts);
  135. HTMLUtil.TD_C(ref output);
  136. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  137. output.Append(sdata.ScriptLinesPerSecond);
  138. HTMLUtil.TD_C(ref output);
  139. HTMLUtil.TR_C(ref output);
  140. HTMLUtil.TR_O(ref output, TRClass);
  141. HTMLUtil.TD_O(ref output, TDHeaderClass);
  142. output.Append("FrmMS");
  143. HTMLUtil.TD_C(ref output);
  144. HTMLUtil.TD_O(ref output, TDHeaderClass);
  145. output.Append("AgtMS");
  146. HTMLUtil.TD_C(ref output);
  147. HTMLUtil.TD_O(ref output, TDHeaderClass);
  148. output.Append("PhysMS");
  149. HTMLUtil.TD_C(ref output);
  150. HTMLUtil.TD_O(ref output, TDHeaderClass);
  151. output.Append("OthrMS");
  152. HTMLUtil.TD_C(ref output);
  153. HTMLUtil.TD_O(ref output, TDHeaderClass);
  154. output.Append("ScrLPS");
  155. HTMLUtil.TD_C(ref output);
  156. HTMLUtil.TD_O(ref output, TDHeaderClass);
  157. output.Append("OutPPS");
  158. HTMLUtil.TD_C(ref output);
  159. HTMLUtil.TD_O(ref output, TDHeaderClass);
  160. output.Append("InPPS");
  161. HTMLUtil.TD_C(ref output);
  162. HTMLUtil.TD_O(ref output, TDHeaderClass);
  163. output.Append("NoAckKB");
  164. HTMLUtil.TD_C(ref output);
  165. HTMLUtil.TD_O(ref output, TDHeaderClass);
  166. output.Append("PndDWN");
  167. HTMLUtil.TD_C(ref output);
  168. HTMLUtil.TD_O(ref output, TDHeaderClass);
  169. output.Append("PndUP");
  170. HTMLUtil.TD_C(ref output);
  171. HTMLUtil.TR_C(ref output);
  172. HTMLUtil.TR_O(ref output, TRClass);
  173. HTMLUtil.TD_O(ref output, TDDataClass);
  174. output.Append(sdata.TotalFrameTime);
  175. HTMLUtil.TD_C(ref output);
  176. HTMLUtil.TD_O(ref output, TDDataClass);
  177. output.Append(sdata.AgentFrameTime);
  178. HTMLUtil.TD_C(ref output);
  179. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  180. output.Append(sdata.PhysicsFrameTime);
  181. HTMLUtil.TD_C(ref output);
  182. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  183. output.Append(sdata.OtherFrameTime);
  184. HTMLUtil.TD_C(ref output);
  185. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  186. output.Append(sdata.ScriptLinesPerSecond);
  187. HTMLUtil.TD_C(ref output);
  188. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  189. output.Append(sdata.OutPacketsPerSecond);
  190. HTMLUtil.TD_C(ref output);
  191. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  192. output.Append(sdata.InPacketsPerSecond);
  193. HTMLUtil.TD_C(ref output);
  194. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  195. output.Append(sdata.UnackedBytes);
  196. HTMLUtil.TD_C(ref output);
  197. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  198. output.Append(sdata.PendingDownloads);
  199. HTMLUtil.TD_C(ref output);
  200. HTMLUtil.TD_O(ref output, TDDataClassCenter);
  201. output.Append(sdata.PendingUploads);
  202. HTMLUtil.TD_C(ref output);
  203. HTMLUtil.TR_C(ref output);
  204. HTMLUtil.TABLE_C(ref output);
  205. }
  206. return output.ToString();
  207. }
  208. #endregion
  209. }
  210. }