diff options
author | BlueWall | 2012-11-25 17:03:14 -0500 |
---|---|---|
committer | BlueWall | 2012-11-25 17:03:14 -0500 |
commit | c754003944d0166bf50b4f94b0c0eea642503bb0 (patch) | |
tree | dfa1c2020d5500d510519d5b2b3236600692f277 /OpenSim/Framework/Monitoring/StatsManager.cs | |
parent | Merge branch 'master' into connector_plugin (diff) | |
parent | Combine TestDeleteSceneObjectAsync() with TestDeRezSceneObject() as they are ... (diff) | |
download | opensim-SC-c754003944d0166bf50b4f94b0c0eea642503bb0.zip opensim-SC-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.gz opensim-SC-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.bz2 opensim-SC-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.xz |
Merge branch 'master' into connector_plugin
Conflicts:
OpenSim/Server/Base/ServicesServerBase.cs
Diffstat (limited to 'OpenSim/Framework/Monitoring/StatsManager.cs')
-rw-r--r-- | OpenSim/Framework/Monitoring/StatsManager.cs | 150 |
1 files changed, 40 insertions, 110 deletions
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 31989e5..0762b01 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.Text; | ||
30 | 31 | ||
31 | namespace OpenSim.Framework.Monitoring | 32 | namespace OpenSim.Framework.Monitoring |
32 | { | 33 | { |
@@ -207,7 +208,7 @@ namespace OpenSim.Framework.Monitoring | |||
207 | return false; | 208 | return false; |
208 | 209 | ||
209 | newContainer = new Dictionary<string, Stat>(container); | 210 | newContainer = new Dictionary<string, Stat>(container); |
210 | newContainer.Remove(stat.UniqueName); | 211 | newContainer.Remove(stat.ShortName); |
211 | 212 | ||
212 | newCategory = new Dictionary<string, Dictionary<string, Stat>>(category); | 213 | newCategory = new Dictionary<string, Dictionary<string, Stat>>(category); |
213 | newCategory.Remove(stat.Container); | 214 | newCategory.Remove(stat.Container); |
@@ -246,129 +247,58 @@ namespace OpenSim.Framework.Monitoring | |||
246 | 247 | ||
247 | return false; | 248 | return false; |
248 | } | 249 | } |
250 | |||
251 | public static void RecordStats() | ||
252 | { | ||
253 | lock (RegisteredStats) | ||
254 | { | ||
255 | foreach (Dictionary<string, Dictionary<string, Stat>> category in RegisteredStats.Values) | ||
256 | { | ||
257 | foreach (Dictionary<string, Stat> container in category.Values) | ||
258 | { | ||
259 | foreach (Stat stat in container.Values) | ||
260 | { | ||
261 | if (stat.MeasuresOfInterest != MeasuresOfInterest.None) | ||
262 | stat.RecordValue(); | ||
263 | } | ||
264 | } | ||
265 | } | ||
266 | } | ||
267 | } | ||
249 | } | 268 | } |
250 | 269 | ||
251 | /// <summary> | 270 | /// <summary> |
252 | /// Verbosity of stat. | 271 | /// Stat type. |
253 | /// </summary> | 272 | /// </summary> |
254 | /// <remarks> | 273 | /// <remarks> |
255 | /// Info will always be displayed. | 274 | /// A push stat is one which is continually updated and so it's value can simply by read. |
275 | /// A pull stat is one where reading the value triggers a collection method - the stat is not continually updated. | ||
256 | /// </remarks> | 276 | /// </remarks> |
257 | public enum StatVerbosity | 277 | public enum StatType |
258 | { | 278 | { |
259 | Debug, | 279 | Push, |
260 | Info | 280 | Pull |
261 | } | 281 | } |
262 | 282 | ||
263 | /// <summary> | 283 | /// <summary> |
264 | /// Holds individual static details | 284 | /// Measures of interest for this stat. |
265 | /// </summary> | 285 | /// </summary> |
266 | public class Stat | 286 | [Flags] |
287 | public enum MeasuresOfInterest | ||
267 | { | 288 | { |
268 | /// <summary> | 289 | None, |
269 | /// Unique stat name used for indexing. Each ShortName in a Category must be unique. | 290 | AverageChangeOverTime |
270 | /// </summary> | ||
271 | public string UniqueName { get; private set; } | ||
272 | |||
273 | /// <summary> | ||
274 | /// Category of this stat (e.g. cache, scene, etc). | ||
275 | /// </summary> | ||
276 | public string Category { get; private set; } | ||
277 | |||
278 | /// <summary> | ||
279 | /// Containing name for this stat. | ||
280 | /// FIXME: In the case of a scene, this is currently the scene name (though this leaves | ||
281 | /// us with a to-be-resolved problem of non-unique region names). | ||
282 | /// </summary> | ||
283 | /// <value> | ||
284 | /// The container. | ||
285 | /// </value> | ||
286 | public string Container { get; private set; } | ||
287 | |||
288 | public StatVerbosity Verbosity { get; private set; } | ||
289 | public string ShortName { get; private set; } | ||
290 | public string Name { get; private set; } | ||
291 | public string Description { get; private set; } | ||
292 | public virtual string UnitName { get; private set; } | ||
293 | |||
294 | public virtual double Value { get; set; } | ||
295 | |||
296 | /// <summary> | ||
297 | /// Constructor | ||
298 | /// </summary> | ||
299 | /// <param name='shortName'>Short name for the stat. Must not contain spaces. e.g. "LongFrames"</param> | ||
300 | /// <param name='name'>Human readable name for the stat. e.g. "Long frames"</param> | ||
301 | /// <param name='unitName'> | ||
302 | /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value. | ||
303 | /// e.g. " frames" | ||
304 | /// </param> | ||
305 | /// <param name='category'>Category under which this stat should appear, e.g. "scene". Do not capitalize.</param> | ||
306 | /// <param name='container'>Entity to which this stat relates. e.g. scene name if this is a per scene stat.</param> | ||
307 | /// <param name='verbosity'>Verbosity of stat. Controls whether it will appear in short stat display or only full display.</param> | ||
308 | /// <param name='description'>Description of stat</param> | ||
309 | public Stat( | ||
310 | string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description) | ||
311 | { | ||
312 | if (StatsManager.SubCommands.Contains(category)) | ||
313 | throw new Exception( | ||
314 | string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); | ||
315 | |||
316 | ShortName = shortName; | ||
317 | Name = name; | ||
318 | UnitName = unitName; | ||
319 | Category = category; | ||
320 | Container = container; | ||
321 | Verbosity = verbosity; | ||
322 | Description = description; | ||
323 | |||
324 | UniqueName = GenUniqueName(Container, Category, ShortName); | ||
325 | } | ||
326 | |||
327 | public static string GenUniqueName(string container, string category, string shortName) | ||
328 | { | ||
329 | return string.Format("{0}+{1}+{2}", container, category, shortName); | ||
330 | } | ||
331 | |||
332 | public virtual string ToConsoleString() | ||
333 | { | ||
334 | return string.Format( | ||
335 | "{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName); | ||
336 | } | ||
337 | } | 291 | } |
338 | 292 | ||
339 | public class PercentageStat : Stat | 293 | /// <summary> |
294 | /// Verbosity of stat. | ||
295 | /// </summary> | ||
296 | /// <remarks> | ||
297 | /// Info will always be displayed. | ||
298 | /// </remarks> | ||
299 | public enum StatVerbosity | ||
340 | { | 300 | { |
341 | public int Antecedent { get; set; } | 301 | Debug, |
342 | public int Consequent { get; set; } | 302 | Info |
343 | |||
344 | public override double Value | ||
345 | { | ||
346 | get | ||
347 | { | ||
348 | int c = Consequent; | ||
349 | |||
350 | // Avoid any chance of a multi-threaded divide-by-zero | ||
351 | if (c == 0) | ||
352 | return 0; | ||
353 | |||
354 | return (double)Antecedent / c * 100; | ||
355 | } | ||
356 | |||
357 | set | ||
358 | { | ||
359 | throw new Exception("Cannot set value on a PercentageStat"); | ||
360 | } | ||
361 | } | ||
362 | |||
363 | public PercentageStat( | ||
364 | string shortName, string name, string category, string container, StatVerbosity verbosity, string description) | ||
365 | : base(shortName, name, "%", category, container, verbosity, description) {} | ||
366 | |||
367 | public override string ToConsoleString() | ||
368 | { | ||
369 | return string.Format( | ||
370 | "{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})", | ||
371 | Category, Container, ShortName, Value, UnitName, Antecedent, Consequent); | ||
372 | } | ||
373 | } | 303 | } |
374 | } \ No newline at end of file | 304 | } \ No newline at end of file |