diff options
Diffstat (limited to 'OpenSim/Framework/Monitoring')
-rw-r--r-- | OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs | 13 | ||||
-rw-r--r-- | OpenSim/Framework/Monitoring/StatsManager.cs | 114 |
2 files changed, 125 insertions, 2 deletions
diff --git a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs index cdd7cc7..8ac9090 100644 --- a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs | |||
@@ -355,10 +355,19 @@ Asset service request failures: {3}" + Environment.NewLine, | |||
355 | sb.Append(Environment.NewLine); | 355 | sb.Append(Environment.NewLine); |
356 | sb.Append( | 356 | sb.Append( |
357 | string.Format( | 357 | string.Format( |
358 | "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}", | 358 | "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}\n\n", |
359 | inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime, | 359 | inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime, |
360 | netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime)); | 360 | netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime)); |
361 | sb.Append(Environment.NewLine); | 361 | |
362 | foreach (KeyValuePair<string, Stat> kvp in StatsManager.RegisteredStats) | ||
363 | { | ||
364 | Stat stat = kvp.Value; | ||
365 | |||
366 | if (stat.Category == "scene" && stat.Verbosity == StatVerbosity.Info) | ||
367 | { | ||
368 | sb.AppendFormat("Slow frames ({0}): {1}\n", stat.Container, stat.Value); | ||
369 | } | ||
370 | } | ||
362 | 371 | ||
363 | /* | 372 | /* |
364 | sb.Append(Environment.NewLine); | 373 | sb.Append(Environment.NewLine); |
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index d78fa6a..02df0ac 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -25,6 +25,9 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
28 | namespace OpenSim.Framework.Monitoring | 31 | namespace OpenSim.Framework.Monitoring |
29 | { | 32 | { |
30 | /// <summary> | 33 | /// <summary> |
@@ -32,6 +35,14 @@ namespace OpenSim.Framework.Monitoring | |||
32 | /// </summary> | 35 | /// </summary> |
33 | public class StatsManager | 36 | public class StatsManager |
34 | { | 37 | { |
38 | /// <summary> | ||
39 | /// Registered stats. | ||
40 | /// </summary> | ||
41 | /// <remarks> | ||
42 | /// Do not add or remove from this dictionary. | ||
43 | /// </remarks> | ||
44 | public static Dictionary<string, Stat> RegisteredStats = new Dictionary<string, Stat>(); | ||
45 | |||
35 | private static AssetStatsCollector assetStats; | 46 | private static AssetStatsCollector assetStats; |
36 | private static UserStatsCollector userStats; | 47 | private static UserStatsCollector userStats; |
37 | private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector(); | 48 | private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector(); |
@@ -61,5 +72,108 @@ namespace OpenSim.Framework.Monitoring | |||
61 | 72 | ||
62 | return userStats; | 73 | return userStats; |
63 | } | 74 | } |
75 | |||
76 | public static bool RegisterStat(Stat stat) | ||
77 | { | ||
78 | lock (RegisteredStats) | ||
79 | { | ||
80 | if (RegisteredStats.ContainsKey(stat.UniqueName)) | ||
81 | { | ||
82 | // XXX: For now just return false. This is to avoid problems in regression tests where all tests | ||
83 | // in a class are run in the same instance of the VM. | ||
84 | return false; | ||
85 | |||
86 | // throw new Exception( | ||
87 | // "StatsManager already contains stat with ShortName {0} in Category {1}", stat.ShortName, stat.Category); | ||
88 | } | ||
89 | |||
90 | // We take a replace-on-write approach here so that we don't need to generate a new Dictionary | ||
91 | Dictionary<string, Stat> newRegisteredStats = new Dictionary<string, Stat>(RegisteredStats); | ||
92 | newRegisteredStats[stat.UniqueName] = stat; | ||
93 | RegisteredStats = newRegisteredStats; | ||
94 | } | ||
95 | |||
96 | return true; | ||
97 | } | ||
98 | |||
99 | public static bool DeregisterStat(Stat stat) | ||
100 | { | ||
101 | lock (RegisteredStats) | ||
102 | { | ||
103 | if (!RegisteredStats.ContainsKey(stat.UniqueName)) | ||
104 | return false; | ||
105 | |||
106 | Dictionary<string, Stat> newRegisteredStats = new Dictionary<string, Stat>(RegisteredStats); | ||
107 | newRegisteredStats.Remove(stat.UniqueName); | ||
108 | RegisteredStats = newRegisteredStats; | ||
109 | |||
110 | return true; | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | |||
115 | /// <summary> | ||
116 | /// Verbosity of stat. | ||
117 | /// </summary> | ||
118 | /// <remarks> | ||
119 | /// Info will always be displayed. | ||
120 | /// </remarks> | ||
121 | public enum StatVerbosity | ||
122 | { | ||
123 | Debug, | ||
124 | Info | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// Holds individual static details | ||
129 | /// </summary> | ||
130 | public class Stat | ||
131 | { | ||
132 | /// <summary> | ||
133 | /// Unique stat name used for indexing. Each ShortName in a Category must be unique. | ||
134 | /// </summary> | ||
135 | public string UniqueName { get; private set; } | ||
136 | |||
137 | /// <summary> | ||
138 | /// Category of this stat (e.g. cache, scene, etc). | ||
139 | /// </summary> | ||
140 | public string Category { get; private set; } | ||
141 | |||
142 | /// <summary> | ||
143 | /// Containing name for this stat. | ||
144 | /// FIXME: In the case of a scene, this is currently the scene name (though this leaves | ||
145 | /// us with a to-be-resolved problem of non-unique region names). | ||
146 | /// </summary> | ||
147 | /// <value> | ||
148 | /// The container. | ||
149 | /// </value> | ||
150 | public string Container { get; private set; } | ||
151 | |||
152 | public StatVerbosity Verbosity { get; private set; } | ||
153 | public string ShortName { get; private set; } | ||
154 | public string Name { get; private set; } | ||
155 | public string Description { get; private set; } | ||
156 | public string UnitName { get; private set; } | ||
157 | |||
158 | public double Value { get; set; } | ||
159 | |||
160 | public Stat( | ||
161 | string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description) | ||
162 | { | ||
163 | ShortName = shortName; | ||
164 | Name = name; | ||
165 | UnitName = unitName; | ||
166 | Category = category; | ||
167 | Container = container; | ||
168 | Verbosity = verbosity; | ||
169 | Description = description; | ||
170 | |||
171 | UniqueName = GenUniqueName(Container, Category, ShortName); | ||
172 | } | ||
173 | |||
174 | public static string GenUniqueName(string container, string category, string shortName) | ||
175 | { | ||
176 | return string.Format("{0}+{1}+{2}", container, category, shortName); | ||
177 | } | ||
64 | } | 178 | } |
65 | } \ No newline at end of file | 179 | } \ No newline at end of file |