]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2208 undefined method getSystemLoadAverage
authorsimonbrandhof <simon.brandhof@gmail.com>
Tue, 22 Feb 2011 15:42:13 +0000 (16:42 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Tue, 22 Feb 2011 15:42:13 +0000 (16:42 +0100)
sonar-server/src/main/webapp/WEB-INF/app/models/server.rb

index 600aa7dc83401d2748ce1d56cbd35f60a5e2a8d5..04574290983a7af0100f8cd20f4534dc70ef7aac 100644 (file)
@@ -54,7 +54,7 @@ class Server
     add_property(system_statistics, 'Max Memory') {"#{java.lang.Runtime.getRuntime().maxMemory() / 1000000} MB"}
     add_property(system_statistics, 'Heap') {"#{java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()}"}
     add_property(system_statistics, 'Non Heap') {"#{java.lang.management.ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage()}"}
-    add_property(system_statistics, 'System Load Average (last minute)') {"#{format_double(100.0 * java.lang.management.ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage())}%"}
+    add_property(system_statistics, 'System Load Average (last minute)') {system_load_average()}
     add_property(system_statistics, 'Loaded Classes (currently/total/unloaded)') {"#{java.lang.management.ManagementFactory.getClassLoadingMXBean().getLoadedClassCount()} / #{java.lang.management.ManagementFactory.getClassLoadingMXBean().getTotalLoadedClassCount()} / #{java.lang.management.ManagementFactory.getClassLoadingMXBean().getUnloadedClassCount()}"}
     add_property(system_statistics, 'Start Time') {"#{format_date(java.util.Date.new(java.lang.management.ManagementFactory.getRuntimeMXBean().getStartTime()))}"}
     add_property(system_statistics, 'Threads (total/peak/daemon)') {"#{java.lang.management.ManagementFactory.getThreadMXBean().getThreadCount()} / #{java.lang.management.ManagementFactory.getThreadMXBean().getPeakThreadCount()} / #{java.lang.management.ManagementFactory.getThreadMXBean().getDaemonThreadCount() }" }
@@ -135,4 +135,13 @@ class Server
         ActiveRecord::Base.connection.instance_variable_get('@connection').connection.get_meta_data
       end
   end
+
+  def system_load_average
+    begin
+      "#{format_double(100.0 * java.lang.management.ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage())}%"
+    rescue
+      # not available on Java 5. See http://jira.codehaus.org/browse/SONAR-2208
+      'N/A'
+    end
+  end
 end
\ No newline at end of file