Add monitored thread last update times as stats in "show stats all"

These have the format server.thread.<thread-name>
0.8.0.3
Justin Clark-Casey (justincc) 2014-03-21 02:06:10 +00:00
parent 33ae733006
commit 47e7febebc
1 changed files with 26 additions and 0 deletions

View File

@ -82,12 +82,32 @@ namespace OpenSim.Framework.Monitoring
/// </summary>
public Func<string> AlarmMethod { get; set; }
/// <summary>
/// Stat structure associated with this thread.
/// </summary>
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);
}
}
/// <summary>
@ -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;