Add 'server' stats information to pCampbot, as used elsewhere in OpenSimulator

This adds the "show stats", "stats record", etc. commands and information on available Threadpool threads, etc.
It also adds the Watchdog which logs warnings if time between executions is unexpectedly large.
bullet-2.82
Justin Clark-Casey (justincc) 2014-08-13 19:53:42 +01:00
parent f1cec684e2
commit f1f935ed95
5 changed files with 47 additions and 0 deletions

View File

@ -82,6 +82,9 @@ namespace OpenSim.Framework.Monitoring
// IRegionModuleBase.Initialize
public void Initialise(IConfigSource source)
{
if (source == null)
return;
IConfig cfg = source.Configs["Monitoring"];
if (cfg != null)

View File

@ -38,6 +38,7 @@ using log4net.Repository;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Monitoring;
using pCampBot.Interfaces;
namespace pCampBot
@ -142,6 +143,11 @@ namespace pCampBot
/// </summary>
private HashSet<string> m_defaultBehaviourSwitches = new HashSet<string>();
/// <summary>
/// Collects general information on this server (which reveals this to be a misnamed class).
/// </summary>
private ServerStatsCollector m_serverStatsCollector;
/// <summary>
/// Constructor Creates MainConsole.Instance to take commands and provide the place to write data
/// </summary>
@ -151,6 +157,12 @@ namespace pCampBot
// to multiple regions.
Settings.MAX_HTTP_CONNECTIONS = int.MaxValue;
// System.Threading.ThreadPool.SetMaxThreads(600, 240);
//
// int workerThreads, iocpThreads;
// System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
// Console.WriteLine("ThreadPool.GetMaxThreads {0} {1}", workerThreads, iocpThreads);
InitBotSendAgentUpdates = true;
InitBotRequestObjectTextures = true;
@ -234,6 +246,14 @@ namespace pCampBot
"Shows the detailed status and settings of a particular bot.", HandleShowBotStatus);
m_bots = new List<Bot>();
Watchdog.Enabled = true;
StatsManager.RegisterConsoleCommands(m_console);
m_serverStatsCollector = new ServerStatsCollector();
m_serverStatsCollector.Initialise(null);
m_serverStatsCollector.Enabled = true;
m_serverStatsCollector.Start();
}
/// <summary>
@ -697,6 +717,8 @@ namespace pCampBot
MainConsole.Instance.Output("Shutting down");
m_serverStatsCollector.Close();
Environment.Exit(0);
}

Binary file not shown.

View File

@ -10,6 +10,10 @@
</appSettings>
<log4net>
<appender name="Console" type="OpenSim.Framework.Console.OpenSimAppender, OpenSim.Framework.Console">
<filter type="log4net.Filter.LoggerMatchFilter">
<loggerToMatch value="special"/>
<acceptOnMatch value="false"/>
</filter>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{HH:mm:ss.fff} - %message" />
</layout>
@ -17,15 +21,32 @@
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file value="pCampBot.log" />
<appendToFile value="true" />
<filter type="log4net.Filter.LoggerMatchFilter">
<loggerToMatch value="special"/>
<acceptOnMatch value="false"/>
</filter>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level - %logger %message%newline" />
</layout>
</appender>
<appender name="StatsLogFileAppender" type="log4net.Appender.FileAppender">
<file value="pCampBotStats.log"/>
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="Console" />
<appender-ref ref="LogFileAppender" />
</root>
<!-- used for stats recording -->
<logger name="special.StatsLogger">
<appender-ref ref="StatsLogFileAppender"/>
</logger>
</log4net>
</configuration>

View File

@ -2531,6 +2531,7 @@
<Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Monitoring"/>
<Reference name="Nini" path="../../../bin/"/>
<Reference name="log4net" path="../../../bin/"/>