From 89ce732f85ca730fc949e5dacd4af469878d6976 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sat, 12 Sep 2020 22:11:21 +0000 Subject: [PATCH] periodically update system info --- _modules/win_agent.py | 4 ++++ api/tacticalrmm/agents/tasks.py | 15 +++++++++++++++ api/tacticalrmm/tacticalrmm/celery.py | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/_modules/win_agent.py b/_modules/win_agent.py index c43cbc79..e2a4e187 100644 --- a/_modules/win_agent.py +++ b/_modules/win_agent.py @@ -252,6 +252,10 @@ def system_info(): } +def local_sys_info(): + return __salt__["cmd.run_bg"]([TAC_RMM, "-m", "sysinfo"]) + + def get_procs(): ret = [] diff --git a/api/tacticalrmm/agents/tasks.py b/api/tacticalrmm/agents/tasks.py index 301df752..1d611775 100644 --- a/api/tacticalrmm/agents/tasks.py +++ b/api/tacticalrmm/agents/tasks.py @@ -96,6 +96,21 @@ def batch_sync_modules_task(): sleep(10) +@app.task +def batch_sysinfo_task(): + # update system info using WMI + agents = Agent.objects.all() + online = [ + i.salt_id + for i in agents + if not i.not_supported("0.11.0") and i.status == "online" + ] + chunks = (online[i : i + 30] for i in range(0, len(online), 30)) + for chunk in chunks: + Agent.salt_batch_async(minions=chunk, func="win_agent.local_sys_info") + sleep(10) + + @app.task def uninstall_agent_task(salt_id): attempts = 0 diff --git a/api/tacticalrmm/tacticalrmm/celery.py b/api/tacticalrmm/tacticalrmm/celery.py index e2148cd3..f8f1eb57 100644 --- a/api/tacticalrmm/tacticalrmm/celery.py +++ b/api/tacticalrmm/tacticalrmm/celery.py @@ -37,6 +37,10 @@ app.conf.beat_schedule = { "task": "agents.tasks.batch_sync_modules_task", "schedule": crontab(minute=40, hour="*/4"), }, + "sys-info": { + "task": "agents.tasks.batch_sysinfo_task", + "schedule": crontab(minute=15, hour="*/2"), + }, }