commit b337e253df18e7a73595b4fc85c7735867ed2611
Author: 冯凯 <371894675@qq.com>
Date: Sun Nov 19 13:46:11 2023 +0800
monitor
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..09bdfea
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,46 @@
+######################################################################
+# Build Tools
+
+.gradle
+/build/
+!gradle/wrapper/gradle-wrapper.jar
+
+target/
+!.mvn/wrapper/maven-wrapper.jar
+
+######################################################################
+# IDE
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### JRebel ###
+rebel.xml
+### NetBeans ###
+nbproject/private/
+build/*
+nbbuild/
+dist/
+nbdist/
+.nb-gradle/
+
+######################################################################
+# Others
+*.log
+*.xml.versionsBackup
+*.swp
+
+!*/build/*.java
+!*/build/*.html
+!*/build/*.xml
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..8a999d3
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,18 @@
+#起始镜像
+FROM anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/openjdk:17-8.6
+#暴露端口号
+EXPOSE 9100
+#挂载目录的位置
+VOLUME /home/logs/dragon-monitor
+#构建复制外部文件到docker
+COPY /target/dragon-monitor.jar /home/app.jar
+#工作目录 exec -it 进入容器内部后的默认的起始目录
+WORKDIR /home
+ENV TIME_ZONE Asia/Shanghai
+#指定东八区
+RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
+
+#启动java 程序
+ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-jar","/home/app.jar"]
+
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..9525481
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,97 @@
+
+
+ com.dragon
+ dragon-visual
+ 3.6.3
+
+ 4.0.0
+
+ dragon-visual-monitor
+
+
+ dragon-visual-monitor监控中心
+
+
+
+
+
+
+ de.codecentric
+ spring-boot-admin-starter-server
+ ${spring-boot-admin.version}
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+
+
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+
+
+
+
+
+ dragon-release
+ dragon-releases
+ http://10.100.1.7:8081/repository/maven-releases/
+
+
+
+
+ dragon-public
+ dragon-maven
+ http://10.100.1.7:8081/repository/maven-public/
+
+
+ public
+ aliyun nexus
+ http://10.100.1.7:8081/repository/maven-releases/
+
+ true
+
+
+
+
+
diff --git a/src/main/java/com/dragon/modules/monitor/DragonMonitorApplication.java b/src/main/java/com/dragon/modules/monitor/DragonMonitorApplication.java
new file mode 100644
index 0000000..41b6ec5
--- /dev/null
+++ b/src/main/java/com/dragon/modules/monitor/DragonMonitorApplication.java
@@ -0,0 +1,18 @@
+package com.dragon.modules.monitor;
+
+import de.codecentric.boot.admin.server.config.EnableAdminServer;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * 监控中心
+ *
+ * @author dragon
+ */
+@EnableAdminServer
+@SpringBootApplication
+public class DragonMonitorApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(DragonMonitorApplication.class, args);
+ }
+}
diff --git a/src/main/java/com/dragon/modules/monitor/config/WebSecurityConfigurer.java b/src/main/java/com/dragon/modules/monitor/config/WebSecurityConfigurer.java
new file mode 100644
index 0000000..a9c8fff
--- /dev/null
+++ b/src/main/java/com/dragon/modules/monitor/config/WebSecurityConfigurer.java
@@ -0,0 +1,48 @@
+package com.dragon.modules.monitor.config;
+
+import de.codecentric.boot.admin.server.config.AdminServerProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.web.SecurityFilterChain;
+import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
+
+/**
+ * 监控权限配置
+ *
+ * @author dragon
+ */
+@EnableWebSecurity
+public class WebSecurityConfigurer {
+ private final String adminContextPath;
+
+ public WebSecurityConfigurer(AdminServerProperties adminServerProperties) {
+ this.adminContextPath = adminServerProperties.getContextPath();
+ }
+
+ @Bean
+ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
+ SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
+ successHandler.setTargetUrlParameter("redirectTo");
+ successHandler.setDefaultTargetUrl(adminContextPath + "/");
+
+ return httpSecurity
+ .headers().frameOptions().disable()
+ .and().authorizeRequests()
+ .antMatchers(adminContextPath + "/assets/**"
+ , adminContextPath + "/login"
+ , adminContextPath + "/actuator/**"
+ , adminContextPath + "/instances/**"
+ ).permitAll()
+ .anyRequest().authenticated()
+ .and()
+ .formLogin().loginPage(adminContextPath + "/login")
+ .successHandler(successHandler).and()
+ .logout().logoutUrl(adminContextPath + "/logout")
+ .and()
+ .httpBasic().and()
+ .csrf()
+ .disable()
+ .build();
+ }
+}
diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt
new file mode 100644
index 0000000..0dd5eee
--- /dev/null
+++ b/src/main/resources/banner.txt
@@ -0,0 +1,2 @@
+Spring Boot Version: ${spring-boot.version}
+Spring Application Name: ${spring.application.name}
diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..582b354
--- /dev/null
+++ b/src/main/resources/bootstrap.yml
@@ -0,0 +1,25 @@
+# Tomcat
+server:
+ port: 9100
+
+# Spring
+spring:
+ application:
+ # 应用名称
+ name: dragon-monitor
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 47.120.38.124:8848
+ config:
+ # 配置中心地址
+ server-addr: 47.120.38.124:8848
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
new file mode 100644
index 0000000..2d87ec7
--- /dev/null
+++ b/src/main/resources/logback.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+ ${log.pattern}
+
+
+
+
+
+ ${log.path}/info.log
+
+
+
+ ${log.path}/info.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ INFO
+
+ ACCEPT
+
+ DENY
+
+
+
+
+ ${log.path}/error.log
+
+
+
+ ${log.path}/error.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ ERROR
+
+ ACCEPT
+
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+