* Expose client statistics to the console via 'show stats'

* Potentially useful for diagnostics without needing to log in a client
* Packet queue statistics commented out for now pending a better way to cope with the information overload
0.6.0-stable
Justin Clarke Casey 2008-07-15 18:07:23 +00:00
parent 00c15eb0c4
commit d75cacb050
2 changed files with 95 additions and 2 deletions

View File

@ -29,6 +29,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework.Statistics.Interfaces;
namespace OpenSim.Framework.Statistics
@ -49,6 +50,28 @@ namespace OpenSim.Framework.Statistics
private long assetServiceRequestFailures;
private long inventoryServiceRetrievalFailures;
private float timeDilation;
private float simFps;
private float physicsFps;
private float agentUpdates;
private float rootAgents;
private float childAgents;
private float totalPrims;
private float activePrims;
private float totalFrameTime;
private float netFrameTime;
private float physicsFrameTime;
private float otherFrameTime;
private float imageFrameTime;
private float inPacketsPerSecond;
private float outPacketsPerSecond;
private float unackedBytes;
private float agentFrameTime;
private float pendingDownloads;
private float pendingUploads;
private float activeScripts;
private float scriptLinesPerSecond;
/// <summary>
/// Number of times that a client thread terminated because of an exception
/// </summary>
@ -86,6 +109,16 @@ namespace OpenSim.Framework.Statistics
/// </summary>
public long InventoryServiceRetrievalFailures { get { return inventoryServiceRetrievalFailures; } }
/// <summary>
/// Retrieve the total frame time (in ms) of the last frame
/// </summary>
//public float TotalFrameTime { get { return totalFrameTime; } }
/// <summary>
/// Retrieve the physics update component (in ms) of the last frame
/// </summary>
//public float PhysicsFrameTime { get { return physicsFrameTime; } }
/// <summary>
/// Retain a dictionary of all packet queues stats reporters
/// </summary>
@ -167,6 +200,38 @@ namespace OpenSim.Framework.Statistics
}
}
/// <summary>
/// This is the method on which the classic sim stats reporter (which collects stats for
/// client purposes) sends information to listeners.
/// </summary>
/// <param name="pack"></param>
public void ReceiveClassicSimStatsPacket(SimStatsPacket statsPacket)
{
// FIXME: Really shouldn't rely on the probably arbitrary order in which
// stats are packed into the packet
timeDilation = statsPacket.Stat[0].StatValue;
simFps = statsPacket.Stat[1].StatValue;
physicsFps = statsPacket.Stat[2].StatValue;
agentUpdates = statsPacket.Stat[3].StatValue;
rootAgents = statsPacket.Stat[4].StatValue;
childAgents = statsPacket.Stat[5].StatValue;
totalPrims = statsPacket.Stat[6].StatValue;
activePrims = statsPacket.Stat[7].StatValue;
totalFrameTime = statsPacket.Stat[8].StatValue;
netFrameTime = statsPacket.Stat[9].StatValue;
physicsFrameTime = statsPacket.Stat[10].StatValue;
otherFrameTime = statsPacket.Stat[11].StatValue;
imageFrameTime = statsPacket.Stat[12].StatValue;
inPacketsPerSecond = statsPacket.Stat[13].StatValue;
outPacketsPerSecond = statsPacket.Stat[14].StatValue;
unackedBytes = statsPacket.Stat[15].StatValue;
agentFrameTime = statsPacket.Stat[16].StatValue;
pendingDownloads = statsPacket.Stat[17].StatValue;
pendingUploads = statsPacket.Stat[18].StatValue;
activeScripts = statsPacket.Stat[19].StatValue;
scriptLinesPerSecond = statsPacket.Stat[20].StatValue;
}
/// <summary>
/// Report back collected statistical information.
/// </summary>
@ -203,6 +268,30 @@ Asset service request failures: {5}"+ Environment.NewLine,
"Initial inventory caching failures: {0}" + Environment.NewLine,
InventoryServiceRetrievalFailures));
sb.Append(Environment.NewLine);
sb.Append("FRAME STATISTICS");
sb.Append(Environment.NewLine);
sb.Append("Dilatn SimFPS PhyFPS AgntUp RootAg ChldAg Prims AtvPrm AtvScr ScrLPS");
sb.Append(Environment.NewLine);
sb.Append(
string.Format(
"{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}",
timeDilation, simFps, physicsFps, agentUpdates, rootAgents,
childAgents, totalPrims, activePrims, activeScripts, scriptLinesPerSecond));
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
// There is no script frame time currently because we don't yet collect it
sb.Append("PktsIn PktOut PendDl PendUl UnackB TotlFt NetFt PhysFt OthrFt AgntFt ImgsFt");
sb.Append(Environment.NewLine);
sb.Append(
string.Format(
"{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}",
inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime,
netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime));
sb.Append(Environment.NewLine);
/*
sb.Append(Environment.NewLine);
sb.Append("PACKET QUEUE STATISTICS");
sb.Append(Environment.NewLine);
@ -219,6 +308,7 @@ Asset service request failures: {5}"+ Environment.NewLine,
sb.Append(packetQueueStatsCollectors[key].Report());
sb.Append(Environment.NewLine);
}
*/
sb.Append(base.Report());

View File

@ -29,6 +29,7 @@ using System;
using System.Timers;
using libsecondlife.Packets;
using OpenSim.Framework;
using OpenSim.Framework.Statistics;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Scenes
@ -114,7 +115,6 @@ namespace OpenSim.Region.Environment.Scenes
public SimStatsReporter(Scene scene)
{
statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000);
m_scene = scene;
ReportingRegion = scene.RegionInfo;
@ -126,6 +126,9 @@ namespace OpenSim.Region.Environment.Scenes
m_report.Interval = statsUpdatesEveryMS;
m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat);
m_report.Enabled = true;
if (StatsManager.SimExtraStats != null)
OnSendStatsResult += StatsManager.SimExtraStats.ReceiveClassicSimStatsPacket;
}
public void SetUpdateMS(int ms)