2016-09-23 7 views
0

私は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 

enter image description here

+0

[コード](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で返されるものを見てみることができますか? –

+0

@WimDeblauweはアドバイスをしてくれてありがとう、それは私にJMXについてもう少し明快さを与えた。私は今VisualVMを使用しています(初めて)、JMX Cient Heartbeat 10スレッドがスリープ状態にあるのに対し、待機状態でJMXサーバー接続タイムアウト221としてスレッドを表示します。 –

+0

'VisualVM-MBeans'プラグインをインストールする必要があります。その後、新しいタブ「MBeans」が追加されます。ここで、 'java.lang'フォルダを開き、ツリー内のOperatingSystemを選択します。右側に、表の「SystemLoadAverage」が表示されます。 –

答えて

0

systemload.average JVMがOperatingSystem MBeanから返すものを返します(java.langツリーノードで利用可能)。返されたものを表示するには、VisualVMのJConsoleまたはVisualVM-Beansプラグインを使用してください。

SystemLoadAverage属性の値が同じ場合は、Spring BootまたはSpring Bootの使用時にバグは発生しません。

+0

@WimDeleauve私の最初の目標はシステムの平均負荷を見つけることになるので、-1を取得する代わりに、Springブート・アクチュエータを使用してsystemload.averageを見つける代替手段はありますか? ?または何か変更を加えることができますか? –

+0

実行中のオペレーティングシステムは? –

+0

Windows 7 Enterprise Edition –

関連する問題