aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-07-21 22:51:11 +0100
committerJustin Clark-Casey (justincc)2014-07-21 22:55:38 +0100
commit200dcee1b7fa799936aaf43a18a34bfbf8b94449 (patch)
tree0eccb6301cd1a04e84e5064653e1a5b32bc4f732 /OpenSim/Framework
parentRevert "Removed unused files: Texture/Mesh server connectors" (diff)
downloadopensim-SC-200dcee1b7fa799936aaf43a18a34bfbf8b94449.zip
opensim-SC-200dcee1b7fa799936aaf43a18a34bfbf8b94449.tar.gz
opensim-SC-200dcee1b7fa799936aaf43a18a34bfbf8b94449.tar.bz2
opensim-SC-200dcee1b7fa799936aaf43a18a34bfbf8b94449.tar.xz
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.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Monitoring/ServerStatsCollector.cs14
1 files changed, 4 insertions, 10 deletions
diff --git a/OpenSim/Framework/Monitoring/ServerStatsCollector.cs b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs
index ac0f0bc..b4e0b16 100644
--- a/OpenSim/Framework/Monitoring/ServerStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs
@@ -141,7 +141,7 @@ namespace OpenSim.Framework.Monitoring
141 processorPercentPerfCounter = new PerfCounterControl(tempPC); 141 processorPercentPerfCounter = new PerfCounterControl(tempPC);
142 // A long time bug in mono is that CPU percent is reported as CPU percent idle. Windows reports CPU percent busy. 142 // A long time bug in mono is that CPU percent is reported as CPU percent idle. Windows reports CPU percent busy.
143 tempStat = new Stat(tempName, tempName, "", "percent", CategoryServer, ContainerProcessor, 143 tempStat = new Stat(tempName, tempName, "", "percent", CategoryServer, ContainerProcessor,
144 StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter, Util.IsWindows() ? 1 : -1); }, 144 StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter); },
145 StatVerbosity.Info); 145 StatVerbosity.Info);
146 StatsManager.RegisterStat(tempStat); 146 StatsManager.RegisterStat(tempStat);
147 RegisteredStats.Add(tempName, tempStat); 147 RegisteredStats.Add(tempName, tempStat);
@@ -253,28 +253,22 @@ namespace OpenSim.Framework.Monitoring
253 // "How to get the CPU Usage in C#": http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c 253 // "How to get the CPU Usage in C#": http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c
254 // "Mono Performance Counters": http://www.mono-project.com/Mono_Performance_Counters 254 // "Mono Performance Counters": http://www.mono-project.com/Mono_Performance_Counters
255 private delegate double PerfCounterNextValue(); 255 private delegate double PerfCounterNextValue();
256
256 private void GetNextValue(Stat stat, PerfCounterControl perfControl) 257 private void GetNextValue(Stat stat, PerfCounterControl perfControl)
257 { 258 {
258 GetNextValue(stat, perfControl, 1.0);
259 }
260 private void GetNextValue(Stat stat, PerfCounterControl perfControl, double factor)
261 {
262 if (Util.EnvironmentTickCountSubtract(perfControl.lastFetch) > performanceCounterSampleInterval) 259 if (Util.EnvironmentTickCountSubtract(perfControl.lastFetch) > performanceCounterSampleInterval)
263 { 260 {
264 if (perfControl != null && perfControl.perfCounter != null) 261 if (perfControl != null && perfControl.perfCounter != null)
265 { 262 {
266 try 263 try
267 { 264 {
268 // Kludge for factor to run double duty. If -1, subtract the value from one 265 stat.Value = perfControl.perfCounter.NextValue();
269 if (factor == -1)
270 stat.Value = 1 - perfControl.perfCounter.NextValue();
271 else
272 stat.Value = perfControl.perfCounter.NextValue() / factor;
273 } 266 }
274 catch (Exception e) 267 catch (Exception e)
275 { 268 {
276 m_log.ErrorFormat("{0} Exception on NextValue fetching {1}: {2}", LogHeader, stat.Name, e); 269 m_log.ErrorFormat("{0} Exception on NextValue fetching {1}: {2}", LogHeader, stat.Name, e);
277 } 270 }
271
278 perfControl.lastFetch = Util.EnvironmentTickCount(); 272 perfControl.lastFetch = Util.EnvironmentTickCount();
279 } 273 }
280 } 274 }