From f9cd5557c5dbb1292cb6895d3da47d54af65b40d Mon Sep 17 00:00:00 2001
From: xuezhixin <xuezhixin@uniontech.com>
Date: Fri, 10 Nov 2023 15:15:58 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A3=80=E6=B5=8B=E7=B3=BB?=
 =?UTF-8?q?=E7=BB=9F=E5=9F=BA=E6=9C=AC=E4=BF=A1=E6=81=AF=E5=B9=B6=E4=B8=8A?=
 =?UTF-8?q?=E4=BC=A0=E5=88=B0=E6=95=B0=E6=8D=AE=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 sysmig_agent/short_task.py | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/sysmig_agent/short_task.py b/sysmig_agent/short_task.py
index 23d461b..11dd9ef 100644
--- a/sysmig_agent/short_task.py
+++ b/sysmig_agent/short_task.py
@@ -103,3 +103,38 @@ def check_kernel(data):
     sql_task_statue(statue, task_id)
     post_server('task_close', task_id)
     return 's'
+
+
+
+def check_info(data):
+    task_id = json.loads(data).get('task_id')
+    # 更新SQL任务状态
+    statue = 1
+    sql_task_statue(statue, task_id)
+    # 发送消息给Server更新任务流状态
+    post_server('task_start', task_id)
+    # 获取agent系统类型
+    agent_os = get_agent_os()
+    # agent storage
+    agent_storage = os_storage()
+    agent_ip = get_local_ip()
+    sql = "UPDATE agent_info SET hostname = '{}', agent_os ='{}', agent_arch = '{}' ,agent_storage = {} ," \
+          "agent_online_status = {} WHERE agent_ip = '{}';".format(platform.node(), agent_os, platform.machine(),
+                                                                   agent_storage, 0, agent_ip)
+    try:
+        DBHelper().execute(sql)
+        statue = 2
+    except:
+        statue = 3
+        sql_task_statue(statue, task_id)
+    # 更新SQL任务状态
+    sql_task_statue(statue, task_id)
+    post_server('task_close', task_id)
+    return 'success'
+
+def get_agent_os():
+    os_version_ret = platform.dist()
+    version = os_version_ret[1].split('.', -1)
+    AGENT_OS = os_version_ret[0] + version[0]
+    return AGENT_OS
+
-- 
2.20.1

