Sync statistics to a file

dsg
Robert Adams 2011-03-10 14:04:10 -08:00
parent d514c31cc2
commit cc2a679121
5 changed files with 76 additions and 39 deletions

View File

@ -64,10 +64,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
// The client connection to the RegionSyncServer
private TcpClient m_client = new TcpClient();
//KittyL: Comment out m_statsTimer for now, will figure out whether we need it for PhysEngine later
//private System.Timers.Timer m_statsTimer = new System.Timers.Timer(30000);
// The queue of incoming messages which need handling
//private Queue<string> m_inQ = new Queue<string>();
@ -105,11 +101,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_addrString = addr;
m_port = port;
m_debugWithViewer = debugWithViewer;
//m_statsTimer.Elapsed += new System.Timers.ElapsedEventHandler(StatsTimerElapsed);
m_sysConfig = sysConfig;
SceneToPhysEngineSyncServer.logEnabled = m_sysConfig.GetBoolean("LogEnabled", false);
SceneToPhysEngineSyncServer.logDir = m_sysConfig.GetString("LogDir", ".");
SceneToPhysEngineSyncServer.logEnabled = m_sysConfig.GetBoolean("PhysLogEnabled", false);
SceneToPhysEngineSyncServer.logDir = m_sysConfig.GetString("PhysLogDir", ".");
//assume we are connecting to the whole scene as one big quark
m_subscribedQuarks = new QuarkSubsriptionInfo(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize);
@ -534,5 +529,29 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
#endregion Handlers for events/updates from Scene
public string StatisticIdentifier()
{
return "PhysEngineToSceneConnector";
}
public string StatisticLine(bool clearFlag)
{
string ret = "";
/*
lock (stats)
{
ret = String.Format("{0},{1},{2},{3},{4},{5}",
msgsIn, msgsOut, bytesIn, bytesOut
);
if (clearFlag)
msgsIn = msgsOut = bytesIn = bytesOut = 0;
}
*/
return ret;
}
public string StatisticTitle()
{
return "msgsIn,msgsOut,bytesIn,bytesOut";
}
}
}

View File

@ -27,7 +27,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
// The SceneToPhysEngineConnector acts as a thread on the RegionSyncServer to handle incoming
// messages from PhysEngineToSceneConnectors that run on Physics Engines. It connects the
// authoratative Scene with remote script engines.
public class SceneToPhysEngineConnector
public class SceneToPhysEngineConnector : ISyncStatistics
{
#region SceneToPhysEngineConnector members
@ -38,9 +38,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private long bytesIn;
private long bytesOut;
private long pollBlocks;
private int lastTotalCount;
private int lastLocalCount;
private int lastRemoteCount;
private int msgCount = 0;
@ -49,7 +46,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
// Set the addr and port for TcpListener
private IPAddress m_addr;
private Int32 m_port;
private int m_connection_number;
private static int m_connection_number = 0;
private Scene m_scene;
object m_syncRoot = new object();
@ -93,32 +90,33 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
get { return m_connection_number; }
}
public string GetStats()
public string StatisticIdentifier()
{
string ret;
//lock (m_syncRoot)
// syncedAvCount = m_syncedAvatars.Count;
return "SceneToPhysEngineConnector" + ConnectionNum.ToString();
}
public string StatisticLine(bool clearFlag)
{
string ret = "";
lock (stats)
{
double secondsSinceLastStats = DateTime.Now.Subtract(lastStatTime).TotalSeconds;
lastStatTime = DateTime.Now;
// ret = String.Format("[{0,4}/{1,4}], [{2,4}/{3,4}], [{4,4}/{5,4}], [{6,4} ({7,4})], [{8,8} ({9,8:00.00})], [{10,4} ({11,4})], [{12,8} ({13,8:00.00})], [{14,8} ({15,4}]",
ret = String.Format("[{0,4}/{1,4}], [{2,6}/{3,6}], [{4,4}/{5,4}], [{6,6} ({7,6})], [{8,4} ({9,4})]",
//lastTotalCount, totalAvCount, // TOTAL AVATARS
//lastLocalCount, syncedAvCount, // LOCAL TO THIS CLIENT VIEW
//lastRemoteCount, totalAvCount - syncedAvCount, // REMOTE (SHOULD = TOTAL - LOCAL)
msgsIn, (int)(msgsIn / secondsSinceLastStats),
bytesIn, 8 * (bytesIn / secondsSinceLastStats / 1000000), // IN
msgsOut, (int)(msgsOut / secondsSinceLastStats),
bytesOut, 8 * (bytesOut / secondsSinceLastStats / 1000000), // OUT
pollBlocks, (int)(pollBlocks / secondsSinceLastStats)); // NUMBER OF TIMES WE BLOCKED WRITING TO SOCKET
msgsIn = msgsOut = bytesIn = bytesOut = pollBlocks = 0;
ret = String.Format("{0},{1},{2},{3},{4}",
msgsIn, msgsOut, bytesIn, bytesOut, pollBlocks
);
if (clearFlag)
msgsIn = msgsOut = bytesIn = bytesOut = pollBlocks = 0;
}
return ret;
}
public string StatisticTitle()
{
return "msgsIn,msgsOut,bytesIn,bytesOut,pollBlocks";
}
// Check if the client is connected
public bool Connected
{ get { return m_tcpclient.Connected; } }
@ -163,6 +161,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_log.WarnFormat("{0} Started thread: {1}", LogHeader, m_receive_loop.Name);
m_receive_loop.Start();
SyncStatisticCollector.Register(this);
//tell the remote script engine about the locX, locY of this authoritative scene
// SendSceneLoc();
m_log.DebugFormat("{0}: SceneToPhysEngineConnector initialized", LogHeader);

View File

@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_log.Warn(LogHeader + " Synchronized");
foreach (SceneToPhysEngineConnector pec in m_physEngineConnectors)
{
m_log.Warn(pec.GetStats());
m_log.Warn(pec.StatisticLine(true));
}
}
}

View File

@ -73,6 +73,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_log.Warn("[REGION SYNC MODULE] Initialised for actor "+ m_actorID);
//The ActorType configuration will be read in and process by an ActorSyncModule, not here.
// parameters for statistic logging
SyncStatisticCollector.LogEnabled = m_sysConfig.GetBoolean("SyncLogEnabled", false);
SyncStatisticCollector.LogDirectory = m_sysConfig.GetString("SyncLogDirectory", ".");
SyncStatisticCollector.LogInterval = m_sysConfig.GetInt("SyncLogInterval", 5000);
SyncStatisticCollector.LogMaxFileTimeMin = m_sysConfig.GetInt("SyncLogMaxFileTimeMin", 5);
SyncStatisticCollector.LogFileHeader = m_sysConfig.GetString("SyncLogFileHeader", "stats-");
}
//Called after Initialise()
@ -1163,10 +1170,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private void SyncStatus(Object[] args)
{
m_log.WarnFormat("[REGION SYNC MODULE]: Description: {0}", SyncConnector.StatusTitle());
int connectorCount = 0;
ForEachSyncConnector(delegate(SyncConnector connector)
{
m_log.WarnFormat("{0}: {1}: {2}", "[REGION SYNC MODULE}", connector.Description, connector.StatusLine());
if (connectorCount++ == 0)
m_log.WarnFormat("[REGION SYNC MODULE]: Description: {0}", connector.StatisticTitle());
m_log.WarnFormat("{0}: {1}: {2}", "[REGION SYNC MODULE}", connector.Description, connector.StatisticLine(true));
});
}

View File

@ -14,7 +14,7 @@ using OpenMetaverse;
namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{
// For implementations, a lot was copied from RegionSyncClientView, especially the SendLoop/ReceiveLoop.
public class SyncConnector
public class SyncConnector : ISyncStatistics
{
private TcpClient m_tcpConnection = null;
private RegionSyncListenerInfo m_remoteListenerInfo = null;
@ -39,7 +39,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private RegionSyncModule m_regionSyncModule = null;
private int m_connectorNum;
// unique connector number across all regions
private static int m_connectorNum = 0;
public int ConnectorNum
{
get { return m_connectorNum; }
@ -69,8 +70,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
get
{
if (m_syncOtherSideRegionName == null)
return String.Format("SyncConnector#{0}", m_connectorNum);
return String.Format("SyncConnector#{0}(A={2},R={1:10})",
return String.Format("SyncConnector{0}", m_connectorNum);
return String.Format("SyncConnector{0}({2}/{1:10})",
m_connectorNum, m_syncOtherSideRegionName, m_syncOtherSideActorID);
}
}
@ -86,6 +87,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_connectorNum = connectorNum;
m_regionSyncModule = syncModule;
lastStatTime = DateTime.Now;
SyncStatisticCollector.Register(this);
m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
}
@ -100,6 +102,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_connectorNum = connectorNum;
m_regionSyncModule = syncModule;
lastStatTime = DateTime.Now;
SyncStatisticCollector.Register(this);
m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
}
@ -299,7 +302,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_regionSyncModule.HandleIncomingMessage(msg, m_syncOtherSideActorID);
}
public string StatusLine()
public string StatisticIdentifier()
{
return this.Description;
}
public string StatisticLine(bool clearFlag)
{
string statLine = "";
lock (stats)
@ -310,14 +318,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
msgsIn, msgsOut, bytesIn, bytesOut, m_outQ.Count,
8 * (bytesIn / secondsSinceLastStats / 1000000),
8 * (bytesOut / secondsSinceLastStats / 1000000) );
msgsIn = msgsOut = bytesIn = bytesOut = 0;
if (clearFlag)
msgsIn = msgsOut = bytesIn = bytesOut = 0;
}
return statLine;
}
public static string StatusTitle()
public string StatisticTitle()
{
return "msgsIn,msgsOut,queueSize,Mbps In,Mbps Out";
return "msgsIn,msgsOut,bytesIn,bytesOut,queueSize,Mbps In,Mbps Out";
}
}
}