diff options
Diffstat (limited to 'OpenSim/Framework/Monitoring')
-rw-r--r-- | OpenSim/Framework/Monitoring/Watchdog.cs | 26 |
1 files changed, 26 insertions, 0 deletions
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 | |||
82 | /// </summary> | 82 | /// </summary> |
83 | public Func<string> AlarmMethod { get; set; } | 83 | public Func<string> AlarmMethod { get; set; } |
84 | 84 | ||
85 | /// <summary> | ||
86 | /// Stat structure associated with this thread. | ||
87 | /// </summary> | ||
88 | public Stat Stat { get; set; } | ||
89 | |||
85 | public ThreadWatchdogInfo(Thread thread, int timeout) | 90 | public ThreadWatchdogInfo(Thread thread, int timeout) |
86 | { | 91 | { |
87 | Thread = thread; | 92 | Thread = thread; |
88 | Timeout = timeout; | 93 | Timeout = timeout; |
89 | FirstTick = Environment.TickCount & Int32.MaxValue; | 94 | FirstTick = Environment.TickCount & Int32.MaxValue; |
90 | LastTick = FirstTick; | 95 | LastTick = FirstTick; |
96 | |||
97 | Stat | ||
98 | = new Stat( | ||
99 | thread.Name, | ||
100 | string.Format("Last update of thread {0}", thread.Name), | ||
101 | "", | ||
102 | "ms", | ||
103 | "server", | ||
104 | "thread", | ||
105 | StatType.Pull, | ||
106 | MeasuresOfInterest.None, | ||
107 | stat => stat.Value = Environment.TickCount & Int32.MaxValue - LastTick, | ||
108 | StatVerbosity.Debug); | ||
109 | |||
110 | StatsManager.RegisterStat(Stat); | ||
91 | } | 111 | } |
92 | 112 | ||
93 | public ThreadWatchdogInfo(ThreadWatchdogInfo previousTwi) | 113 | public ThreadWatchdogInfo(ThreadWatchdogInfo previousTwi) |
@@ -100,6 +120,11 @@ namespace OpenSim.Framework.Monitoring | |||
100 | AlarmIfTimeout = previousTwi.AlarmIfTimeout; | 120 | AlarmIfTimeout = previousTwi.AlarmIfTimeout; |
101 | AlarmMethod = previousTwi.AlarmMethod; | 121 | AlarmMethod = previousTwi.AlarmMethod; |
102 | } | 122 | } |
123 | |||
124 | public void Cleanup() | ||
125 | { | ||
126 | StatsManager.DeregisterStat(Stat); | ||
127 | } | ||
103 | } | 128 | } |
104 | 129 | ||
105 | /// <summary> | 130 | /// <summary> |
@@ -238,6 +263,7 @@ namespace OpenSim.Framework.Monitoring | |||
238 | m_log.DebugFormat( | 263 | m_log.DebugFormat( |
239 | "[WATCHDOG]: Removing thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId); | 264 | "[WATCHDOG]: Removing thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId); |
240 | 265 | ||
266 | twi.Cleanup(); | ||
241 | m_threads.Remove(threadID); | 267 | m_threads.Remove(threadID); |
242 | 268 | ||
243 | return true; | 269 | return true; |