diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/UserStatistics/WebStatsModule.cs | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index c11ea02..625eba4 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs | |||
@@ -61,7 +61,7 @@ namespace OpenSim.Region.UserStatistics | |||
61 | /// <summary> | 61 | /// <summary> |
62 | /// User statistics sessions keyed by agent ID | 62 | /// User statistics sessions keyed by agent ID |
63 | /// </summary> | 63 | /// </summary> |
64 | private Dictionary<UUID, UserSessionID> m_sessions = new Dictionary<UUID, UserSessionID>(); | 64 | private Dictionary<UUID, UserSession> m_sessions = new Dictionary<UUID, UserSession>(); |
65 | 65 | ||
66 | private List<Scene> m_scenes = new List<Scene>(); | 66 | private List<Scene> m_scenes = new List<Scene>(); |
67 | private Dictionary<string, IStatsController> reports = new Dictionary<string, IStatsController>(); | 67 | private Dictionary<string, IStatsController> reports = new Dictionary<string, IStatsController>(); |
@@ -319,14 +319,18 @@ namespace OpenSim.Region.UserStatistics | |||
319 | 319 | ||
320 | private void OnMakeRootAgent(ScenePresence agent) | 320 | private void OnMakeRootAgent(ScenePresence agent) |
321 | { | 321 | { |
322 | // m_log.DebugFormat( | ||
323 | // "[WEB STATS MODULE]: Looking for session {0} for {1} in {2}", | ||
324 | // agent.ControllingClient.SessionId, agent.Name, agent.Scene.Name); | ||
325 | |||
322 | lock (m_sessions) | 326 | lock (m_sessions) |
323 | { | 327 | { |
324 | UserSessionID uid; | 328 | UserSession uid; |
325 | 329 | ||
326 | if (!m_sessions.ContainsKey(agent.UUID)) | 330 | if (!m_sessions.ContainsKey(agent.UUID)) |
327 | { | 331 | { |
328 | UserSessionData usd = UserSessionUtil.newUserSessionData(); | 332 | UserSessionData usd = UserSessionUtil.newUserSessionData(); |
329 | uid = new UserSessionID(); | 333 | uid = new UserSession(); |
330 | uid.name_f = agent.Firstname; | 334 | uid.name_f = agent.Firstname; |
331 | uid.name_l = agent.Lastname; | 335 | uid.name_l = agent.Lastname; |
332 | uid.session_data = usd; | 336 | uid.session_data = usd; |
@@ -411,9 +415,9 @@ namespace OpenSim.Region.UserStatistics | |||
411 | return String.Empty; | 415 | return String.Empty; |
412 | } | 416 | } |
413 | 417 | ||
414 | private UserSessionID ParseViewerStats(string request, UUID agentID) | 418 | private UserSession ParseViewerStats(string request, UUID agentID) |
415 | { | 419 | { |
416 | UserSessionID uid = new UserSessionID(); | 420 | UserSession uid = new UserSession(); |
417 | UserSessionData usd; | 421 | UserSessionData usd; |
418 | OSD message = OSDParser.DeserializeLLSDXml(request); | 422 | OSD message = OSDParser.DeserializeLLSDXml(request); |
419 | OSDMap mmap; | 423 | OSDMap mmap; |
@@ -425,22 +429,25 @@ namespace OpenSim.Region.UserStatistics | |||
425 | if (!m_sessions.ContainsKey(agentID)) | 429 | if (!m_sessions.ContainsKey(agentID)) |
426 | { | 430 | { |
427 | m_log.WarnFormat("[WEB STATS MODULE]: no session for stat disclosure for agent {0}", agentID); | 431 | m_log.WarnFormat("[WEB STATS MODULE]: no session for stat disclosure for agent {0}", agentID); |
428 | return new UserSessionID(); | 432 | return new UserSession(); |
429 | } | 433 | } |
434 | |||
430 | uid = m_sessions[agentID]; | 435 | uid = m_sessions[agentID]; |
436 | |||
437 | // m_log.DebugFormat("[WEB STATS MODULE]: Got session {0} for {1}", uid.session_id, agentID); | ||
431 | } | 438 | } |
432 | else | 439 | else |
433 | { | 440 | { |
434 | // parse through the beginning to locate the session | 441 | // parse through the beginning to locate the session |
435 | if (message.Type != OSDType.Map) | 442 | if (message.Type != OSDType.Map) |
436 | return new UserSessionID(); | 443 | return new UserSession(); |
437 | 444 | ||
438 | mmap = (OSDMap)message; | 445 | mmap = (OSDMap)message; |
439 | { | 446 | { |
440 | UUID sessionID = mmap["session_id"].AsUUID(); | 447 | UUID sessionID = mmap["session_id"].AsUUID(); |
441 | 448 | ||
442 | if (sessionID == UUID.Zero) | 449 | if (sessionID == UUID.Zero) |
443 | return new UserSessionID(); | 450 | return new UserSession(); |
444 | 451 | ||
445 | 452 | ||
446 | // search through each session looking for the owner | 453 | // search through each session looking for the owner |
@@ -459,7 +466,7 @@ namespace OpenSim.Region.UserStatistics | |||
459 | // can't find a session | 466 | // can't find a session |
460 | if (agentID == UUID.Zero) | 467 | if (agentID == UUID.Zero) |
461 | { | 468 | { |
462 | return new UserSessionID(); | 469 | return new UserSession(); |
463 | } | 470 | } |
464 | } | 471 | } |
465 | } | 472 | } |
@@ -468,12 +475,12 @@ namespace OpenSim.Region.UserStatistics | |||
468 | usd = uid.session_data; | 475 | usd = uid.session_data; |
469 | 476 | ||
470 | if (message.Type != OSDType.Map) | 477 | if (message.Type != OSDType.Map) |
471 | return new UserSessionID(); | 478 | return new UserSession(); |
472 | 479 | ||
473 | mmap = (OSDMap)message; | 480 | mmap = (OSDMap)message; |
474 | { | 481 | { |
475 | if (mmap["agent"].Type != OSDType.Map) | 482 | if (mmap["agent"].Type != OSDType.Map) |
476 | return new UserSessionID(); | 483 | return new UserSession(); |
477 | OSDMap agent_map = (OSDMap)mmap["agent"]; | 484 | OSDMap agent_map = (OSDMap)mmap["agent"]; |
478 | usd.agent_id = agentID; | 485 | usd.agent_id = agentID; |
479 | usd.name_f = uid.name_f; | 486 | usd.name_f = uid.name_f; |
@@ -493,17 +500,18 @@ namespace OpenSim.Region.UserStatistics | |||
493 | (float)agent_map["fps"].AsReal()); | 500 | (float)agent_map["fps"].AsReal()); |
494 | 501 | ||
495 | if (mmap["downloads"].Type != OSDType.Map) | 502 | if (mmap["downloads"].Type != OSDType.Map) |
496 | return new UserSessionID(); | 503 | return new UserSession(); |
497 | OSDMap downloads_map = (OSDMap)mmap["downloads"]; | 504 | OSDMap downloads_map = (OSDMap)mmap["downloads"]; |
498 | usd.d_object_kb = (float)downloads_map["object_kbytes"].AsReal(); | 505 | usd.d_object_kb = (float)downloads_map["object_kbytes"].AsReal(); |
499 | usd.d_texture_kb = (float)downloads_map["texture_kbytes"].AsReal(); | 506 | usd.d_texture_kb = (float)downloads_map["texture_kbytes"].AsReal(); |
500 | usd.d_world_kb = (float)downloads_map["workd_kbytes"].AsReal(); | 507 | usd.d_world_kb = (float)downloads_map["workd_kbytes"].AsReal(); |
501 | 508 | ||
509 | // m_log.DebugFormat("[WEB STATS MODULE]: mmap[\"session_id\"] = [{0}]", mmap["session_id"].AsUUID()); | ||
502 | 510 | ||
503 | usd.session_id = mmap["session_id"].AsUUID(); | 511 | usd.session_id = mmap["session_id"].AsUUID(); |
504 | 512 | ||
505 | if (mmap["system"].Type != OSDType.Map) | 513 | if (mmap["system"].Type != OSDType.Map) |
506 | return new UserSessionID(); | 514 | return new UserSession(); |
507 | OSDMap system_map = (OSDMap)mmap["system"]; | 515 | OSDMap system_map = (OSDMap)mmap["system"]; |
508 | 516 | ||
509 | usd.s_cpu = system_map["cpu"].AsString(); | 517 | usd.s_cpu = system_map["cpu"].AsString(); |
@@ -512,13 +520,13 @@ namespace OpenSim.Region.UserStatistics | |||
512 | usd.s_ram = system_map["ram"].AsInteger(); | 520 | usd.s_ram = system_map["ram"].AsInteger(); |
513 | 521 | ||
514 | if (mmap["stats"].Type != OSDType.Map) | 522 | if (mmap["stats"].Type != OSDType.Map) |
515 | return new UserSessionID(); | 523 | return new UserSession(); |
516 | 524 | ||
517 | OSDMap stats_map = (OSDMap)mmap["stats"]; | 525 | OSDMap stats_map = (OSDMap)mmap["stats"]; |
518 | { | 526 | { |
519 | 527 | ||
520 | if (stats_map["failures"].Type != OSDType.Map) | 528 | if (stats_map["failures"].Type != OSDType.Map) |
521 | return new UserSessionID(); | 529 | return new UserSession(); |
522 | OSDMap stats_failures = (OSDMap)stats_map["failures"]; | 530 | OSDMap stats_failures = (OSDMap)stats_map["failures"]; |
523 | usd.f_dropped = stats_failures["dropped"].AsInteger(); | 531 | usd.f_dropped = stats_failures["dropped"].AsInteger(); |
524 | usd.f_failed_resends = stats_failures["failed_resends"].AsInteger(); | 532 | usd.f_failed_resends = stats_failures["failed_resends"].AsInteger(); |
@@ -527,18 +535,18 @@ namespace OpenSim.Region.UserStatistics | |||
527 | usd.f_send_packet = stats_failures["send_packet"].AsInteger(); | 535 | usd.f_send_packet = stats_failures["send_packet"].AsInteger(); |
528 | 536 | ||
529 | if (stats_map["net"].Type != OSDType.Map) | 537 | if (stats_map["net"].Type != OSDType.Map) |
530 | return new UserSessionID(); | 538 | return new UserSession(); |
531 | OSDMap stats_net = (OSDMap)stats_map["net"]; | 539 | OSDMap stats_net = (OSDMap)stats_map["net"]; |
532 | { | 540 | { |
533 | if (stats_net["in"].Type != OSDType.Map) | 541 | if (stats_net["in"].Type != OSDType.Map) |
534 | return new UserSessionID(); | 542 | return new UserSession(); |
535 | 543 | ||
536 | OSDMap net_in = (OSDMap)stats_net["in"]; | 544 | OSDMap net_in = (OSDMap)stats_net["in"]; |
537 | usd.n_in_kb = (float)net_in["kbytes"].AsReal(); | 545 | usd.n_in_kb = (float)net_in["kbytes"].AsReal(); |
538 | usd.n_in_pk = net_in["packets"].AsInteger(); | 546 | usd.n_in_pk = net_in["packets"].AsInteger(); |
539 | 547 | ||
540 | if (stats_net["out"].Type != OSDType.Map) | 548 | if (stats_net["out"].Type != OSDType.Map) |
541 | return new UserSessionID(); | 549 | return new UserSession(); |
542 | OSDMap net_out = (OSDMap)stats_net["out"]; | 550 | OSDMap net_out = (OSDMap)stats_net["out"]; |
543 | 551 | ||
544 | usd.n_out_kb = (float)net_out["kbytes"].AsReal(); | 552 | usd.n_out_kb = (float)net_out["kbytes"].AsReal(); |
@@ -549,11 +557,18 @@ namespace OpenSim.Region.UserStatistics | |||
549 | 557 | ||
550 | uid.session_data = usd; | 558 | uid.session_data = usd; |
551 | m_sessions[agentID] = uid; | 559 | m_sessions[agentID] = uid; |
560 | |||
561 | // m_log.DebugFormat( | ||
562 | // "[WEB STATS MODULE]: Parse data for {0} {1}, session {2}", uid.name_f, uid.name_l, uid.session_id); | ||
563 | |||
552 | return uid; | 564 | return uid; |
553 | } | 565 | } |
554 | 566 | ||
555 | private void UpdateUserStats(UserSessionID uid, SqliteConnection db) | 567 | private void UpdateUserStats(UserSession uid, SqliteConnection db) |
556 | { | 568 | { |
569 | // m_log.DebugFormat( | ||
570 | // "[WEB STATS MODULE]: Updating user stats for {0} {1}, session {2}", uid.name_f, uid.name_l, uid.session_id); | ||
571 | |||
557 | if (uid.session_id == UUID.Zero) | 572 | if (uid.session_id == UUID.Zero) |
558 | return; | 573 | return; |
559 | 574 | ||
@@ -740,7 +755,6 @@ VALUES | |||
740 | s.min_ping = ArrayMin_f(__ping); | 755 | s.min_ping = ArrayMin_f(__ping); |
741 | s.max_ping = ArrayMax_f(__ping); | 756 | s.max_ping = ArrayMax_f(__ping); |
742 | s.mode_ping = ArrayMode_f(__ping); | 757 | s.mode_ping = ArrayMode_f(__ping); |
743 | |||
744 | } | 758 | } |
745 | 759 | ||
746 | #region Statistics | 760 | #region Statistics |
@@ -985,7 +999,7 @@ VALUES | |||
985 | } | 999 | } |
986 | #region structs | 1000 | #region structs |
987 | 1001 | ||
988 | public struct UserSessionID | 1002 | public class UserSession |
989 | { | 1003 | { |
990 | public UUID session_id; | 1004 | public UUID session_id; |
991 | public UUID region_id; | 1005 | public UUID region_id; |