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