Fix CPU processor use reporting on Mono.

Despite the comments in the code, it appears that the issue where the .NET performance counter was wrongly idle time time on Mono was fixed in 2009.
https://bugzilla.novell.com/show_bug.cgi?id=468625
Which means that the workaround is no longer necessary and produces bad results instead.
bullet-2.82
Justin Clark-Casey (justincc) 2014-07-21 22:51:11 +01:00
parent 1a9c14b041
commit 200dcee1b7
1 changed files with 4 additions and 10 deletions

View File

@ -141,7 +141,7 @@ namespace OpenSim.Framework.Monitoring
processorPercentPerfCounter = new PerfCounterControl(tempPC); 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. // 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, tempStat = new Stat(tempName, tempName, "", "percent", CategoryServer, ContainerProcessor,
StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter, Util.IsWindows() ? 1 : -1); }, StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter); },
StatVerbosity.Info); StatVerbosity.Info);
StatsManager.RegisterStat(tempStat); StatsManager.RegisterStat(tempStat);
RegisteredStats.Add(tempName, tempStat); RegisteredStats.Add(tempName, tempStat);
@ -253,11 +253,8 @@ namespace OpenSim.Framework.Monitoring
// "How to get the CPU Usage in C#": http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c // "How to get the CPU Usage in C#": http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c
// "Mono Performance Counters": http://www.mono-project.com/Mono_Performance_Counters // "Mono Performance Counters": http://www.mono-project.com/Mono_Performance_Counters
private delegate double PerfCounterNextValue(); private delegate double PerfCounterNextValue();
private void GetNextValue(Stat stat, PerfCounterControl perfControl) private void GetNextValue(Stat stat, PerfCounterControl perfControl)
{
GetNextValue(stat, perfControl, 1.0);
}
private void GetNextValue(Stat stat, PerfCounterControl perfControl, double factor)
{ {
if (Util.EnvironmentTickCountSubtract(perfControl.lastFetch) > performanceCounterSampleInterval) if (Util.EnvironmentTickCountSubtract(perfControl.lastFetch) > performanceCounterSampleInterval)
{ {
@ -265,16 +262,13 @@ namespace OpenSim.Framework.Monitoring
{ {
try try
{ {
// Kludge for factor to run double duty. If -1, subtract the value from one stat.Value = perfControl.perfCounter.NextValue();
if (factor == -1)
stat.Value = 1 - perfControl.perfCounter.NextValue();
else
stat.Value = perfControl.perfCounter.NextValue() / factor;
} }
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat("{0} Exception on NextValue fetching {1}: {2}", LogHeader, stat.Name, e); m_log.ErrorFormat("{0} Exception on NextValue fetching {1}: {2}", LogHeader, stat.Name, e);
} }
perfControl.lastFetch = Util.EnvironmentTickCount(); perfControl.lastFetch = Util.EnvironmentTickCount();
} }
} }