diff options
Diffstat (limited to 'OpenSim/Framework/Monitoring/Stats')
-rw-r--r-- | OpenSim/Framework/Monitoring/Stats/Stat.cs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs index 2e7665f..c57ee0c 100644 --- a/OpenSim/Framework/Monitoring/Stats/Stat.cs +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs | |||
@@ -27,8 +27,10 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
30 | using System.Text; | 32 | using System.Text; |
31 | 33 | using log4net; | |
32 | using OpenMetaverse.StructuredData; | 34 | using OpenMetaverse.StructuredData; |
33 | 35 | ||
34 | namespace OpenSim.Framework.Monitoring | 36 | namespace OpenSim.Framework.Monitoring |
@@ -38,6 +40,10 @@ namespace OpenSim.Framework.Monitoring | |||
38 | /// </summary> | 40 | /// </summary> |
39 | public class Stat : IDisposable | 41 | public class Stat : IDisposable |
40 | { | 42 | { |
43 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | public static readonly char[] DisallowedShortNameCharacters = { '.' }; | ||
46 | |||
41 | /// <summary> | 47 | /// <summary> |
42 | /// Category of this stat (e.g. cache, scene, etc). | 48 | /// Category of this stat (e.g. cache, scene, etc). |
43 | /// </summary> | 49 | /// </summary> |
@@ -95,7 +101,7 @@ namespace OpenSim.Framework.Monitoring | |||
95 | /// <remarks> | 101 | /// <remarks> |
96 | /// Will be null if no measures of interest require samples. | 102 | /// Will be null if no measures of interest require samples. |
97 | /// </remarks> | 103 | /// </remarks> |
98 | private static Queue<double> m_samples; | 104 | private Queue<double> m_samples; |
99 | 105 | ||
100 | /// <summary> | 106 | /// <summary> |
101 | /// Maximum number of statistical samples. | 107 | /// Maximum number of statistical samples. |
@@ -162,6 +168,12 @@ namespace OpenSim.Framework.Monitoring | |||
162 | throw new Exception( | 168 | throw new Exception( |
163 | string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); | 169 | string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); |
164 | 170 | ||
171 | foreach (char c in DisallowedShortNameCharacters) | ||
172 | { | ||
173 | if (shortName.IndexOf(c) != -1) | ||
174 | throw new Exception(string.Format("Stat name {0} cannot contain character {1}", shortName, c)); | ||
175 | } | ||
176 | |||
165 | ShortName = shortName; | 177 | ShortName = shortName; |
166 | Name = name; | 178 | Name = name; |
167 | Description = description; | 179 | Description = description; |
@@ -204,6 +216,8 @@ namespace OpenSim.Framework.Monitoring | |||
204 | if (m_samples.Count >= m_maxSamples) | 216 | if (m_samples.Count >= m_maxSamples) |
205 | m_samples.Dequeue(); | 217 | m_samples.Dequeue(); |
206 | 218 | ||
219 | // m_log.DebugFormat("[STAT]: Recording value {0} for {1}", newValue, Name); | ||
220 | |||
207 | m_samples.Enqueue(newValue); | 221 | m_samples.Enqueue(newValue); |
208 | } | 222 | } |
209 | } | 223 | } |
@@ -242,6 +256,10 @@ namespace OpenSim.Framework.Monitoring | |||
242 | 256 | ||
243 | lock (m_samples) | 257 | lock (m_samples) |
244 | { | 258 | { |
259 | // m_log.DebugFormat( | ||
260 | // "[STAT]: Samples for {0} are {1}", | ||
261 | // Name, string.Join(",", m_samples.Select(s => s.ToString()).ToArray())); | ||
262 | |||
245 | foreach (double s in m_samples) | 263 | foreach (double s in m_samples) |
246 | { | 264 | { |
247 | if (lastSample != null) | 265 | if (lastSample != null) |
@@ -253,7 +271,7 @@ namespace OpenSim.Framework.Monitoring | |||
253 | 271 | ||
254 | int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1; | 272 | int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1; |
255 | 273 | ||
256 | sb.AppendFormat(", {0:0.##}{1}/s", totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000), UnitName); | 274 | sb.AppendFormat(", {0:0.##} {1}/s", totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000), UnitName); |
257 | } | 275 | } |
258 | } | 276 | } |
259 | } | 277 | } |