alibaba/Sentinel

(系统自适应保护)基于load的保护为什么没有support container?

Open

#2,165 opened on Apr 26, 2021

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Java (8,150 forks)batch import
area/metricshelp wanted

Repository metrics

Stars
 (23,109 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

SystemStatusListener.java

我们看到cpu usage是support container的,为什么system load average没有support container呢? 多谢!!!

BTW, Google Cadvisor里面可以拿到container的system load average信息: container_cpu_load_average_10s (https://github.com/google/cadvisor/blob/master/docs/storage/prometheus.md)

@Override
    public void run() {
        try {
            OperatingSystemMXBean osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
            currentLoad = osBean.getSystemLoadAverage();

            /*
             * Java Doc copied from {@link OperatingSystemMXBean#getSystemCpuLoad()}:</br>
             * Returns the "recent cpu usage" for the whole system. This value is a double in the [0.0,1.0] interval.
             * A value of 0.0 means that all CPUs were idle during the recent period of time observed, while a value
             * of 1.0 means that all CPUs were actively running 100% of the time during the recent period being
             * observed. All values between 0.0 and 1.0 are possible depending of the activities going on in the
             * system. If the system recent cpu usage is not available, the method returns a negative value.
             */
            double systemCpuUsage = osBean.getSystemCpuLoad();

            // calculate process cpu usage to support application running in container environment
            RuntimeMXBean runtimeBean = ManagementFactory.getPlatformMXBean(RuntimeMXBean.class);
            

Contributor guide