From 8114f895c2973ac9e2e456ac2aaad8deb23f3852 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 10 Oct 2011 22:17:29 +0100 Subject: [PATCH] Provide a way to turn the MonitorModule on and off Default is currently on since this is the historical setting --- .../Framework/Monitoring/MonitorModule.cs | 52 +++++++++++++------ bin/OpenSimDefaults.ini | 5 ++ 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index 09095c2445..057ed6f20e 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs @@ -41,16 +41,48 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring { public class MonitorModule : IRegionModule { + /// + /// Is this module enabled? + /// + public bool Enabled { get; private set; } + private Scene m_scene; private readonly List m_monitors = new List(); private readonly List m_alerts = new List(); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + #region Implementation of IRegionModule + + public MonitorModule() + { + Enabled = true; + } + + public void Initialise(Scene scene, IConfigSource source) + { + IConfig cnfg = source.Configs["Monitoring"]; + + if (cnfg != null) + Enabled = cnfg.GetBoolean("Enabled", true); + + if (!Enabled) + return; + + m_scene = scene; + + m_scene.AddCommand(this, "monitor report", + "monitor report", + "Returns a variety of statistics about the current region and/or simulator", + DebugMonitors); + + MainServer.Instance.AddHTTPHandler("/monitorstats/" + m_scene.RegionInfo.RegionID, StatsPage); + } + 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.GetFriendlyValue()); + m_log.Info("[MonitorModule]: " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetName() + " = " + monitor.GetFriendlyValue()); } } @@ -62,20 +94,6 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring } } - #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); - - MainServer.Instance.AddHTTPHandler("/monitorstats/" + m_scene.RegionInfo.RegionID, StatsPage); - } - public Hashtable StatsPage(Hashtable request) { // If request was for a specific monitor @@ -133,6 +151,9 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring public void PostInitialise() { + if (!Enabled) + return; + m_monitors.Add(new AgentCountMonitor(m_scene)); m_monitors.Add(new ChildAgentCountMonitor(m_scene)); m_monitors.Add(new GCMemoryMonitor()); @@ -161,7 +182,6 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring public void Close() { - } public string Name diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 8660f4fdb6..9cedd980ec 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1417,6 +1417,11 @@ RootReprioritizationDistance = 10.0 ChildReprioritizationDistance = 20.0 +[Monitoring] + ; Enable region monitoring + ; If true, this will print out an error if more than a minute has passed since the last simulator frame + ; Also is another source of region statistics provided via the regionstats URL + Enabled = true ; View region statistics via a web page ; See http://opensimulator.org/wiki/FAQ#Region_Statistics_on_a_Web_Page