private double tryGetProcessCpu() {
        long[] startThreads = threadBean.getAllThreadIds();
        long startTime = System.nanoTime();
        long startUseTime = 0;
        long temp;
        for (long id : startThreads) {
            temp = threadBean.getThreadCpuTime(id);
            if (temp >= 0) {
                startUseTime += temp;
            } else {
                return INVALID_CPU;
            }
        }
        AgentUtils.silenceSleepInMs(5000);
        long[] endThreads = threadBean.getAllThreadIds();
        long endTime = System.nanoTime();
        long endUseTime = 0;
        for (long id : endThreads) {
            temp = threadBean.getThreadCpuTime(id);
            if (temp >= 0) {
                endUseTime += temp;
            } else {
                return INVALID_CPU;
            }
        }
        long usedTime = endUseTime - startUseTime;
        long totalPassedTime = endTime - startTime;
        return (((double) usedTime) / totalPassedTime) * 100;
    }
Collect various indicators of agent processes for backend problem analysis
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentStatusManager.java