From 30eea2618dcc0a43d1d4d764590100c19bd7c05d Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Fri, 22 Feb 2008 20:50:30 +0000
Subject: * Implement packet queue statistics * This will show the packets
waiting in each queue for each client logged into a region server * These are
displayed using 'show stats' on the region command line * This is in pursuit
of a memory leak. * This will require a prebuild
---
.../Framework/Statistics/SimExtraStatsReporter.cs | 95 ++++++++++++++++++++--
1 file changed, 88 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/Statistics/SimExtraStatsReporter.cs b/OpenSim/Framework/Statistics/SimExtraStatsReporter.cs
index c8b8223..acf2ecb 100644
--- a/OpenSim/Framework/Statistics/SimExtraStatsReporter.cs
+++ b/OpenSim/Framework/Statistics/SimExtraStatsReporter.cs
@@ -26,12 +26,19 @@
*
*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+
using OpenSim.Framework;
+using OpenSim.Framework.Statistics.Interfaces;
+
+using libsecondlife;
namespace OpenSim.Framework.Statistics
{
public class SimExtraStatsReporter
- {
+ {
private long assetsInCache;
private long texturesInCache;
private long assetCacheMemoryUsage;
@@ -42,6 +49,12 @@ namespace OpenSim.Framework.Statistics
public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } }
public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } }
+ ///
+ /// Retain a dictionary of all packet queues stats reporters
+ ///
+ private IDictionary packetQueueStatsReporters
+ = new Dictionary();
+
public void AddAsset(AssetBase asset)
{
assetsInCache++;
@@ -56,19 +69,87 @@ namespace OpenSim.Framework.Statistics
texturesInCache++;
textureCacheMemoryUsage += image.Data.Length;
}
- }
+ }
+
+ ///
+ /// Register as a packet queue stats provider
+ ///
+ /// An agent LLUUID
+ ///
+ public void RegisterPacketQueueStatsProvider(LLUUID uuid, IPullStatsProvider provider)
+ {
+ lock (packetQueueStatsReporters)
+ {
+ packetQueueStatsReporters[uuid] = new PacketQueueStatsReporter(provider);
+ }
+ }
+
+ ///
+ /// Deregister a packet queue stats provider
+ ///
+ /// An agent LLUUID
+ public void DeregisterPacketQueueStatsProvider(LLUUID uuid)
+ {
+ lock (packetQueueStatsReporters)
+ {
+ packetQueueStatsReporters.Remove(uuid);
+ }
+ }
///
/// Report back collected statistical information.
///
///
public string Report()
- {
- return string.Format(
+ {
+ StringBuilder sb = new StringBuilder(Environment.NewLine);
+ sb.Append("PACKET QUEUE STATISTICS");
+ sb.Append(Environment.NewLine);
+ sb.Append(
+ string.Format(
@"Asset cache contains {0,6} assets using {1,10:0.000}K
-Texture cache contains {2,6} textures using {3,10:0.000}K",
- AssetsInCache, AssetCacheMemoryUsage / 1024.0,
- TexturesInCache, TextureCacheMemoryUsage / 1024.0);
+Texture cache contains {2,6} textures using {3,10:0.000}K" + Environment.NewLine,
+ AssetsInCache, AssetCacheMemoryUsage / 1024.0,
+ TexturesInCache, TextureCacheMemoryUsage / 1024.0));
+
+ sb.Append(Environment.NewLine);
+ sb.Append("PACKET QUEUE STATISTICS");
+ sb.Append(Environment.NewLine);
+ sb.Append("Agent UUID ");
+ sb.Append(" Send In Out Resend ");
+ sb.Append(" Land Wind Cloud Task Texture Asset");
+ sb.Append(Environment.NewLine);
+
+ foreach (LLUUID key in packetQueueStatsReporters.Keys)
+ {
+ sb.Append(string.Format("{0}: ", key));
+ sb.Append(packetQueueStatsReporters[key].Report());
+ sb.Append(Environment.NewLine);
+ }
+
+ return sb.ToString();
}
}
+
+ ///
+ /// Pull packet queue stats from packet queues and report
+ ///
+ public class PacketQueueStatsReporter
+ {
+ private IPullStatsProvider m_statsProvider;
+
+ public PacketQueueStatsReporter(IPullStatsProvider provider)
+ {
+ m_statsProvider = provider;
+ }
+
+ ///
+ /// Report back collected statistical information.
+ ///
+ ///
+ public string Report()
+ {
+ return m_statsProvider.GetStats();
+ }
+ }
}
--
cgit v1.1