diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/UserStatistics/Default_Report.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/UserStatistics/Default_Report.cs')
-rw-r--r-- | OpenSim/Region/UserStatistics/Default_Report.cs | 250 |
1 files changed, 0 insertions, 250 deletions
diff --git a/OpenSim/Region/UserStatistics/Default_Report.cs b/OpenSim/Region/UserStatistics/Default_Report.cs deleted file mode 100644 index cdc615c..0000000 --- a/OpenSim/Region/UserStatistics/Default_Report.cs +++ /dev/null | |||
@@ -1,250 +0,0 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using System.Text; | ||
33 | using Mono.Data.SqliteClient; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Framework.Monitoring; | ||
37 | |||
38 | |||
39 | namespace OpenSim.Region.UserStatistics | ||
40 | { | ||
41 | public class Default_Report : IStatsController | ||
42 | { | ||
43 | |||
44 | public string ReportName | ||
45 | { | ||
46 | get { return "Home"; } | ||
47 | } | ||
48 | |||
49 | #region IStatsController Members | ||
50 | |||
51 | public Hashtable ProcessModel(Hashtable pParams) | ||
52 | { | ||
53 | SqliteConnection conn = (SqliteConnection)pParams["DatabaseConnection"]; | ||
54 | List<Scene> m_scene = (List<Scene>)pParams["Scenes"]; | ||
55 | |||
56 | stats_default_page_values mData = rep_DefaultReport_data(conn, m_scene); | ||
57 | mData.sim_stat_data = (Dictionary<UUID,USimStatsData>)pParams["SimStats"]; | ||
58 | mData.stats_reports = (Dictionary<string, IStatsController>) pParams["Reports"]; | ||
59 | |||
60 | Hashtable nh = new Hashtable(); | ||
61 | nh.Add("hdata", mData); | ||
62 | nh.Add("Reports", pParams["Reports"]); | ||
63 | |||
64 | return nh; | ||
65 | } | ||
66 | |||
67 | public string RenderView(Hashtable pModelResult) | ||
68 | { | ||
69 | stats_default_page_values mData = (stats_default_page_values) pModelResult["hdata"]; | ||
70 | return rep_Default_report_view(mData); | ||
71 | } | ||
72 | |||
73 | #endregion | ||
74 | |||
75 | public string rep_Default_report_view(stats_default_page_values values) | ||
76 | { | ||
77 | |||
78 | |||
79 | StringBuilder output = new StringBuilder(); | ||
80 | |||
81 | |||
82 | |||
83 | const string TableClass = "defaultr"; | ||
84 | const string TRClass = "defaultr"; | ||
85 | const string TDHeaderClass = "header"; | ||
86 | const string TDDataClass = "content"; | ||
87 | //const string TDDataClassRight = "contentright"; | ||
88 | const string TDDataClassCenter = "contentcenter"; | ||
89 | |||
90 | const string STYLESHEET = | ||
91 | @" | ||
92 | <STYLE> | ||
93 | body | ||
94 | { | ||
95 | font-size:15px; font-family:Helvetica, Verdana; color:Black; | ||
96 | } | ||
97 | TABLE.defaultr { } | ||
98 | TR.defaultr { padding: 5px; } | ||
99 | TD.header { font-weight:bold; padding:5px; } | ||
100 | TD.content {} | ||
101 | TD.contentright { text-align: right; } | ||
102 | TD.contentcenter { text-align: center; } | ||
103 | TD.align_top { vertical-align: top; } | ||
104 | </STYLE> | ||
105 | "; | ||
106 | HTMLUtil.HtmlHeaders_O(ref output); | ||
107 | |||
108 | HTMLUtil.InsertProtoTypeAJAX(ref output); | ||
109 | string[] ajaxUpdaterDivs = new string[3]; | ||
110 | int[] ajaxUpdaterSeconds = new int[3]; | ||
111 | string[] ajaxUpdaterReportFragments = new string[3]; | ||
112 | |||
113 | ajaxUpdaterDivs[0] = "activeconnections"; | ||
114 | ajaxUpdaterSeconds[0] = 10; | ||
115 | ajaxUpdaterReportFragments[0] = "activeconnectionsajax.html"; | ||
116 | |||
117 | ajaxUpdaterDivs[1] = "activesimstats"; | ||
118 | ajaxUpdaterSeconds[1] = 20; | ||
119 | ajaxUpdaterReportFragments[1] = "simstatsajax.html"; | ||
120 | |||
121 | ajaxUpdaterDivs[2] = "activelog"; | ||
122 | ajaxUpdaterSeconds[2] = 5; | ||
123 | ajaxUpdaterReportFragments[2] = "activelogajax.html"; | ||
124 | |||
125 | HTMLUtil.InsertPeriodicUpdaters(ref output, ajaxUpdaterDivs, ajaxUpdaterSeconds, ajaxUpdaterReportFragments); | ||
126 | |||
127 | output.Append(STYLESHEET); | ||
128 | HTMLUtil.HtmlHeaders_C(ref output); | ||
129 | HTMLUtil.AddReportLinks(ref output, values.stats_reports, ""); | ||
130 | HTMLUtil.TABLE_O(ref output, TableClass); | ||
131 | HTMLUtil.TR_O(ref output, TRClass); | ||
132 | HTMLUtil.TD_O(ref output, TDHeaderClass); | ||
133 | output.Append("# Users Total"); | ||
134 | HTMLUtil.TD_C(ref output); | ||
135 | HTMLUtil.TD_O(ref output, TDHeaderClass); | ||
136 | output.Append("# Sessions Total"); | ||
137 | HTMLUtil.TD_C(ref output); | ||
138 | HTMLUtil.TD_O(ref output, TDHeaderClass); | ||
139 | output.Append("Avg Client FPS"); | ||
140 | HTMLUtil.TD_C(ref output); | ||
141 | HTMLUtil.TD_O(ref output, TDHeaderClass); | ||
142 | output.Append("Avg Client Mem Use"); | ||
143 | HTMLUtil.TD_C(ref output); | ||
144 | HTMLUtil.TD_O(ref output, TDHeaderClass); | ||
145 | output.Append("Avg Sim FPS"); | ||
146 | HTMLUtil.TD_C(ref output); | ||
147 | HTMLUtil.TD_O(ref output, TDHeaderClass); | ||
148 | output.Append("Avg Ping"); | ||
149 | HTMLUtil.TD_C(ref output); | ||
150 | HTMLUtil.TD_O(ref output, TDHeaderClass); | ||
151 | output.Append("KB Out Total"); | ||
152 | HTMLUtil.TD_C(ref output); | ||
153 | HTMLUtil.TD_O(ref output, TDHeaderClass); | ||
154 | output.Append("KB In Total"); | ||
155 | HTMLUtil.TD_C(ref output); | ||
156 | HTMLUtil.TR_C(ref output); | ||
157 | HTMLUtil.TR_O(ref output, TRClass); | ||
158 | HTMLUtil.TD_O(ref output, TDDataClass); | ||
159 | output.Append(values.total_num_users); | ||
160 | HTMLUtil.TD_C(ref output); | ||
161 | HTMLUtil.TD_O(ref output, TDDataClass); | ||
162 | output.Append(values.total_num_sessions); | ||
163 | HTMLUtil.TD_C(ref output); | ||
164 | HTMLUtil.TD_O(ref output, TDDataClassCenter); | ||
165 | output.Append(values.avg_client_fps); | ||
166 | HTMLUtil.TD_C(ref output); | ||
167 | HTMLUtil.TD_O(ref output, TDDataClassCenter); | ||
168 | output.Append(values.avg_client_mem_use); | ||
169 | HTMLUtil.TD_C(ref output); | ||
170 | HTMLUtil.TD_O(ref output, TDDataClassCenter); | ||
171 | output.Append(values.avg_sim_fps); | ||
172 | HTMLUtil.TD_C(ref output); | ||
173 | HTMLUtil.TD_O(ref output, TDDataClassCenter); | ||
174 | output.Append(values.avg_ping); | ||
175 | HTMLUtil.TD_C(ref output); | ||
176 | HTMLUtil.TD_O(ref output, TDDataClassCenter); | ||
177 | output.Append(values.total_kb_out); | ||
178 | HTMLUtil.TD_C(ref output); | ||
179 | HTMLUtil.TD_O(ref output, TDDataClassCenter); | ||
180 | output.Append(values.total_kb_in); | ||
181 | HTMLUtil.TD_C(ref output); | ||
182 | HTMLUtil.TR_C(ref output); | ||
183 | HTMLUtil.TABLE_C(ref output); | ||
184 | |||
185 | HTMLUtil.HR(ref output, ""); | ||
186 | HTMLUtil.TABLE_O(ref output, ""); | ||
187 | HTMLUtil.TR_O(ref output, ""); | ||
188 | HTMLUtil.TD_O(ref output, "align_top"); | ||
189 | output.Append("<DIV id=\"activeconnections\">Active Connections loading...</DIV>"); | ||
190 | HTMLUtil.TD_C(ref output); | ||
191 | HTMLUtil.TD_O(ref output, "align_top"); | ||
192 | output.Append("<DIV id=\"activesimstats\">SimStats loading...</DIV>"); | ||
193 | output.Append("<DIV id=\"activelog\">ActiveLog loading...</DIV>"); | ||
194 | HTMLUtil.TD_C(ref output); | ||
195 | HTMLUtil.TR_C(ref output); | ||
196 | HTMLUtil.TABLE_C(ref output); | ||
197 | output.Append("</BODY></HTML>"); | ||
198 | // TODO: FIXME: template | ||
199 | return output.ToString(); | ||
200 | } | ||
201 | |||
202 | |||
203 | |||
204 | public stats_default_page_values rep_DefaultReport_data(SqliteConnection db, List<Scene> m_scene) | ||
205 | { | ||
206 | stats_default_page_values returnstruct = new stats_default_page_values(); | ||
207 | returnstruct.all_scenes = m_scene.ToArray(); | ||
208 | lock (db) | ||
209 | { | ||
210 | string SQL = @"SELECT COUNT(DISTINCT agent_id) as agents, COUNT(*) as sessions, AVG(avg_fps) as client_fps, | ||
211 | AVG(avg_sim_fps) as savg_sim_fps, AVG(avg_ping) as sav_ping, SUM(n_out_kb) as num_in_kb, | ||
212 | 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 | ||
213 | FROM stats_session_data;"; | ||
214 | SqliteCommand cmd = new SqliteCommand(SQL, db); | ||
215 | SqliteDataReader sdr = cmd.ExecuteReader(); | ||
216 | if (sdr.HasRows) | ||
217 | { | ||
218 | sdr.Read(); | ||
219 | returnstruct.total_num_users = Convert.ToInt32(sdr["agents"]); | ||
220 | returnstruct.total_num_sessions = Convert.ToInt32(sdr["sessions"]); | ||
221 | returnstruct.avg_client_fps = Convert.ToSingle(sdr["client_fps"]); | ||
222 | returnstruct.avg_sim_fps = Convert.ToSingle(sdr["savg_sim_fps"]); | ||
223 | returnstruct.avg_ping = Convert.ToSingle(sdr["sav_ping"]); | ||
224 | returnstruct.total_kb_out = Convert.ToSingle(sdr["num_out_kb"]); | ||
225 | returnstruct.total_kb_in = Convert.ToSingle(sdr["num_in_kb"]); | ||
226 | returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]); | ||
227 | |||
228 | } | ||
229 | } | ||
230 | return returnstruct; | ||
231 | } | ||
232 | |||
233 | } | ||
234 | |||
235 | public struct stats_default_page_values | ||
236 | { | ||
237 | public int total_num_users; | ||
238 | public int total_num_sessions; | ||
239 | public float avg_client_fps; | ||
240 | public float avg_client_mem_use; | ||
241 | public float avg_sim_fps; | ||
242 | public float avg_ping; | ||
243 | public float total_kb_out; | ||
244 | public float total_kb_in; | ||
245 | public float avg_client_resends; | ||
246 | public Scene[] all_scenes; | ||
247 | public Dictionary<UUID, USimStatsData> sim_stat_data; | ||
248 | public Dictionary<string, IStatsController> stats_reports; | ||
249 | } | ||
250 | } | ||