我是Spring Boot Actuator Metrics的新用户,我需要确定系统的CPU利用率。/metrics url确实提供了其余的详细信息,但是systemload.average返回-1 (如果平均负载不可用,则返回1)。你能告诉我我哪里出错了吗?我该怎么改正呢?我使用的是maven和Eclipse IDE (Mars)。我正在访问本地主机本身的指标详细信息。url为http://localhost:8080/details/metrics (用于上下文路径的详细信息)
这是我的代码: Application.java文件包spring.boot.admin.actuator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;
@EnableAutoConfiguration
@ComponentScan
@PropertySource(value = "classpath:application.properties")
public class Application{
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}POM文件">http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<groupId>spring.boot.admin</groupId>
<artifactId>actuator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>actuator</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.7.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
</project>
**application.properties file**
management.port=8080
management.context-path=/details
management.security.enabled=true
endpoints.health.enabled=false
security.basic.enabled=true
security.user.name=admin
security.user.password=admin
endpoints.health.id=health
endpoints.health.sensitive=true
endpoints.health.enabled=true
endpoints.metrics.id=metrics
endpoints.metrics.sensitive=true
endpoints.metrics.enabled=true
endpoints.server.id=server
endpoints.server.sensitive=false
endpoints.server.enabled=true
endpoints.info.id=info
endpoints.info.sensitive=false
endpoints.info.enabled=true
info.app.name=Spring Actuator Example
info.app.description=Spring Actuator Working Examples
info.app.version=0.0.1-SNAPSHOT
management.security.enabled=trueThe enter image description here
发布于 2016-09-23 19:25:06
systemload.average通过OperatingSystem MBean (在java.lang树节点中提供)返回JVM返回的内容。使用JConsole或VisualVM中的VisualVM-Beans插件查看返回的内容。
如果SystemLoadAverage属性的值是相同的,那么这不是Spring Boot中的bug,也不是您对Spring Boot的使用。
https://stackoverflow.com/questions/39654056
复制相似问题