add wmi task

This commit is contained in:
wh1te909 2021-01-16 10:31:00 +00:00
parent 3af4c329aa
commit 188bad061b
2 changed files with 21 additions and 0 deletions

View File

@ -133,6 +133,23 @@ def auto_self_agent_update_task() -> None:
agent_update(pk) agent_update(pk)
@app.task
def get_wmi_task():
agents = Agent.objects.all()
online = [
i
for i in agents
if pyver.parse(i.version) >= pyver.parse("1.2.0") and i.status == "online"
]
chunks = (online[i : i + 50] for i in range(0, len(online), 50))
for chunk in chunks:
for agent in chunk:
asyncio.run(agent.nats_cmd({"func": "wmi"}, wait=False))
sleep(0.1)
rand = random.randint(3, 7)
sleep(rand)
@app.task @app.task
def sync_sysinfo_task(): def sync_sysinfo_task():
agents = Agent.objects.all() agents = Agent.objects.all()

View File

@ -45,6 +45,10 @@ app.conf.beat_schedule = {
"task": "agents.tasks.sync_sysinfo_task", "task": "agents.tasks.sync_sysinfo_task",
"schedule": crontab(minute=55, hour="*"), "schedule": crontab(minute=55, hour="*"),
}, },
"get-wmi": {
"task": "agents.tasks.get_wmi_task",
"schedule": crontab(minute="*/18"),
},
"check-agentservice": { "check-agentservice": {
"task": "agents.tasks.monitor_agents_task", "task": "agents.tasks.monitor_agents_task",
"schedule": crontab(minute="*/15"), "schedule": crontab(minute="*/15"),