From 2bee150aac6d4996140ddf1f9bd09ba444901033 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 28 Nov 2010 20:45:03 +0100 Subject: Implement health monitoring of the packet receiving and sending threads --- OpenSim/Region/Framework/Scenes/Scene.cs | 39 +++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 216eb51..83887b4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -174,6 +174,8 @@ namespace OpenSim.Region.Framework.Scenes private volatile bool shuttingdown; private int m_lastUpdate; + private int m_lastIncoming; + private int m_lastOutgoing; private bool m_firstHeartbeat = true; private object m_deleting_scene_object = new object(); @@ -567,6 +569,8 @@ namespace OpenSim.Region.Framework.Scenes m_regionName = m_regInfo.RegionName; m_datastore = m_regInfo.DataStore; m_lastUpdate = Util.EnvironmentTickCount(); + m_lastIncoming = Util.EnvironmentTickCount(); + m_lastOutgoing = Util.EnvironmentTickCount(); m_physicalPrim = physicalPrim; m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; @@ -4543,11 +4547,17 @@ namespace OpenSim.Region.Framework.Scenes // 1 = sim is up and accepting http requests. The heartbeat has // stopped and the sim is probably locked up, but a remote // admin restart may succeed - // + // // 2 = Sim is up and the heartbeat is running. The sim is likely - // usable for people within and logins _may_ work + // usable for people within + // + // 3 = Sim is up and one packet thread is running. Sim is + // unstable and will not accept new logins + // + // 4 = Sim is up and both packet threads are running. Sim is + // likely usable // - // 3 = We have seen a new user enter within the past 4 minutes + // 5 = We have seen a new user enter within the past 4 minutes // which can be seen as positive confirmation of sim health // int health=1; // Start at 1, means we're up @@ -4557,6 +4567,16 @@ namespace OpenSim.Region.Framework.Scenes else return health; + if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastIncoming)) < 1000)) + health+=1; + else + return health; + + if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastOutgoing)) < 1000)) + health+=1; + else + return health; + // A login in the last 4 mins? We can't be doing too badly // if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) @@ -5106,5 +5126,18 @@ namespace OpenSim.Region.Framework.Scenes m_log.Debug("[SCENE]: Finished dropped attachment deletion"); } } + + public void ThreadAlive(int threadCode) + { + switch(threadCode) + { + case 1: // Incoming + m_lastIncoming = Util.EnvironmentTickCount(); + break; + case 2: // Incoming + m_lastOutgoing = Util.EnvironmentTickCount(); + break; + } + } } } -- cgit v1.1