diff options
author | Justin Clark-Casey (justincc) | 2011-01-20 22:57:12 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-01-20 22:57:12 +0000 |
commit | 1baf63dbae8208172aa457963636116d42dbe9b3 (patch) | |
tree | 09adc7a1192da09b44d4afad503e56ce0fa85f18 /OpenSim/Region/CoreModules | |
parent | remove unimplemented "show assets" command (diff) | |
download | opensim-SC_OLD-1baf63dbae8208172aa457963636116d42dbe9b3.zip opensim-SC_OLD-1baf63dbae8208172aa457963636116d42dbe9b3.tar.gz opensim-SC_OLD-1baf63dbae8208172aa457963636116d42dbe9b3.tar.bz2 opensim-SC_OLD-1baf63dbae8208172aa457963636116d42dbe9b3.tar.xz |
Move "show queues" command out of OpenSim.cs and into a separate module.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/UDP/Linden/LindenUDPModule.cs | 200 |
1 files changed, 200 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/UDP/Linden/LindenUDPModule.cs b/OpenSim/Region/CoreModules/Agent/UDP/Linden/LindenUDPModule.cs new file mode 100644 index 0000000..3240434 --- /dev/null +++ b/OpenSim/Region/CoreModules/Agent/UDP/Linden/LindenUDPModule.cs | |||
@@ -0,0 +1,200 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using Mono.Addins; | ||
34 | using Nini.Config; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Framework.Statistics; | ||
39 | using OpenSim.Region.Framework.Interfaces; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.UDP.Linden | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// A module that just holds commands for inspecting/changing the Linden UDP client stack | ||
46 | /// </summary> | ||
47 | /// <remarks> | ||
48 | /// All actual client stack functionality remains in OpenSim.Region.ClientStack.LindenUDP | ||
49 | /// </remarks> | ||
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPModule")] | ||
51 | public class LindenUDPModule : ISharedRegionModule | ||
52 | { | ||
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | |||
55 | protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | ||
56 | |||
57 | public string Name { get { return "Linden UDP Module"; } } | ||
58 | |||
59 | public Type ReplaceableInterface { get { return null; } } | ||
60 | |||
61 | public void Initialise(IConfigSource source) | ||
62 | { | ||
63 | // m_log.DebugFormat("[LINDEN UDP MODULE]: INITIALIZED MODULE"); | ||
64 | } | ||
65 | |||
66 | public void PostInitialise() | ||
67 | { | ||
68 | // m_log.DebugFormat("[LINDEN UDP MODULE]: POST INITIALIZED MODULE"); | ||
69 | } | ||
70 | |||
71 | public void Close() | ||
72 | { | ||
73 | // m_log.DebugFormat("[LINDEN UDP MODULE]: CLOSED MODULE"); | ||
74 | } | ||
75 | |||
76 | public void AddRegion(Scene scene) | ||
77 | { | ||
78 | // m_log.DebugFormat("[LINDEN UDP MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); | ||
79 | |||
80 | lock (m_scenes) | ||
81 | m_scenes[scene.RegionInfo.RegionID] = scene; | ||
82 | |||
83 | scene.AddCommand( | ||
84 | this, "show queues", | ||
85 | "show queues [full]", | ||
86 | "Show queue data for each client", | ||
87 | "Without the 'full' option, only users actually on the region are shown." | ||
88 | + " With the 'full' option child agents of users in neighbouring regions are also shown.", | ||
89 | ShowQueuesReport); | ||
90 | } | ||
91 | |||
92 | public void RemoveRegion(Scene scene) | ||
93 | { | ||
94 | // m_log.DebugFormat("[LINDEN UDP MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | ||
95 | |||
96 | lock (m_scenes) | ||
97 | m_scenes.Remove(scene.RegionInfo.RegionID); | ||
98 | } | ||
99 | |||
100 | public void RegionLoaded(Scene scene) | ||
101 | { | ||
102 | // m_log.DebugFormat("[LINDEN UDP MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); | ||
103 | } | ||
104 | |||
105 | protected void ShowQueuesReport(string module, string[] cmd) | ||
106 | { | ||
107 | MainConsole.Instance.Output(GetQueuesReport(cmd)); | ||
108 | } | ||
109 | |||
110 | /// <summary> | ||
111 | /// Generate UDP Queue data report for each client | ||
112 | /// </summary> | ||
113 | /// <param name="showParams"></param> | ||
114 | /// <returns></returns> | ||
115 | protected string GetQueuesReport(string[] showParams) | ||
116 | { | ||
117 | bool showChildren = false; | ||
118 | |||
119 | if (showParams.Length > 2 && showParams[2] == "full") | ||
120 | showChildren = true; | ||
121 | |||
122 | StringBuilder report = new StringBuilder(); | ||
123 | |||
124 | int columnPadding = 2; | ||
125 | int maxNameLength = 18; | ||
126 | int maxRegionNameLength = 14; | ||
127 | int maxTypeLength = 4; | ||
128 | int totalInfoFieldsLength = maxNameLength + columnPadding + maxRegionNameLength + columnPadding + maxTypeLength + columnPadding; | ||
129 | |||
130 | report.AppendFormat("{0,-" + maxNameLength + "}{1,-" + columnPadding + "}", "User", ""); | ||
131 | report.AppendFormat("{0,-" + maxRegionNameLength + "}{1,-" + columnPadding + "}", "Region", ""); | ||
132 | report.AppendFormat("{0,-" + maxTypeLength + "}{1,-" + columnPadding + "}", "Type", ""); | ||
133 | |||
134 | report.AppendFormat( | ||
135 | "{0,7} {1,7} {2,9} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7} {10,7}\n", | ||
136 | "Pkts", | ||
137 | "Pkts", | ||
138 | "Bytes", | ||
139 | "Pkts", | ||
140 | "Pkts", | ||
141 | "Pkts", | ||
142 | "Pkts", | ||
143 | "Pkts", | ||
144 | "Pkts", | ||
145 | "Pkts", | ||
146 | "Pkts"); | ||
147 | |||
148 | report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); | ||
149 | report.AppendFormat( | ||
150 | "{0,7} {1,7} {2,9} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7} {10,7}\n", | ||
151 | "Out", | ||
152 | "In", | ||
153 | "Unacked", | ||
154 | "Resend", | ||
155 | "Land", | ||
156 | "Wind", | ||
157 | "Cloud", | ||
158 | "Task", | ||
159 | "Texture", | ||
160 | "Asset", | ||
161 | "State"); | ||
162 | |||
163 | lock (m_scenes) | ||
164 | { | ||
165 | foreach (Scene scene in m_scenes.Values) | ||
166 | { | ||
167 | scene.ForEachClient( | ||
168 | delegate(IClientAPI client) | ||
169 | { | ||
170 | if (client is IStatsCollector) | ||
171 | { | ||
172 | bool isChild = scene.PresenceChildStatus(client.AgentId); | ||
173 | if (isChild && !showChildren) | ||
174 | return; | ||
175 | |||
176 | string name = client.Name; | ||
177 | string regionName = scene.RegionInfo.RegionName; | ||
178 | |||
179 | report.AppendFormat( | ||
180 | "{0,-" + maxNameLength + "}{1,-" + columnPadding + "}", | ||
181 | name.Length > maxNameLength ? name.Substring(0, maxNameLength) : name, ""); | ||
182 | report.AppendFormat( | ||
183 | "{0,-" + maxRegionNameLength + "}{1,-" + columnPadding + "}", | ||
184 | regionName.Length > maxRegionNameLength ? regionName.Substring(0, maxRegionNameLength) : regionName, ""); | ||
185 | report.AppendFormat( | ||
186 | "{0,-" + maxTypeLength + "}{1,-" + columnPadding + "}", | ||
187 | isChild ? "Cd" : "Rt", ""); | ||
188 | |||
189 | IStatsCollector stats = (IStatsCollector)client; | ||
190 | |||
191 | report.AppendLine(stats.Report()); | ||
192 | } | ||
193 | }); | ||
194 | } | ||
195 | } | ||
196 | |||
197 | return report.ToString(); | ||
198 | } | ||
199 | } | ||
200 | } \ No newline at end of file | ||