首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java Spring Boot执行器指标系统平均负载返回-1

Java Spring Boot执行器指标系统平均负载返回-1
EN

Stack Overflow用户
提问于 2016-09-23 14:32:23
回答 1查看 2.3K关注 0票数 0

我是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;

代码语言:javascript
复制
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

代码语言:javascript
复制
  <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

The enter image description here

EN

回答 1

Stack Overflow用户

发布于 2016-09-23 19:25:06

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

如果SystemLoadAverage属性的值是相同的,那么这不是Spring Boot中的bug,也不是您对Spring Boot的使用。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39654056

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档