aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-02-23 00:45:39 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-02-23 00:45:39 +0100
commit3cd1f4c44ff2fffe3bd16f92c27da2218dffeba7 (patch)
tree8cce24a0ce7c4b69608442107c7a85fc26ae112f /server
parente0a45822f9a18b4b1d0d22f53b2218cd60795f6f (diff)
downloadsonarqube-3cd1f4c44ff2fffe3bd16f92c27da2218dffeba7.tar.gz
sonarqube-3cd1f4c44ff2fffe3bd16f92c27da2218dffeba7.zip
SONAR-5936 improve display
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/BaseMonitorMBean.java7
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseMonitor.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/JvmPropertiesMonitor.java11
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/Monitor.java13
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/PluginsMonitor.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitorMBean.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SystemMonitor.java116
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/JvmPropertiesMonitorTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/SonarQubeMonitorTest.java2
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/system_controller.rb17
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/server.rb208
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/system/_monitor.html.erb16
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/system/_row.html.erb4
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/system/index.html.erb77
15 files changed, 86 insertions, 403 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/BaseMonitorMBean.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/BaseMonitorMBean.java
index 6b982a7ba7d..20c863c3f49 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/BaseMonitorMBean.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/BaseMonitorMBean.java
@@ -30,6 +30,10 @@ import javax.management.OperationsException;
import java.lang.management.ManagementFactory;
+/**
+ * Base implementation of {@link org.sonar.server.platform.monitoring.Monitor}
+ * that is exported as a JMX bean
+ */
public abstract class BaseMonitorMBean implements Monitor, Startable {
/**
@@ -44,6 +48,9 @@ public abstract class BaseMonitorMBean implements Monitor, Startable {
}
}
+ /**
+ * Unregister, if needed
+ */
@Override
public void stop() {
try {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseMonitor.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseMonitor.java
index 9ce60700212..e2d33e65f8e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseMonitor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseMonitor.java
@@ -33,6 +33,9 @@ import java.sql.SQLException;
import java.util.LinkedHashMap;
import java.util.Map;
+/**
+ * Information about database and connection pool
+ */
public class DatabaseMonitor extends BaseMonitorMBean implements DatabaseMonitorMBean {
private final DatabaseVersion dbVersion;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/JvmPropertiesMonitor.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/JvmPropertiesMonitor.java
index 1d40dbd2d7e..6ca8718ac43 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/JvmPropertiesMonitor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/JvmPropertiesMonitor.java
@@ -20,9 +20,12 @@
package org.sonar.server.platform.monitoring;
+import com.google.common.collect.Maps;
+
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
+import java.util.SortedMap;
public class JvmPropertiesMonitor implements Monitor {
@Override
@@ -32,10 +35,10 @@ public class JvmPropertiesMonitor implements Monitor {
@Override
public LinkedHashMap<String, Object> attributes() {
- LinkedHashMap<String, Object> attributes = new LinkedHashMap<>();
- for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
- attributes.put(Objects.toString(entry.getKey()), Objects.toString(entry.getValue()));
+ SortedMap<String, Object> sortedProps = Maps.newTreeMap();
+ for (Map.Entry<Object, Object> systemProp : System.getProperties().entrySet()) {
+ sortedProps.put(Objects.toString(systemProp.getKey()), Objects.toString(systemProp.getValue()));
}
- return attributes;
+ return new LinkedHashMap<>(sortedProps);
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/Monitor.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/Monitor.java
index 661c86dba07..5eb7dd989f7 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/Monitor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/Monitor.java
@@ -23,7 +23,18 @@ import org.sonar.api.ServerComponent;
import java.util.LinkedHashMap;
+/**
+ * Any component that is involved in the informations returned by the web service api/system/info
+ */
public interface Monitor extends ServerComponent {
- LinkedHashMap<String,Object> attributes();
+ /**
+ * Name of section in System Info page
+ */
String name();
+
+ /**
+ * Type of attribute values must be supported by {@link org.sonar.api.utils.text.JsonWriter#valueObject(Object)}
+ * because of JSON export by {@link org.sonar.server.platform.ws.SystemInfoWsAction}
+ */
+ LinkedHashMap<String,Object> attributes();
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/PluginsMonitor.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/PluginsMonitor.java
index ed93664394a..2f2ee647e63 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/PluginsMonitor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/PluginsMonitor.java
@@ -29,6 +29,9 @@ import org.sonar.api.platform.PluginRepository;
import java.util.LinkedHashMap;
import java.util.List;
+/**
+ * Installed plugins (excluding core plugins)
+ */
public class PluginsMonitor implements Monitor {
private final PluginRepository repository;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java
index 2846f282303..a043b8dc5b7 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java
@@ -29,8 +29,6 @@ import org.sonar.server.user.SecurityRealmFactory;
import java.util.LinkedHashMap;
-import static org.sonar.api.utils.DateUtils.formatDateTime;
-
public class SonarQubeMonitor extends BaseMonitorMBean implements SonarQubeMonitorMBean {
private final Settings settings;
@@ -54,11 +52,6 @@ public class SonarQubeMonitor extends BaseMonitorMBean implements SonarQubeMonit
return server.getVersion();
}
- @Override
- public String getStartedAt() {
- return formatDateTime(server.getStartedAt());
- }
-
public String getExternalUserAuthentication() {
SecurityRealm realm = securityRealmFactory.getRealm();
if (realm == null) {
@@ -89,7 +82,6 @@ public class SonarQubeMonitor extends BaseMonitorMBean implements SonarQubeMonit
LinkedHashMap<String, Object> attributes = new LinkedHashMap<>();
attributes.put("Server ID", getServerId());
attributes.put("Version", getVersion());
- attributes.put("Started at", getStartedAt());
attributes.put("External User Authentication", getExternalUserAuthentication());
attributes.put("Automatic User Creation", getAutomaticUserCreation());
attributes.put("Allow Users to Sign Up", getAllowUsersToSignUp());
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitorMBean.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitorMBean.java
index 56b8f4744e7..7c010b4403a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitorMBean.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitorMBean.java
@@ -24,6 +24,4 @@ public interface SonarQubeMonitorMBean {
String getServerId();
String getVersion();
-
- String getStartedAt();
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SystemMonitor.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SystemMonitor.java
index b4ea751303c..e40f13fc542 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SystemMonitor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SystemMonitor.java
@@ -32,6 +32,10 @@ import java.util.LinkedHashMap;
import static org.sonar.api.utils.DateUtils.formatDateTime;
+/**
+ * JVM runtime information. Not exported as a MXBean because these informations
+ * are natively provided.
+ */
public class SystemMonitor implements Monitor {
private final System2 system;
@@ -48,100 +52,30 @@ public class SystemMonitor implements Monitor {
return "System";
}
- public String getSystemDate() {
- return formatDateTime(new Date(system.now()));
- }
-
- public String getJvmVendor() {
- return runtimeMXBean().getVmVendor();
- }
-
- public String getJvmName() {
- return runtimeMXBean().getVmName();
- }
-
- public String getJvmVersion() {
- return runtimeMXBean().getVmVersion();
- }
-
- public int getProcessors() {
- return runtime().availableProcessors();
- }
-
- public String getSystemClasspath() {
- return runtimeMXBean().getClassPath();
- }
-
- public String getBootClasspath() {
- return runtimeMXBean().getBootClassPath();
- }
-
- public String getLibraryPath() {
- return runtimeMXBean().getLibraryPath();
- }
-
- public String getTotalMemory() {
- return formatMemory(runtime().totalMemory());
- }
-
- public String getFreeMemory() {
- return formatMemory(runtime().freeMemory());
- }
-
- public String getMaxMemory() {
- return formatMemory(runtime().maxMemory());
- }
-
- public String getHeapMemory() {
- return memoryMXBean().getHeapMemoryUsage().toString();
- }
-
- public String getNonHeapMemory() {
- return memoryMXBean().getNonHeapMemoryUsage().toString();
- }
-
- public String getSystemLoadAverage() {
- return String.format("%.1f%% (last minute)", ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage() * 100.0);
- }
-
- public String getLoadedClasses() {
- return String.format("currently: %d, total: %d, unloaded: %d",
- classLoadingMXBean().getLoadedClassCount(),
- classLoadingMXBean().getTotalLoadedClassCount(),
- classLoadingMXBean().getUnloadedClassCount());
- }
-
- public String getStartTime() {
- return formatDateTime(new Date(runtimeMXBean().getStartTime()));
- }
-
- public String getThreads() {
- return String.format("total: %d, peak: %d, daemon: %d",
- threadMXBean().getThreadCount(),
- threadMXBean().getPeakThreadCount(),
- threadMXBean().getDaemonThreadCount());
- }
-
@Override
public LinkedHashMap<String, Object> attributes() {
LinkedHashMap<String, Object> attributes = new LinkedHashMap<>();
- attributes.put("System Date", getSystemDate());
- attributes.put("JVM Vendor", getJvmVendor());
- attributes.put("JVM Name", getJvmName());
- attributes.put("JVM Version", getJvmVersion());
- attributes.put("Processors", getProcessors());
- attributes.put("System Classpath", getSystemClasspath());
- attributes.put("BootClassPath", getBootClasspath());
- attributes.put("Library Path", getLibraryPath());
- attributes.put("Total Memory", getTotalMemory());
- attributes.put("Free Memory", getFreeMemory());
- attributes.put("Max Memory", getMaxMemory());
- attributes.put("Heap", getHeapMemory());
- attributes.put("Non Heap", getNonHeapMemory());
- attributes.put("System Load Average", getSystemLoadAverage());
- attributes.put("Loaded Classes", getLoadedClasses());
- attributes.put("Start Time", getStartTime());
- attributes.put("Threads", getThreads());
+ attributes.put("System Date", formatDateTime(new Date(system.now())));
+ attributes.put("Start Time", formatDateTime(new Date(runtimeMXBean().getStartTime())));
+ attributes.put("JVM Vendor", runtimeMXBean().getVmVendor());
+ attributes.put("JVM Name", runtimeMXBean().getVmName());
+ attributes.put("JVM Version", runtimeMXBean().getVmVersion());
+ attributes.put("Processors", runtime().availableProcessors());
+ attributes.put("System Classpath", runtimeMXBean().getClassPath());
+ attributes.put("BootClassPath", runtimeMXBean().getBootClassPath());
+ attributes.put("Library Path", runtimeMXBean().getLibraryPath());
+ attributes.put("Total Memory", formatMemory(runtime().totalMemory()));
+ attributes.put("Free Memory", formatMemory(runtime().freeMemory()));
+ attributes.put("Max Memory", formatMemory(runtime().maxMemory()));
+ attributes.put("Heap", memoryMXBean().getHeapMemoryUsage().toString());
+ attributes.put("Non Heap", memoryMXBean().getNonHeapMemoryUsage().toString());
+ attributes.put("System Load Average", String.format("%.1f%% (last minute)", ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage() * 100.0));
+ attributes.put("Loaded Classes", classLoadingMXBean().getLoadedClassCount());
+ attributes.put("Total Loaded Classes", classLoadingMXBean().getTotalLoadedClassCount());
+ attributes.put("Unloaded Classes", classLoadingMXBean().getUnloadedClassCount());
+ attributes.put("Threads", threadMXBean().getThreadCount());
+ attributes.put("Threads Peak", threadMXBean().getPeakThreadCount());
+ attributes.put("Daemon Thread", threadMXBean().getDaemonThreadCount());
return attributes;
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/JvmPropertiesMonitorTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/JvmPropertiesMonitorTest.java
index 208516d7276..332b9b1fe6c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/JvmPropertiesMonitorTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/JvmPropertiesMonitorTest.java
@@ -32,6 +32,6 @@ public class JvmPropertiesMonitorTest {
JvmPropertiesMonitor sut = new JvmPropertiesMonitor();
LinkedHashMap<String, Object> attributes = sut.attributes();
- assertThat(attributes).containsKey("java.vm.vendor");
+ assertThat(attributes).containsKeys("java.vm.vendor", "os.name");
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/SonarQubeMonitorTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/SonarQubeMonitorTest.java
index 6972f98e6e7..cf19f567eba 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/SonarQubeMonitorTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/SonarQubeMonitorTest.java
@@ -41,6 +41,6 @@ public class SonarQubeMonitorTest {
SonarQubeMonitor monitor = new SonarQubeMonitor(settings, new SecurityRealmFactory(settings), server);
LinkedHashMap<String, Object> attributes = monitor.attributes();
- assertThat(attributes).containsKeys("Started at", "Server ID");
+ assertThat(attributes).containsKeys("Server ID", "Version");
}
}
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>