diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Agent/UDP/Linden')
-rw-r--r-- | OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | 163 |
1 files changed, 140 insertions, 23 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 992f38e..ec18db0 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) |
@@ -294,7 +304,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
294 | private string GetImageQueuesReport(string[] showParams) | 304 | private string GetImageQueuesReport(string[] showParams) |
295 | { | 305 | { |
296 | if (showParams.Length < 5 || showParams.Length > 6) | 306 | if (showParams.Length < 5 || showParams.Length > 6) |
297 | return "Usage: image queues show <first-name> <last-name> [full]"; | 307 | return "Usage: show image queues <first-name> <last-name> [full]"; |
298 | 308 | ||
299 | string firstName = showParams[3]; | 309 | string firstName = showParams[3]; |
300 | string lastName = showParams[4]; | 310 | string lastName = showParams[4]; |
@@ -385,7 +395,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
385 | report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); | 395 | report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); |
386 | 396 | ||
387 | report.AppendFormat( | 397 | report.AppendFormat( |
388 | "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n", | 398 | "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n", |
389 | "Since", | 399 | "Since", |
390 | "Pkts", | 400 | "Pkts", |
391 | "Pkts", | 401 | "Pkts", |
@@ -397,12 +407,11 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
397 | "Q Pkts", | 407 | "Q Pkts", |
398 | "Q Pkts", | 408 | "Q Pkts", |
399 | "Q Pkts", | 409 | "Q Pkts", |
400 | "Q Pkts", | ||
401 | "Q Pkts"); | 410 | "Q Pkts"); |
402 | 411 | ||
403 | report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); | 412 | report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); |
404 | report.AppendFormat( | 413 | report.AppendFormat( |
405 | "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n", | 414 | "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n", |
406 | "Last In", | 415 | "Last In", |
407 | "In", | 416 | "In", |
408 | "Out", | 417 | "Out", |
@@ -414,8 +423,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
414 | "Cloud", | 423 | "Cloud", |
415 | "Task", | 424 | "Task", |
416 | "Texture", | 425 | "Texture", |
417 | "Asset", | 426 | "Asset"); |
418 | "State"); | ||
419 | 427 | ||
420 | lock (m_scenes) | 428 | lock (m_scenes) |
421 | { | 429 | { |
@@ -424,24 +432,24 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
424 | scene.ForEachClient( | 432 | scene.ForEachClient( |
425 | delegate(IClientAPI client) | 433 | delegate(IClientAPI client) |
426 | { | 434 | { |
427 | bool isChild = client.SceneAgent.IsChildAgent; | ||
428 | if (isChild && !showChildren) | ||
429 | return; | ||
430 | |||
431 | string name = client.Name; | ||
432 | if (pname != "" && name != pname) | ||
433 | return; | ||
434 | |||
435 | string regionName = scene.RegionInfo.RegionName; | ||
436 | |||
437 | report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); | ||
438 | report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); | ||
439 | report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); | ||
440 | |||
441 | if (client is IStatsCollector) | 435 | if (client is IStatsCollector) |
442 | { | 436 | { |
443 | IStatsCollector stats = (IStatsCollector)client; | 437 | |
438 | bool isChild = client.SceneAgent.IsChildAgent; | ||
439 | if (isChild && !showChildren) | ||
440 | return; | ||
444 | 441 | ||
442 | string name = client.Name; | ||
443 | if (pname != "" && name != pname) | ||
444 | return; | ||
445 | |||
446 | string regionName = scene.RegionInfo.RegionName; | ||
447 | |||
448 | report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); | ||
449 | report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); | ||
450 | report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); | ||
451 | |||
452 | IStatsCollector stats = (IStatsCollector)client; | ||
445 | report.AppendLine(stats.Report()); | 453 | report.AppendLine(stats.Report()); |
446 | } | 454 | } |
447 | }); | 455 | }); |
@@ -587,6 +595,115 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
587 | (throttleRates.Asset * 8) / 1000); | 595 | (throttleRates.Asset * 8) / 1000); |
588 | 596 | ||
589 | return report.ToString(); | 597 | return report.ToString(); |
590 | } | 598 | } |
599 | |||
600 | /// <summary> | ||
601 | /// Show client stats data | ||
602 | /// </summary> | ||
603 | /// <param name="showParams"></param> | ||
604 | /// <returns></returns> | ||
605 | protected string HandleClientStatsReport(string[] showParams) | ||
606 | { | ||
607 | // NOTE: This writes to m_log on purpose. We want to store this information | ||
608 | // in case we need to analyze it later. | ||
609 | // | ||
610 | if (showParams.Length <= 4) | ||
611 | { | ||
612 | m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "AgentUpdates"); | ||
613 | foreach (Scene scene in m_scenes.Values) | ||
614 | { | ||
615 | scene.ForEachClient( | ||
616 | delegate(IClientAPI client) | ||
617 | { | ||
618 | if (client is LLClientView) | ||
619 | { | ||
620 | LLClientView llClient = client as LLClientView; | ||
621 | ClientInfo cinfo = llClient.UDPClient.GetClientInfo(); | ||
622 | int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum(); | ||
623 | avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); | ||
624 | |||
625 | string childAgentStatus; | ||
626 | |||
627 | if (llClient.SceneAgent != null) | ||
628 | childAgentStatus = llClient.SceneAgent.IsChildAgent ? "N" : "Y"; | ||
629 | else | ||
630 | childAgentStatus = "Off!"; | ||
631 | |||
632 | m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", | ||
633 | scene.RegionInfo.RegionName, llClient.Name, | ||
634 | childAgentStatus, | ||
635 | (DateTime.Now - cinfo.StartedTime).Minutes, | ||
636 | avg_reqs, | ||
637 | string.Format( | ||
638 | "{0} ({1:0.00}%)", | ||
639 | llClient.TotalAgentUpdates, | ||
640 | (float)cinfo.SyncRequests["AgentUpdate"] / llClient.TotalAgentUpdates * 100)); | ||
641 | } | ||
642 | }); | ||
643 | } | ||
644 | return string.Empty; | ||
645 | } | ||
646 | |||
647 | string fname = "", lname = ""; | ||
648 | |||
649 | if (showParams.Length > 3) | ||
650 | fname = showParams[3]; | ||
651 | if (showParams.Length > 4) | ||
652 | lname = showParams[4]; | ||
653 | |||
654 | foreach (Scene scene in m_scenes.Values) | ||
655 | { | ||
656 | scene.ForEachClient( | ||
657 | delegate(IClientAPI client) | ||
658 | { | ||
659 | if (client is LLClientView) | ||
660 | { | ||
661 | LLClientView llClient = client as LLClientView; | ||
662 | |||
663 | if (llClient.Name == fname + " " + lname) | ||
664 | { | ||
665 | |||
666 | ClientInfo cinfo = llClient.GetClientInfo(); | ||
667 | AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(llClient.CircuitCode); | ||
668 | if (aCircuit == null) // create a dummy one | ||
669 | aCircuit = new AgentCircuitData(); | ||
670 | |||
671 | if (!llClient.SceneAgent.IsChildAgent) | ||
672 | m_log.InfoFormat("[INFO]: {0} # {1} # {2}", llClient.Name, aCircuit.Viewer, aCircuit.Id0); | ||
673 | |||
674 | int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum(); | ||
675 | avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); | ||
676 | |||
677 | m_log.InfoFormat("[INFO]:"); | ||
678 | m_log.InfoFormat("[INFO]: {0} # {1} # Time: {2}min # Avg Reqs/min: {3}", scene.RegionInfo.RegionName, | ||
679 | (llClient.SceneAgent.IsChildAgent ? "Child" : "Root"), (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs); | ||
680 | |||
681 | Dictionary<string, int> sortedDict = (from entry in cinfo.AsyncRequests orderby entry.Value descending select entry) | ||
682 | .ToDictionary(pair => pair.Key, pair => pair.Value); | ||
683 | PrintRequests("TOP ASYNC", sortedDict, cinfo.AsyncRequests.Values.Sum()); | ||
684 | |||
685 | sortedDict = (from entry in cinfo.SyncRequests orderby entry.Value descending select entry) | ||
686 | .ToDictionary(pair => pair.Key, pair => pair.Value); | ||
687 | PrintRequests("TOP SYNC", sortedDict, cinfo.SyncRequests.Values.Sum()); | ||
688 | |||
689 | sortedDict = (from entry in cinfo.GenericRequests orderby entry.Value descending select entry) | ||
690 | .ToDictionary(pair => pair.Key, pair => pair.Value); | ||
691 | PrintRequests("TOP GENERIC", sortedDict, cinfo.GenericRequests.Values.Sum()); | ||
692 | } | ||
693 | } | ||
694 | }); | ||
695 | } | ||
696 | return string.Empty; | ||
697 | } | ||
698 | |||
699 | private void PrintRequests(string type, Dictionary<string, int> sortedDict, int sum) | ||
700 | { | ||
701 | m_log.InfoFormat("[INFO]:"); | ||
702 | m_log.InfoFormat("[INFO]: {0,25}", type); | ||
703 | foreach (KeyValuePair<string, int> kvp in sortedDict.Take(12)) | ||
704 | m_log.InfoFormat("[INFO]: {0,25} {1,-6}", kvp.Key, kvp.Value); | ||
705 | m_log.InfoFormat("[INFO]: {0,25}", "..."); | ||
706 | m_log.InfoFormat("[INFO]: {0,25} {1,-6}", "Total", sum); | ||
707 | } | ||
591 | } | 708 | } |
592 | } \ No newline at end of file | 709 | } \ No newline at end of file |