From fc3543c24aa31d353bbb3778245641f3db293271 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 2 Oct 2022 11:24:39 +0100 Subject: [PATCH] performance counters are windows only, we are not, so .. gone --- .../Monitoring/ServerStatsCollector.cs | 34 ++++++++++--------- OpenSim/Framework/Monitoring/Stats/Stat.cs | 12 +++---- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/OpenSim/Framework/Monitoring/ServerStatsCollector.cs b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs index a26a6e0366..80a6c9c6af 100644 --- a/OpenSim/Framework/Monitoring/ServerStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs @@ -35,7 +35,6 @@ using System.Threading; using log4net; using Nini.Config; using OpenMetaverse.StructuredData; -using OpenSim.Framework; namespace OpenSim.Framework.Monitoring { @@ -57,9 +56,9 @@ namespace OpenSim.Framework.Monitoring public string NetworkInterfaceTypes = "Ethernet"; - readonly int performanceCounterSampleInterval = 500; -// int lastperformanceCounterSampleTime = 0; - + //readonly int performanceCounterSampleInterval = 500; + //int lastperformanceCounterSampleTime = 0; + /* private class PerfCounterControl { public PerformanceCounter perfCounter; @@ -78,6 +77,7 @@ namespace OpenSim.Framework.Monitoring } PerfCounterControl processorPercentPerfCounter = null; + */ // IRegionModuleBase.Initialize public void Initialise(IConfigSource source) @@ -138,22 +138,22 @@ namespace OpenSim.Framework.Monitoring public void RegisterServerStats() { -// lastperformanceCounterSampleTime = Util.EnvironmentTickCount(); - PerformanceCounter tempPC; - Stat tempStat; - string tempName; + //lastperformanceCounterSampleTime = Util.EnvironmentTickCount(); + //PerformanceCounter tempPC; + //Stat tempStat; + //string tempName; try { - tempName = "CPUPercent"; - tempPC = new PerformanceCounter("Processor", "% Processor Time", "_Total"); - processorPercentPerfCounter = new PerfCounterControl(tempPC); + //tempName = "CPUPercent"; + //tempPC = new PerformanceCounter("Processor", "% Processor Time", "_Total"); + //processorPercentPerfCounter = new PerfCounterControl(tempPC); // A long time bug in mono is that CPU percent is reported as CPU percent idle. Windows reports CPU percent busy. - tempStat = new Stat(tempName, tempName, "", "percent", CategoryServer, ContainerProcessor, - StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter); }, - StatVerbosity.Info); - StatsManager.RegisterStat(tempStat); - RegisteredStats.Add(tempName, tempStat); + //tempStat = new Stat(tempName, tempName, "", "percent", CategoryServer, ContainerProcessor, + // StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter); }, + // StatVerbosity.Info); + //StatsManager.RegisterStat(tempStat); + //RegisteredStats.Add(tempName, tempStat); MakeStat("TotalProcessorTime", null, "sec", ContainerProcessor, (s) => { s.Value = Math.Round(Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds, 3); }); @@ -300,6 +300,7 @@ namespace OpenSim.Framework.Monitoring }); } + /* // Notes on performance counters: // "How To Read Performance Counters": http://blogs.msdn.com/b/bclteam/archive/2006/06/02/618156.aspx // "How to get the CPU Usage in C#": http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c @@ -325,6 +326,7 @@ namespace OpenSim.Framework.Monitoring } } } + */ // Lookup the nic that goes with this stat and set the value by using a fetch action. // Not sure about closure with delegates inside delegates. diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs index 97c76f922f..2bc8c4c499 100644 --- a/OpenSim/Framework/Monitoring/Stats/Stat.cs +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs @@ -27,10 +27,7 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Reflection; using System.Text; -using log4net; using OpenMetaverse.StructuredData; namespace OpenSim.Framework.Monitoring @@ -315,9 +312,9 @@ namespace OpenSim.Framework.Monitoring lock (m_samples) { - // m_log.DebugFormat( - // "[STAT]: Samples for {0} are {1}", - // Name, string.Join(",", m_samples.Select(s => s.ToString()).ToArray())); + //m_log.DebugFormat( + // "[STAT]: Samples for {0} are {1}", + // Name, string.Join(",", m_samples.Select(s => s.ToString()).ToArray())); foreach (double s in m_samples) { @@ -331,8 +328,7 @@ namespace OpenSim.Framework.Monitoring if (lastSample != null && penultimateSample != null) { - lastChangeOverTime - = ((double)lastSample - (double)penultimateSample) / (Watchdog.WATCHDOG_INTERVAL_MS / 1000); + lastChangeOverTime = ((double)lastSample - (double)penultimateSample) / (Watchdog.WATCHDOG_INTERVAL_MS / 1000); } int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1;