From 62aad4c18f1ebc0780ce47cf179f3d5550ff0837 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 10 Oct 2011 23:48:53 +0100 Subject: Add other region stats (total frame time, physics fps, etc.) currently missing from MonitorModule Unlike the other 3 stats mechanisms, monitor data can be queried per individual region, which makes this useful. This doesn't affect an of the existing monitored stats. --- .../CoreModules/Framework/Monitoring/IMonitor.cs | 27 +++- .../Framework/Monitoring/MonitorModule.cs | 154 ++++++++++++++++++++- .../Monitoring/Monitors/AgentCountMonitor.cs | 7 +- .../Monitoring/Monitors/ChildAgentCountMonitor.cs | 7 +- .../Monitoring/Monitors/EventFrameMonitor.cs | 7 +- .../Monitoring/Monitors/GCMemoryMonitor.cs | 7 +- .../Monitoring/Monitors/GenericMonitor.cs | 80 +++++++++++ .../Monitoring/Monitors/LandFrameMonitor.cs | 7 +- .../Monitoring/Monitors/LastFrameTimeMonitor.cs | 7 +- .../Monitoring/Monitors/ObjectCountMonitor.cs | 7 +- .../Monitoring/Monitors/PWSMemoryMonitor.cs | 7 +- .../Monitoring/Monitors/PhysicsFrameMonitor.cs | 7 +- .../Monitors/PhysicsUpdateFrameMonitor.cs | 7 +- .../Monitoring/Monitors/ThreadCountMonitor.cs | 7 +- .../Monitoring/Monitors/TotalFrameMonitor.cs | 7 +- .../Region/Framework/Scenes/SimStatsReporter.cs | 2 +- 16 files changed, 326 insertions(+), 21 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GenericMonitor.cs diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/IMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/IMonitor.cs index 9f618cc..72c7a4a 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/IMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/IMonitor.cs @@ -29,8 +29,31 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring { interface IMonitor { - double GetValue(); + /// + /// Name of the monitor. + /// + /// + /// This is the name used in XML. + /// + /// string GetName(); - string GetFriendlyValue(); // Convert to readable numbers + + /// + /// Value of this monitor + /// + /// + double GetValue(); + + /// + /// Human-readable name of the monitor + /// + /// + string GetFriendlyName(); + + /// + /// Human readable value. + /// + /// + string GetFriendlyValue(); } } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index 057ed6f..a9dc1fe 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs @@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring { foreach (IMonitor monitor in m_monitors) { - m_log.Info("[MonitorModule]: " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetName() + " = " + monitor.GetFriendlyValue()); + m_log.Info("[MonitorModule]: " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetFriendlyName() + " = " + monitor.GetFriendlyValue()); } } @@ -132,11 +132,9 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring string xml = ""; foreach (IMonitor monitor in m_monitors) { - string elemName = monitor.ToString(); - if (elemName.StartsWith(monitor.GetType().Namespace)) - elemName = elemName.Substring(monitor.GetType().Namespace.Length + 1); - - xml += "<" + elemName + ">" + monitor.GetValue() + ""; + string elemName = monitor.GetName(); + xml += "<" + elemName + ">" + monitor.GetValue().ToString() + ""; +// m_log.DebugFormat("[MONITOR MODULE]: {0} = {1}", elemName, monitor.GetValue()); } xml += ""; @@ -166,6 +164,150 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring m_monitors.Add(new EventFrameMonitor(m_scene)); m_monitors.Add(new LandFrameMonitor(m_scene)); m_monitors.Add(new LastFrameTimeMonitor(m_scene)); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "TimeDilationMonitor", + "Time Dilation", + m => m.Scene.StatsReporter.LastReportedSimStats[0], + m => m.GetValue().ToString())); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "SimFPSMonitor", + "Sim FPS", + m => m.Scene.StatsReporter.LastReportedSimStats[1], + m => string.Format("{0}", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "PhysicsFPSMonitor", + "Physics FPS", + m => m.Scene.StatsReporter.LastReportedSimStats[2], + m => string.Format("{0}", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "AgentUpdatesPerSecondMonitor", + "Agent Updates", + m => m.Scene.StatsReporter.LastReportedSimStats[3], + m => string.Format("{0} per second", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "ActiveObjectCountMonitor", + "Active Objects", + m => m.Scene.StatsReporter.LastReportedSimStats[7], + m => string.Format("{0}", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "ActiveScriptsMonitor", + "Active Scripts", + m => m.Scene.StatsReporter.LastReportedSimStats[19], + m => string.Format("{0}", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "ScriptEventsPerSecondMonitor", + "Script Events", + m => m.Scene.StatsReporter.LastReportedSimStats[20], + m => string.Format("{0} per second", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "InPacketsPerSecondMonitor", + "In Packets", + m => m.Scene.StatsReporter.LastReportedSimStats[13], + m => string.Format("{0} per second", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "OutPacketsPerSecondMonitor", + "Out Packets", + m => m.Scene.StatsReporter.LastReportedSimStats[14], + m => string.Format("{0} per second", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "UnackedBytesMonitor", + "Unacked Bytes", + m => m.Scene.StatsReporter.LastReportedSimStats[15], + m => string.Format("{0}", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "PendingDownloadsMonitor", + "Pending Downloads", + m => m.Scene.StatsReporter.LastReportedSimStats[17], + m => string.Format("{0}", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "PendingUploadsMonitor", + "Pending Uploads", + m => m.Scene.StatsReporter.LastReportedSimStats[18], + m => string.Format("{0}", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "TotalFrameTimeMonitor", + "Total Frame Time", + m => m.Scene.StatsReporter.LastReportedSimStats[8], + m => string.Format("{0} ms", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "NetFrameTimeMonitor", + "Net Frame Time", + m => m.Scene.StatsReporter.LastReportedSimStats[9], + m => string.Format("{0} ms", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "PhysicsFrameTimeMonitor", + "Physics Frame Time", + m => m.Scene.StatsReporter.LastReportedSimStats[10], + m => string.Format("{0} ms", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "SimulationFrameTimeMonitor", + "Simulation Frame Time", + m => m.Scene.StatsReporter.LastReportedSimStats[12], + m => string.Format("{0} ms", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "AgentFrameTimeMonitor", + "Agent Frame Time", + m => m.Scene.StatsReporter.LastReportedSimStats[16], + m => string.Format("{0} ms", m.GetValue()))); + + m_monitors.Add( + new GenericMonitor( + m_scene, + "ImagesFrameTimeMonitor", + "Images Frame Time", + m => m.Scene.StatsReporter.LastReportedSimStats[11], + m => string.Format("{0} ms", m.GetValue()))); m_alerts.Add(new DeadlockAlert(m_monitors.Find(x => x is LastFrameTimeMonitor) as LastFrameTimeMonitor)); diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/AgentCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/AgentCountMonitor.cs index 4a2029e..3fb5e3a 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/AgentCountMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/AgentCountMonitor.cs @@ -40,12 +40,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors #region Implementation of IMonitor + public string GetName() + { + return "AgentCountMonitor"; + } + public double GetValue() { return m_scene.SceneGraph.GetRootAgentCount(); } - public string GetName() + public string GetFriendlyName() { return "Root Agent Count"; } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ChildAgentCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ChildAgentCountMonitor.cs index 4ab3edd..be0e8fb 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ChildAgentCountMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ChildAgentCountMonitor.cs @@ -40,12 +40,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors #region Implementation of IMonitor + public string GetName() + { + return "ChildAgentCountMonitor"; + } + public double GetValue() { return m_scene.SceneGraph.GetChildAgentCount(); } - public string GetName() + public string GetFriendlyName() { return "Child Agent Count"; } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/EventFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/EventFrameMonitor.cs index 356458d..1c44c78 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/EventFrameMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/EventFrameMonitor.cs @@ -40,12 +40,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors #region Implementation of IMonitor + public string GetName() + { + return "EventFrameMonitor"; + } + public double GetValue() { return m_scene.MonitorEventTime; } - public string GetName() + public string GetFriendlyName() { return "Total Event Frame Time"; } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GCMemoryMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GCMemoryMonitor.cs index aa2e9c0..3f4d4a2 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GCMemoryMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GCMemoryMonitor.cs @@ -33,12 +33,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors { #region Implementation of IMonitor + public string GetName() + { + return "GCMemoryMonitor"; + } + public double GetValue() { return GC.GetTotalMemory(false); } - public string GetName() + public string GetFriendlyName() { return "GC Reported Memory"; } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GenericMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GenericMonitor.cs new file mode 100644 index 0000000..551c49c --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GenericMonitor.cs @@ -0,0 +1,80 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class GenericMonitor : IMonitor + { + public Scene Scene { get; private set; } + public string Name { get; private set; } + public string FriendlyName { get; private set; } + + private readonly Func m_getValueAction; + private readonly Func m_getFriendlyValueAction; + + public GenericMonitor( + Scene scene, + string name, + string friendlyName, + Func getValueAction, + Func getFriendlyValueAction) + { + Scene = scene; + Name = name; + FriendlyName = name; + m_getFriendlyValueAction = getFriendlyValueAction; + m_getValueAction = getValueAction; + } + + public double GetValue() + { + return m_getValueAction(this); + } + + public string GetName() + { + return Name; + } + + public string GetFriendlyName() + { + return FriendlyName; + } + + public string GetFriendlyValue() + { + return m_getFriendlyValueAction(this); + } + } +} + + + + diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LandFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LandFrameMonitor.cs index e1c36de..262735e 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LandFrameMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LandFrameMonitor.cs @@ -40,12 +40,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors #region Implementation of IMonitor + public string GetName() + { + return "LandFrameMonitor"; + } + public double GetValue() { return m_scene.MonitorLandTime; } - public string GetName() + public string GetFriendlyName() { return "Land Frame Time"; } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs index f21a3ae..3acb4ad 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs @@ -41,12 +41,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors #region Implementation of IMonitor + public string GetName() + { + return "LastFrameTimeMonitor"; + } + public double GetValue() { return Environment.TickCount - m_scene.MonitorLastFrameTick; } - public string GetName() + public string GetFriendlyName() { return "Last Completed Frame At"; } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ObjectCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ObjectCountMonitor.cs index 10804f9..52a2df1 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ObjectCountMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ObjectCountMonitor.cs @@ -40,12 +40,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors #region Implementation of IMonitor + public string GetName() + { + return "ObjectCountMonitor"; + } + public double GetValue() { return m_scene.SceneGraph.GetTotalObjectsCount(); } - public string GetName() + public string GetFriendlyName() { return "Total Objects Count"; } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PWSMemoryMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PWSMemoryMonitor.cs index 5f6190c..07c13d1 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PWSMemoryMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PWSMemoryMonitor.cs @@ -33,12 +33,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors { #region Implementation of IMonitor + public string GetName() + { + return "PWSMemoryMonitor"; + } + public double GetValue() { return System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64; } - public string GetName() + public string GetFriendlyName() { return "Private Working Set Memory"; } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsFrameMonitor.cs index 7c5bb0a..b10fa75 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsFrameMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsFrameMonitor.cs @@ -40,12 +40,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors #region Implementation of IMonitor + public string GetName() + { + return "PhysicsFrameMonitor"; + } + public double GetValue() { return m_scene.MonitorPhysicsSyncTime + m_scene.MonitorPhysicsUpdateTime; } - public string GetName() + public string GetFriendlyName() { return "Total Physics Frame Time"; } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsUpdateFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsUpdateFrameMonitor.cs index 1894b3b..a85d8cc 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsUpdateFrameMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsUpdateFrameMonitor.cs @@ -40,12 +40,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors #region Implementation of IMonitor + public string GetName() + { + return "PhysicsUpdateFrameMonitor"; + } + public double GetValue() { return m_scene.MonitorPhysicsUpdateTime; } - public string GetName() + public string GetFriendlyName() { return "Physics Update Frame Time"; } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ThreadCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ThreadCountMonitor.cs index 63ddf07..fcfe32a 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ThreadCountMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ThreadCountMonitor.cs @@ -32,12 +32,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors { #region Implementation of IMonitor + public string GetName() + { + return "ThreadCountMonitor"; + } + public double GetValue() { return System.Diagnostics.Process.GetCurrentProcess().Threads.Count; } - public string GetName() + public string GetFriendlyName() { return "Total Threads"; } diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/TotalFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/TotalFrameMonitor.cs index c3942bf..a46795d 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/TotalFrameMonitor.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/TotalFrameMonitor.cs @@ -40,12 +40,17 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors #region Implementation of IMonitor + public string GetName() + { + return "TotalFrameMonitor"; + } + public double GetValue() { return m_scene.MonitorFrameTime; } - public string GetName() + public string GetFriendlyName() { return "Total Frame Time"; } diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index b9d38d0..8e1c8f0 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -52,7 +52,7 @@ namespace OpenSim.Region.Framework.Scenes private YourStatsAreWrong handlerStatsIncorrect = null; - private enum Stats : uint + public enum Stats : uint { TimeDilation = 0, SimFPS = 1, -- cgit v1.1