Skip to content

Commit

Permalink
springboot-actuator监控工程提交
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwujing committed Jan 17, 2019
1 parent 2f7285f commit 8f234e4
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 0 deletions.
48 changes: 48 additions & 0 deletions springboot-actuator/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>1.0.0</groupId>
<artifactId>springboot-actuator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>springboot-actuator</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/>
</parent>

<dependencies>
<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-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>test</scope>
</dependency>
</dependencies>
</project>
42 changes: 42 additions & 0 deletions springboot-actuator/src/main/java/com/pancm/ActuatorApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.pancm;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


/**
*
* @Title: ActuatorApp
* @Description:
启动程序之后,在浏览器输入: http://localhost:8888/monitor 加上
1. /autoconfig 可以得到配置生效信息
2. /configprops 可以得到属性的内容和默认值
3. /beans 可 以得到bean的别名、类型、是否单例、类的地址、依赖等信息
4. /dump 可 以得到线程名、线程ID、线程的状态、是否等待锁资源等信息
5. /env 可以得到环境变量、JVM 属性、命令行参数、项目使用的jar包等信息
5.1 /sun.boot.library.path 可以得到JDK安装路径
6. /health 可以得到磁盘检测和数据库检测等信息
7. /mappings 可以得到全部的URI路径,以及它们和控制器的映射关系
8. /metrics 可以得到JVM内容使用、GC情况、类加载信息
8.1 /gc.* 可以得到GC相关信息
8.2 /mem.* 可以得到内存信息
...
9. /info 可以得到自定义的配置信息
10. /shutdown 可以进行关闭程序 post请求
11. /trace 可以得到所Web请求的详细信息
* @Version:1.0.0
* @author pancm
* @date 2019年1月17日
*/
@SpringBootApplication
public class ActuatorApp
{
public static void main( String[] args )
{
SpringApplication.run(ActuatorApp.class, args);
System.out.println("Actuator启动成功!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.pancm.web;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWorldController {

@RequestMapping("/hello")
public String index(String name) {
return "Hello " + name;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @Title: package-info
* @Description:
* @Version:1.0.0
* @author pancm
* @date 2019年1月17日
*/
package com.pancm.web;
18 changes: 18 additions & 0 deletions springboot-actuator/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server:
port: 8181
management:
security:
enabled: false #关掉安全认证
port: 8888 #管理端口
context-path: /monitor #actuator的访问路径

# 是否允许关闭
endpoints:
shutdown:
enabled: true


info:
app:
name:springboot-actuator
version:1.0
38 changes: 38 additions & 0 deletions springboot-actuator/src/test/java/com/pancm/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.pancm;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}

/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}

/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
10 changes: 10 additions & 0 deletions springboot-actuator/target/classes/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Implementation-Title: springboot-actuator
Implementation-Version: 0.0.1-SNAPSHOT
Built-By: Administrator
Implementation-Vendor-Id: 1.0.0
Build-Jdk: 1.8.0_131
Implementation-URL: http://maven.apache.org
Created-By: Maven Integration for Eclipse
Implementation-Vendor: Pivotal Software, Inc.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Generated by Maven Integration for Eclipse
#Thu Jan 17 16:50:21 CST 2019
version=0.0.1-SNAPSHOT
groupId=1.0.0
m2e.projectName=springboot-actuator
m2e.projectLocation=D\:\\git\\GitHub\\springBoot-study\\springboot-actuator
artifactId=springboot-actuator
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>1.0.0</groupId>
<artifactId>springboot-actuator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>springboot-actuator</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/>
</parent>

<dependencies>
<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-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>test</scope>
</dependency>
</dependencies>
</project>
18 changes: 18 additions & 0 deletions springboot-actuator/target/classes/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server:
port: 8181
management:
security:
enabled: false #关掉安全认证
port: 8888 #管理端口
context-path: /monitor #actuator的访问路径

# 是否允许关闭
endpoints:
shutdown:
enabled: true


info:
app:
name:springboot-actuator
version:1.0

0 comments on commit 8f234e4

Please sign in to comment.