aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Framework/Monitoring/Alerts/DeadlockAlert.cs37
-rw-r--r--OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs25
-rw-r--r--OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs34
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs3
4 files changed, 98 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Alerts/DeadlockAlert.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Alerts/DeadlockAlert.cs
new file mode 100644
index 0000000..b546ccb
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Alerts/DeadlockAlert.cs
@@ -0,0 +1,37 @@
1using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors;
2
3namespace OpenSim.Region.CoreModules.Framework.Monitoring.Alerts
4{
5 class DeadlockAlert : IAlert
6 {
7 private LastFrameTimeMonitor m_monitor;
8
9 public DeadlockAlert(LastFrameTimeMonitor m_monitor)
10 {
11 this.m_monitor = m_monitor;
12 }
13
14 #region Implementation of IAlert
15
16 public string GetName()
17 {
18 return "Potential Deadlock Alert";
19 }
20
21 public void Test()
22 {
23 if (m_monitor.GetValue() > 60 * 1000)
24 {
25 if(OnTriggerAlert != null)
26 {
27 OnTriggerAlert(typeof (DeadlockAlert),
28 (int) (m_monitor.GetValue()/1000) + " second(s) since last frame processed.", true);
29 }
30 }
31 }
32
33 public event Alert OnTriggerAlert;
34
35 #endregion
36 }
37}
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs
index d4a7692..769af8d 100644
--- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs
@@ -2,6 +2,7 @@
2using System.Reflection; 2using System.Reflection;
3using log4net; 3using log4net;
4using Nini.Config; 4using Nini.Config;
5using OpenSim.Region.CoreModules.Framework.Monitoring.Alerts;
5using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors; 6using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors;
6using OpenSim.Region.Framework.Interfaces; 7using OpenSim.Region.Framework.Interfaces;
7using OpenSim.Region.Framework.Scenes; 8using OpenSim.Region.Framework.Scenes;
@@ -12,13 +13,22 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring
12 { 13 {
13 private Scene m_scene; 14 private Scene m_scene;
14 private readonly List<IMonitor> m_monitors = new List<IMonitor>(); 15 private readonly List<IMonitor> m_monitors = new List<IMonitor>();
16 private readonly List<IAlert> m_alerts = new List<IAlert>();
15 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 17 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
16 18
17 public void DebugMonitors(string module, string[] args) 19 public void DebugMonitors(string module, string[] args)
18 { 20 {
19 foreach (IMonitor monitor in m_monitors) 21 foreach (IMonitor monitor in m_monitors)
20 { 22 {
21 m_log.Info("[MonitorModule] " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetName() + " = " + monitor.GetValue()); 23 m_log.Info("[MonitorModule] " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetName() + " = " + monitor.GetFriendlyValue());
24 }
25 }
26
27 public void TestAlerts()
28 {
29 foreach (IAlert alert in m_alerts)
30 {
31 alert.Test();
22 } 32 }
23 } 33 }
24 34
@@ -48,6 +58,19 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring
48 m_monitors.Add(new TotalFrameMonitor(m_scene)); 58 m_monitors.Add(new TotalFrameMonitor(m_scene));
49 m_monitors.Add(new EventFrameMonitor(m_scene)); 59 m_monitors.Add(new EventFrameMonitor(m_scene));
50 m_monitors.Add(new LandFrameMonitor(m_scene)); 60 m_monitors.Add(new LandFrameMonitor(m_scene));
61 m_monitors.Add(new LastFrameTimeMonitor(m_scene));
62
63 m_alerts.Add(new DeadlockAlert(m_monitors.Find(x => x is LastFrameTimeMonitor) as LastFrameTimeMonitor));
64
65 foreach (IAlert alert in m_alerts)
66 {
67 alert.OnTriggerAlert += OnTriggerAlert;
68 }
69 }
70
71 void OnTriggerAlert(System.Type reporter, string reason, bool fatal)
72 {
73 m_log.Error("[Monitor] " + reporter.Name + " for " + m_scene.RegionInfo.RegionName + " reports " + reason + " (Fatal: " + fatal + ")");
51 } 74 }
52 75
53 public void Close() 76 public void Close()
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs
new file mode 100644
index 0000000..36363f8
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs
@@ -0,0 +1,34 @@
1using System;
2using OpenSim.Region.Framework.Scenes;
3
4namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
5{
6 class LastFrameTimeMonitor : IMonitor
7 {
8 private readonly Scene m_scene;
9
10 public LastFrameTimeMonitor(Scene scene)
11 {
12 m_scene = scene;
13 }
14
15 #region Implementation of IMonitor
16
17 public double GetValue()
18 {
19 return Environment.TickCount - m_scene.MonitorLastFrameTick;
20 }
21
22 public string GetName()
23 {
24 return "Last Completed Frame At";
25 }
26
27 public string GetFriendlyValue()
28 {
29 return (int)GetValue() + "ms ago";
30 }
31
32 #endregion
33 }
34}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 07fdc9f..1e7803f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -279,6 +279,7 @@ namespace OpenSim.Region.Framework.Scenes
279 private int backupMS; 279 private int backupMS;
280 private int terrainMS; 280 private int terrainMS;
281 private int landMS; 281 private int landMS;
282 private int lastCompletedFrame;
282 283
283 public int MonitorFrameTime { get { return frameMS; } } 284 public int MonitorFrameTime { get { return frameMS; } }
284 public int MonitorPhysicsUpdateTime { get { return physicsMS; } } 285 public int MonitorPhysicsUpdateTime { get { return physicsMS; } }
@@ -289,6 +290,7 @@ namespace OpenSim.Region.Framework.Scenes
289 public int MonitorBackupTime { get { return backupMS; } } 290 public int MonitorBackupTime { get { return backupMS; } }
290 public int MonitorTerrainTime { get { return terrainMS; } } 291 public int MonitorTerrainTime { get { return terrainMS; } }
291 public int MonitorLandTime { get { return landMS; } } 292 public int MonitorLandTime { get { return landMS; } }
293 public int MonitorLastFrameTick { get { return lastCompletedFrame; } }
292 294
293 private bool m_physics_enabled = true; 295 private bool m_physics_enabled = true;
294 private bool m_scripts_enabled = true; 296 private bool m_scripts_enabled = true;
@@ -1129,6 +1131,7 @@ namespace OpenSim.Region.Framework.Scenes
1129 otherMS = tickCount - otherMS; 1131 otherMS = tickCount - otherMS;
1130 tmpFrameMS -= tickCount; 1132 tmpFrameMS -= tickCount;
1131 frameMS = tmpFrameMS; 1133 frameMS = tmpFrameMS;
1134 lastCompletedFrame = tickCount;
1132 1135
1133 // if (m_frame%m_update_avatars == 0) 1136 // if (m_frame%m_update_avatars == 0)
1134 // UpdateInWorldTime(); 1137 // UpdateInWorldTime();