diff options
Diffstat (limited to 'OpenSim/Region/UserStatistics')
-rw-r--r-- | OpenSim/Region/UserStatistics/WebStatsModule.cs | 200 |
1 files changed, 101 insertions, 99 deletions
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index f627e37..b9ba4bc 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs | |||
@@ -83,6 +83,9 @@ namespace OpenSim.Region.UserStatistics | |||
83 | { | 83 | { |
84 | if (m_scenes.Count == 0) | 84 | if (m_scenes.Count == 0) |
85 | { | 85 | { |
86 | if (Util.IsWindows()) | ||
87 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); | ||
88 | |||
86 | //IConfig startupConfig = config.Configs["Startup"]; | 89 | //IConfig startupConfig = config.Configs["Startup"]; |
87 | 90 | ||
88 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); | 91 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); |
@@ -221,13 +224,11 @@ namespace OpenSim.Region.UserStatistics | |||
221 | concurrencyCounter--; | 224 | concurrencyCounter--; |
222 | 225 | ||
223 | response_code = 200; | 226 | response_code = 200; |
224 | |||
225 | } | 227 | } |
226 | else | 228 | else |
227 | { | 229 | { |
228 | strOut = MainServer.Instance.GetHTTP404(""); | 230 | strOut = MainServer.Instance.GetHTTP404(""); |
229 | } | 231 | } |
230 | |||
231 | 232 | ||
232 | responsedata["int_response_code"] = response_code; | 233 | responsedata["int_response_code"] = response_code; |
233 | responsedata["content_type"] = contenttype; | 234 | responsedata["content_type"] = contenttype; |
@@ -244,43 +245,44 @@ namespace OpenSim.Region.UserStatistics | |||
244 | // TODO: FIXME: implement stats migrations | 245 | // TODO: FIXME: implement stats migrations |
245 | const string SQL = @"SELECT * FROM migrations LIMIT 1"; | 246 | const string SQL = @"SELECT * FROM migrations LIMIT 1"; |
246 | 247 | ||
247 | SqliteCommand cmd = new SqliteCommand(SQL, db); | 248 | using (SqliteCommand cmd = new SqliteCommand(SQL, db)) |
248 | |||
249 | try | ||
250 | { | ||
251 | cmd.ExecuteNonQuery(); | ||
252 | } | ||
253 | catch (SqliteSyntaxException) | ||
254 | { | 249 | { |
255 | CreateTables(db); | 250 | try |
251 | { | ||
252 | cmd.ExecuteNonQuery(); | ||
253 | } | ||
254 | catch (SqliteSyntaxException) | ||
255 | { | ||
256 | CreateTables(db); | ||
257 | } | ||
256 | } | 258 | } |
257 | } | 259 | } |
258 | } | 260 | } |
259 | 261 | ||
260 | public void CreateTables(SqliteConnection db) | 262 | public void CreateTables(SqliteConnection db) |
261 | { | 263 | { |
262 | SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db); | 264 | using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db)) |
263 | createcmd.ExecuteNonQuery(); | 265 | { |
266 | createcmd.ExecuteNonQuery(); | ||
264 | 267 | ||
265 | createcmd.CommandText = SQL_MIGRA_TABLE_CREATE; | 268 | createcmd.CommandText = SQL_MIGRA_TABLE_CREATE; |
266 | createcmd.ExecuteNonQuery(); | 269 | createcmd.ExecuteNonQuery(); |
270 | } | ||
267 | } | 271 | } |
268 | 272 | ||
269 | public virtual void PostInitialise() | 273 | public virtual void PostInitialise() |
270 | { | 274 | { |
271 | if (!enabled) | 275 | if (!enabled) |
272 | { | ||
273 | return; | 276 | return; |
274 | } | 277 | |
275 | AddHandlers(); | 278 | AddHandlers(); |
276 | } | 279 | } |
277 | 280 | ||
278 | public virtual void Close() | 281 | public virtual void Close() |
279 | { | 282 | { |
280 | if (!enabled) | 283 | if (!enabled) |
281 | { | ||
282 | return; | 284 | return; |
283 | } | 285 | |
284 | dbConn.Close(); | 286 | dbConn.Close(); |
285 | dbConn.Dispose(); | 287 | dbConn.Dispose(); |
286 | m_sessions.Clear(); | 288 | m_sessions.Clear(); |
@@ -301,7 +303,8 @@ namespace OpenSim.Region.UserStatistics | |||
301 | 303 | ||
302 | public void OnRegisterCaps(UUID agentID, Caps caps) | 304 | public void OnRegisterCaps(UUID agentID, Caps caps) |
303 | { | 305 | { |
304 | m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | 306 | // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); |
307 | |||
305 | string capsPath = "/CAPS/VS/" + UUID.Random(); | 308 | string capsPath = "/CAPS/VS/" + UUID.Random(); |
306 | caps.RegisterHandler("ViewerStats", | 309 | caps.RegisterHandler("ViewerStats", |
307 | new RestStreamHandler("POST", capsPath, | 310 | new RestStreamHandler("POST", capsPath, |
@@ -315,7 +318,6 @@ namespace OpenSim.Region.UserStatistics | |||
315 | 318 | ||
316 | public void OnDeRegisterCaps(UUID agentID, Caps caps) | 319 | public void OnDeRegisterCaps(UUID agentID, Caps caps) |
317 | { | 320 | { |
318 | |||
319 | } | 321 | } |
320 | 322 | ||
321 | protected virtual void AddHandlers() | 323 | protected virtual void AddHandlers() |
@@ -365,7 +367,6 @@ namespace OpenSim.Region.UserStatistics | |||
365 | 367 | ||
366 | public void OnMakeChildAgent(ScenePresence agent) | 368 | public void OnMakeChildAgent(ScenePresence agent) |
367 | { | 369 | { |
368 | |||
369 | } | 370 | } |
370 | 371 | ||
371 | public void OnClientClosed(UUID agentID, Scene scene) | 372 | public void OnClientClosed(UUID agentID, Scene scene) |
@@ -427,6 +428,7 @@ namespace OpenSim.Region.UserStatistics | |||
427 | return scene.RegionInfo.RegionID; | 428 | return scene.RegionInfo.RegionID; |
428 | } | 429 | } |
429 | } | 430 | } |
431 | |||
430 | return UUID.Zero; | 432 | return UUID.Zero; |
431 | } | 433 | } |
432 | 434 | ||
@@ -455,14 +457,14 @@ namespace OpenSim.Region.UserStatistics | |||
455 | UserSessionData usd; | 457 | UserSessionData usd; |
456 | OSD message = OSDParser.DeserializeLLSDXml(request); | 458 | OSD message = OSDParser.DeserializeLLSDXml(request); |
457 | OSDMap mmap; | 459 | OSDMap mmap; |
460 | |||
458 | lock (m_sessions) | 461 | lock (m_sessions) |
459 | { | 462 | { |
460 | if (agentID != UUID.Zero) | 463 | if (agentID != UUID.Zero) |
461 | { | 464 | { |
462 | |||
463 | if (!m_sessions.ContainsKey(agentID)) | 465 | if (!m_sessions.ContainsKey(agentID)) |
464 | { | 466 | { |
465 | m_log.Warn("[WEB STATS MODULE]: no session for stat disclosure"); | 467 | m_log.WarnFormat("[WEB STATS MODULE]: no session for stat disclosure for agent {0}", agentID); |
466 | return new UserSessionID(); | 468 | return new UserSessionID(); |
467 | } | 469 | } |
468 | uid = m_sessions[agentID]; | 470 | uid = m_sessions[agentID]; |
@@ -582,8 +584,6 @@ namespace OpenSim.Region.UserStatistics | |||
582 | usd.n_out_kb = (float)net_out["kbytes"].AsReal(); | 584 | usd.n_out_kb = (float)net_out["kbytes"].AsReal(); |
583 | usd.n_out_pk = net_out["packets"].AsInteger(); | 585 | usd.n_out_pk = net_out["packets"].AsInteger(); |
584 | } | 586 | } |
585 | |||
586 | |||
587 | } | 587 | } |
588 | } | 588 | } |
589 | 589 | ||
@@ -599,83 +599,85 @@ namespace OpenSim.Region.UserStatistics | |||
599 | 599 | ||
600 | lock (db) | 600 | lock (db) |
601 | { | 601 | { |
602 | SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db); | 602 | using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db)) |
603 | updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString())); | ||
604 | updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString())); | ||
605 | updatecmd.Parameters.Add(new SqliteParameter(":region_id", uid.session_data.region_id.ToString())); | ||
606 | updatecmd.Parameters.Add(new SqliteParameter(":last_updated", (int) uid.session_data.last_updated)); | ||
607 | updatecmd.Parameters.Add(new SqliteParameter(":remote_ip", uid.session_data.remote_ip)); | ||
608 | updatecmd.Parameters.Add(new SqliteParameter(":name_f", uid.session_data.name_f)); | ||
609 | updatecmd.Parameters.Add(new SqliteParameter(":name_l", uid.session_data.name_l)); | ||
610 | updatecmd.Parameters.Add(new SqliteParameter(":avg_agents_in_view", uid.session_data.avg_agents_in_view)); | ||
611 | updatecmd.Parameters.Add(new SqliteParameter(":min_agents_in_view", | ||
612 | (int) uid.session_data.min_agents_in_view)); | ||
613 | updatecmd.Parameters.Add(new SqliteParameter(":max_agents_in_view", | ||
614 | (int) uid.session_data.max_agents_in_view)); | ||
615 | updatecmd.Parameters.Add(new SqliteParameter(":mode_agents_in_view", | ||
616 | (int) uid.session_data.mode_agents_in_view)); | ||
617 | updatecmd.Parameters.Add(new SqliteParameter(":avg_fps", uid.session_data.avg_fps)); | ||
618 | updatecmd.Parameters.Add(new SqliteParameter(":min_fps", uid.session_data.min_fps)); | ||
619 | updatecmd.Parameters.Add(new SqliteParameter(":max_fps", uid.session_data.max_fps)); | ||
620 | updatecmd.Parameters.Add(new SqliteParameter(":mode_fps", uid.session_data.mode_fps)); | ||
621 | updatecmd.Parameters.Add(new SqliteParameter(":a_language", uid.session_data.a_language)); | ||
622 | updatecmd.Parameters.Add(new SqliteParameter(":mem_use", uid.session_data.mem_use)); | ||
623 | updatecmd.Parameters.Add(new SqliteParameter(":meters_traveled", uid.session_data.meters_traveled)); | ||
624 | updatecmd.Parameters.Add(new SqliteParameter(":avg_ping", uid.session_data.avg_ping)); | ||
625 | updatecmd.Parameters.Add(new SqliteParameter(":min_ping", uid.session_data.min_ping)); | ||
626 | updatecmd.Parameters.Add(new SqliteParameter(":max_ping", uid.session_data.max_ping)); | ||
627 | updatecmd.Parameters.Add(new SqliteParameter(":mode_ping", uid.session_data.mode_ping)); | ||
628 | updatecmd.Parameters.Add(new SqliteParameter(":regions_visited", uid.session_data.regions_visited)); | ||
629 | updatecmd.Parameters.Add(new SqliteParameter(":run_time", uid.session_data.run_time)); | ||
630 | updatecmd.Parameters.Add(new SqliteParameter(":avg_sim_fps", uid.session_data.avg_sim_fps)); | ||
631 | updatecmd.Parameters.Add(new SqliteParameter(":min_sim_fps", uid.session_data.min_sim_fps)); | ||
632 | updatecmd.Parameters.Add(new SqliteParameter(":max_sim_fps", uid.session_data.max_sim_fps)); | ||
633 | updatecmd.Parameters.Add(new SqliteParameter(":mode_sim_fps", uid.session_data.mode_sim_fps)); | ||
634 | updatecmd.Parameters.Add(new SqliteParameter(":start_time", uid.session_data.start_time)); | ||
635 | updatecmd.Parameters.Add(new SqliteParameter(":client_version", uid.session_data.client_version)); | ||
636 | updatecmd.Parameters.Add(new SqliteParameter(":s_cpu", uid.session_data.s_cpu)); | ||
637 | updatecmd.Parameters.Add(new SqliteParameter(":s_gpu", uid.session_data.s_gpu)); | ||
638 | updatecmd.Parameters.Add(new SqliteParameter(":s_os", uid.session_data.s_os)); | ||
639 | updatecmd.Parameters.Add(new SqliteParameter(":s_ram", uid.session_data.s_ram)); | ||
640 | updatecmd.Parameters.Add(new SqliteParameter(":d_object_kb", uid.session_data.d_object_kb)); | ||
641 | updatecmd.Parameters.Add(new SqliteParameter(":d_texture_kb", uid.session_data.d_texture_kb)); | ||
642 | updatecmd.Parameters.Add(new SqliteParameter(":d_world_kb", uid.session_data.d_world_kb)); | ||
643 | updatecmd.Parameters.Add(new SqliteParameter(":n_in_kb", uid.session_data.n_in_kb)); | ||
644 | updatecmd.Parameters.Add(new SqliteParameter(":n_in_pk", uid.session_data.n_in_pk)); | ||
645 | updatecmd.Parameters.Add(new SqliteParameter(":n_out_kb", uid.session_data.n_out_kb)); | ||
646 | updatecmd.Parameters.Add(new SqliteParameter(":n_out_pk", uid.session_data.n_out_pk)); | ||
647 | updatecmd.Parameters.Add(new SqliteParameter(":f_dropped", uid.session_data.f_dropped)); | ||
648 | updatecmd.Parameters.Add(new SqliteParameter(":f_failed_resends", uid.session_data.f_failed_resends)); | ||
649 | updatecmd.Parameters.Add(new SqliteParameter(":f_invalid", uid.session_data.f_invalid)); | ||
650 | |||
651 | updatecmd.Parameters.Add(new SqliteParameter(":f_off_circuit", uid.session_data.f_off_circuit)); | ||
652 | updatecmd.Parameters.Add(new SqliteParameter(":f_resent", uid.session_data.f_resent)); | ||
653 | updatecmd.Parameters.Add(new SqliteParameter(":f_send_packet", uid.session_data.f_send_packet)); | ||
654 | |||
655 | updatecmd.Parameters.Add(new SqliteParameter(":session_key", uid.session_data.session_id.ToString())); | ||
656 | updatecmd.Parameters.Add(new SqliteParameter(":agent_key", uid.session_data.agent_id.ToString())); | ||
657 | updatecmd.Parameters.Add(new SqliteParameter(":region_key", uid.session_data.region_id.ToString())); | ||
658 | // m_log.Debug("UPDATE"); | ||
659 | |||
660 | int result = updatecmd.ExecuteNonQuery(); | ||
661 | |||
662 | if (result == 0) | ||
663 | { | 603 | { |
664 | // m_log.Debug("INSERT"); | 604 | updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString())); |
665 | updatecmd.CommandText = SQL_STATS_TABLE_INSERT; | 605 | updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString())); |
666 | try | 606 | updatecmd.Parameters.Add(new SqliteParameter(":region_id", uid.session_data.region_id.ToString())); |
667 | { | 607 | updatecmd.Parameters.Add(new SqliteParameter(":last_updated", (int) uid.session_data.last_updated)); |
668 | updatecmd.ExecuteNonQuery(); | 608 | updatecmd.Parameters.Add(new SqliteParameter(":remote_ip", uid.session_data.remote_ip)); |
669 | } | 609 | updatecmd.Parameters.Add(new SqliteParameter(":name_f", uid.session_data.name_f)); |
670 | catch (SqliteExecutionException) | 610 | updatecmd.Parameters.Add(new SqliteParameter(":name_l", uid.session_data.name_l)); |
611 | updatecmd.Parameters.Add(new SqliteParameter(":avg_agents_in_view", uid.session_data.avg_agents_in_view)); | ||
612 | updatecmd.Parameters.Add(new SqliteParameter(":min_agents_in_view", | ||
613 | (int) uid.session_data.min_agents_in_view)); | ||
614 | updatecmd.Parameters.Add(new SqliteParameter(":max_agents_in_view", | ||
615 | (int) uid.session_data.max_agents_in_view)); | ||
616 | updatecmd.Parameters.Add(new SqliteParameter(":mode_agents_in_view", | ||
617 | (int) uid.session_data.mode_agents_in_view)); | ||
618 | updatecmd.Parameters.Add(new SqliteParameter(":avg_fps", uid.session_data.avg_fps)); | ||
619 | updatecmd.Parameters.Add(new SqliteParameter(":min_fps", uid.session_data.min_fps)); | ||
620 | updatecmd.Parameters.Add(new SqliteParameter(":max_fps", uid.session_data.max_fps)); | ||
621 | updatecmd.Parameters.Add(new SqliteParameter(":mode_fps", uid.session_data.mode_fps)); | ||
622 | updatecmd.Parameters.Add(new SqliteParameter(":a_language", uid.session_data.a_language)); | ||
623 | updatecmd.Parameters.Add(new SqliteParameter(":mem_use", uid.session_data.mem_use)); | ||
624 | updatecmd.Parameters.Add(new SqliteParameter(":meters_traveled", uid.session_data.meters_traveled)); | ||
625 | updatecmd.Parameters.Add(new SqliteParameter(":avg_ping", uid.session_data.avg_ping)); | ||
626 | updatecmd.Parameters.Add(new SqliteParameter(":min_ping", uid.session_data.min_ping)); | ||
627 | updatecmd.Parameters.Add(new SqliteParameter(":max_ping", uid.session_data.max_ping)); | ||
628 | updatecmd.Parameters.Add(new SqliteParameter(":mode_ping", uid.session_data.mode_ping)); | ||
629 | updatecmd.Parameters.Add(new SqliteParameter(":regions_visited", uid.session_data.regions_visited)); | ||
630 | updatecmd.Parameters.Add(new SqliteParameter(":run_time", uid.session_data.run_time)); | ||
631 | updatecmd.Parameters.Add(new SqliteParameter(":avg_sim_fps", uid.session_data.avg_sim_fps)); | ||
632 | updatecmd.Parameters.Add(new SqliteParameter(":min_sim_fps", uid.session_data.min_sim_fps)); | ||
633 | updatecmd.Parameters.Add(new SqliteParameter(":max_sim_fps", uid.session_data.max_sim_fps)); | ||
634 | updatecmd.Parameters.Add(new SqliteParameter(":mode_sim_fps", uid.session_data.mode_sim_fps)); | ||
635 | updatecmd.Parameters.Add(new SqliteParameter(":start_time", uid.session_data.start_time)); | ||
636 | updatecmd.Parameters.Add(new SqliteParameter(":client_version", uid.session_data.client_version)); | ||
637 | updatecmd.Parameters.Add(new SqliteParameter(":s_cpu", uid.session_data.s_cpu)); | ||
638 | updatecmd.Parameters.Add(new SqliteParameter(":s_gpu", uid.session_data.s_gpu)); | ||
639 | updatecmd.Parameters.Add(new SqliteParameter(":s_os", uid.session_data.s_os)); | ||
640 | updatecmd.Parameters.Add(new SqliteParameter(":s_ram", uid.session_data.s_ram)); | ||
641 | updatecmd.Parameters.Add(new SqliteParameter(":d_object_kb", uid.session_data.d_object_kb)); | ||
642 | updatecmd.Parameters.Add(new SqliteParameter(":d_texture_kb", uid.session_data.d_texture_kb)); | ||
643 | updatecmd.Parameters.Add(new SqliteParameter(":d_world_kb", uid.session_data.d_world_kb)); | ||
644 | updatecmd.Parameters.Add(new SqliteParameter(":n_in_kb", uid.session_data.n_in_kb)); | ||
645 | updatecmd.Parameters.Add(new SqliteParameter(":n_in_pk", uid.session_data.n_in_pk)); | ||
646 | updatecmd.Parameters.Add(new SqliteParameter(":n_out_kb", uid.session_data.n_out_kb)); | ||
647 | updatecmd.Parameters.Add(new SqliteParameter(":n_out_pk", uid.session_data.n_out_pk)); | ||
648 | 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)); | ||
650 | 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)); | ||
653 | 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)); | ||
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 | |||
660 | // m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id); | ||
661 | |||
662 | int result = updatecmd.ExecuteNonQuery(); | ||
663 | |||
664 | if (result == 0) | ||
671 | { | 665 | { |
672 | m_log.Warn("[WEB STATS MODULE]: failed to write stats to storage Execution Exception"); | 666 | // m_log.DebugFormat("[WEB STATS MODULE]: Database stats insert for {0}", uid.session_data.agent_id); |
673 | } | 667 | |
674 | catch (SqliteSyntaxException) | 668 | updatecmd.CommandText = SQL_STATS_TABLE_INSERT; |
675 | { | ||
676 | m_log.Warn("[WEB STATS MODULE]: failed to write stats to storage SQL Syntax Exception"); | ||
677 | } | ||
678 | 669 | ||
670 | try | ||
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 | } | ||
679 | } | 681 | } |
680 | } | 682 | } |
681 | } | 683 | } |