diff options
Diffstat (limited to 'OpenSim/Framework/Monitoring/StatsManager.cs')
-rw-r--r-- | OpenSim/Framework/Monitoring/StatsManager.cs | 130 |
1 files changed, 74 insertions, 56 deletions
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 24db6d4..12d3a75 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | ||
30 | using System.Text; | 31 | using System.Text; |
31 | 32 | ||
32 | namespace OpenSim.Framework.Monitoring | 33 | namespace OpenSim.Framework.Monitoring |
@@ -54,13 +55,13 @@ namespace OpenSim.Framework.Monitoring | |||
54 | public static SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>> RegisteredStats | 55 | public static SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>> RegisteredStats |
55 | = new SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>>(); | 56 | = new SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>>(); |
56 | 57 | ||
57 | private static AssetStatsCollector assetStats; | 58 | // private static AssetStatsCollector assetStats; |
58 | private static UserStatsCollector userStats; | 59 | // private static UserStatsCollector userStats; |
59 | private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector(); | 60 | // private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector(); |
60 | 61 | ||
61 | public static AssetStatsCollector AssetStats { get { return assetStats; } } | 62 | // public static AssetStatsCollector AssetStats { get { return assetStats; } } |
62 | public static UserStatsCollector UserStats { get { return userStats; } } | 63 | // public static UserStatsCollector UserStats { get { return userStats; } } |
63 | public static SimExtraStatsCollector SimExtraStats { get { return simExtraStats; } } | 64 | public static SimExtraStatsCollector SimExtraStats { get; set; } |
64 | 65 | ||
65 | public static void RegisterConsoleCommands(ICommandConsole console) | 66 | public static void RegisterConsoleCommands(ICommandConsole console) |
66 | { | 67 | { |
@@ -68,12 +69,14 @@ namespace OpenSim.Framework.Monitoring | |||
68 | "General", | 69 | "General", |
69 | false, | 70 | false, |
70 | "show stats", | 71 | "show stats", |
71 | "show stats [list|all|<category>]", | 72 | "show stats [list|all|(<category>[.<container>])+", |
72 | "Show statistical information for this server", | 73 | "Show statistical information for this server", |
73 | "If no final argument is specified then legacy statistics information is currently shown.\n" | 74 | "If no final argument is specified then legacy statistics information is currently shown.\n" |
74 | + "If list is specified then statistic categories are shown.\n" | 75 | + "'list' argument will show statistic categories.\n" |
75 | + "If all is specified then all registered statistics are shown.\n" | 76 | + "'all' will show all statistics.\n" |
76 | + "If a category name is specified then only statistics from that category are shown.\n" | 77 | + "A <category> name will show statistics from that category.\n" |
78 | + "A <category>.<container> name will show statistics from that category in that container.\n" | ||
79 | + "More than one name can be given separated by spaces.\n" | ||
77 | + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", | 80 | + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", |
78 | HandleShowStatsCommand); | 81 | HandleShowStatsCommand); |
79 | } | 82 | } |
@@ -84,43 +87,47 @@ namespace OpenSim.Framework.Monitoring | |||
84 | 87 | ||
85 | if (cmd.Length > 2) | 88 | if (cmd.Length > 2) |
86 | { | 89 | { |
87 | var categoryName = cmd[2]; | 90 | foreach (string name in cmd.Skip(2)) |
88 | var containerName = cmd.Length > 3 ? cmd[3] : String.Empty; | ||
89 | |||
90 | if (categoryName == AllSubCommand) | ||
91 | { | 91 | { |
92 | foreach (var category in RegisteredStats.Values) | 92 | string[] components = name.Split('.'); |
93 | |||
94 | string categoryName = components[0]; | ||
95 | string containerName = components.Length > 1 ? components[1] : null; | ||
96 | |||
97 | if (categoryName == AllSubCommand) | ||
93 | { | 98 | { |
94 | OutputCategoryStatsToConsole(con, category); | 99 | OutputAllStatsToConsole(con); |
95 | } | 100 | } |
96 | } | 101 | else if (categoryName == ListSubCommand) |
97 | else if (categoryName == ListSubCommand) | ||
98 | { | ||
99 | con.Output("Statistic categories available are:"); | ||
100 | foreach (string category in RegisteredStats.Keys) | ||
101 | con.OutputFormat(" {0}", category); | ||
102 | } | ||
103 | else | ||
104 | { | ||
105 | SortedDictionary<string, SortedDictionary<string, Stat>> category; | ||
106 | if (!RegisteredStats.TryGetValue(categoryName, out category)) | ||
107 | { | 102 | { |
108 | con.OutputFormat("No such category as {0}", categoryName); | 103 | con.Output("Statistic categories available are:"); |
104 | foreach (string category in RegisteredStats.Keys) | ||
105 | con.OutputFormat(" {0}", category); | ||
109 | } | 106 | } |
110 | else | 107 | else |
111 | { | 108 | { |
112 | if (String.IsNullOrEmpty(containerName)) | 109 | SortedDictionary<string, SortedDictionary<string, Stat>> category; |
113 | OutputCategoryStatsToConsole(con, category); | 110 | if (!RegisteredStats.TryGetValue(categoryName, out category)) |
111 | { | ||
112 | con.OutputFormat("No such category as {0}", categoryName); | ||
113 | } | ||
114 | else | 114 | else |
115 | { | 115 | { |
116 | SortedDictionary<string, Stat> container; | 116 | if (String.IsNullOrEmpty(containerName)) |
117 | if (category.TryGetValue(containerName, out container)) | ||
118 | { | 117 | { |
119 | OutputContainerStatsToConsole(con, container); | 118 | OutputCategoryStatsToConsole(con, category); |
120 | } | 119 | } |
121 | else | 120 | else |
122 | { | 121 | { |
123 | con.OutputFormat("No such container {0} in category {1}", containerName, categoryName); | 122 | SortedDictionary<string, Stat> container; |
123 | if (category.TryGetValue(containerName, out container)) | ||
124 | { | ||
125 | OutputContainerStatsToConsole(con, container); | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | con.OutputFormat("No such container {0} in category {1}", containerName, categoryName); | ||
130 | } | ||
124 | } | 131 | } |
125 | } | 132 | } |
126 | } | 133 | } |
@@ -129,7 +136,18 @@ namespace OpenSim.Framework.Monitoring | |||
129 | else | 136 | else |
130 | { | 137 | { |
131 | // Legacy | 138 | // Legacy |
132 | con.Output(SimExtraStats.Report()); | 139 | if (SimExtraStats != null) |
140 | con.Output(SimExtraStats.Report()); | ||
141 | else | ||
142 | OutputAllStatsToConsole(con); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | private static void OutputAllStatsToConsole(ICommandConsole con) | ||
147 | { | ||
148 | foreach (var category in RegisteredStats.Values) | ||
149 | { | ||
150 | OutputCategoryStatsToConsole(con, category); | ||
133 | } | 151 | } |
134 | } | 152 | } |
135 | 153 | ||
@@ -150,27 +168,27 @@ namespace OpenSim.Framework.Monitoring | |||
150 | } | 168 | } |
151 | } | 169 | } |
152 | 170 | ||
153 | /// <summary> | 171 | // /// <summary> |
154 | /// Start collecting statistics related to assets. | 172 | // /// Start collecting statistics related to assets. |
155 | /// Should only be called once. | 173 | // /// Should only be called once. |
156 | /// </summary> | 174 | // /// </summary> |
157 | public static AssetStatsCollector StartCollectingAssetStats() | 175 | // public static AssetStatsCollector StartCollectingAssetStats() |
158 | { | 176 | // { |
159 | assetStats = new AssetStatsCollector(); | 177 | // assetStats = new AssetStatsCollector(); |
160 | 178 | // | |
161 | return assetStats; | 179 | // return assetStats; |
162 | } | 180 | // } |
163 | 181 | // | |
164 | /// <summary> | 182 | // /// <summary> |
165 | /// Start collecting statistics related to users. | 183 | // /// Start collecting statistics related to users. |
166 | /// Should only be called once. | 184 | // /// Should only be called once. |
167 | /// </summary> | 185 | // /// </summary> |
168 | public static UserStatsCollector StartCollectingUserStats() | 186 | // public static UserStatsCollector StartCollectingUserStats() |
169 | { | 187 | // { |
170 | userStats = new UserStatsCollector(); | 188 | // userStats = new UserStatsCollector(); |
171 | 189 | // | |
172 | return userStats; | 190 | // return userStats; |
173 | } | 191 | // } |
174 | 192 | ||
175 | /// <summary> | 193 | /// <summary> |
176 | /// Registers a statistic. | 194 | /// Registers a statistic. |