private void LogSimStats(SimStats stats) { SimStatsPacket pack = new SimStatsPacket(); pack.Region = new SimStatsPacket.RegionBlock(); pack.Region.RegionX = stats.RegionX; pack.Region.RegionY = stats.RegionY; pack.Region.RegionFlags = stats.RegionFlags; pack.Region.ObjectCapacity = stats.ObjectCapacity; //pack.Region = //stats.RegionBlock; pack.Stat = stats.StatsBlock; pack.Header.Reliable = false; // note that we are inside the reporter lock when called DateTime now = DateTime.Now; // hide some time information into the packet pack.Header.Sequence = (uint)now.Ticks; lock (m_statLockObject) // m_statLog is shared so make sure there is only executer here { try { if (m_statLog == null || now > m_statLog.StartTime + m_statLogPeriod) { // First log file or time has expired, start writing to a new log file if (m_statLog != null && m_statLog.Log != null) { m_statLog.Log.Close(); } m_statLog = new StatLogger(); m_statLog.StartTime = now; m_statLog.Path = (m_statsDir.Length > 0 ? m_statsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "") + String.Format("stats-{0}.log", now.ToString("yyyyMMddHHmmss")); m_statLog.Log = new BinaryWriter(File.Open(m_statLog.Path, FileMode.Append, FileAccess.Write)); } // Write the serialized data to disk if (m_statLog != null && m_statLog.Log != null) { m_statLog.Log.Write(pack.ToBytes()); } } catch (Exception ex) { m_log.Error("statistics gathering failed: " + ex.Message, ex); if (m_statLog != null && m_statLog.Log != null) { m_statLog.Log.Close(); } m_statLog = null; } } return; }
public SimStats( uint regionX, uint regionY, uint regionFlags, uint objectCapacity, SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock, UUID pRUUID) { regionUUID = pRUUID; m_regionX = regionX; m_regionY = regionY; m_regionFlags = regionFlags; m_objectCapacity = objectCapacity; m_regionBlock = regionBlock; m_statsBlock = statsBlock; }
void LogSimStats(SimStats stats) { SimStatsPacket pack = new SimStatsPacket { Region = stats.RegionBlock, Stat = stats.StatsBlock, Header = { Reliable = false } }; // note that we are inside the reporter lock when called DateTime now = DateTime.Now; // hide some time information into the packet pack.Header.Sequence = (uint)now.Ticks; lock (m_statLockObject) // m_statLog is shared so make sure there is only executer here { try { if (m_statLog == null || now > m_statLog.StartTime + m_statLogPeriod) { // First log file or time has expired, start writing to a new log file if (m_statLog != null && m_statLog.Log != null) { m_statLog.Log.Close(); } m_statLog = new StatLogger { StartTime = now, Path = (m_statsDir.Length > 0 ? m_statsDir + Path.DirectorySeparatorChar : "") + string.Format("stats-{0}.log", now.ToString("yyyyMMddHHmmss")) }; m_statLog.Log = new BinaryWriter(File.Open(m_statLog.Path, FileMode.Append, FileAccess.Write)); } // Write the serialized data to disk if (m_statLog != null && m_statLog.Log != null) { m_statLog.Log.Write(pack.ToBytes()); } } catch (Exception ex) { MainConsole.Instance.ErrorFormat("[Binary stats]: Statistics gathering failed: {0}", ex); if (m_statLog != null && m_statLog.Log != null) { m_statLog.Log.Close(); } m_statLog = null; } } return; }
private void LogSimStats(SimStats stats) { SimStatsPacket pack = new SimStatsPacket(); pack.Region = stats.RegionBlock; pack.Stat = stats.StatsBlock; pack.Header.Reliable = false; // note that we are inside the reporter lock when called DateTime now = DateTime.Now; // hide some time information into the packet pack.Header.Sequence = (uint)now.Ticks; lock (m_statLockObject) // m_statLog is shared so make sure there is only executer here { try { if (m_statLog == null || now > m_statLog.StartTime + m_statLogPeriod) { // First log file or time has expired, start writing to a new log file if (m_statLog != null && m_statLog.Log != null) { m_statLog.Log.Close(); } m_statLog = new StatLogger(); m_statLog.StartTime = now; m_statLog.Path = (m_statsDir.Length > 0 ? m_statsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "") + String.Format("stats-{0}.log", now.ToString("yyyyMMddHHmmss")); m_statLog.Log = new BinaryWriter(File.Open(m_statLog.Path, FileMode.Append, FileAccess.Write)); } // Write the serialized data to disk if (m_statLog != null && m_statLog.Log != null) m_statLog.Log.Write(pack.ToBytes()); } catch (Exception ex) { m_log.Error("statistics gathering failed: " + ex.Message, ex); if (m_statLog != null && m_statLog.Log != null) { m_statLog.Log.Close(); } m_statLog = null; } } return; }
public SimStats(SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock, UUID pRUUID) { regionUUID = pRUUID; m_regionBlock = regionBlock; m_statsBlock = statsBlock; }
private void SimStatsHandler(Packet packet, Simulator simulator) { if (!Client.Settings.ENABLE_SIMSTATS) { return; } SimStatsPacket stats = (SimStatsPacket)packet; for (int i = 0; i < stats.Stat.Length; i++) { SimStatsPacket.StatBlock s = stats.Stat[i]; switch (s.StatID) { case 0: simulator.Stats.Dilation = s.StatValue; break; case 1: simulator.Stats.FPS = Convert.ToInt32(s.StatValue); break; case 2: simulator.Stats.PhysicsFPS = s.StatValue; break; case 3: simulator.Stats.AgentUpdates = s.StatValue; break; case 4: simulator.Stats.FrameTime = s.StatValue; break; case 5: simulator.Stats.NetTime = s.StatValue; break; case 7: simulator.Stats.PhysicsTime = s.StatValue; break; case 8: simulator.Stats.ImageTime = s.StatValue; break; case 9: simulator.Stats.ScriptTime = s.StatValue; break; case 10: simulator.Stats.OtherTime = s.StatValue; break; case 11: simulator.Stats.Objects = Convert.ToInt32(s.StatValue); break; case 12: simulator.Stats.ScriptedObjects = Convert.ToInt32(s.StatValue); break; case 13: simulator.Stats.Agents = Convert.ToInt32(s.StatValue); break; case 14: simulator.Stats.ChildAgents = Convert.ToInt32(s.StatValue); break; case 15: simulator.Stats.ActiveScripts = Convert.ToInt32(s.StatValue); break; case 16: simulator.Stats.LSLIPS = Convert.ToInt32(s.StatValue); break; case 17: simulator.Stats.INPPS = Convert.ToInt32(s.StatValue); break; case 18: simulator.Stats.OUTPPS = Convert.ToInt32(s.StatValue); break; case 19: simulator.Stats.PendingDownloads = Convert.ToInt32(s.StatValue); break; case 20: simulator.Stats.PendingUploads = Convert.ToInt32(s.StatValue); break; case 21: simulator.Stats.VirtualSize = Convert.ToInt32(s.StatValue); break; case 22: simulator.Stats.ResidentSize = Convert.ToInt32(s.StatValue); break; case 23: simulator.Stats.PendingLocalUploads = Convert.ToInt32(s.StatValue); break; case 24: simulator.Stats.UnackedBytes = Convert.ToInt32(s.StatValue); break; } } }
private void InitializeStatsPacket() { m_stats = new SimStatsPacket(); m_stats.PidStat.PID = m_pid; m_stats.Region.RegionX = (uint)(m_scene.MinPosition.X / 256d); m_stats.Region.RegionY = (uint)(m_scene.MinPosition.Y / 256d); Array statTypes = Enum.GetValues(typeof(SimStatType)); m_stats.Stat = new SimStatsPacket.StatBlock[statTypes.Length]; foreach (uint statIndex in statTypes) m_stats.Stat[statIndex] = new SimStatsPacket.StatBlock { StatID = statIndex }; }