aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Monitoring
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Monitoring')
-rw-r--r--OpenSim/Framework/Monitoring/StatsManager.cs53
1 files changed, 22 insertions, 31 deletions
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index 0bac247..5c8d934 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -30,6 +30,8 @@ using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Linq; 31using System.Linq;
32using System.Text; 32using System.Text;
33using System.Reflection;
34using log4net;
33 35
34using OpenSim.Framework; 36using OpenSim.Framework;
35using OpenMetaverse.StructuredData; 37using OpenMetaverse.StructuredData;
@@ -41,6 +43,8 @@ namespace OpenSim.Framework.Monitoring
41 /// </summary> 43 /// </summary>
42 public static class StatsManager 44 public static class StatsManager
43 { 45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
44 // Subcommand used to list other stats. 48 // Subcommand used to list other stats.
45 public const string AllSubCommand = "all"; 49 public const string AllSubCommand = "all";
46 50
@@ -98,6 +102,7 @@ namespace OpenSim.Framework.Monitoring
98 public static void HandleShowStatsCommand(string module, string[] cmd) 102 public static void HandleShowStatsCommand(string module, string[] cmd)
99 { 103 {
100 ICommandConsole con = MainConsole.Instance; 104 ICommandConsole con = MainConsole.Instance;
105 StringBuilder report = new StringBuilder();
101 106
102 if (cmd.Length > 2) 107 if (cmd.Length > 2)
103 { 108 {
@@ -111,7 +116,8 @@ namespace OpenSim.Framework.Monitoring
111 116
112 if (categoryName == AllSubCommand) 117 if (categoryName == AllSubCommand)
113 { 118 {
114 OutputAllStatsToConsole(con); 119 foreach (string report2 in GetAllStatsReports())
120 report.AppendLine(report2);
115 } 121 }
116 else if (categoryName == ListSubCommand) 122 else if (categoryName == ListSubCommand)
117 { 123 {
@@ -130,7 +136,8 @@ namespace OpenSim.Framework.Monitoring
130 { 136 {
131 if (String.IsNullOrEmpty(containerName)) 137 if (String.IsNullOrEmpty(containerName))
132 { 138 {
133 OutputCategoryStatsToConsole(con, category); 139 foreach (string report2 in GetCategoryStatsReports(category))
140 report.AppendLine(report2);
134 } 141 }
135 else 142 else
136 { 143 {
@@ -139,14 +146,15 @@ namespace OpenSim.Framework.Monitoring
139 { 146 {
140 if (String.IsNullOrEmpty(statName)) 147 if (String.IsNullOrEmpty(statName))
141 { 148 {
142 OutputContainerStatsToConsole(con, container); 149 foreach (string report2 in GetContainerStatsReports(container))
150 report.AppendLine(report2);
143 } 151 }
144 else 152 else
145 { 153 {
146 Stat stat; 154 Stat stat;
147 if (container.TryGetValue(statName, out stat)) 155 if (container.TryGetValue(statName, out stat))
148 { 156 {
149 OutputStatToConsole(con, stat); 157 report.AppendLine(stat.ToConsoleString());
150 } 158 }
151 else 159 else
152 { 160 {
@@ -168,10 +176,18 @@ namespace OpenSim.Framework.Monitoring
168 { 176 {
169 // Legacy 177 // Legacy
170 if (SimExtraStats != null) 178 if (SimExtraStats != null)
171 con.Output(SimExtraStats.Report()); 179 {
180 report.Append(SimExtraStats.Report());
181 }
172 else 182 else
173 OutputAllStatsToConsole(con); 183 {
184 foreach (string report2 in GetAllStatsReports())
185 report.AppendLine(report2);
186 }
174 } 187 }
188
189 if (report.Length > 0)
190 m_log.Debug(string.Join(" ", cmd) + "\n" + report.ToString());
175 } 191 }
176 192
177 public static List<string> GetAllStatsReports() 193 public static List<string> GetAllStatsReports()
@@ -184,12 +200,6 @@ namespace OpenSim.Framework.Monitoring
184 return reports; 200 return reports;
185 } 201 }
186 202
187 private static void OutputAllStatsToConsole(ICommandConsole con)
188 {
189 foreach (string report in GetAllStatsReports())
190 con.Output(report);
191 }
192
193 private static List<string> GetCategoryStatsReports( 203 private static List<string> GetCategoryStatsReports(
194 SortedDictionary<string, SortedDictionary<string, Stat>> category) 204 SortedDictionary<string, SortedDictionary<string, Stat>> category)
195 { 205 {
@@ -201,13 +211,6 @@ namespace OpenSim.Framework.Monitoring
201 return reports; 211 return reports;
202 } 212 }
203 213
204 private static void OutputCategoryStatsToConsole(
205 ICommandConsole con, SortedDictionary<string, SortedDictionary<string, Stat>> category)
206 {
207 foreach (string report in GetCategoryStatsReports(category))
208 con.Output(report);
209 }
210
211 private static List<string> GetContainerStatsReports(SortedDictionary<string, Stat> container) 214 private static List<string> GetContainerStatsReports(SortedDictionary<string, Stat> container)
212 { 215 {
213 List<string> reports = new List<string>(); 216 List<string> reports = new List<string>();
@@ -218,18 +221,6 @@ namespace OpenSim.Framework.Monitoring
218 return reports; 221 return reports;
219 } 222 }
220 223
221 private static void OutputContainerStatsToConsole(
222 ICommandConsole con, SortedDictionary<string, Stat> container)
223 {
224 foreach (string report in GetContainerStatsReports(container))
225 con.Output(report);
226 }
227
228 private static void OutputStatToConsole(ICommandConsole con, Stat stat)
229 {
230 con.Output(stat.ToConsoleString());
231 }
232
233 // Creates an OSDMap of the format: 224 // Creates an OSDMap of the format:
234 // { categoryName: { 225 // { categoryName: {
235 // containerName: { 226 // containerName: {