aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-01-20 22:57:12 +0000
committerJustin Clark-Casey (justincc)2011-01-20 22:57:12 +0000
commit1baf63dbae8208172aa457963636116d42dbe9b3 (patch)
tree09adc7a1192da09b44d4afad503e56ce0fa85f18
parentremove unimplemented "show assets" command (diff)
downloadopensim-SC-1baf63dbae8208172aa457963636116d42dbe9b3.zip
opensim-SC-1baf63dbae8208172aa457963636116d42dbe9b3.tar.gz
opensim-SC-1baf63dbae8208172aa457963636116d42dbe9b3.tar.bz2
opensim-SC-1baf63dbae8208172aa457963636116d42dbe9b3.tar.xz
Move "show queues" command out of OpenSim.cs and into a separate module.
-rw-r--r--OpenSim/Region/Application/OpenSim.cs99
-rw-r--r--OpenSim/Region/CoreModules/Agent/UDP/Linden/LindenUDPModule.cs200
2 files changed, 200 insertions, 99 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 1832c3d..00a97be 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -301,13 +301,6 @@ namespace OpenSim
301 m_console.Commands.AddCommand("region", false, "show regions", 301 m_console.Commands.AddCommand("region", false, "show regions",
302 "show regions", 302 "show regions",
303 "Show region data", HandleShow); 303 "Show region data", HandleShow);
304
305 m_console.Commands.AddCommand("region", false, "show queues",
306 "show queues [full]",
307 "Show queue data for each client",
308 "Without the 'full' option, only users actually on the region are shown."
309 + " With the 'full' option child agents of users in neighbouring regions are also shown.",
310 HandleShow);
311 304
312 m_console.Commands.AddCommand("region", false, "show ratings", 305 m_console.Commands.AddCommand("region", false, "show ratings",
313 "show ratings", 306 "show ratings",
@@ -951,10 +944,6 @@ namespace OpenSim
951 }); 944 });
952 break; 945 break;
953 946
954 case "queues":
955 Notice(GetQueuesReport(showParams));
956 break;
957
958 case "ratings": 947 case "ratings":
959 m_sceneManager.ForEachScene( 948 m_sceneManager.ForEachScene(
960 delegate(Scene scene) 949 delegate(Scene scene)
@@ -982,94 +971,6 @@ namespace OpenSim
982 } 971 }
983 972
984 /// <summary> 973 /// <summary>
985 /// Generate UDP Queue data report for each client
986 /// </summary>
987 /// <param name="showParams"></param>
988 /// <returns></returns>
989 private string GetQueuesReport(string[] showParams)
990 {
991 bool showChildren = false;
992
993 if (showParams.Length > 1 && showParams[1] == "full")
994 showChildren = true;
995
996 StringBuilder report = new StringBuilder();
997
998 int columnPadding = 2;
999 int maxNameLength = 18;
1000 int maxRegionNameLength = 14;
1001 int maxTypeLength = 4;
1002 int totalInfoFieldsLength = maxNameLength + columnPadding + maxRegionNameLength + columnPadding + maxTypeLength + columnPadding;
1003
1004 report.AppendFormat("{0,-" + maxNameLength + "}{1,-" + columnPadding + "}", "User", "");
1005 report.AppendFormat("{0,-" + maxRegionNameLength + "}{1,-" + columnPadding + "}", "Region", "");
1006 report.AppendFormat("{0,-" + maxTypeLength + "}{1,-" + columnPadding + "}", "Type", "");
1007
1008 report.AppendFormat(
1009 "{0,7} {1,7} {2,9} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7} {10,7}\n",
1010 "Pkts",
1011 "Pkts",
1012 "Bytes",
1013 "Pkts",
1014 "Pkts",
1015 "Pkts",
1016 "Pkts",
1017 "Pkts",
1018 "Pkts",
1019 "Pkts",
1020 "Pkts");
1021
1022 report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", "");
1023 report.AppendFormat(
1024 "{0,7} {1,7} {2,9} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7} {10,7}\n",
1025 "Out",
1026 "In",
1027 "Unacked",
1028 "Resend",
1029 "Land",
1030 "Wind",
1031 "Cloud",
1032 "Task",
1033 "Texture",
1034 "Asset",
1035 "State");
1036
1037 m_sceneManager.ForEachScene(
1038 delegate(Scene scene)
1039 {
1040 scene.ForEachClient(
1041 delegate(IClientAPI client)
1042 {
1043 if (client is IStatsCollector)
1044 {
1045 bool isChild = scene.PresenceChildStatus(client.AgentId);
1046 if (isChild && !showChildren)
1047 return;
1048
1049 string name = client.Name;
1050 string regionName = scene.RegionInfo.RegionName;
1051
1052 report.AppendFormat(
1053 "{0,-" + maxNameLength + "}{1,-" + columnPadding + "}",
1054 name.Length > maxNameLength ? name.Substring(0, maxNameLength) : name, "");
1055 report.AppendFormat(
1056 "{0,-" + maxRegionNameLength + "}{1,-" + columnPadding + "}",
1057 regionName.Length > maxRegionNameLength ? regionName.Substring(0, maxRegionNameLength) : regionName, "");
1058 report.AppendFormat(
1059 "{0,-" + maxTypeLength + "}{1,-" + columnPadding + "}",
1060 isChild ? "Cd" : "Rt", "");
1061
1062 IStatsCollector stats = (IStatsCollector)client;
1063
1064 report.AppendLine(stats.Report());
1065 }
1066 });
1067 });
1068
1069 return report.ToString();
1070 }
1071
1072 /// <summary>
1073 /// Use XML2 format to serialize data to a file 974 /// Use XML2 format to serialize data to a file
1074 /// </summary> 975 /// </summary>
1075 /// <param name="module"></param> 976 /// <param name="module"></param>
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33using Mono.Addins;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Console;
38using OpenSim.Framework.Statistics;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes;
41
42namespace 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