aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/UserStatistics
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-02-28 22:54:21 +0000
committerJustin Clark-Casey (justincc)2012-02-28 22:54:21 +0000
commit2fce7dd593571986cc08122a4fe015800fa765a6 (patch)
tree88c464dd29efaca93787bd0cf6fff6c8cd03902d /OpenSim/Region/UserStatistics
parentMove libopenjpeg native libraries into lib32 and lib64 as appropriate. (diff)
downloadopensim-SC-2fce7dd593571986cc08122a4fe015800fa765a6.zip
opensim-SC-2fce7dd593571986cc08122a4fe015800fa765a6.tar.gz
opensim-SC-2fce7dd593571986cc08122a4fe015800fa765a6.tar.bz2
opensim-SC-2fce7dd593571986cc08122a4fe015800fa765a6.tar.xz
Call Dispose() via using() on SqliteCommands in WebStatsModule after use.
Diffstat (limited to 'OpenSim/Region/UserStatistics')
-rw-r--r--OpenSim/Region/UserStatistics/WebStatsModule.cs197
1 files changed, 98 insertions, 99 deletions
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs
index ad272f7..b9ba4bc 100644
--- a/OpenSim/Region/UserStatistics/WebStatsModule.cs
+++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs
@@ -224,13 +224,11 @@ namespace OpenSim.Region.UserStatistics
224 concurrencyCounter--; 224 concurrencyCounter--;
225 225
226 response_code = 200; 226 response_code = 200;
227
228 } 227 }
229 else 228 else
230 { 229 {
231 strOut = MainServer.Instance.GetHTTP404(""); 230 strOut = MainServer.Instance.GetHTTP404("");
232 } 231 }
233
234 232
235 responsedata["int_response_code"] = response_code; 233 responsedata["int_response_code"] = response_code;
236 responsedata["content_type"] = contenttype; 234 responsedata["content_type"] = contenttype;
@@ -247,43 +245,44 @@ namespace OpenSim.Region.UserStatistics
247 // TODO: FIXME: implement stats migrations 245 // TODO: FIXME: implement stats migrations
248 const string SQL = @"SELECT * FROM migrations LIMIT 1"; 246 const string SQL = @"SELECT * FROM migrations LIMIT 1";
249 247
250 SqliteCommand cmd = new SqliteCommand(SQL, db); 248 using (SqliteCommand cmd = new SqliteCommand(SQL, db))
251
252 try
253 {
254 cmd.ExecuteNonQuery();
255 }
256 catch (SqliteSyntaxException)
257 { 249 {
258 CreateTables(db); 250 try
251 {
252 cmd.ExecuteNonQuery();
253 }
254 catch (SqliteSyntaxException)
255 {
256 CreateTables(db);
257 }
259 } 258 }
260 } 259 }
261 } 260 }
262 261
263 public void CreateTables(SqliteConnection db) 262 public void CreateTables(SqliteConnection db)
264 { 263 {
265 SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db); 264 using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db))
266 createcmd.ExecuteNonQuery(); 265 {
266 createcmd.ExecuteNonQuery();
267 267
268 createcmd.CommandText = SQL_MIGRA_TABLE_CREATE; 268 createcmd.CommandText = SQL_MIGRA_TABLE_CREATE;
269 createcmd.ExecuteNonQuery(); 269 createcmd.ExecuteNonQuery();
270 }
270 } 271 }
271 272
272 public virtual void PostInitialise() 273 public virtual void PostInitialise()
273 { 274 {
274 if (!enabled) 275 if (!enabled)
275 {
276 return; 276 return;
277 } 277
278 AddHandlers(); 278 AddHandlers();
279 } 279 }
280 280
281 public virtual void Close() 281 public virtual void Close()
282 { 282 {
283 if (!enabled) 283 if (!enabled)
284 {
285 return; 284 return;
286 } 285
287 dbConn.Close(); 286 dbConn.Close();
288 dbConn.Dispose(); 287 dbConn.Dispose();
289 m_sessions.Clear(); 288 m_sessions.Clear();
@@ -304,7 +303,8 @@ namespace OpenSim.Region.UserStatistics
304 303
305 public void OnRegisterCaps(UUID agentID, Caps caps) 304 public void OnRegisterCaps(UUID agentID, Caps caps)
306 { 305 {
307 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
308 string capsPath = "/CAPS/VS/" + UUID.Random(); 308 string capsPath = "/CAPS/VS/" + UUID.Random();
309 caps.RegisterHandler("ViewerStats", 309 caps.RegisterHandler("ViewerStats",
310 new RestStreamHandler("POST", capsPath, 310 new RestStreamHandler("POST", capsPath,
@@ -318,7 +318,6 @@ namespace OpenSim.Region.UserStatistics
318 318
319 public void OnDeRegisterCaps(UUID agentID, Caps caps) 319 public void OnDeRegisterCaps(UUID agentID, Caps caps)
320 { 320 {
321
322 } 321 }
323 322
324 protected virtual void AddHandlers() 323 protected virtual void AddHandlers()
@@ -368,7 +367,6 @@ namespace OpenSim.Region.UserStatistics
368 367
369 public void OnMakeChildAgent(ScenePresence agent) 368 public void OnMakeChildAgent(ScenePresence agent)
370 { 369 {
371
372 } 370 }
373 371
374 public void OnClientClosed(UUID agentID, Scene scene) 372 public void OnClientClosed(UUID agentID, Scene scene)
@@ -430,6 +428,7 @@ namespace OpenSim.Region.UserStatistics
430 return scene.RegionInfo.RegionID; 428 return scene.RegionInfo.RegionID;
431 } 429 }
432 } 430 }
431
433 return UUID.Zero; 432 return UUID.Zero;
434 } 433 }
435 434
@@ -458,14 +457,14 @@ namespace OpenSim.Region.UserStatistics
458 UserSessionData usd; 457 UserSessionData usd;
459 OSD message = OSDParser.DeserializeLLSDXml(request); 458 OSD message = OSDParser.DeserializeLLSDXml(request);
460 OSDMap mmap; 459 OSDMap mmap;
460
461 lock (m_sessions) 461 lock (m_sessions)
462 { 462 {
463 if (agentID != UUID.Zero) 463 if (agentID != UUID.Zero)
464 { 464 {
465
466 if (!m_sessions.ContainsKey(agentID)) 465 if (!m_sessions.ContainsKey(agentID))
467 { 466 {
468 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);
469 return new UserSessionID(); 468 return new UserSessionID();
470 } 469 }
471 uid = m_sessions[agentID]; 470 uid = m_sessions[agentID];
@@ -585,8 +584,6 @@ namespace OpenSim.Region.UserStatistics
585 usd.n_out_kb = (float)net_out["kbytes"].AsReal(); 584 usd.n_out_kb = (float)net_out["kbytes"].AsReal();
586 usd.n_out_pk = net_out["packets"].AsInteger(); 585 usd.n_out_pk = net_out["packets"].AsInteger();
587 } 586 }
588
589
590 } 587 }
591 } 588 }
592 589
@@ -602,83 +599,85 @@ namespace OpenSim.Region.UserStatistics
602 599
603 lock (db) 600 lock (db)
604 { 601 {
605 SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db); 602 using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db))
606 updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString()));
607 updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString()));
608 updatecmd.Parameters.Add(new SqliteParameter(":region_id", uid.session_data.region_id.ToString()));
609 updatecmd.Parameters.Add(new SqliteParameter(":last_updated", (int) uid.session_data.last_updated));
610 updatecmd.Parameters.Add(new SqliteParameter(":remote_ip", uid.session_data.remote_ip));
611 updatecmd.Parameters.Add(new SqliteParameter(":name_f", uid.session_data.name_f));
612 updatecmd.Parameters.Add(new SqliteParameter(":name_l", uid.session_data.name_l));
613 updatecmd.Parameters.Add(new SqliteParameter(":avg_agents_in_view", uid.session_data.avg_agents_in_view));
614 updatecmd.Parameters.Add(new SqliteParameter(":min_agents_in_view",
615 (int) uid.session_data.min_agents_in_view));
616 updatecmd.Parameters.Add(new SqliteParameter(":max_agents_in_view",
617 (int) uid.session_data.max_agents_in_view));
618 updatecmd.Parameters.Add(new SqliteParameter(":mode_agents_in_view",
619 (int) uid.session_data.mode_agents_in_view));
620 updatecmd.Parameters.Add(new SqliteParameter(":avg_fps", uid.session_data.avg_fps));
621 updatecmd.Parameters.Add(new SqliteParameter(":min_fps", uid.session_data.min_fps));
622 updatecmd.Parameters.Add(new SqliteParameter(":max_fps", uid.session_data.max_fps));
623 updatecmd.Parameters.Add(new SqliteParameter(":mode_fps", uid.session_data.mode_fps));
624 updatecmd.Parameters.Add(new SqliteParameter(":a_language", uid.session_data.a_language));
625 updatecmd.Parameters.Add(new SqliteParameter(":mem_use", uid.session_data.mem_use));
626 updatecmd.Parameters.Add(new SqliteParameter(":meters_traveled", uid.session_data.meters_traveled));
627 updatecmd.Parameters.Add(new SqliteParameter(":avg_ping", uid.session_data.avg_ping));
628 updatecmd.Parameters.Add(new SqliteParameter(":min_ping", uid.session_data.min_ping));
629 updatecmd.Parameters.Add(new SqliteParameter(":max_ping", uid.session_data.max_ping));
630 updatecmd.Parameters.Add(new SqliteParameter(":mode_ping", uid.session_data.mode_ping));
631 updatecmd.Parameters.Add(new SqliteParameter(":regions_visited", uid.session_data.regions_visited));
632 updatecmd.Parameters.Add(new SqliteParameter(":run_time", uid.session_data.run_time));
633 updatecmd.Parameters.Add(new SqliteParameter(":avg_sim_fps", uid.session_data.avg_sim_fps));
634 updatecmd.Parameters.Add(new SqliteParameter(":min_sim_fps", uid.session_data.min_sim_fps));
635 updatecmd.Parameters.Add(new SqliteParameter(":max_sim_fps", uid.session_data.max_sim_fps));
636 updatecmd.Parameters.Add(new SqliteParameter(":mode_sim_fps", uid.session_data.mode_sim_fps));
637 updatecmd.Parameters.Add(new SqliteParameter(":start_time", uid.session_data.start_time));
638 updatecmd.Parameters.Add(new SqliteParameter(":client_version", uid.session_data.client_version));
639 updatecmd.Parameters.Add(new SqliteParameter(":s_cpu", uid.session_data.s_cpu));
640 updatecmd.Parameters.Add(new SqliteParameter(":s_gpu", uid.session_data.s_gpu));
641 updatecmd.Parameters.Add(new SqliteParameter(":s_os", uid.session_data.s_os));
642 updatecmd.Parameters.Add(new SqliteParameter(":s_ram", uid.session_data.s_ram));
643 updatecmd.Parameters.Add(new SqliteParameter(":d_object_kb", uid.session_data.d_object_kb));
644 updatecmd.Parameters.Add(new SqliteParameter(":d_texture_kb", uid.session_data.d_texture_kb));
645 updatecmd.Parameters.Add(new SqliteParameter(":d_world_kb", uid.session_data.d_world_kb));
646 updatecmd.Parameters.Add(new SqliteParameter(":n_in_kb", uid.session_data.n_in_kb));
647 updatecmd.Parameters.Add(new SqliteParameter(":n_in_pk", uid.session_data.n_in_pk));
648 updatecmd.Parameters.Add(new SqliteParameter(":n_out_kb", uid.session_data.n_out_kb));
649 updatecmd.Parameters.Add(new SqliteParameter(":n_out_pk", uid.session_data.n_out_pk));
650 updatecmd.Parameters.Add(new SqliteParameter(":f_dropped", uid.session_data.f_dropped));
651 updatecmd.Parameters.Add(new SqliteParameter(":f_failed_resends", uid.session_data.f_failed_resends));
652 updatecmd.Parameters.Add(new SqliteParameter(":f_invalid", uid.session_data.f_invalid));
653
654 updatecmd.Parameters.Add(new SqliteParameter(":f_off_circuit", uid.session_data.f_off_circuit));
655 updatecmd.Parameters.Add(new SqliteParameter(":f_resent", uid.session_data.f_resent));
656 updatecmd.Parameters.Add(new SqliteParameter(":f_send_packet", uid.session_data.f_send_packet));
657
658 updatecmd.Parameters.Add(new SqliteParameter(":session_key", uid.session_data.session_id.ToString()));
659 updatecmd.Parameters.Add(new SqliteParameter(":agent_key", uid.session_data.agent_id.ToString()));
660 updatecmd.Parameters.Add(new SqliteParameter(":region_key", uid.session_data.region_id.ToString()));
661// m_log.Debug("UPDATE");
662
663 int result = updatecmd.ExecuteNonQuery();
664
665 if (result == 0)
666 { 603 {
667// m_log.Debug("INSERT"); 604 updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString()));
668 updatecmd.CommandText = SQL_STATS_TABLE_INSERT; 605 updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString()));
669 try 606 updatecmd.Parameters.Add(new SqliteParameter(":region_id", uid.session_data.region_id.ToString()));
670 { 607 updatecmd.Parameters.Add(new SqliteParameter(":last_updated", (int) uid.session_data.last_updated));
671 updatecmd.ExecuteNonQuery(); 608 updatecmd.Parameters.Add(new SqliteParameter(":remote_ip", uid.session_data.remote_ip));
672 } 609 updatecmd.Parameters.Add(new SqliteParameter(":name_f", uid.session_data.name_f));
673 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)
674 { 665 {
675 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);
676 } 667
677 catch (SqliteSyntaxException) 668 updatecmd.CommandText = SQL_STATS_TABLE_INSERT;
678 {
679 m_log.Warn("[WEB STATS MODULE]: failed to write stats to storage SQL Syntax Exception");
680 }
681 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 }
682 } 681 }
683 } 682 }
684 } 683 }