aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-07-25 23:11:50 +0100
committerJustin Clark-Casey (justincc)2012-07-25 23:11:50 +0100
commit35efa88c26d249d315837fdca0faf643511e1a4e (patch)
tree00227cb097196ca172ed9639c536e4934326e89f /OpenSim/Framework/Statistics/SimExtraStatsCollector.cs
parentAdd MemoryWatchdog class missing from git master a1e9964 (diff)
downloadopensim-SC_OLD-35efa88c26d249d315837fdca0faf643511e1a4e.zip
opensim-SC_OLD-35efa88c26d249d315837fdca0faf643511e1a4e.tar.gz
opensim-SC_OLD-35efa88c26d249d315837fdca0faf643511e1a4e.tar.bz2
opensim-SC_OLD-35efa88c26d249d315837fdca0faf643511e1a4e.tar.xz
Rename OpenSim.Framework.Statistics to OpenSim.Framework.Monitoring.
This better reflects the long-term purpose of that project and matches Monitoring modules.
Diffstat (limited to 'OpenSim/Framework/Statistics/SimExtraStatsCollector.cs')
-rw-r--r--OpenSim/Framework/Statistics/SimExtraStatsCollector.cs464
1 files changed, 0 insertions, 464 deletions
diff --git a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs b/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs
deleted file mode 100644
index a506e3b..0000000
--- a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs
+++ /dev/null
@@ -1,464 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32using OpenMetaverse;
33using OpenSim.Framework.Statistics.Interfaces;
34using OpenMetaverse.StructuredData;
35
36namespace OpenSim.Framework.Statistics
37{
38 /// <summary>
39 /// Collects sim statistics which aren't already being collected for the linden viewer's statistics pane
40 /// </summary>
41 public class SimExtraStatsCollector : BaseStatsCollector
42 {
43 private long abnormalClientThreadTerminations;
44
45// private long assetsInCache;
46// private long texturesInCache;
47// private long assetCacheMemoryUsage;
48// private long textureCacheMemoryUsage;
49// private TimeSpan assetRequestTimeAfterCacheMiss;
50// private long blockedMissingTextureRequests;
51
52// private long assetServiceRequestFailures;
53// private long inventoryServiceRetrievalFailures;
54
55 private volatile float timeDilation;
56 private volatile float simFps;
57 private volatile float physicsFps;
58 private volatile float agentUpdates;
59 private volatile float rootAgents;
60 private volatile float childAgents;
61 private volatile float totalPrims;
62 private volatile float activePrims;
63 private volatile float totalFrameTime;
64 private volatile float netFrameTime;
65 private volatile float physicsFrameTime;
66 private volatile float otherFrameTime;
67 private volatile float imageFrameTime;
68 private volatile float inPacketsPerSecond;
69 private volatile float outPacketsPerSecond;
70 private volatile float unackedBytes;
71 private volatile float agentFrameTime;
72 private volatile float pendingDownloads;
73 private volatile float pendingUploads;
74 private volatile float activeScripts;
75 private volatile float scriptLinesPerSecond;
76
77 /// <summary>
78 /// Number of times that a client thread terminated because of an exception
79 /// </summary>
80 public long AbnormalClientThreadTerminations { get { return abnormalClientThreadTerminations; } }
81
82// /// <summary>
83// /// These statistics are being collected by push rather than pull. Pull would be simpler, but I had the
84// /// notion of providing some flow statistics (which pull wouldn't give us). Though admittedly these
85// /// haven't yet been implemented...
86// /// </summary>
87// public long AssetsInCache { get { return assetsInCache; } }
88//
89// /// <value>
90// /// Currently unused
91// /// </value>
92// public long TexturesInCache { get { return texturesInCache; } }
93//
94// /// <value>
95// /// Currently misleading since we can't currently subtract removed asset memory usage without a performance hit
96// /// </value>
97// public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } }
98//
99// /// <value>
100// /// Currently unused
101// /// </value>
102// public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } }
103
104 public float TimeDilation { get { return timeDilation; } }
105 public float SimFps { get { return simFps; } }
106 public float PhysicsFps { get { return physicsFps; } }
107 public float AgentUpdates { get { return agentUpdates; } }
108 public float RootAgents { get { return rootAgents; } }
109 public float ChildAgents { get { return childAgents; } }
110 public float TotalPrims { get { return totalPrims; } }
111 public float ActivePrims { get { return activePrims; } }
112 public float TotalFrameTime { get { return totalFrameTime; } }
113 public float NetFrameTime { get { return netFrameTime; } }
114 public float PhysicsFrameTime { get { return physicsFrameTime; } }
115 public float OtherFrameTime { get { return otherFrameTime; } }
116 public float ImageFrameTime { get { return imageFrameTime; } }
117 public float InPacketsPerSecond { get { return inPacketsPerSecond; } }
118 public float OutPacketsPerSecond { get { return outPacketsPerSecond; } }
119 public float UnackedBytes { get { return unackedBytes; } }
120 public float AgentFrameTime { get { return agentFrameTime; } }
121 public float PendingDownloads { get { return pendingDownloads; } }
122 public float PendingUploads { get { return pendingUploads; } }
123 public float ActiveScripts { get { return activeScripts; } }
124 public float ScriptLinesPerSecond { get { return scriptLinesPerSecond; } }
125
126// /// <summary>
127// /// This is the time it took for the last asset request made in response to a cache miss.
128// /// </summary>
129// public TimeSpan AssetRequestTimeAfterCacheMiss { get { return assetRequestTimeAfterCacheMiss; } }
130//
131// /// <summary>
132// /// Number of persistent requests for missing textures we have started blocking from clients. To some extent
133// /// this is just a temporary statistic to keep this problem in view - the root cause of this lies either
134// /// in a mishandling of the reply protocol, related to avatar appearance or may even originate in graphics
135// /// driver bugs on clients (though this seems less likely).
136// /// </summary>
137// public long BlockedMissingTextureRequests { get { return blockedMissingTextureRequests; } }
138//
139// /// <summary>
140// /// Record the number of times that an asset request has failed. Failures are effectively exceptions, such as
141// /// request timeouts. If an asset service replies that a particular asset cannot be found, this is not counted
142// /// as a failure
143// /// </summary>
144// public long AssetServiceRequestFailures { get { return assetServiceRequestFailures; } }
145
146 /// <summary>
147 /// Number of known failures to retrieve avatar inventory from the inventory service. This does not
148 /// cover situations where the inventory service accepts the request but never returns any data, since
149 /// we do not yet timeout this situation.
150 /// </summary>
151 /// <remarks>Commented out because we do not cache inventory at this point</remarks>
152// public long InventoryServiceRetrievalFailures { get { return inventoryServiceRetrievalFailures; } }
153
154 /// <summary>
155 /// Retrieve the total frame time (in ms) of the last frame
156 /// </summary>
157 //public float TotalFrameTime { get { return totalFrameTime; } }
158
159 /// <summary>
160 /// Retrieve the physics update component (in ms) of the last frame
161 /// </summary>
162 //public float PhysicsFrameTime { get { return physicsFrameTime; } }
163
164 /// <summary>
165 /// Retain a dictionary of all packet queues stats reporters
166 /// </summary>
167 private IDictionary<UUID, PacketQueueStatsCollector> packetQueueStatsCollectors
168 = new Dictionary<UUID, PacketQueueStatsCollector>();
169
170 public void AddAbnormalClientThreadTermination()
171 {
172 abnormalClientThreadTerminations++;
173 }
174
175// public void AddAsset(AssetBase asset)
176// {
177// assetsInCache++;
178// //assetCacheMemoryUsage += asset.Data.Length;
179// }
180//
181// public void RemoveAsset(UUID uuid)
182// {
183// assetsInCache--;
184// }
185//
186// public void AddTexture(AssetBase image)
187// {
188// if (image.Data != null)
189// {
190// texturesInCache++;
191//
192// // This could have been a pull stat, though there was originally a nebulous idea to measure flow rates
193// textureCacheMemoryUsage += image.Data.Length;
194// }
195// }
196//
197// /// <summary>
198// /// Signal that the asset cache has been cleared.
199// /// </summary>
200// public void ClearAssetCacheStatistics()
201// {
202// assetsInCache = 0;
203// assetCacheMemoryUsage = 0;
204// texturesInCache = 0;
205// textureCacheMemoryUsage = 0;
206// }
207//
208// public void AddAssetRequestTimeAfterCacheMiss(TimeSpan ts)
209// {
210// assetRequestTimeAfterCacheMiss = ts;
211// }
212//
213// public void AddBlockedMissingTextureRequest()
214// {
215// blockedMissingTextureRequests++;
216// }
217//
218// public void AddAssetServiceRequestFailure()
219// {
220// assetServiceRequestFailures++;
221// }
222
223// public void AddInventoryServiceRetrievalFailure()
224// {
225// inventoryServiceRetrievalFailures++;
226// }
227
228 /// <summary>
229 /// Register as a packet queue stats provider
230 /// </summary>
231 /// <param name="uuid">An agent UUID</param>
232 /// <param name="provider"></param>
233 public void RegisterPacketQueueStatsProvider(UUID uuid, IPullStatsProvider provider)
234 {
235 lock (packetQueueStatsCollectors)
236 {
237 // FIXME: If the region service is providing more than one region, then the child and root agent
238 // queues are wrongly replacing each other here.
239 packetQueueStatsCollectors[uuid] = new PacketQueueStatsCollector(provider);
240 }
241 }
242
243 /// <summary>
244 /// Deregister a packet queue stats provider
245 /// </summary>
246 /// <param name="uuid">An agent UUID</param>
247 public void DeregisterPacketQueueStatsProvider(UUID uuid)
248 {
249 lock (packetQueueStatsCollectors)
250 {
251 packetQueueStatsCollectors.Remove(uuid);
252 }
253 }
254
255 /// <summary>
256 /// This is the method on which the classic sim stats reporter (which collects stats for
257 /// client purposes) sends information to listeners.
258 /// </summary>
259 /// <param name="pack"></param>
260 public void ReceiveClassicSimStatsPacket(SimStats stats)
261 {
262 // FIXME: SimStats shouldn't allow an arbitrary stat packing order (which is inherited from the original
263 // SimStatsPacket that was being used).
264 timeDilation = stats.StatsBlock[0].StatValue;
265 simFps = stats.StatsBlock[1].StatValue;
266 physicsFps = stats.StatsBlock[2].StatValue;
267 agentUpdates = stats.StatsBlock[3].StatValue;
268 rootAgents = stats.StatsBlock[4].StatValue;
269 childAgents = stats.StatsBlock[5].StatValue;
270 totalPrims = stats.StatsBlock[6].StatValue;
271 activePrims = stats.StatsBlock[7].StatValue;
272 totalFrameTime = stats.StatsBlock[8].StatValue;
273 netFrameTime = stats.StatsBlock[9].StatValue;
274 physicsFrameTime = stats.StatsBlock[10].StatValue;
275 otherFrameTime = stats.StatsBlock[11].StatValue;
276 imageFrameTime = stats.StatsBlock[12].StatValue;
277 inPacketsPerSecond = stats.StatsBlock[13].StatValue;
278 outPacketsPerSecond = stats.StatsBlock[14].StatValue;
279 unackedBytes = stats.StatsBlock[15].StatValue;
280 agentFrameTime = stats.StatsBlock[16].StatValue;
281 pendingDownloads = stats.StatsBlock[17].StatValue;
282 pendingUploads = stats.StatsBlock[18].StatValue;
283 activeScripts = stats.StatsBlock[19].StatValue;
284 scriptLinesPerSecond = stats.StatsBlock[20].StatValue;
285 }
286
287 /// <summary>
288 /// Report back collected statistical information.
289 /// </summary>
290 /// <returns></returns>
291 public override string Report()
292 {
293 StringBuilder sb = new StringBuilder(Environment.NewLine);
294// sb.Append("ASSET STATISTICS");
295// sb.Append(Environment.NewLine);
296
297 /*
298 sb.Append(
299 string.Format(
300@"Asset cache contains {0,6} non-texture assets using {1,10} K
301Texture cache contains {2,6} texture assets using {3,10} K
302Latest asset request time after cache miss: {4}s
303Blocked client requests for missing textures: {5}
304Asset service request failures: {6}"+ Environment.NewLine,
305 AssetsInCache, Math.Round(AssetCacheMemoryUsage / 1024.0),
306 TexturesInCache, Math.Round(TextureCacheMemoryUsage / 1024.0),
307 assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0,
308 BlockedMissingTextureRequests,
309 AssetServiceRequestFailures));
310 */
311
312 /*
313 sb.Append(
314 string.Format(
315@"Asset cache contains {0,6} assets
316Latest asset request time after cache miss: {1}s
317Blocked client requests for missing textures: {2}
318Asset service request failures: {3}" + Environment.NewLine,
319 AssetsInCache,
320 assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0,
321 BlockedMissingTextureRequests,
322 AssetServiceRequestFailures));
323 */
324
325 sb.Append(Environment.NewLine);
326 sb.Append("CONNECTION STATISTICS");
327 sb.Append(Environment.NewLine);
328 sb.Append(
329 string.Format(
330 "Abnormal client thread terminations: {0}" + Environment.NewLine,
331 abnormalClientThreadTerminations));
332
333// sb.Append(Environment.NewLine);
334// sb.Append("INVENTORY STATISTICS");
335// sb.Append(Environment.NewLine);
336// sb.Append(
337// string.Format(
338// "Initial inventory caching failures: {0}" + Environment.NewLine,
339// InventoryServiceRetrievalFailures));
340
341 sb.Append(Environment.NewLine);
342 sb.Append("FRAME STATISTICS");
343 sb.Append(Environment.NewLine);
344 sb.Append("Dilatn SimFPS PhyFPS AgntUp RootAg ChldAg Prims AtvPrm AtvScr ScrLPS");
345 sb.Append(Environment.NewLine);
346 sb.Append(
347 string.Format(
348 "{0,6:0.00} {1,6:0} {2,6:0.0} {3,6:0.0} {4,6:0} {5,6:0} {6,6:0} {7,6:0} {8,6:0} {9,6:0}",
349 timeDilation, simFps, physicsFps, agentUpdates, rootAgents,
350 childAgents, totalPrims, activePrims, activeScripts, scriptLinesPerSecond));
351
352 sb.Append(Environment.NewLine);
353 sb.Append(Environment.NewLine);
354 // There is no script frame time currently because we don't yet collect it
355 sb.Append("PktsIn PktOut PendDl PendUl UnackB TotlFt NetFt PhysFt OthrFt AgntFt ImgsFt");
356 sb.Append(Environment.NewLine);
357 sb.Append(
358 string.Format(
359 "{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}",
360 inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime,
361 netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime));
362 sb.Append(Environment.NewLine);
363
364 /*
365 sb.Append(Environment.NewLine);
366 sb.Append("PACKET QUEUE STATISTICS");
367 sb.Append(Environment.NewLine);
368 sb.Append("Agent UUID ");
369 sb.Append(
370 string.Format(
371 " {0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
372 "Send", "In", "Out", "Resend", "Land", "Wind", "Cloud", "Task", "Texture", "Asset"));
373 sb.Append(Environment.NewLine);
374
375 foreach (UUID key in packetQueueStatsCollectors.Keys)
376 {
377 sb.Append(string.Format("{0}: ", key));
378 sb.Append(packetQueueStatsCollectors[key].Report());
379 sb.Append(Environment.NewLine);
380 }
381 */
382
383 sb.Append(base.Report());
384
385 return sb.ToString();
386 }
387
388 /// <summary>
389 /// Report back collected statistical information as json serialization.
390 /// </summary>
391 /// <returns></returns>
392 public override string XReport(string uptime, string version)
393 {
394 OSDMap args = new OSDMap(30);
395// args["AssetsInCache"] = OSD.FromString (String.Format ("{0:0.##}", AssetsInCache));
396// args["TimeAfterCacheMiss"] = OSD.FromString (String.Format ("{0:0.##}",
397// assetRequestTimeAfterCacheMiss.Milliseconds / 1000.0));
398// args["BlockedMissingTextureRequests"] = OSD.FromString (String.Format ("{0:0.##}",
399// BlockedMissingTextureRequests));
400// args["AssetServiceRequestFailures"] = OSD.FromString (String.Format ("{0:0.##}",
401// AssetServiceRequestFailures));
402// args["abnormalClientThreadTerminations"] = OSD.FromString (String.Format ("{0:0.##}",
403// abnormalClientThreadTerminations));
404// args["InventoryServiceRetrievalFailures"] = OSD.FromString (String.Format ("{0:0.##}",
405// InventoryServiceRetrievalFailures));
406 args["Dilatn"] = OSD.FromString (String.Format ("{0:0.##}", timeDilation));
407 args["SimFPS"] = OSD.FromString (String.Format ("{0:0.##}", simFps));
408 args["PhyFPS"] = OSD.FromString (String.Format ("{0:0.##}", physicsFps));
409 args["AgntUp"] = OSD.FromString (String.Format ("{0:0.##}", agentUpdates));
410 args["RootAg"] = OSD.FromString (String.Format ("{0:0.##}", rootAgents));
411 args["ChldAg"] = OSD.FromString (String.Format ("{0:0.##}", childAgents));
412 args["Prims"] = OSD.FromString (String.Format ("{0:0.##}", totalPrims));
413 args["AtvPrm"] = OSD.FromString (String.Format ("{0:0.##}", activePrims));
414 args["AtvScr"] = OSD.FromString (String.Format ("{0:0.##}", activeScripts));
415 args["ScrLPS"] = OSD.FromString (String.Format ("{0:0.##}", scriptLinesPerSecond));
416 args["PktsIn"] = OSD.FromString (String.Format ("{0:0.##}", inPacketsPerSecond));
417 args["PktOut"] = OSD.FromString (String.Format ("{0:0.##}", outPacketsPerSecond));
418 args["PendDl"] = OSD.FromString (String.Format ("{0:0.##}", pendingDownloads));
419 args["PendUl"] = OSD.FromString (String.Format ("{0:0.##}", pendingUploads));
420 args["UnackB"] = OSD.FromString (String.Format ("{0:0.##}", unackedBytes));
421 args["TotlFt"] = OSD.FromString (String.Format ("{0:0.##}", totalFrameTime));
422 args["NetFt"] = OSD.FromString (String.Format ("{0:0.##}", netFrameTime));
423 args["PhysFt"] = OSD.FromString (String.Format ("{0:0.##}", physicsFrameTime));
424 args["OthrFt"] = OSD.FromString (String.Format ("{0:0.##}", otherFrameTime));
425 args["AgntFt"] = OSD.FromString (String.Format ("{0:0.##}", agentFrameTime));
426 args["ImgsFt"] = OSD.FromString (String.Format ("{0:0.##}", imageFrameTime));
427 args["Memory"] = OSD.FromString (base.XReport (uptime, version));
428 args["Uptime"] = OSD.FromString (uptime);
429 args["Version"] = OSD.FromString (version);
430
431 string strBuffer = "";
432 strBuffer = OSDParser.SerializeJsonString(args);
433
434 return strBuffer;
435 }
436 }
437
438 /// <summary>
439 /// Pull packet queue stats from packet queues and report
440 /// </summary>
441 public class PacketQueueStatsCollector : IStatsCollector
442 {
443 private IPullStatsProvider m_statsProvider;
444
445 public PacketQueueStatsCollector(IPullStatsProvider provider)
446 {
447 m_statsProvider = provider;
448 }
449
450 /// <summary>
451 /// Report back collected statistical information.
452 /// </summary>
453 /// <returns></returns>
454 public string Report()
455 {
456 return m_statsProvider.GetStats();
457 }
458
459 public string XReport(string uptime, string version)
460 {
461 return "";
462 }
463 }
464}