From 686f16cedda4daac1663f30b17e65bde7fc4af2b Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Tue, 10 Jun 2008 23:19:38 +0000
Subject: * If a server has statistics, print these out to the log every hour
to get some idea of how these evolve * When returning GC.GetTotalMemory(),
force collection first in order to get more accurate figures
---
OpenSim/Framework/Servers/BaseOpenSimServer.cs | 21 +++++++++++++++++++++
OpenSim/Framework/Statistics/BaseStatsCollector.cs | 2 +-
2 files changed, 22 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 0ee21ac..852e1b1 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -28,6 +28,7 @@
using System;
using System.IO;
using System.Reflection;
+using System.Timers;
using log4net;
using OpenSim.Framework.Console;
using OpenSim.Framework.Statistics;
@@ -41,6 +42,12 @@ namespace OpenSim.Framework.Servers
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ ///
+ /// This will control a periodic log printout of the current 'show stats' (if they are active) for this
+ /// server.
+ ///
+ private Timer m_periodicLogStatsTimer = new Timer(60 * 60 * 1000);
+
protected ConsoleBase m_console;
///
@@ -68,6 +75,20 @@ namespace OpenSim.Framework.Servers
{
m_startuptime = DateTime.Now;
m_version = VersionInfo.Version;
+
+ m_periodicLogStatsTimer.Elapsed += new ElapsedEventHandler(LogStats);
+ m_periodicLogStatsTimer.Enabled = true;
+ }
+
+ ///
+ /// Print statistics to the logfile, if they are active
+ ///
+ protected void LogStats(object source, ElapsedEventArgs e)
+ {
+ if (m_stats != null)
+ {
+ m_log.Info(m_stats.Report());
+ }
}
///
diff --git a/OpenSim/Framework/Statistics/BaseStatsCollector.cs b/OpenSim/Framework/Statistics/BaseStatsCollector.cs
index c888f4c..225c551 100644
--- a/OpenSim/Framework/Statistics/BaseStatsCollector.cs
+++ b/OpenSim/Framework/Statistics/BaseStatsCollector.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Framework.Statistics
sb.Append(
string.Format(
"Allocated to OpenSim : {0} MB" + Environment.NewLine,
- Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)));
+ Math.Round(GC.GetTotalMemory(true) / 1024.0 / 1024.0)));
return sb.ToString();
}
--
cgit v1.1