From 47e7febebcbd12d534b0ba248cb4bfc7da4c9d43 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 21 Mar 2014 02:06:10 +0000 Subject: Add monitored thread last update times as stats in "show stats all" These have the format server.thread. --- OpenSim/Framework/Monitoring/Watchdog.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index 45762a6..427ed7b 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs @@ -82,12 +82,32 @@ namespace OpenSim.Framework.Monitoring /// public Func AlarmMethod { get; set; } + /// + /// Stat structure associated with this thread. + /// + public Stat Stat { get; set; } + public ThreadWatchdogInfo(Thread thread, int timeout) { Thread = thread; Timeout = timeout; FirstTick = Environment.TickCount & Int32.MaxValue; LastTick = FirstTick; + + Stat + = new Stat( + thread.Name, + string.Format("Last update of thread {0}", thread.Name), + "", + "ms", + "server", + "thread", + StatType.Pull, + MeasuresOfInterest.None, + stat => stat.Value = Environment.TickCount & Int32.MaxValue - LastTick, + StatVerbosity.Debug); + + StatsManager.RegisterStat(Stat); } public ThreadWatchdogInfo(ThreadWatchdogInfo previousTwi) @@ -100,6 +120,11 @@ namespace OpenSim.Framework.Monitoring AlarmIfTimeout = previousTwi.AlarmIfTimeout; AlarmMethod = previousTwi.AlarmMethod; } + + public void Cleanup() + { + StatsManager.DeregisterStat(Stat); + } } /// @@ -238,6 +263,7 @@ namespace OpenSim.Framework.Monitoring m_log.DebugFormat( "[WATCHDOG]: Removing thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId); + twi.Cleanup(); m_threads.Remove(threadID); return true; -- cgit v1.1