diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-02-23 00:45:39 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-02-23 00:45:39 +0100 |
commit | 3cd1f4c44ff2fffe3bd16f92c27da2218dffeba7 (patch) | |
tree | 8cce24a0ce7c4b69608442107c7a85fc26ae112f /server/sonar-web/src/main | |
parent | e0a45822f9a18b4b1d0d22f53b2218cd60795f6f (diff) | |
download | sonarqube-3cd1f4c44ff2fffe3bd16f92c27da2218dffeba7.tar.gz sonarqube-3cd1f4c44ff2fffe3bd16f92c27da2218dffeba7.zip |
SONAR-5936 improve display
Diffstat (limited to 'server/sonar-web/src/main')
5 files changed, 27 insertions, 295 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/system_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/system_controller.rb index 9bb32af6f5a..aad178a17c9 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/system_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/system_controller.rb @@ -23,15 +23,14 @@ class SystemController < ApplicationController before_filter :admin_required def index - @server=Server.new - - filename = 'SystemInfo' - server_id = @server.sonar_property(ServerIdConfigurationController::PROPERTY_SERVER_ID) - filename += '-' + server_id.to_s if server_id - - respond_to do |format| - format.html - end + @monitors = [ + Java::OrgSonarServerPlatform::Platform.component(Java::OrgSonarServerPlatformMonitoring::SonarQubeMonitor.java_class), + Java::OrgSonarServerPlatform::Platform.component(Java::OrgSonarServerPlatformMonitoring::DatabaseMonitor.java_class), + Java::OrgSonarServerPlatform::Platform.component(Java::OrgSonarServerPlatformMonitoring::SystemMonitor.java_class), + Java::OrgSonarServerPlatform::Platform.component(Java::OrgSonarServerPlatformMonitoring::EsClusterMonitor.java_class), + Java::OrgSonarServerPlatform::Platform.component(Java::OrgSonarServerPlatformMonitoring::EsNodesMonitor.java_class), + Java::OrgSonarServerPlatform::Platform.component(Java::OrgSonarServerPlatformMonitoring::JvmPropertiesMonitor.java_class) + ] end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/server.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/server.rb deleted file mode 100644 index 2da765f923f..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/server.rb +++ /dev/null @@ -1,208 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2014 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 3 of the License, or (at your option) any later version. -# -# SonarQube is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -include ActionView::Helpers::NumberHelper - -class Server - - def info - system_info + sonar_info + system_statistics + sonar_plugins + system_properties + cluster_info + nodes_info - end - - def system_info - system_info=[] - add_property(system_info, 'System date') { java.util.Date.new() } - add_property(system_info, 'JVM Vendor') { java.lang.management.ManagementFactory.getRuntimeMXBean().getVmVendor() } - add_property(system_info, 'JVM Name') { java.lang.management.ManagementFactory.getRuntimeMXBean().getVmName() } - add_property(system_info, 'JVM Version') { java.lang.management.ManagementFactory.getRuntimeMXBean().getVmVersion() } - #add_property(system_info, 'Java Version') { java_property('java.runtime.version') } - #add_property(system_info, 'Java Home') { java_property('java.home') } - #add_property(system_info, 'JIT Compiler') { java_property('java.compiler') } - #add_property(system_info, 'Application Server Container') { $servlet_context.getServerInfo() } - #add_property(system_info, 'User Name') { java_property('user.name') } - #add_property(system_info, 'User TimeZone') { java_property('user.timezone') } - #add_property(system_info, 'OS') { "#{java_property('os.name')} / #{java_property('os.arch')} / #{java_property('os.version')}" } - add_property(system_info, 'Processors') { java.lang.Runtime.getRuntime().availableProcessors() } - add_property(system_info, 'System Classpath') { java.lang.management.ManagementFactory.getRuntimeMXBean().getClassPath() } - add_property(system_info, 'Boot Classpath') { java.lang.management.ManagementFactory.getRuntimeMXBean().getBootClassPath() } - add_property(system_info, 'Library Path') { java.lang.management.ManagementFactory.getRuntimeMXBean().getLibraryPath() } - add_property(system_statistics, 'Total Memory') { "#{java.lang.Runtime.getRuntime().totalMemory() / 1000000} MB" } - add_property(system_statistics, 'Free Memory') { "#{java.lang.Runtime.getRuntime().freeMemory() / 1000000} MB" } - 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)') { 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() }" } - system_info - end - - #TODO to remove - def system_statistics - system_statistics=[] - add_property(system_statistics, 'Total Memory') { "#{java.lang.Runtime.getRuntime().totalMemory() / 1000000} MB" } - add_property(system_statistics, 'Free Memory') { "#{java.lang.Runtime.getRuntime().freeMemory() / 1000000} MB" } - 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)') { 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() }" } - system_statistics - end - - def sonar_info - sonar_info=[] - add_property(sonar_info, 'Server ID') { sonar_property(ServerIdConfigurationController::PROPERTY_SERVER_ID) } - add_property(sonar_info, 'Version') { org.sonar.server.platform.Platform.getServer().getVersion() } - add_property(sonar_info, 'Started at') { org.sonar.server.platform.Platform.getServer().getStartedAt() } - #add_property(sonar_info, 'Database') { "#{jdbc_metadata.getDatabaseProductName()} #{jdbc_metadata.getDatabaseProductVersion()}" } - #add_property(sonar_info, 'Database URL') { sonar_property('sonar.jdbc.url') } - #add_property(sonar_info, 'Database Login') { sonar_property('sonar.jdbc.username') } - #add_property(sonar_info, 'Database Driver') { "#{jdbc_metadata.getDriverName()} #{jdbc_metadata.getDriverVersion()}" } - #add_property(sonar_info, 'Database Active Connections') { "#{Java::OrgSonarServerUi::JRubyFacade.getInstance().getDatabase().getDataSource().getNumActive()}" } - #add_property(sonar_info, 'Database Max. Active Connections') { sonar_property('sonar.jdbc.maxActive') } - #add_property(sonar_info, 'Database Max. Pool Wait') { sonar_property('sonar.jdbc.maxWait') } - add_property(sonar_info, 'External User Authentication') { realm_name } - add_property(sonar_info, 'Automatic User Creation') { sonar_property(org.sonar.api.CoreProperties.CORE_AUTHENTICATOR_CREATE_USERS) } - add_property(sonar_info, 'Allow Users to Sign Up') { sonar_property(org.sonar.api.CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY) } - add_property(sonar_info, 'Force Authentication') { sonar_property(org.sonar.api.CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY) } - sonar_info - end - - def cluster_info - search_info=[] - search_health = Java::OrgSonarServerPlatform::Platform.component(Java::OrgSonarServerSearch::SearchHealth.java_class) - node_health = search_health.getClusterHealth() - add_property(search_info, 'Cluster State') { node_health.isClusterAvailable() ? 'Available' : 'Unavailable' } - add_property(search_info, 'Number of Nodes') { node_health.getNumberOfNodes() } - - search_health.getIndexHealth().each do |name, index_health| - add_property(search_info, "#{name} - Document Count") { index_health.getDocumentCount() } - add_property(search_info, "#{name} - Last Sync") { index_health.getLastSynchronization() } - add_property(search_info, "#{name} - Optimization") { index_health.isOptimized() ? 'Optimized' : "Unoptimized (Segments: #{index_health.getSegmentcount()}, Pending Deletions: #{index_health.getPendingDeletion()})" } - end - - search_info - end - - def nodes_info - nodes_info=[] - search_health = Java::OrgSonarServerPlatform::Platform.component(Java::OrgSonarServerSearch::SearchHealth.java_class) - search_health.getNodesHealth().each do |name, node_health| - node_info=[] - add_property(node_info, 'Node Name') { name } - add_property(node_info, 'Node Type') { node_health.isMaster() ? 'Master' : 'Slave' } - add_property(node_info, 'Node Address') { node_health.getAddress() } - add_property(node_info, 'JVM Heap Usage') { node_health.getJvmHeapUsedPercent() } - add_property(node_info, 'JVM Threads') { node_health.getJvmThreads() } - add_property(node_info, 'JVM Uptime') { Internal.i18n.ageFromNow(node_health.getJvmUpSince()) } - add_property(node_info, 'Disk Usage') { node_health.getFsUsedPercent() } - add_property(node_info, 'Open Files') { node_health.getOpenFiles() } - add_property(node_info, 'CPU Load Average') { node_health.getProcessCpuPercent() } - add_property(node_info, 'Field Cache Size') { number_to_human_size(node_health.getFieldCacheMemory()) } - add_property(node_info, 'Filter Cache Size') { number_to_human_size(node_health.getFilterCacheMemory()) } - node_health.getPerformanceStats().each do |performance| - message = performance.getStatus().toString() == "ERROR" || performance.getStatus().toString() == "WARN" ? "- #{performance.getStatus()}: #{performance.getMessage()}" : ""; - if performance.getName().include? "Eviction" - add_property(node_info, performance.getName()) { "#{performance.getValue()} #{message} " } - else - add_property(node_info, performance.getName()) { "#{format_double(performance.getValue())} ms #{message} " } - end - end - nodes_info.push(node_info) - end - - nodes_info - end - - #TODO should be removed - def sonar_plugins - sonar_plugins=[] - Java::OrgSonarServerUi::JRubyFacade.getInstance().getPluginsMetadata().to_a.select { |plugin| !plugin.isCore() }.sort.each do |plugin| - add_property(sonar_plugins, plugin.getName()) { plugin.getVersion() } - end - sonar_plugins - end - - def system_properties - system_properties=[] - keys=java.lang.System.getProperties().keySet().to_a.sort - keys.each do |key| - add_property(system_properties, key) { java.lang.System.getProperty(key) } - end - system_properties - end - - def sonar_property(key) - Java::OrgSonarServerUi::JRubyFacade.getInstance().getConfigurationValue(key) - end - - private - - def java_property(key) - java.lang.System.getProperty(key) - end - - def add_property(properties, label) - begin - value=yield || '-' - properties<<[label, value] - rescue Exception => e - Rails.logger.error("Can not get the property #{label}") - Rails.logger.error(e) - properties<<[label, 'N/A'] - end - end - - def format_double(d) - (d * 10).to_i / 10.0 - end - - def format_date(date) - java.text.SimpleDateFormat.new("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(date) - end - - def realm_name - realm_factory = Api::Utils.java_facade.getCoreComponentByClassname('org.sonar.server.user.SecurityRealmFactory') - if realm_factory && realm_factory.getRealm() - realm_factory.getRealm().getName() - else - nil - end - end - - def jdbc_metadata - @metadata ||= - begin - 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 diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/_monitor.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/_monitor.html.erb new file mode 100644 index 00000000000..3765dfa9b2c --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/_monitor.html.erb @@ -0,0 +1,16 @@ +<table class="data width100" id="<%= monitor.name().parameterize -%>"> + <thead> + <tr> + <th colspan="2"><h2><%= h monitor.name() -%></h2></th> + </tr> + </thead> + <tbody> + <% monitor.attributes().entrySet().each do |attribute| %> + <tr class="<%= cycle('even','odd') -%>"> + <td width="25%" nowrap="nowrap"><%= h attribute.getKey() -%></td> + <td width="75%"><%= h attribute.getValue() -%></td> + </tr> + <% end %> + </tbody> + </table> + <br/> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/_row.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/_row.html.erb deleted file mode 100644 index 2140ac62569..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/_row.html.erb +++ /dev/null @@ -1,4 +0,0 @@ - <tr class="<%= cycle('even','odd', :name => name) -%>"> - <td width="25%" nowrap="nowrap"><%= title -%></td> - <td width="75%"><%= value -%></td> - </tr>
\ No newline at end of file diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/index.html.erb index f237a396468..d909fffc09d 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/index.html.erb @@ -6,81 +6,10 @@ <a href="<%= ApplicationController.root_context -%>/api/system/info" id="download-link">Download</a> </div> </div> - <p class="page-description"><%= message('system_info.page.description') -%></p> </header> - <table class="data width100" id="sonar"> - <thead> - <tr> - <th colspan="2"><h2>SonarQube Info</h2></th> - </tr> - </thead> - <tbody> - <% @server.sonar_info.each do |data| %> - <%= render :partial => 'row', :locals => {:title => data[0], :value => data[1], :name => 'sonar'} %> - <% end %> - </tbody> - </table> + <% @monitors.each do |monitor| %> + <%= render :partial => 'monitor', :locals => {:monitor => monitor} -%> + <% end %> - <br/> - - <table class="data width100" id="system_info"> - <thead> - <tr> - <th colspan="2"><h2>System Info</h2></th> - </tr> - </thead> - <tbody> - <% @server.system_info.each do |data| %> - <%= render :partial => 'row', :locals => {:title => data[0], :value => data[1], :name => 'system'} %> - <% end %> - </tbody> - </table> - - <br/> - - <table class="data width100" id="cluster_info"> - <thead> - <tr> - <th colspan="2"><h2>ElasticSearch - Cluster</h2></th> - </tr> - </thead> - <tbody> - <% @server.cluster_info.each do |data| %> - <%= render :partial => 'row', :locals => {:title => data[0], :value => data[1], :name => 'cluster'} %> - <% end %> - </tbody> - </table> - - <br/> - - <% @server.nodes_info.each do |node_info| -%> - <table class="data width100" id="cluster_info<%= node_info[0][1] -%>"> - <thead> - <tr> - <th colspan="2"><h2>ElasticSearch - <%= node_info[0][1] -%></h2></th> - </tr> - </thead> - <tbody> - <% node_info.drop(1).each do |data| %> - <%= render :partial => 'row', :locals => {:title => data[0], :value => data[1], :name => 'node'} %> - <% end %> - </tbody> - </table> - - <br/> - <% end -%> - - <table class="data width100" id="system_properties"> - <thead> - <tr> - <th colspan="2"><h2>System Properties</h2></th> - </tr> - </thead> - <tbody> - <% @server.system_properties.each do |data| %> - <%= render :partial => 'row', :locals => {:title => data[0], :value => data[1], :name => 'system_properties'} %> - <% end %> - </tbody> - </table> </div> |