diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Monitoring/StatsManager.cs | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index e6a2304..c8e838c 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -35,9 +35,9 @@ using OpenMetaverse.StructuredData; | |||
35 | namespace OpenSim.Framework.Monitoring | 35 | namespace OpenSim.Framework.Monitoring |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// Singleton used to provide access to statistics reporters | 38 | /// Static class used to register/deregister/fetch statistics |
39 | /// </summary> | 39 | /// </summary> |
40 | public class StatsManager | 40 | public static class StatsManager |
41 | { | 41 | { |
42 | // Subcommand used to list other stats. | 42 | // Subcommand used to list other stats. |
43 | public const string AllSubCommand = "all"; | 43 | public const string AllSubCommand = "all"; |
@@ -81,6 +81,8 @@ namespace OpenSim.Framework.Monitoring | |||
81 | + "More than one name can be given separated by spaces.\n" | 81 | + "More than one name can be given separated by spaces.\n" |
82 | + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", | 82 | + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", |
83 | HandleShowStatsCommand); | 83 | HandleShowStatsCommand); |
84 | |||
85 | StatsLogger.RegisterConsoleCommands(console); | ||
84 | } | 86 | } |
85 | 87 | ||
86 | public static void HandleShowStatsCommand(string module, string[] cmd) | 88 | public static void HandleShowStatsCommand(string module, string[] cmd) |
@@ -145,29 +147,55 @@ namespace OpenSim.Framework.Monitoring | |||
145 | } | 147 | } |
146 | } | 148 | } |
147 | 149 | ||
148 | private static void OutputAllStatsToConsole(ICommandConsole con) | 150 | public static List<string> GetAllStatsReports() |
149 | { | 151 | { |
152 | List<string> reports = new List<string>(); | ||
153 | |||
150 | foreach (var category in RegisteredStats.Values) | 154 | foreach (var category in RegisteredStats.Values) |
151 | { | 155 | reports.AddRange(GetCategoryStatsReports(category)); |
152 | OutputCategoryStatsToConsole(con, category); | 156 | |
153 | } | 157 | return reports; |
158 | } | ||
159 | |||
160 | private static void OutputAllStatsToConsole(ICommandConsole con) | ||
161 | { | ||
162 | foreach (string report in GetAllStatsReports()) | ||
163 | con.Output(report); | ||
164 | } | ||
165 | |||
166 | private static List<string> GetCategoryStatsReports( | ||
167 | SortedDictionary<string, SortedDictionary<string, Stat>> category) | ||
168 | { | ||
169 | List<string> reports = new List<string>(); | ||
170 | |||
171 | foreach (var container in category.Values) | ||
172 | reports.AddRange(GetContainerStatsReports(container)); | ||
173 | |||
174 | return reports; | ||
154 | } | 175 | } |
155 | 176 | ||
156 | private static void OutputCategoryStatsToConsole( | 177 | private static void OutputCategoryStatsToConsole( |
157 | ICommandConsole con, SortedDictionary<string, SortedDictionary<string, Stat>> category) | 178 | ICommandConsole con, SortedDictionary<string, SortedDictionary<string, Stat>> category) |
158 | { | 179 | { |
159 | foreach (var container in category.Values) | 180 | foreach (string report in GetCategoryStatsReports(category)) |
160 | { | 181 | con.Output(report); |
161 | OutputContainerStatsToConsole(con, container); | ||
162 | } | ||
163 | } | 182 | } |
164 | 183 | ||
165 | private static void OutputContainerStatsToConsole( ICommandConsole con, SortedDictionary<string, Stat> container) | 184 | private static List<string> GetContainerStatsReports(SortedDictionary<string, Stat> container) |
166 | { | 185 | { |
186 | List<string> reports = new List<string>(); | ||
187 | |||
167 | foreach (Stat stat in container.Values) | 188 | foreach (Stat stat in container.Values) |
168 | { | 189 | reports.Add(stat.ToConsoleString()); |
169 | con.Output(stat.ToConsoleString()); | 190 | |
170 | } | 191 | return reports; |
192 | } | ||
193 | |||
194 | private static void OutputContainerStatsToConsole( | ||
195 | ICommandConsole con, SortedDictionary<string, Stat> container) | ||
196 | { | ||
197 | foreach (string report in GetContainerStatsReports(container)) | ||
198 | con.Output(report); | ||
171 | } | 199 | } |
172 | 200 | ||
173 | // Creates an OSDMap of the format: | 201 | // Creates an OSDMap of the format: |
@@ -257,7 +285,7 @@ namespace OpenSim.Framework.Monitoring | |||
257 | // } | 285 | // } |
258 | 286 | ||
259 | /// <summary> | 287 | /// <summary> |
260 | /// Registers a statistic. | 288 | /// Register a statistic. |
261 | /// </summary> | 289 | /// </summary> |
262 | /// <param name='stat'></param> | 290 | /// <param name='stat'></param> |
263 | /// <returns></returns> | 291 | /// <returns></returns> |