aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SimStatsReporter.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs48
1 files changed, 43 insertions, 5 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index a4afd47..cb102d0 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -26,7 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29//using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Timers; 30using System.Timers;
31using OpenMetaverse.Packets; 31using OpenMetaverse.Packets;
32using OpenSim.Framework; 32using OpenSim.Framework;
@@ -35,10 +35,18 @@ using OpenSim.Region.Framework.Interfaces;
35 35
36namespace OpenSim.Region.Framework.Scenes 36namespace OpenSim.Region.Framework.Scenes
37{ 37{
38 /// <summary>
39 /// Collect statistics from the scene to send to the client and for access by other monitoring tools.
40 /// </summary>
41 /// <remarks>
42 /// FIXME: This should be a monitoring region module
43 /// </remarks>
38 public class SimStatsReporter 44 public class SimStatsReporter
39 { 45 {
40// private static readonly log4net.ILog m_log 46 private static readonly log4net.ILog m_log
41// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 47 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
48
49 public const string LastReportedObjectUpdateStatName = "LastReportedObjectUpdates";
42 50
43 public delegate void SendStatResult(SimStats stats); 51 public delegate void SendStatResult(SimStats stats);
44 52
@@ -113,6 +121,14 @@ namespace OpenSim.Region.Framework.Scenes
113 get { return lastReportedSimStats; } 121 get { return lastReportedSimStats; }
114 } 122 }
115 123
124 /// <summary>
125 /// Extra sim statistics that are used by monitors but not sent to the client.
126 /// </summary>
127 /// <value>
128 /// The keys are the stat names.
129 /// </value>
130 private Dictionary<string, float> m_lastReportedExtraSimStats = new Dictionary<string, float>();
131
116 // Sending a stats update every 3 seconds- 132 // Sending a stats update every 3 seconds-
117 private int statsUpdatesEveryMS = 3000; 133 private int statsUpdatesEveryMS = 3000;
118 private float statsUpdateFactor = 0; 134 private float statsUpdateFactor = 0;
@@ -387,7 +403,20 @@ namespace OpenSim.Region.Framework.Scenes
387 } 403 }
388 404
389 // Extra statistics that aren't currently sent to clients 405 // Extra statistics that aren't currently sent to clients
390 LastReportedObjectUpdates = m_objectUpdates / statsUpdateFactor; 406 lock (m_lastReportedExtraSimStats)
407 {
408 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / statsUpdateFactor;
409
410 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
411
412 if (physicsStats != null)
413 {
414 foreach (KeyValuePair<string, float> tuple in physicsStats)
415 {
416 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / statsUpdateFactor;
417 }
418 }
419 }
391 420
392 resetvalues(); 421 resetvalues();
393 } 422 }
@@ -546,7 +575,10 @@ namespace OpenSim.Region.Framework.Scenes
546 public void AddPendingDownloads(int count) 575 public void AddPendingDownloads(int count)
547 { 576 {
548 m_pendingDownloads += count; 577 m_pendingDownloads += count;
549 if (m_pendingDownloads < 0) m_pendingDownloads = 0; 578
579 if (m_pendingDownloads < 0)
580 m_pendingDownloads = 0;
581
550 //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads); 582 //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads);
551 } 583 }
552 584
@@ -568,5 +600,11 @@ namespace OpenSim.Region.Framework.Scenes
568 } 600 }
569 601
570 #endregion 602 #endregion
603
604 public Dictionary<string, float> GetExtraSimStats()
605 {
606 lock (m_lastReportedExtraSimStats)
607 return new Dictionary<string, float>(m_lastReportedExtraSimStats);
608 }
571 } 609 }
572} 610}