29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Reflection;
33 using Mono.Data.SqliteClient;
35 using OpenMetaverse.StructuredData;
36 using OpenSim.Region.Framework.Scenes;
37 using OpenSim.Framework.Monitoring;
40 namespace OpenSim.
Region.UserStatistics
45 public string ReportName
47 get {
return "Home"; }
50 #region IStatsController Members
54 SqliteConnection conn = (SqliteConnection)pParams[
"DatabaseConnection"];
55 List<Scene> m_scene = (List<Scene>)pParams[
"Scenes"];
58 mData.sim_stat_data = (Dictionary<UUID,USimStatsData>)pParams[
"SimStats"];
59 mData.stats_reports = (Dictionary<string, IStatsController>) pParams[
"Reports"];
61 Hashtable nh =
new Hashtable();
62 nh.Add(
"hdata", mData);
63 nh.Add(
"Reports", pParams[
"Reports"]);
71 return rep_Default_report_view(mData);
80 StringBuilder output =
new StringBuilder();
84 const string TableClass =
"defaultr";
85 const string TRClass =
"defaultr";
86 const string TDHeaderClass =
"header";
87 const string TDDataClass =
"content";
89 const string TDDataClassCenter =
"contentcenter";
91 const string STYLESHEET =
96 font-size:15px; font-family:Helvetica, Verdana; color:Black;
99 TR.defaultr { padding: 5px; }
100 TD.header { font-weight:bold; padding:5px; }
102 TD.contentright { text-align: right; }
103 TD.contentcenter { text-align: center; }
104 TD.align_top { vertical-align: top; }
107 HTMLUtil.HtmlHeaders_O(ref output);
109 HTMLUtil.InsertProtoTypeAJAX(ref output);
110 string[] ajaxUpdaterDivs =
new string[3];
111 int[] ajaxUpdaterSeconds =
new int[3];
112 string[] ajaxUpdaterReportFragments =
new string[3];
114 ajaxUpdaterDivs[0] =
"activeconnections";
115 ajaxUpdaterSeconds[0] = 10;
116 ajaxUpdaterReportFragments[0] =
"activeconnectionsajax.html";
118 ajaxUpdaterDivs[1] =
"activesimstats";
119 ajaxUpdaterSeconds[1] = 20;
120 ajaxUpdaterReportFragments[1] =
"simstatsajax.html";
122 ajaxUpdaterDivs[2] =
"activelog";
123 ajaxUpdaterSeconds[2] = 5;
124 ajaxUpdaterReportFragments[2] =
"activelogajax.html";
126 HTMLUtil.InsertPeriodicUpdaters(ref output, ajaxUpdaterDivs, ajaxUpdaterSeconds, ajaxUpdaterReportFragments);
128 output.Append(STYLESHEET);
129 HTMLUtil.HtmlHeaders_C(ref output);
130 HTMLUtil.AddReportLinks(ref output, values.stats_reports,
"");
131 HTMLUtil.TABLE_O(ref output, TableClass);
132 HTMLUtil.TR_O(ref output, TRClass);
133 HTMLUtil.TD_O(ref output, TDHeaderClass);
134 output.Append(
"# Users Total");
135 HTMLUtil.TD_C(ref output);
136 HTMLUtil.TD_O(ref output, TDHeaderClass);
137 output.Append(
"# Sessions Total");
138 HTMLUtil.TD_C(ref output);
139 HTMLUtil.TD_O(ref output, TDHeaderClass);
140 output.Append(
"Avg Client FPS");
141 HTMLUtil.TD_C(ref output);
142 HTMLUtil.TD_O(ref output, TDHeaderClass);
143 output.Append(
"Avg Client Mem Use");
144 HTMLUtil.TD_C(ref output);
145 HTMLUtil.TD_O(ref output, TDHeaderClass);
146 output.Append(
"Avg Sim FPS");
147 HTMLUtil.TD_C(ref output);
148 HTMLUtil.TD_O(ref output, TDHeaderClass);
149 output.Append(
"Avg Ping");
150 HTMLUtil.TD_C(ref output);
151 HTMLUtil.TD_O(ref output, TDHeaderClass);
152 output.Append(
"KB Out Total");
153 HTMLUtil.TD_C(ref output);
154 HTMLUtil.TD_O(ref output, TDHeaderClass);
155 output.Append(
"KB In Total");
156 HTMLUtil.TD_C(ref output);
157 HTMLUtil.TR_C(ref output);
158 HTMLUtil.TR_O(ref output, TRClass);
159 HTMLUtil.TD_O(ref output, TDDataClass);
160 output.Append(values.total_num_users);
161 HTMLUtil.TD_C(ref output);
162 HTMLUtil.TD_O(ref output, TDDataClass);
163 output.Append(values.total_num_sessions);
164 HTMLUtil.TD_C(ref output);
165 HTMLUtil.TD_O(ref output, TDDataClassCenter);
166 output.Append(values.avg_client_fps);
167 HTMLUtil.TD_C(ref output);
168 HTMLUtil.TD_O(ref output, TDDataClassCenter);
169 output.Append(values.avg_client_mem_use);
170 HTMLUtil.TD_C(ref output);
171 HTMLUtil.TD_O(ref output, TDDataClassCenter);
172 output.Append(values.avg_sim_fps);
173 HTMLUtil.TD_C(ref output);
174 HTMLUtil.TD_O(ref output, TDDataClassCenter);
175 output.Append(values.avg_ping);
176 HTMLUtil.TD_C(ref output);
177 HTMLUtil.TD_O(ref output, TDDataClassCenter);
178 output.Append(values.total_kb_out);
179 HTMLUtil.TD_C(ref output);
180 HTMLUtil.TD_O(ref output, TDDataClassCenter);
181 output.Append(values.total_kb_in);
182 HTMLUtil.TD_C(ref output);
183 HTMLUtil.TR_C(ref output);
184 HTMLUtil.TABLE_C(ref output);
186 HTMLUtil.HR(ref output,
"");
187 HTMLUtil.TABLE_O(ref output,
"");
188 HTMLUtil.TR_O(ref output,
"");
189 HTMLUtil.TD_O(ref output,
"align_top");
190 output.Append(
"<DIV id=\"activeconnections\">Active Connections loading...</DIV>");
191 HTMLUtil.TD_C(ref output);
192 HTMLUtil.TD_O(ref output,
"align_top");
193 output.Append(
"<DIV id=\"activesimstats\">SimStats loading...</DIV>");
194 output.Append(
"<DIV id=\"activelog\">ActiveLog loading...</DIV>");
195 HTMLUtil.TD_C(ref output);
196 HTMLUtil.TR_C(ref output);
197 HTMLUtil.TABLE_C(ref output);
198 output.Append(
"</BODY></HTML>");
200 return output.ToString();
208 returnstruct.all_scenes = m_scene.ToArray();
211 string SQL =
@"SELECT COUNT(DISTINCT agent_id) as agents, COUNT(*) as sessions, AVG(avg_fps) as client_fps,
212 AVG(avg_sim_fps) as savg_sim_fps, AVG(avg_ping) as sav_ping, SUM(n_out_kb) as num_in_kb,
213 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
214 FROM stats_session_data;";
215 SqliteCommand cmd =
new SqliteCommand(SQL, db);
216 SqliteDataReader sdr = cmd.ExecuteReader();
220 returnstruct.total_num_users = Convert.ToInt32(sdr[
"agents"]);
221 returnstruct.total_num_sessions = Convert.ToInt32(sdr[
"sessions"]);
222 returnstruct.avg_client_fps = Convert.ToSingle(sdr[
"client_fps"]);
223 returnstruct.avg_sim_fps = Convert.ToSingle(sdr[
"savg_sim_fps"]);
224 returnstruct.avg_ping = Convert.ToSingle(sdr[
"sav_ping"]);
225 returnstruct.total_kb_out = Convert.ToSingle(sdr[
"num_out_kb"]);
226 returnstruct.total_kb_in = Convert.ToSingle(sdr[
"num_in_kb"]);
227 returnstruct.avg_client_mem_use = Convert.ToSingle(sdr[
"sav_mem_use"]);
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();
Hashtable ProcessModel(Hashtable pParams)
string RenderJson(Hashtable pModelResult)
Return summar information in the form:
OpenMetaverse.StructuredData.OSDMap OSDMap
string RenderView(Hashtable pModelResult)
stats_default_page_values rep_DefaultReport_data(SqliteConnection db, List< Scene > m_scene)
Dictionary< UUID, USimStatsData > sim_stat_data
Dictionary< string, IStatsController > stats_reports
string rep_Default_report_view(stats_default_page_values values)