aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/UserStatistics/Default_Report.cs
diff options
context:
space:
mode:
authorTeravus Ovares2009-01-03 03:30:03 +0000
committerTeravus Ovares2009-01-03 03:30:03 +0000
commite9cef70f892bfbf4aad0e4471a958367766d849a (patch)
tree397e078977b430526a2f04041e0dfb9a5fb99156 /OpenSim/Region/UserStatistics/Default_Report.cs
parentSplit agent updates into two messages: full update and position+camera update... (diff)
downloadopensim-SC_OLD-e9cef70f892bfbf4aad0e4471a958367766d849a.zip
opensim-SC_OLD-e9cef70f892bfbf4aad0e4471a958367766d849a.tar.gz
opensim-SC_OLD-e9cef70f892bfbf4aad0e4471a958367766d849a.tar.bz2
opensim-SC_OLD-e9cef70f892bfbf4aad0e4471a958367766d849a.tar.xz
* Updates the sim stats module. Cleans out some of the rot.
* Adds a prototype web stats module which is disabled by default. It's functional with one report right now, however, the database structure may change, so I don't recommend enabling this to keep actual stats right now. I'll let you know when it's safe. * Adds Prototype for ajaxy web content * removed a warning or two.
Diffstat (limited to 'OpenSim/Region/UserStatistics/Default_Report.cs')
-rw-r--r--OpenSim/Region/UserStatistics/Default_Report.cs215
1 files changed, 215 insertions, 0 deletions
diff --git a/OpenSim/Region/UserStatistics/Default_Report.cs b/OpenSim/Region/UserStatistics/Default_Report.cs
new file mode 100644
index 0000000..02b15ad
--- /dev/null
+++ b/OpenSim/Region/UserStatistics/Default_Report.cs
@@ -0,0 +1,215 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Reflection;
5using System.Text;
6using Mono.Data.SqliteClient;
7using OpenMetaverse;
8using OpenSim.Region.Environment.Scenes;
9using OpenSim.Framework.Statistics;
10
11
12namespace OpenSim.Region.UserStatistics
13{
14 public class Default_Report : IStatsController
15 {
16
17 public Default_Report()
18 {
19
20 }
21
22 #region IStatsController Members
23
24 public Hashtable ProcessModel(Hashtable pParams)
25 {
26 SqliteConnection conn = (SqliteConnection)pParams["DatabaseConnection"];
27 List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
28
29 stats_default_page_values mData = rep_DefaultReport_data(conn, m_scene);
30 mData.sim_stat_data = (Dictionary<UUID,USimStatsData>)pParams["SimStats"];
31
32 Hashtable nh = new Hashtable();
33 nh.Add("hdata", mData);
34
35 return nh;
36 }
37
38 public string RenderView(Hashtable pModelResult)
39 {
40 stats_default_page_values mData = (stats_default_page_values) pModelResult["hdata"];
41 return rep_Default_report_view(mData);
42 }
43
44 #endregion
45
46 public string rep_Default_report_view(stats_default_page_values values)
47 {
48
49 StringBuilder output = new StringBuilder();
50
51
52
53 const string TableClass = "defaultr";
54 const string TRClass = "defaultr";
55 const string TDHeaderClass = "header";
56 const string TDDataClass = "content";
57 //const string TDDataClassRight = "contentright";
58 const string TDDataClassCenter = "contentcenter";
59
60 const string STYLESHEET =
61 @"
62<STYLE>
63body
64{
65 font-size:15px; font-family:Helvetica, Verdana; color:Black;
66}
67TABLE.defaultr { }
68TR.defaultr { padding: 5px; }
69TD.header { font-weight:bold; padding:5px; }
70TD.content {}
71TD.contentright { text-align: right; }
72TD.contentcenter { text-align: center; }
73TD.align_top { vertical-align: top; }
74</STYLE>
75";
76 HTMLUtil.HtmlHeaders_O(ref output);
77
78 HTMLUtil.InsertProtoTypeAJAX(ref output);
79 string[] ajaxUpdaterDivs = new string[2];
80 int[] ajaxUpdaterSeconds = new int[2];
81 string[] ajaxUpdaterReportFragments = new string[2];
82
83 ajaxUpdaterDivs[0] = "activeconnections";
84 ajaxUpdaterSeconds[0] = 10;
85 ajaxUpdaterReportFragments[0] = "activeconnectionsajax.ajax";
86
87 ajaxUpdaterDivs[1] = "activesimstats";
88 ajaxUpdaterSeconds[1] = 20;
89 ajaxUpdaterReportFragments[1] = "simstatsajax.ajax";
90
91 HTMLUtil.InsertPeriodicUpdaters(ref output, ajaxUpdaterDivs, ajaxUpdaterSeconds, ajaxUpdaterReportFragments);
92
93 output.Append(STYLESHEET);
94 HTMLUtil.HtmlHeaders_C(ref output);
95
96 HTMLUtil.TABLE_O(ref output, TableClass);
97 HTMLUtil.TR_O(ref output, TRClass);
98 HTMLUtil.TD_O(ref output, TDHeaderClass);
99 output.Append("# Users Total");
100 HTMLUtil.TD_C(ref output);
101 HTMLUtil.TD_O(ref output, TDHeaderClass);
102 output.Append("# Sessions Total");
103 HTMLUtil.TD_C(ref output);
104 HTMLUtil.TD_O(ref output, TDHeaderClass);
105 output.Append("Avg Client FPS");
106 HTMLUtil.TD_C(ref output);
107 HTMLUtil.TD_O(ref output, TDHeaderClass);
108 output.Append("Avg Client Mem Use");
109 HTMLUtil.TD_C(ref output);
110 HTMLUtil.TD_O(ref output, TDHeaderClass);
111 output.Append("Avg Sim FPS");
112 HTMLUtil.TD_C(ref output);
113 HTMLUtil.TD_O(ref output, TDHeaderClass);
114 output.Append("Avg Ping");
115 HTMLUtil.TD_C(ref output);
116 HTMLUtil.TD_O(ref output, TDHeaderClass);
117 output.Append("KB Out Total");
118 HTMLUtil.TD_C(ref output);
119 HTMLUtil.TD_O(ref output, TDHeaderClass);
120 output.Append("KB In Total");
121 HTMLUtil.TD_C(ref output);
122 HTMLUtil.TR_C(ref output);
123 HTMLUtil.TR_O(ref output, TRClass);
124 HTMLUtil.TD_O(ref output, TDDataClass);
125 output.Append(values.total_num_users);
126 HTMLUtil.TD_C(ref output);
127 HTMLUtil.TD_O(ref output, TDDataClass);
128 output.Append(values.total_num_sessions);
129 HTMLUtil.TD_C(ref output);
130 HTMLUtil.TD_O(ref output, TDDataClassCenter);
131 output.Append(values.avg_client_fps);
132 HTMLUtil.TD_C(ref output);
133 HTMLUtil.TD_O(ref output, TDDataClassCenter);
134 output.Append(values.avg_client_mem_use);
135 HTMLUtil.TD_C(ref output);
136 HTMLUtil.TD_O(ref output, TDDataClassCenter);
137 output.Append(values.avg_sim_fps);
138 HTMLUtil.TD_C(ref output);
139 HTMLUtil.TD_O(ref output, TDDataClassCenter);
140 output.Append(values.avg_ping);
141 HTMLUtil.TD_C(ref output);
142 HTMLUtil.TD_O(ref output, TDDataClassCenter);
143 output.Append(values.total_kb_out);
144 HTMLUtil.TD_C(ref output);
145 HTMLUtil.TD_O(ref output, TDDataClassCenter);
146 output.Append(values.total_kb_in);
147 HTMLUtil.TD_C(ref output);
148 HTMLUtil.TR_C(ref output);
149 HTMLUtil.TABLE_C(ref output);
150
151 HTMLUtil.HR(ref output, "");
152 HTMLUtil.TABLE_O(ref output, "");
153 HTMLUtil.TR_O(ref output, "");
154 HTMLUtil.TD_O(ref output, "align_top");
155 output.Append("<DIV id=\"activeconnections\">loading...</DIV>");
156 HTMLUtil.TD_C(ref output);
157 HTMLUtil.TD_O(ref output, "align_top");
158 output.Append("<DIV id=\"activesimstats\">loading...</DIV>");
159
160 HTMLUtil.TD_C(ref output);
161 HTMLUtil.TR_C(ref output);
162 HTMLUtil.TABLE_C(ref output);
163 output.Append("</BODY></HTML>");
164 // TODO: FIXME: template
165 return output.ToString();
166 }
167
168
169
170 public stats_default_page_values rep_DefaultReport_data(SqliteConnection db, List<Scene> m_scene)
171 {
172 stats_default_page_values returnstruct = new stats_default_page_values();
173 returnstruct.all_scenes = m_scene.ToArray();
174 lock (db)
175 {
176 string SQL = @"SELECT COUNT(DISTINCT agent_id) as agents, COUNT(*) as sessions, AVG(avg_fps) as client_fps,
177 AVG(avg_sim_fps) as savg_sim_fps, AVG(avg_ping) as sav_ping, SUM(n_out_kb) as num_in_kb,
178 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
179 FROM stats_session_data;";
180 SqliteCommand cmd = new SqliteCommand(SQL, db);
181 SqliteDataReader sdr = cmd.ExecuteReader();
182 if (sdr.HasRows)
183 {
184 sdr.Read();
185 returnstruct.total_num_users = Convert.ToInt32(sdr["agents"]);
186 returnstruct.total_num_sessions = Convert.ToInt32(sdr["sessions"]);
187 returnstruct.avg_client_fps = Convert.ToSingle(sdr["client_fps"]);
188 returnstruct.avg_sim_fps = Convert.ToSingle(sdr["savg_sim_fps"]);
189 returnstruct.avg_ping = Convert.ToSingle(sdr["sav_ping"]);
190 returnstruct.total_kb_out = Convert.ToSingle(sdr["num_out_kb"]);
191 returnstruct.total_kb_in = Convert.ToSingle(sdr["num_in_kb"]);
192 returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]);
193
194 }
195 }
196 return returnstruct;
197 }
198
199 }
200
201 public struct stats_default_page_values
202 {
203 public int total_num_users;
204 public int total_num_sessions;
205 public float avg_client_fps;
206 public float avg_client_mem_use;
207 public float avg_sim_fps;
208 public float avg_ping;
209 public float total_kb_out;
210 public float total_kb_in;
211 public float avg_client_resends;
212 public Scene[] all_scenes;
213 public Dictionary<UUID, USimStatsData> sim_stat_data;
214 }
215}