diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | 123 |
1 files changed, 121 insertions, 2 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 992f38e..1eb0a6b 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Text; | 32 | using System.Text; |
32 | using log4net; | 33 | using log4net; |
@@ -51,7 +52,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
51 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")] | 52 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")] |
52 | public class LindenUDPInfoModule : ISharedRegionModule | 53 | public class LindenUDPInfoModule : ISharedRegionModule |
53 | { | 54 | { |
54 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 56 | ||
56 | protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | 57 | protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); |
57 | 58 | ||
@@ -130,6 +131,15 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
130 | "Go on/off emergency monitoring mode", | 131 | "Go on/off emergency monitoring mode", |
131 | "Go on/off emergency monitoring mode", | 132 | "Go on/off emergency monitoring mode", |
132 | HandleEmergencyMonitoring); | 133 | HandleEmergencyMonitoring); |
134 | |||
135 | scene.AddCommand( | ||
136 | "Comms", this, "show client stats", | ||
137 | "show client stats [first_name last_name]", | ||
138 | "Show client request stats", | ||
139 | "Without the 'first_name last_name' option, all clients are shown." | ||
140 | + " With the 'first_name last_name' option only a specific client is shown.", | ||
141 | (mod, cmd) => MainConsole.Instance.Output(HandleClientStatsReport(cmd))); | ||
142 | |||
133 | } | 143 | } |
134 | 144 | ||
135 | public void RemoveRegion(Scene scene) | 145 | public void RemoveRegion(Scene scene) |
@@ -587,6 +597,115 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
587 | (throttleRates.Asset * 8) / 1000); | 597 | (throttleRates.Asset * 8) / 1000); |
588 | 598 | ||
589 | return report.ToString(); | 599 | return report.ToString(); |
590 | } | 600 | } |
601 | |||
602 | /// <summary> | ||
603 | /// Show client stats data | ||
604 | /// </summary> | ||
605 | /// <param name="showParams"></param> | ||
606 | /// <returns></returns> | ||
607 | protected string HandleClientStatsReport(string[] showParams) | ||
608 | { | ||
609 | // NOTE: This writes to m_log on purpose. We want to store this information | ||
610 | // in case we need to analyze it later. | ||
611 | // | ||
612 | if (showParams.Length <= 4) | ||
613 | { | ||
614 | m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "AgentUpdates"); | ||
615 | foreach (Scene scene in m_scenes.Values) | ||
616 | { | ||
617 | scene.ForEachClient( | ||
618 | delegate(IClientAPI client) | ||
619 | { | ||
620 | if (client is LLClientView) | ||
621 | { | ||
622 | LLClientView llClient = client as LLClientView; | ||
623 | ClientInfo cinfo = llClient.UDPClient.GetClientInfo(); | ||
624 | int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum(); | ||
625 | avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); | ||
626 | |||
627 | string childAgentStatus; | ||
628 | |||
629 | if (llClient.SceneAgent != null) | ||
630 | childAgentStatus = llClient.SceneAgent.IsChildAgent ? "N" : "Y"; | ||
631 | else | ||
632 | childAgentStatus = "Off!"; | ||
633 | |||
634 | m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", | ||
635 | scene.RegionInfo.RegionName, llClient.Name, | ||
636 | childAgentStatus, | ||
637 | (DateTime.Now - cinfo.StartedTime).Minutes, | ||
638 | avg_reqs, | ||
639 | string.Format( | ||
640 | "{0} ({1:0.00}%)", | ||
641 | llClient.TotalAgentUpdates, | ||
642 | (float)cinfo.SyncRequests["AgentUpdate"] / llClient.TotalAgentUpdates * 100)); | ||
643 | } | ||
644 | }); | ||
645 | } | ||
646 | return string.Empty; | ||
647 | } | ||
648 | |||
649 | string fname = "", lname = ""; | ||
650 | |||
651 | if (showParams.Length > 3) | ||
652 | fname = showParams[3]; | ||
653 | if (showParams.Length > 4) | ||
654 | lname = showParams[4]; | ||
655 | |||
656 | foreach (Scene scene in m_scenes.Values) | ||
657 | { | ||
658 | scene.ForEachClient( | ||
659 | delegate(IClientAPI client) | ||
660 | { | ||
661 | if (client is LLClientView) | ||
662 | { | ||
663 | LLClientView llClient = client as LLClientView; | ||
664 | |||
665 | if (llClient.Name == fname + " " + lname) | ||
666 | { | ||
667 | |||
668 | ClientInfo cinfo = llClient.GetClientInfo(); | ||
669 | AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(llClient.CircuitCode); | ||
670 | if (aCircuit == null) // create a dummy one | ||
671 | aCircuit = new AgentCircuitData(); | ||
672 | |||
673 | if (!llClient.SceneAgent.IsChildAgent) | ||
674 | m_log.InfoFormat("[INFO]: {0} # {1} # {2}", llClient.Name, aCircuit.Viewer, aCircuit.Id0); | ||
675 | |||
676 | int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum(); | ||
677 | avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); | ||
678 | |||
679 | m_log.InfoFormat("[INFO]:"); | ||
680 | m_log.InfoFormat("[INFO]: {0} # {1} # Time: {2}min # Avg Reqs/min: {3}", scene.RegionInfo.RegionName, | ||
681 | (llClient.SceneAgent.IsChildAgent ? "Child" : "Root"), (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs); | ||
682 | |||
683 | Dictionary<string, int> sortedDict = (from entry in cinfo.AsyncRequests orderby entry.Value descending select entry) | ||
684 | .ToDictionary(pair => pair.Key, pair => pair.Value); | ||
685 | PrintRequests("TOP ASYNC", sortedDict, cinfo.AsyncRequests.Values.Sum()); | ||
686 | |||
687 | sortedDict = (from entry in cinfo.SyncRequests orderby entry.Value descending select entry) | ||
688 | .ToDictionary(pair => pair.Key, pair => pair.Value); | ||
689 | PrintRequests("TOP SYNC", sortedDict, cinfo.SyncRequests.Values.Sum()); | ||
690 | |||
691 | sortedDict = (from entry in cinfo.GenericRequests orderby entry.Value descending select entry) | ||
692 | .ToDictionary(pair => pair.Key, pair => pair.Value); | ||
693 | PrintRequests("TOP GENERIC", sortedDict, cinfo.GenericRequests.Values.Sum()); | ||
694 | } | ||
695 | } | ||
696 | }); | ||
697 | } | ||
698 | return string.Empty; | ||
699 | } | ||
700 | |||
701 | private void PrintRequests(string type, Dictionary<string, int> sortedDict, int sum) | ||
702 | { | ||
703 | m_log.InfoFormat("[INFO]:"); | ||
704 | m_log.InfoFormat("[INFO]: {0,25}", type); | ||
705 | foreach (KeyValuePair<string, int> kvp in sortedDict.Take(12)) | ||
706 | m_log.InfoFormat("[INFO]: {0,25} {1,-6}", kvp.Key, kvp.Value); | ||
707 | m_log.InfoFormat("[INFO]: {0,25}", "..."); | ||
708 | m_log.InfoFormat("[INFO]: {0,25} {1,-6}", "Total", sum); | ||
709 | } | ||
591 | } | 710 | } |
592 | } \ No newline at end of file | 711 | } \ No newline at end of file |