diff options
Diffstat (limited to 'OpenSim/Framework/Monitoring/StatsManager.cs')
-rw-r--r-- | OpenSim/Framework/Monitoring/StatsManager.cs | 69 |
1 files changed, 44 insertions, 25 deletions
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 0762b01..24db6d4 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -51,8 +51,8 @@ namespace OpenSim.Framework.Monitoring | |||
51 | /// <remarks> | 51 | /// <remarks> |
52 | /// Do not add or remove directly from this dictionary. | 52 | /// Do not add or remove directly from this dictionary. |
53 | /// </remarks> | 53 | /// </remarks> |
54 | public static Dictionary<string, Dictionary<string, Dictionary<string, Stat>>> RegisteredStats | 54 | public static SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>> RegisteredStats |
55 | = new Dictionary<string, Dictionary<string, Dictionary<string, Stat>>>(); | 55 | = new SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>>(); |
56 | 56 | ||
57 | private static AssetStatsCollector assetStats; | 57 | private static AssetStatsCollector assetStats; |
58 | private static UserStatsCollector userStats; | 58 | private static UserStatsCollector userStats; |
@@ -85,6 +85,7 @@ namespace OpenSim.Framework.Monitoring | |||
85 | if (cmd.Length > 2) | 85 | if (cmd.Length > 2) |
86 | { | 86 | { |
87 | var categoryName = cmd[2]; | 87 | var categoryName = cmd[2]; |
88 | var containerName = cmd.Length > 3 ? cmd[3] : String.Empty; | ||
88 | 89 | ||
89 | if (categoryName == AllSubCommand) | 90 | if (categoryName == AllSubCommand) |
90 | { | 91 | { |
@@ -101,14 +102,27 @@ namespace OpenSim.Framework.Monitoring | |||
101 | } | 102 | } |
102 | else | 103 | else |
103 | { | 104 | { |
104 | Dictionary<string, Dictionary<string, Stat>> category; | 105 | SortedDictionary<string, SortedDictionary<string, Stat>> category; |
105 | if (!RegisteredStats.TryGetValue(categoryName, out category)) | 106 | if (!RegisteredStats.TryGetValue(categoryName, out category)) |
106 | { | 107 | { |
107 | con.OutputFormat("No such category as {0}", categoryName); | 108 | con.OutputFormat("No such category as {0}", categoryName); |
108 | } | 109 | } |
109 | else | 110 | else |
110 | { | 111 | { |
111 | OutputCategoryStatsToConsole(con, category); | 112 | if (String.IsNullOrEmpty(containerName)) |
113 | OutputCategoryStatsToConsole(con, category); | ||
114 | else | ||
115 | { | ||
116 | SortedDictionary<string, Stat> container; | ||
117 | if (category.TryGetValue(containerName, out container)) | ||
118 | { | ||
119 | OutputContainerStatsToConsole(con, container); | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | con.OutputFormat("No such container {0} in category {1}", containerName, categoryName); | ||
124 | } | ||
125 | } | ||
112 | } | 126 | } |
113 | } | 127 | } |
114 | } | 128 | } |
@@ -120,14 +134,19 @@ namespace OpenSim.Framework.Monitoring | |||
120 | } | 134 | } |
121 | 135 | ||
122 | private static void OutputCategoryStatsToConsole( | 136 | private static void OutputCategoryStatsToConsole( |
123 | ICommandConsole con, Dictionary<string, Dictionary<string, Stat>> category) | 137 | ICommandConsole con, SortedDictionary<string, SortedDictionary<string, Stat>> category) |
124 | { | 138 | { |
125 | foreach (var container in category.Values) | 139 | foreach (var container in category.Values) |
126 | { | 140 | { |
127 | foreach (Stat stat in container.Values) | 141 | OutputContainerStatsToConsole(con, container); |
128 | { | 142 | } |
129 | con.Output(stat.ToConsoleString()); | 143 | } |
130 | } | 144 | |
145 | private static void OutputContainerStatsToConsole( ICommandConsole con, SortedDictionary<string, Stat> container) | ||
146 | { | ||
147 | foreach (Stat stat in container.Values) | ||
148 | { | ||
149 | con.Output(stat.ToConsoleString()); | ||
131 | } | 150 | } |
132 | } | 151 | } |
133 | 152 | ||
@@ -160,8 +179,8 @@ namespace OpenSim.Framework.Monitoring | |||
160 | /// <returns></returns> | 179 | /// <returns></returns> |
161 | public static bool RegisterStat(Stat stat) | 180 | public static bool RegisterStat(Stat stat) |
162 | { | 181 | { |
163 | Dictionary<string, Dictionary<string, Stat>> category = null, newCategory; | 182 | SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory; |
164 | Dictionary<string, Stat> container = null, newContainer; | 183 | SortedDictionary<string, Stat> container = null, newContainer; |
165 | 184 | ||
166 | lock (RegisteredStats) | 185 | lock (RegisteredStats) |
167 | { | 186 | { |
@@ -175,14 +194,14 @@ namespace OpenSim.Framework.Monitoring | |||
175 | // This means that we don't need to lock or copy them on iteration, which will be a much more | 194 | // This means that we don't need to lock or copy them on iteration, which will be a much more |
176 | // common operation after startup. | 195 | // common operation after startup. |
177 | if (container != null) | 196 | if (container != null) |
178 | newContainer = new Dictionary<string, Stat>(container); | 197 | newContainer = new SortedDictionary<string, Stat>(container); |
179 | else | 198 | else |
180 | newContainer = new Dictionary<string, Stat>(); | 199 | newContainer = new SortedDictionary<string, Stat>(); |
181 | 200 | ||
182 | if (category != null) | 201 | if (category != null) |
183 | newCategory = new Dictionary<string, Dictionary<string, Stat>>(category); | 202 | newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category); |
184 | else | 203 | else |
185 | newCategory = new Dictionary<string, Dictionary<string, Stat>>(); | 204 | newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(); |
186 | 205 | ||
187 | newContainer[stat.ShortName] = stat; | 206 | newContainer[stat.ShortName] = stat; |
188 | newCategory[stat.Container] = newContainer; | 207 | newCategory[stat.Container] = newContainer; |
@@ -196,21 +215,21 @@ namespace OpenSim.Framework.Monitoring | |||
196 | /// Deregister a statistic | 215 | /// Deregister a statistic |
197 | /// </summary>> | 216 | /// </summary>> |
198 | /// <param name='stat'></param> | 217 | /// <param name='stat'></param> |
199 | /// <returns></returns | 218 | /// <returns></returns> |
200 | public static bool DeregisterStat(Stat stat) | 219 | public static bool DeregisterStat(Stat stat) |
201 | { | 220 | { |
202 | Dictionary<string, Dictionary<string, Stat>> category = null, newCategory; | 221 | SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory; |
203 | Dictionary<string, Stat> container = null, newContainer; | 222 | SortedDictionary<string, Stat> container = null, newContainer; |
204 | 223 | ||
205 | lock (RegisteredStats) | 224 | lock (RegisteredStats) |
206 | { | 225 | { |
207 | if (!TryGetStat(stat, out category, out container)) | 226 | if (!TryGetStat(stat, out category, out container)) |
208 | return false; | 227 | return false; |
209 | 228 | ||
210 | newContainer = new Dictionary<string, Stat>(container); | 229 | newContainer = new SortedDictionary<string, Stat>(container); |
211 | newContainer.Remove(stat.ShortName); | 230 | newContainer.Remove(stat.ShortName); |
212 | 231 | ||
213 | newCategory = new Dictionary<string, Dictionary<string, Stat>>(category); | 232 | newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category); |
214 | newCategory.Remove(stat.Container); | 233 | newCategory.Remove(stat.Container); |
215 | 234 | ||
216 | newCategory[stat.Container] = newContainer; | 235 | newCategory[stat.Container] = newContainer; |
@@ -220,15 +239,15 @@ namespace OpenSim.Framework.Monitoring | |||
220 | } | 239 | } |
221 | } | 240 | } |
222 | 241 | ||
223 | public static bool TryGetStats(string category, out Dictionary<string, Dictionary<string, Stat>> stats) | 242 | public static bool TryGetStats(string category, out SortedDictionary<string, SortedDictionary<string, Stat>> stats) |
224 | { | 243 | { |
225 | return RegisteredStats.TryGetValue(category, out stats); | 244 | return RegisteredStats.TryGetValue(category, out stats); |
226 | } | 245 | } |
227 | 246 | ||
228 | public static bool TryGetStat( | 247 | public static bool TryGetStat( |
229 | Stat stat, | 248 | Stat stat, |
230 | out Dictionary<string, Dictionary<string, Stat>> category, | 249 | out SortedDictionary<string, SortedDictionary<string, Stat>> category, |
231 | out Dictionary<string, Stat> container) | 250 | out SortedDictionary<string, Stat> container) |
232 | { | 251 | { |
233 | category = null; | 252 | category = null; |
234 | container = null; | 253 | container = null; |
@@ -252,9 +271,9 @@ namespace OpenSim.Framework.Monitoring | |||
252 | { | 271 | { |
253 | lock (RegisteredStats) | 272 | lock (RegisteredStats) |
254 | { | 273 | { |
255 | foreach (Dictionary<string, Dictionary<string, Stat>> category in RegisteredStats.Values) | 274 | foreach (SortedDictionary<string, SortedDictionary<string, Stat>> category in RegisteredStats.Values) |
256 | { | 275 | { |
257 | foreach (Dictionary<string, Stat> container in category.Values) | 276 | foreach (SortedDictionary<string, Stat> container in category.Values) |
258 | { | 277 | { |
259 | foreach (Stat stat in container.Values) | 278 | foreach (Stat stat in container.Values) |
260 | { | 279 | { |