mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 18:25:33 +08:00
* Implements new 'Monitoring' system for reporting performance.
* Mostly the same set as the StatsMonitor used for Viewer notification, but exposes some new frametimes - including EventMS, PhysicsUpdateMS, LandUpdateMS; new memory monitoring - both GC.TotalMemory and Process.PrivateWorkingMemory64; also exposes ThreadCount (using System.Diagnostics.Process) * Type 'monitor report' on the console to see output. * SNMP Implementation forthcoming.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring
|
||||
{
|
||||
interface IMonitor
|
||||
{
|
||||
double GetValue();
|
||||
string GetName();
|
||||
string GetFriendlyValue(); // Convert to readable numbers
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring
|
||||
{
|
||||
public class MonitorModule : IRegionModule
|
||||
{
|
||||
private Scene m_scene;
|
||||
private readonly List<IMonitor> m_monitors = new List<IMonitor>();
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public void DebugMonitors(string module, string[] args)
|
||||
{
|
||||
foreach (IMonitor monitor in m_monitors)
|
||||
{
|
||||
m_log.Info("[MonitorModule] " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetName() + " = " + monitor.GetValue());
|
||||
}
|
||||
}
|
||||
|
||||
#region Implementation of IRegionModule
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource source)
|
||||
{
|
||||
m_scene = scene;
|
||||
|
||||
|
||||
m_scene.AddCommand(this, "monitor report",
|
||||
"monitor report",
|
||||
"Returns a variety of statistics about the current region and/or simulator",
|
||||
DebugMonitors);
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
m_monitors.Add(new AgentCountMonitor(m_scene));
|
||||
m_monitors.Add(new ChildAgentCountMonitor(m_scene));
|
||||
m_monitors.Add(new GCMemoryMonitor());
|
||||
m_monitors.Add(new ObjectCountMonitor(m_scene));
|
||||
m_monitors.Add(new PhysicsFrameMonitor(m_scene));
|
||||
m_monitors.Add(new PhysicsUpdateFrameMonitor(m_scene));
|
||||
m_monitors.Add(new PWSMemoryMonitor());
|
||||
m_monitors.Add(new ThreadCountMonitor());
|
||||
m_monitors.Add(new TotalFrameMonitor(m_scene));
|
||||
m_monitors.Add(new EventFrameMonitor(m_scene));
|
||||
m_monitors.Add(new LandFrameMonitor(m_scene));
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "Region Health Monitoring Module"; }
|
||||
}
|
||||
|
||||
public bool IsSharedModule
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class AgentCountMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public AgentCountMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.SceneGraph.GetRootAgentCount();
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Root Agent Count";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + " agent(s)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class ChildAgentCountMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public ChildAgentCountMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.SceneGraph.GetChildAgentCount();
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Child Agent Count";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + " child agent(s)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class EventFrameMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public EventFrameMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.MonitorEventTime;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Total Event Frame Time";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + "ms";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class GCMemoryMonitor : IMonitor
|
||||
{
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return GC.GetTotalMemory(false);
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "GC Reported Memory";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)(GetValue() / (1024*1024)) + "MB (Global)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class LandFrameMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public LandFrameMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.MonitorLandTime;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Land Frame Time";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + "ms";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class ObjectCountMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public ObjectCountMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.SceneGraph.GetTotalObjectsCount();
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Total Objects Count";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + " Object(s)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class PWSMemoryMonitor : IMonitor
|
||||
{
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Private Working Set Memory";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)(GetValue() / (1024 * 1024)) + "MB (Global)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class PhysicsFrameMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public PhysicsFrameMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.MonitorPhysicsSyncTime + m_scene.MonitorPhysicsUpdateTime;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Total Physics Frame Time";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + "ms";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class PhysicsUpdateFrameMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public PhysicsUpdateFrameMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.MonitorPhysicsUpdateTime;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Physics Update Frame Time";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + "ms";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class ThreadCountMonitor : IMonitor
|
||||
{
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return System.Diagnostics.Process.GetCurrentProcess().Threads.Count;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Total Threads";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + " Thread(s) (Global)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class TotalFrameMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public TotalFrameMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.MonitorFrameTime;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Total Frame Time";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + "ms";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user