diff options
author | Melanie | 2012-04-17 01:54:54 +0100 |
---|---|---|
committer | Melanie | 2012-04-17 01:54:54 +0100 |
commit | 74aa8eee1255d457d0c865682a7c5466ae8d640e (patch) | |
tree | d7fed81841ad48e09836ee3582b7161921339f9e /OpenSim/Region/UserStatistics/WebStatsModule.cs | |
parent | Merge branch 'master' of ssh://melanie@3dhosting.de/var/git/careminster into ... (diff) | |
parent | Add test TestGetChildPartPosition() (diff) | |
download | opensim-SC-74aa8eee1255d457d0c865682a7c5466ae8d640e.zip opensim-SC-74aa8eee1255d457d0c865682a7c5466ae8d640e.tar.gz opensim-SC-74aa8eee1255d457d0c865682a7c5466ae8d640e.tar.bz2 opensim-SC-74aa8eee1255d457d0c865682a7c5466ae8d640e.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Diffstat (limited to 'OpenSim/Region/UserStatistics/WebStatsModule.cs')
-rw-r--r-- | OpenSim/Region/UserStatistics/WebStatsModule.cs | 153 |
1 files changed, 31 insertions, 122 deletions
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index b9ba4bc..4248035 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs | |||
@@ -90,7 +90,7 @@ namespace OpenSim.Region.UserStatistics | |||
90 | 90 | ||
91 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); | 91 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); |
92 | dbConn.Open(); | 92 | dbConn.Open(); |
93 | CheckAndUpdateDatabase(dbConn); | 93 | CreateTables(dbConn); |
94 | 94 | ||
95 | Prototype_distributor protodep = new Prototype_distributor(); | 95 | Prototype_distributor protodep = new Prototype_distributor(); |
96 | Updater_distributor updatedep = new Updater_distributor(); | 96 | Updater_distributor updatedep = new Updater_distributor(); |
@@ -131,7 +131,7 @@ namespace OpenSim.Region.UserStatistics | |||
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | public void ReceiveClassicSimStatsPacket(SimStats stats) | 134 | private void ReceiveClassicSimStatsPacket(SimStats stats) |
135 | { | 135 | { |
136 | if (!enabled) | 136 | if (!enabled) |
137 | { | 137 | { |
@@ -163,7 +163,7 @@ namespace OpenSim.Region.UserStatistics | |||
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | public Hashtable HandleUnknownCAPSRequest(Hashtable request) | 166 | private Hashtable HandleUnknownCAPSRequest(Hashtable request) |
167 | { | 167 | { |
168 | //string regpath = request["uri"].ToString(); | 168 | //string regpath = request["uri"].ToString(); |
169 | int response_code = 200; | 169 | int response_code = 200; |
@@ -178,7 +178,7 @@ namespace OpenSim.Region.UserStatistics | |||
178 | return responsedata; | 178 | return responsedata; |
179 | } | 179 | } |
180 | 180 | ||
181 | public Hashtable HandleStatsRequest(Hashtable request) | 181 | private Hashtable HandleStatsRequest(Hashtable request) |
182 | { | 182 | { |
183 | lastHit = System.Environment.TickCount; | 183 | lastHit = System.Environment.TickCount; |
184 | Hashtable responsedata = new Hashtable(); | 184 | Hashtable responsedata = new Hashtable(); |
@@ -237,36 +237,12 @@ namespace OpenSim.Region.UserStatistics | |||
237 | 237 | ||
238 | return responsedata; | 238 | return responsedata; |
239 | } | 239 | } |
240 | |||
241 | public void CheckAndUpdateDatabase(SqliteConnection db) | ||
242 | { | ||
243 | lock (db) | ||
244 | { | ||
245 | // TODO: FIXME: implement stats migrations | ||
246 | const string SQL = @"SELECT * FROM migrations LIMIT 1"; | ||
247 | |||
248 | using (SqliteCommand cmd = new SqliteCommand(SQL, db)) | ||
249 | { | ||
250 | try | ||
251 | { | ||
252 | cmd.ExecuteNonQuery(); | ||
253 | } | ||
254 | catch (SqliteSyntaxException) | ||
255 | { | ||
256 | CreateTables(db); | ||
257 | } | ||
258 | } | ||
259 | } | ||
260 | } | ||
261 | 240 | ||
262 | public void CreateTables(SqliteConnection db) | 241 | private void CreateTables(SqliteConnection db) |
263 | { | 242 | { |
264 | using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db)) | 243 | using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db)) |
265 | { | 244 | { |
266 | createcmd.ExecuteNonQuery(); | 245 | createcmd.ExecuteNonQuery(); |
267 | |||
268 | createcmd.CommandText = SQL_MIGRA_TABLE_CREATE; | ||
269 | createcmd.ExecuteNonQuery(); | ||
270 | } | 246 | } |
271 | } | 247 | } |
272 | 248 | ||
@@ -301,7 +277,7 @@ namespace OpenSim.Region.UserStatistics | |||
301 | get { return true; } | 277 | get { return true; } |
302 | } | 278 | } |
303 | 279 | ||
304 | public void OnRegisterCaps(UUID agentID, Caps caps) | 280 | private void OnRegisterCaps(UUID agentID, Caps caps) |
305 | { | 281 | { |
306 | // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | 282 | // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); |
307 | 283 | ||
@@ -316,7 +292,7 @@ namespace OpenSim.Region.UserStatistics | |||
316 | })); | 292 | })); |
317 | } | 293 | } |
318 | 294 | ||
319 | public void OnDeRegisterCaps(UUID agentID, Caps caps) | 295 | private void OnDeRegisterCaps(UUID agentID, Caps caps) |
320 | { | 296 | { |
321 | } | 297 | } |
322 | 298 | ||
@@ -336,7 +312,7 @@ namespace OpenSim.Region.UserStatistics | |||
336 | } | 312 | } |
337 | } | 313 | } |
338 | 314 | ||
339 | public void OnMakeRootAgent(ScenePresence agent) | 315 | private void OnMakeRootAgent(ScenePresence agent) |
340 | { | 316 | { |
341 | UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle); | 317 | UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle); |
342 | 318 | ||
@@ -365,11 +341,11 @@ namespace OpenSim.Region.UserStatistics | |||
365 | } | 341 | } |
366 | } | 342 | } |
367 | 343 | ||
368 | public void OnMakeChildAgent(ScenePresence agent) | 344 | private void OnMakeChildAgent(ScenePresence agent) |
369 | { | 345 | { |
370 | } | 346 | } |
371 | 347 | ||
372 | public void OnClientClosed(UUID agentID, Scene scene) | 348 | private void OnClientClosed(UUID agentID, Scene scene) |
373 | { | 349 | { |
374 | lock (m_sessions) | 350 | lock (m_sessions) |
375 | { | 351 | { |
@@ -380,7 +356,7 @@ namespace OpenSim.Region.UserStatistics | |||
380 | } | 356 | } |
381 | } | 357 | } |
382 | 358 | ||
383 | public string readLogLines(int amount) | 359 | private string readLogLines(int amount) |
384 | { | 360 | { |
385 | Encoding encoding = Encoding.ASCII; | 361 | Encoding encoding = Encoding.ASCII; |
386 | int sizeOfChar = encoding.GetByteCount("\n"); | 362 | int sizeOfChar = encoding.GetByteCount("\n"); |
@@ -418,7 +394,7 @@ namespace OpenSim.Region.UserStatistics | |||
418 | return encoding.GetString(buffer); | 394 | return encoding.GetString(buffer); |
419 | } | 395 | } |
420 | 396 | ||
421 | public UUID GetRegionUUIDFromHandle(ulong regionhandle) | 397 | private UUID GetRegionUUIDFromHandle(ulong regionhandle) |
422 | { | 398 | { |
423 | lock (m_scenes) | 399 | lock (m_scenes) |
424 | { | 400 | { |
@@ -441,17 +417,17 @@ namespace OpenSim.Region.UserStatistics | |||
441 | /// <param name="agentID"></param> | 417 | /// <param name="agentID"></param> |
442 | /// <param name="caps"></param> | 418 | /// <param name="caps"></param> |
443 | /// <returns></returns> | 419 | /// <returns></returns> |
444 | public string ViewerStatsReport(string request, string path, string param, | 420 | private string ViewerStatsReport(string request, string path, string param, |
445 | UUID agentID, Caps caps) | 421 | UUID agentID, Caps caps) |
446 | { | 422 | { |
447 | // m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID); | 423 | // m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID); |
448 | 424 | ||
449 | UpdateUserStats(ParseViewerStats(request,agentID), dbConn); | 425 | UpdateUserStats(ParseViewerStats(request, agentID), dbConn); |
450 | 426 | ||
451 | return String.Empty; | 427 | return String.Empty; |
452 | } | 428 | } |
453 | 429 | ||
454 | public UserSessionID ParseViewerStats(string request, UUID agentID) | 430 | private UserSessionID ParseViewerStats(string request, UUID agentID) |
455 | { | 431 | { |
456 | UserSessionID uid = new UserSessionID(); | 432 | UserSessionID uid = new UserSessionID(); |
457 | UserSessionData usd; | 433 | UserSessionData usd; |
@@ -592,14 +568,14 @@ namespace OpenSim.Region.UserStatistics | |||
592 | return uid; | 568 | return uid; |
593 | } | 569 | } |
594 | 570 | ||
595 | public void UpdateUserStats(UserSessionID uid, SqliteConnection db) | 571 | private void UpdateUserStats(UserSessionID uid, SqliteConnection db) |
596 | { | 572 | { |
597 | if (uid.session_id == UUID.Zero) | 573 | if (uid.session_id == UUID.Zero) |
598 | return; | 574 | return; |
599 | 575 | ||
600 | lock (db) | 576 | lock (db) |
601 | { | 577 | { |
602 | using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db)) | 578 | using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_INSERT, db)) |
603 | { | 579 | { |
604 | updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString())); | 580 | updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString())); |
605 | updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString())); | 581 | updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString())); |
@@ -648,44 +624,26 @@ namespace OpenSim.Region.UserStatistics | |||
648 | updatecmd.Parameters.Add(new SqliteParameter(":f_dropped", uid.session_data.f_dropped)); | 624 | updatecmd.Parameters.Add(new SqliteParameter(":f_dropped", uid.session_data.f_dropped)); |
649 | updatecmd.Parameters.Add(new SqliteParameter(":f_failed_resends", uid.session_data.f_failed_resends)); | 625 | updatecmd.Parameters.Add(new SqliteParameter(":f_failed_resends", uid.session_data.f_failed_resends)); |
650 | updatecmd.Parameters.Add(new SqliteParameter(":f_invalid", uid.session_data.f_invalid)); | 626 | updatecmd.Parameters.Add(new SqliteParameter(":f_invalid", uid.session_data.f_invalid)); |
651 | |||
652 | updatecmd.Parameters.Add(new SqliteParameter(":f_off_circuit", uid.session_data.f_off_circuit)); | 627 | updatecmd.Parameters.Add(new SqliteParameter(":f_off_circuit", uid.session_data.f_off_circuit)); |
653 | updatecmd.Parameters.Add(new SqliteParameter(":f_resent", uid.session_data.f_resent)); | 628 | updatecmd.Parameters.Add(new SqliteParameter(":f_resent", uid.session_data.f_resent)); |
654 | updatecmd.Parameters.Add(new SqliteParameter(":f_send_packet", uid.session_data.f_send_packet)); | 629 | updatecmd.Parameters.Add(new SqliteParameter(":f_send_packet", uid.session_data.f_send_packet)); |
655 | |||
656 | updatecmd.Parameters.Add(new SqliteParameter(":session_key", uid.session_data.session_id.ToString())); | ||
657 | updatecmd.Parameters.Add(new SqliteParameter(":agent_key", uid.session_data.agent_id.ToString())); | ||
658 | updatecmd.Parameters.Add(new SqliteParameter(":region_key", uid.session_data.region_id.ToString())); | ||
659 | 630 | ||
660 | // m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id); | 631 | // StringBuilder parameters = new StringBuilder(); |
661 | 632 | // SqliteParameterCollection spc = updatecmd.Parameters; | |
662 | int result = updatecmd.ExecuteNonQuery(); | 633 | // foreach (SqliteParameter sp in spc) |
663 | 634 | // parameters.AppendFormat("{0}={1},", sp.ParameterName, sp.Value); | |
664 | if (result == 0) | 635 | // |
665 | { | 636 | // m_log.DebugFormat("[WEB STATS MODULE]: Parameters {0}", parameters); |
666 | // m_log.DebugFormat("[WEB STATS MODULE]: Database stats insert for {0}", uid.session_data.agent_id); | ||
667 | 637 | ||
668 | updatecmd.CommandText = SQL_STATS_TABLE_INSERT; | 638 | // m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id); |
669 | 639 | ||
670 | try | 640 | updatecmd.ExecuteNonQuery(); |
671 | { | ||
672 | updatecmd.ExecuteNonQuery(); | ||
673 | } | ||
674 | catch (Exception e) | ||
675 | { | ||
676 | m_log.WarnFormat( | ||
677 | "[WEB STATS MODULE]: failed to write stats for {0}, storage Execution Exception {1}{2}", | ||
678 | uid.session_data.agent_id, e.Message, e.StackTrace); | ||
679 | } | ||
680 | } | ||
681 | } | 641 | } |
682 | } | 642 | } |
683 | } | 643 | } |
684 | 644 | ||
685 | #region SQL | 645 | #region SQL |
686 | private const string SQL_MIGRA_TABLE_CREATE = @"create table migrations(name varchar(100), version int)"; | 646 | private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE IF NOT EXISTS stats_session_data ( |
687 | |||
688 | private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE stats_session_data ( | ||
689 | session_id VARCHAR(36) NOT NULL PRIMARY KEY, | 647 | session_id VARCHAR(36) NOT NULL PRIMARY KEY, |
690 | agent_id VARCHAR(36) NOT NULL DEFAULT '', | 648 | agent_id VARCHAR(36) NOT NULL DEFAULT '', |
691 | region_id VARCHAR(36) NOT NULL DEFAULT '', | 649 | region_id VARCHAR(36) NOT NULL DEFAULT '', |
@@ -735,11 +693,11 @@ namespace OpenSim.Region.UserStatistics | |||
735 | f_send_packet INT NOT NULL DEFAULT '0' | 693 | f_send_packet INT NOT NULL DEFAULT '0' |
736 | );"; | 694 | );"; |
737 | 695 | ||
738 | private const string SQL_STATS_TABLE_INSERT = @"INSERT INTO stats_session_data ( | 696 | private const string SQL_STATS_TABLE_INSERT = @"INSERT OR REPLACE INTO stats_session_data ( |
739 | session_id, agent_id, region_id, last_updated, remote_ip, name_f, name_l, avg_agents_in_view, min_agents_in_view, max_agents_in_view, | 697 | session_id, agent_id, region_id, last_updated, remote_ip, name_f, name_l, avg_agents_in_view, min_agents_in_view, max_agents_in_view, |
740 | mode_agents_in_view, avg_fps, min_fps, max_fps, mode_fps, a_language, mem_use, meters_traveled, avg_ping, min_ping, max_ping, mode_ping, | 698 | mode_agents_in_view, avg_fps, min_fps, max_fps, mode_fps, a_language, mem_use, meters_traveled, avg_ping, min_ping, max_ping, mode_ping, |
741 | regions_visited, run_time, avg_sim_fps, min_sim_fps, max_sim_fps, mode_sim_fps, start_time, client_version, s_cpu, s_gpu, s_os, s_ram, | 699 | regions_visited, run_time, avg_sim_fps, min_sim_fps, max_sim_fps, mode_sim_fps, start_time, client_version, s_cpu, s_gpu, s_os, s_ram, |
742 | d_object_kb, d_texture_kb, n_in_kb, n_in_pk, n_out_kb, n_out_pk, f_dropped, f_failed_resends, f_invalid, f_invalid, f_off_circuit, | 700 | d_object_kb, d_texture_kb, d_world_kb, n_in_kb, n_in_pk, n_out_kb, n_out_pk, f_dropped, f_failed_resends, f_invalid, f_off_circuit, |
743 | f_resent, f_send_packet | 701 | f_resent, f_send_packet |
744 | ) | 702 | ) |
745 | VALUES | 703 | VALUES |
@@ -747,62 +705,13 @@ VALUES | |||
747 | :session_id, :agent_id, :region_id, :last_updated, :remote_ip, :name_f, :name_l, :avg_agents_in_view, :min_agents_in_view, :max_agents_in_view, | 705 | :session_id, :agent_id, :region_id, :last_updated, :remote_ip, :name_f, :name_l, :avg_agents_in_view, :min_agents_in_view, :max_agents_in_view, |
748 | :mode_agents_in_view, :avg_fps, :min_fps, :max_fps, :mode_fps, :a_language, :mem_use, :meters_traveled, :avg_ping, :min_ping, :max_ping, :mode_ping, | 706 | :mode_agents_in_view, :avg_fps, :min_fps, :max_fps, :mode_fps, :a_language, :mem_use, :meters_traveled, :avg_ping, :min_ping, :max_ping, :mode_ping, |
749 | :regions_visited, :run_time, :avg_sim_fps, :min_sim_fps, :max_sim_fps, :mode_sim_fps, :start_time, :client_version, :s_cpu, :s_gpu, :s_os, :s_ram, | 707 | :regions_visited, :run_time, :avg_sim_fps, :min_sim_fps, :max_sim_fps, :mode_sim_fps, :start_time, :client_version, :s_cpu, :s_gpu, :s_os, :s_ram, |
750 | :d_object_kb, :d_texture_kb, :n_in_kb, :n_in_pk, :n_out_kb, :n_out_pk, :f_dropped, :f_failed_resends, :f_invalid, :f_invalid, :f_off_circuit, | 708 | :d_object_kb, :d_texture_kb, :d_world_kb, :n_in_kb, :n_in_pk, :n_out_kb, :n_out_pk, :f_dropped, :f_failed_resends, :f_invalid, :f_off_circuit, |
751 | :f_resent, :f_send_packet | 709 | :f_resent, :f_send_packet |
752 | ) | 710 | ) |
753 | "; | 711 | "; |
754 | 712 | ||
755 | private const string SQL_STATS_TABLE_UPDATE = @" | 713 | #endregion |
756 | UPDATE stats_session_data | 714 | |
757 | set session_id=:session_id, | ||
758 | agent_id=:agent_id, | ||
759 | region_id=:region_id, | ||
760 | last_updated=:last_updated, | ||
761 | remote_ip=:remote_ip, | ||
762 | name_f=:name_f, | ||
763 | name_l=:name_l, | ||
764 | avg_agents_in_view=:avg_agents_in_view, | ||
765 | min_agents_in_view=:min_agents_in_view, | ||
766 | max_agents_in_view=:max_agents_in_view, | ||
767 | mode_agents_in_view=:mode_agents_in_view, | ||
768 | avg_fps=:avg_fps, | ||
769 | min_fps=:min_fps, | ||
770 | max_fps=:max_fps, | ||
771 | mode_fps=:mode_fps, | ||
772 | a_language=:a_language, | ||
773 | mem_use=:mem_use, | ||
774 | meters_traveled=:meters_traveled, | ||
775 | avg_ping=:avg_ping, | ||
776 | min_ping=:min_ping, | ||
777 | max_ping=:max_ping, | ||
778 | mode_ping=:mode_ping, | ||
779 | regions_visited=:regions_visited, | ||
780 | run_time=:run_time, | ||
781 | avg_sim_fps=:avg_sim_fps, | ||
782 | min_sim_fps=:min_sim_fps, | ||
783 | max_sim_fps=:max_sim_fps, | ||
784 | mode_sim_fps=:mode_sim_fps, | ||
785 | start_time=:start_time, | ||
786 | client_version=:client_version, | ||
787 | s_cpu=:s_cpu, | ||
788 | s_gpu=:s_gpu, | ||
789 | s_os=:s_os, | ||
790 | s_ram=:s_ram, | ||
791 | d_object_kb=:d_object_kb, | ||
792 | d_texture_kb=:d_texture_kb, | ||
793 | d_world_kb=:d_world_kb, | ||
794 | n_in_kb=:n_in_kb, | ||
795 | n_in_pk=:n_in_pk, | ||
796 | n_out_kb=:n_out_kb, | ||
797 | n_out_pk=:n_out_pk, | ||
798 | f_dropped=:f_dropped, | ||
799 | f_failed_resends=:f_failed_resends, | ||
800 | f_invalid=:f_invalid, | ||
801 | f_off_circuit=:f_off_circuit, | ||
802 | f_resent=:f_resent, | ||
803 | f_send_packet=:f_send_packet | ||
804 | WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"; | ||
805 | #endregion | ||
806 | } | 715 | } |
807 | 716 | ||
808 | public static class UserSessionUtil | 717 | public static class UserSessionUtil |