From cf2d4ce83c66489f094cb95243279e241b8c8afa Mon Sep 17 00:00:00 2001 From: wenweihuang Date: Tue, 6 Aug 2024 09:55:49 +0800 Subject: [PATCH] [INLONG-10751][Agent] Report Agent process status for backend problem analysis --- .../java/org/apache/inlong/agent/store/InstanceStore.java | 1 - .../org/apache/inlong/agent/core/AgentStatusManager.java | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/store/InstanceStore.java b/inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/store/InstanceStore.java index cacca39f59a..476d014e570 100644 --- a/inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/store/InstanceStore.java +++ b/inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/store/InstanceStore.java @@ -60,7 +60,6 @@ public int getRunningInstanceCount() { int count = 0; for (KeyValueEntity entity : result) { if (entity.getAsInstanceProfile().getState() == InstanceStateEnum.DEFAULT) { - LOGGER.info("test123 {}", entity.getAsInstanceProfile().getInstanceId()); count++; } } diff --git a/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentStatusManager.java b/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentStatusManager.java index 11210c532ec..3f7756ddcf3 100644 --- a/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentStatusManager.java +++ b/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentStatusManager.java @@ -83,6 +83,8 @@ public class AgentStatusManager { public static AtomicLong sendPackageCount = new AtomicLong(); private DefaultMessageSender sender; private List statusFieldsPre = Lists.newArrayList(); + private String processStartupTime = format.format(runtimeMXBean.getStartTime()); + private String systemStartupTime = ExcuteLinux.exeCmd("who -b|awk '{print $(NF-1), $NF}'").replaceAll("\r|\n", ""); private AgentStatusManager(AgentManager agentManager) { this.agentManager = agentManager; @@ -201,7 +203,7 @@ public List getStatusMessage() { fields.add(conf.get(AGENT_CLUSTER_NAME)); fields.add(conf.get(AGENT_CLUSTER_TAG)); fields.add(TaskManager.class.getPackage().getImplementationVersion()); - fields.add(format.format(runtimeMXBean.getStartTime())); + fields.add(processStartupTime); fields.add(String.valueOf(runtime.availableProcessors())); fields.add(String.valueOf(twoDecimal(getProcessCpu()))); fields.add(String.valueOf(twoDecimal((double) runtime.freeMemory() / GB))); @@ -220,7 +222,7 @@ public List getStatusMessage() { fields.add(agentManager.getTaskManager().getTaskResultMd5()); fields.add(String.valueOf(agentManager.getTaskManager().getTaskStore().getTasks().size())); fields.add(String.valueOf(OffsetManager.getInstance().getRunningInstanceCount())); - fields.add(ExcuteLinux.exeCmd("who -b|awk '{print $(NF-1), $NF}'").replaceAll("\r|\n", "")); + fields.add(systemStartupTime); fields.add(String.valueOf(sendPackageCount.getAndSet(0))); fields.add(String.valueOf(sendDataLen.getAndSet(0))); fields.add(String.valueOf(MemoryManager.getInstance().getLeft(AGENT_GLOBAL_READER_SOURCE_PERMIT)));