29 using System.Collections.Generic;
30 using System.Diagnostics;
34 using OpenMetaverse.StructuredData;
35 using OpenSim.Framework.Monitoring.Interfaces;
38 namespace OpenSim.Framework.Monitoring
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 spareTime;
76 private volatile float sleepTime;
77 private volatile float physicsStep;
80 private volatile float scriptLinesPerSecond;
81 private volatile float m_frameDilation;
82 private volatile float m_usersLoggingIn;
83 private volatile float m_totalGeoPrims;
84 private volatile float m_totalMeshes;
85 private volatile float m_inUseThreads;
109 public float TimeDilation {
get {
return timeDilation; } }
110 public float SimFps {
get {
return simFps; } }
111 public float PhysicsFps {
get {
return physicsFps; } }
112 public float AgentUpdates {
get {
return agentUpdates; } }
113 public float RootAgents {
get {
return rootAgents; } }
114 public float ChildAgents {
get {
return childAgents; } }
115 public float TotalPrims {
get {
return totalPrims; } }
116 public float ActivePrims {
get {
return activePrims; } }
117 public float TotalFrameTime {
get {
return totalFrameTime; } }
118 public float NetFrameTime {
get {
return netFrameTime; } }
119 public float PhysicsFrameTime {
get {
return physicsFrameTime; } }
120 public float OtherFrameTime {
get {
return otherFrameTime; } }
121 public float ImageFrameTime {
get {
return imageFrameTime; } }
122 public float InPacketsPerSecond {
get {
return inPacketsPerSecond; } }
123 public float OutPacketsPerSecond {
get {
return outPacketsPerSecond; } }
124 public float UnackedBytes {
get {
return unackedBytes; } }
125 public float AgentFrameTime {
get {
return agentFrameTime; } }
126 public float PendingDownloads {
get {
return pendingDownloads; } }
127 public float PendingUploads {
get {
return pendingUploads; } }
128 public float ActiveScripts {
get {
return activeScripts; } }
129 public float ScriptLinesPerSecond {
get {
return scriptLinesPerSecond; } }
172 private IDictionary<UUID, PacketQueueStatsCollector> packetQueueStatsCollectors
173 =
new Dictionary<UUID, PacketQueueStatsCollector>();
235 lock (packetQueueStatsCollectors)
249 lock (packetQueueStatsCollectors)
251 packetQueueStatsCollectors.Remove(uuid);
268 timeDilation = stats.StatsBlock[0].StatValue;
269 simFps = stats.StatsBlock[1].StatValue;
270 physicsFps = stats.StatsBlock[2].StatValue;
271 agentUpdates = stats.StatsBlock[3].StatValue;
272 rootAgents = stats.StatsBlock[4].StatValue;
273 childAgents = stats.StatsBlock[5].StatValue;
274 totalPrims = stats.StatsBlock[6].StatValue;
275 activePrims = stats.StatsBlock[7].StatValue;
276 totalFrameTime = stats.StatsBlock[8].StatValue;
277 netFrameTime = stats.StatsBlock[9].StatValue;
278 physicsFrameTime = stats.StatsBlock[10].StatValue;
279 imageFrameTime = stats.StatsBlock[11].StatValue;
280 otherFrameTime = stats.StatsBlock[12].StatValue;
281 inPacketsPerSecond = stats.StatsBlock[13].StatValue;
282 outPacketsPerSecond = stats.StatsBlock[14].StatValue;
283 unackedBytes = stats.StatsBlock[15].StatValue;
284 agentFrameTime = stats.StatsBlock[16].StatValue;
285 pendingDownloads = stats.StatsBlock[17].StatValue;
286 pendingUploads = stats.StatsBlock[18].StatValue;
287 activeScripts = stats.StatsBlock[19].StatValue;
288 sleepTime = stats.StatsBlock[20].StatValue;
289 spareTime = stats.StatsBlock[21].StatValue;
290 physicsStep = stats.StatsBlock[22].StatValue;
292 scriptLinesPerSecond = stats.ExtraStatsBlock[0].StatValue;
293 m_frameDilation = stats.ExtraStatsBlock[1].StatValue;
294 m_usersLoggingIn = stats.ExtraStatsBlock[2].StatValue;
295 m_totalGeoPrims = stats.ExtraStatsBlock[3].StatValue;
296 m_totalMeshes = stats.ExtraStatsBlock[4].StatValue;
297 m_inUseThreads = stats.ExtraStatsBlock[5].StatValue;
306 StringBuilder sb =
new StringBuilder(Environment.NewLine);
338 sb.Append(Environment.NewLine);
339 sb.Append(
"CONNECTION STATISTICS");
340 sb.Append(Environment.NewLine);
342 List<Stat> stats = StatsManager.GetStatsFromEachContainer(
"clientstack",
"ClientLogoutsDueToNoReceives");
345 "Client logouts due to no data receive timeout: {0}\n\n",
346 stats != null ? stats.Sum(s => s.Value).ToString() :
"unknown");
356 sb.Append(Environment.NewLine);
357 sb.Append(
"SAMPLE FRAME STATISTICS");
358 sb.Append(Environment.NewLine);
359 sb.Append(
"Dilatn SimFPS PhyFPS AgntUp RootAg ChldAg Prims AtvPrm AtvScr ScrLPS");
360 sb.Append(Environment.NewLine);
363 "{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}",
364 timeDilation, simFps, physicsFps, agentUpdates, rootAgents,
365 childAgents, totalPrims, activePrims, activeScripts, scriptLinesPerSecond));
367 sb.Append(Environment.NewLine);
368 sb.Append(Environment.NewLine);
370 sb.Append(
"PktsIn PktOut PendDl PendUl UnackB TotlFt NetFt PhysFt OthrFt AgntFt ImgsFt");
371 sb.Append(Environment.NewLine);
374 "{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",
375 inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime,
376 netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime));
415 sb.Append(base.Report());
417 return sb.ToString();
424 public override string XReport(
string uptime,
string version)
426 return OSDParser.SerializeJsonString(OReport(uptime, version));
438 double memUsage = Process.GetCurrentProcess().WorkingSet64 / 1024.0;
442 int numberThreadsRunning = 0;
443 foreach (ProcessThread currentThread
in
444 Process.GetCurrentProcess().Threads)
449 if (currentThread != null &&
450 currentThread.ThreadState == ThreadState.Running)
452 numberThreadsRunning++;
468 args[
"Dilatn"] = OSD.FromString (String.Format (
"{0:0.##}", timeDilation));
469 args[
"SimFPS"] = OSD.FromString (String.Format (
"{0:0.##}", simFps));
470 args[
"PhyFPS"] = OSD.FromString (String.Format (
"{0:0.##}", physicsFps));
471 args[
"AgntUp"] = OSD.FromString (String.Format (
"{0:0.##}", agentUpdates));
472 args[
"RootAg"] = OSD.FromString (String.Format (
"{0:0.##}", rootAgents));
473 args[
"ChldAg"] = OSD.FromString (String.Format (
"{0:0.##}", childAgents));
474 args[
"Prims"] = OSD.FromString (String.Format (
"{0:0.##}", totalPrims));
475 args[
"AtvPrm"] = OSD.FromString (String.Format (
"{0:0.##}", activePrims));
476 args[
"AtvScr"] = OSD.FromString (String.Format (
"{0:0.##}", activeScripts));
477 args[
"ScrLPS"] = OSD.FromString (String.Format (
"{0:0.##}", scriptLinesPerSecond));
478 args[
"PktsIn"] = OSD.FromString (String.Format (
"{0:0.##}", inPacketsPerSecond));
479 args[
"PktOut"] = OSD.FromString (String.Format (
"{0:0.##}", outPacketsPerSecond));
480 args[
"PendDl"] = OSD.FromString (String.Format (
"{0:0.##}", pendingDownloads));
481 args[
"PendUl"] = OSD.FromString (String.Format (
"{0:0.##}", pendingUploads));
482 args[
"UnackB"] = OSD.FromString (String.Format (
"{0:0.##}", unackedBytes));
483 args[
"TotlFt"] = OSD.FromString (String.Format (
"{0:0.##}", totalFrameTime));
484 args[
"NetFt"] = OSD.FromString (String.Format (
"{0:0.##}", netFrameTime));
485 args[
"PhysFt"] = OSD.FromString (String.Format (
"{0:0.##}", physicsFrameTime));
486 args[
"OthrFt"] = OSD.FromString (String.Format (
"{0:0.##}", otherFrameTime));
487 args[
"AgntFt"] = OSD.FromString (String.Format (
"{0:0.##}", agentFrameTime));
488 args[
"ImgsFt"] = OSD.FromString (String.Format (
"{0:0.##}", imageFrameTime));
489 args[
"Memory"] = OSD.FromString (base.XReport (uptime, version));
490 args[
"Uptime"] = OSD.FromString (uptime);
491 args[
"Version"] = OSD.FromString (version);
493 args[
"FrameDilatn"] = OSD.FromString(String.Format(
"{0:0.##}", m_frameDilation));
494 args[
"Logging in Users"] = OSD.FromString(String.Format(
"{0:0.##}",
496 args[
"GeoPrims"] = OSD.FromString(String.Format(
"{0:0.##}",
498 args[
"Mesh Objects"] = OSD.FromString(String.Format(
"{0:0.##}",
500 args[
"XEngine Thread Count"] = OSD.FromString(String.Format(
"{0:0.##}",
502 args[
"Util Thread Count"] = OSD.FromString(String.Format(
"{0:0.##}",
503 Util.GetSmartThreadPoolInfo().InUseThreads));
504 args[
"System Thread Count"] = OSD.FromString(String.Format(
505 "{0:0.##}", numberThreadsRunning));
506 args[
"ProcMem"] = OSD.FromString(String.Format(
"{0:#,###,###.##}",
523 m_statsProvider = provider;
532 return m_statsProvider.GetStats();
535 public string XReport(
string uptime,
string version)
Implemented by classes which collect up non-viewer statistical information
PacketQueueStatsCollector(IPullStatsProvider provider)
string XReport(string uptime, string version)
Report back collected statistical information in json
Implemented by objects which allow statistical information to be pulled from them.
OpenMetaverse.StructuredData.OSDMap OSDMap
Enapsulate statistics for a simulator/scene.
Pull packet queue stats from packet queues and report
Statistics which all collectors are interested in reporting
OSDMap OReport(string uptime, string version)
Report back collected statistical information as an OSDMap of key/values
string Report()
Report back collected statistical information.