Java Spring Boot Actuator Metrics 系统负载平均返回 -1 [英] Java Spring Boot Actuator Metrics system load average returning -1
问题描述
我是 Spring Boot Actuator Metrics 的新用户,我需要确定系统的 CPU 利用率./metrics url 确实给了我其余的细节,但是 systemload.average 返回 -1(如果平均负载不可用,则返回 -1).你能告诉我我哪里出错了,我该如何纠正?我正在使用 maven 和 Eclipse IDE (Mars).我正在访问本地主机本身的指标详细信息.url 是 http://localhost:8080/details/metrics(用于上下文路径的详细信息)>
这是我的代码:应用程序.java文件包 spring.boot.admin.actuator;
import org.springframework.boot.SpringApplication;导入 org.springframework.boot.autoconfigure.EnableAutoConfiguration;导入 org.springframework.context.annotation.ComponentScan;导入 org.springframework.context.annotation.PropertySource;@EnableAutoConfiguration@ComponentScan@PropertySource(value = "classpath:application.properties")公共类应用{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
spring.boot.admin <artifactId>执行器</artifactId><version>0.0.1-SNAPSHOT</version><包装>罐</包装><name>执行器</name><url>http://maven.apache.org</url><属性><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></属性><父母><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.3.7.RELEASE</version></父母><依赖项><依赖><groupId>junit</groupId><artifactId>junit</artifactId><version>3.8.1</version><范围>测试</范围></依赖><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></依赖><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></依赖><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></依赖><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></依赖></依赖项></项目>**application.properties 文件**管理端口=8080management.context-path=/detailsmanagement.security.enabled=trueendpoints.health.enabled=falsesecurity.basic.enabled=truesecurity.user.name=adminsecurity.user.password=adminendpoints.health.id=healthendpoints.health.sensitive=trueendpoints.health.enabled=trueendpoints.metrics.id=metricsendpoints.metrics.sensitive=trueendpoints.metrics.enabled=trueendpoints.server.id=服务器endpoints.server.sensitive=falseendpoints.server.enabled=trueendpoints.info.id=信息endpoints.info.sensitive=falseendpoints.info.enabled=trueinfo.app.name=弹簧执行器示例info.app.description=弹簧执行器工作示例info.app.version=0.0.1-快照management.security.enabled=true
systemload.average
返回 JVM 通过 OperatingSystem MBean 返回的内容(可在 java.lang
树节点).使用 JConsole 或 VisualVM 中的 VisualVM-Beans 插件查看那里返回的内容.
如果 SystemLoadAverage
属性的值相同,则说明 Spring Boot 或您使用 Spring Boot 没有问题.
I am a new user to Spring Boot Actuator Metrics, I need to determine the CPU utilization of the system. The /metrics url does give me rest of the details, however the systemload.average returns -1 (if load average is not available -1 is returned). Could you let me know where I went wrong and how do I correct it? I am using maven and Eclipse IDE (Mars). I am accessing metric details on localhost itself. the url is http://localhost:8080/details/metrics (details used for context path)
Here is my code: Application.java file 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 File 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
The enter image description here
The systemload.average
returns what the JVM returns through the OperatingSystem MBean (Available in the java.lang
tree node). Use JConsole or the VisualVM-Beans plugin in VisualVM to view what is returned there.
If the value of the SystemLoadAverage
attribute is the same, it is no bug in Spring Boot or your usage of Spring Boot.
这篇关于Java Spring Boot Actuator Metrics 系统负载平均返回 -1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!