私はSpring Boot Actuator Metricsの新しいユーザーです。システムのCPU使用率を判断する必要があります。/metrics URLは詳細を残しますが、systemload.averageは-1を返します(負荷平均が利用できない場合は-1が返されます)。どこが間違っているのか教えてください。どうすれば修正できますか? 私はMavenとEclipse IDE(Mars)を使用しています。私はローカルホスト自体のメトリックの詳細にアクセスしています。 URLはhttp://localhost:8080/details/metricsJava Spring Boot Actuatorメトリクスシステムの負荷平均が戻る-1
ここは私のコードである(詳細はコンテキストパスに使用される): 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=true
[コード](https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/) SystemPublicMetrics.java#L97)がJMXを使用しています。あなたはVisualVMで返されるものを見てみることができますか? –
@WimDeblauweはアドバイスをしてくれてありがとう、それは私にJMXについてもう少し明快さを与えた。私は今VisualVMを使用しています(初めて)、JMX Cient Heartbeat 10スレッドがスリープ状態にあるのに対し、待機状態でJMXサーバー接続タイムアウト221としてスレッドを表示します。 –
'VisualVM-MBeans'プラグインをインストールする必要があります。その後、新しいタブ「MBeans」が追加されます。ここで、 'java.lang'フォルダを開き、ツリー内のOperatingSystemを選択します。右側に、表の「SystemLoadAverage」が表示されます。 –