Java Spring Boot Actuator Metrics系统负载平均值返回-1

时间:2016-09-23 06:32:23

标签: java spring spring-boot spring-boot-actuator

我是Spring Boot Actuator Metrics的新用户,我需要确定系统的CPU利用率。 / metrics url确实给了我其余的细节,但是systemload.average返回-1(如果加载平均值不可用,则返回-1)。你能让我知道我哪里出错了吗?我该怎么纠正它? 我正在使用maven和Eclipse IDE(Mars)。我正在访问localhost本身的度量标准详细信息。网址为http://localhost:8080/details/metrics(用于上下文路径的详细信息)

这是我的代码: Application.java文件     package 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=true

enter image description here

1 个答案:

答案 0 :(得分:0)

systemload.average返回JVM通过OperatingSystem MBean返回的内容(在java.lang树节点中可用)。在VisualVM中使用JConsole或VisualVM-Beans插件来查看返回的内容。

如果SystemLoadAverage属性的值相同,则Spring Boot中没有错误或使用Spring Boot。