mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2025-06-03 11:57:56 +08:00
Compare commits
5 Commits
833e97a89d
...
c9b866885a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c9b866885a | ||
![]() |
f496f12fe3 | ||
![]() |
6e6ce666b8 | ||
![]() |
f82e9e5f0a | ||
![]() |
26e4990f0a |
@ -25,6 +25,10 @@
|
||||
<groupId>top.wu2020</groupId>
|
||||
<artifactId>wu-framework-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -6,10 +6,11 @@ RUN echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
|
||||
ENV APP_JAR_NAME=$APP_NAME \
|
||||
JAVA_OPTS="-Xms512m -Xmx1024m -Djava.security.egd=file:/dev/./urandom" \
|
||||
JAVA_OPTS="-Xms512m -Xmx1024m -XX:+UseContainerSupport -XX:InitialRAMPercentage=50.0 -XX:MaxRAMPercentage=80.0 -Djava.security.egd=file:/dev/./urandom" \
|
||||
PARAMS=""
|
||||
|
||||
|
||||
#UseContainerSupport:启用容器感知内存和 CPU 限制。
|
||||
#InitialRAMPercentage/MaxRAMPercentage:自动计算 JVM 堆内存上限,避免 OOM。
|
||||
COPY target/*.jar /app.jar
|
||||
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client;
|
||||
|
||||
import io.micrometer.core.instrument.Tags;
|
||||
import io.micrometer.core.instrument.binder.system.FileDescriptorMetrics;
|
||||
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
|
||||
import io.micrometer.core.instrument.binder.system.UptimeMetrics;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties;
|
||||
import org.springframework.boot.actuate.metrics.system.DiskSpaceMetricsBinder;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@Import({MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class})
|
||||
public class MetricsConfig {
|
||||
|
||||
// fix cgroup2fs环境
|
||||
@Bean
|
||||
public UptimeMetrics uptimeMetrics() {
|
||||
try {
|
||||
return new UptimeMetrics();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to initialize UptimeMetrics: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Bean
|
||||
public ProcessorMetrics processorMetrics() {
|
||||
try {
|
||||
return new ProcessorMetrics();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to initialize ProcessorMetrics: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Bean
|
||||
public FileDescriptorMetrics fileDescriptorMetrics(){
|
||||
try {
|
||||
return new FileDescriptorMetrics();
|
||||
}catch (Exception e){
|
||||
System.err.println("Failed to initialize FileDescriptorMetrics: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Bean
|
||||
public DiskSpaceMetricsBinder diskSpaceMetrics(MetricsProperties properties) {
|
||||
try {
|
||||
List<File> paths = properties.getSystem().getDiskspace().getPaths();
|
||||
return new DiskSpaceMetricsBinder(paths, Tags.empty());
|
||||
}catch (Exception e){
|
||||
System.err.println("Failed to initialize DiskSpaceMetricsBinder: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user