Agent: Simplify logic for sending logs in ControlClient

This commit is contained in:
Shreya Malviya 2022-09-28 17:44:28 +05:30 committed by Mike Salvatore
parent 8e3918cebe
commit 29c08ff40c
1 changed files with 4 additions and 2 deletions

View File

@ -13,6 +13,7 @@ from infection_monkey.config import GUID
from infection_monkey.island_api_client import IIslandAPIClient from infection_monkey.island_api_client import IIslandAPIClient
from infection_monkey.network.info import get_host_subnets from infection_monkey.network.info import get_host_subnets
from infection_monkey.utils import agent_process from infection_monkey.utils import agent_process
from infection_monkey.utils.ids import get_agent_id
disable_warnings() # noqa DUO131 disable_warnings() # noqa DUO131
@ -70,8 +71,9 @@ class ControlClient:
def send_log(self, log): def send_log(self, log):
try: try:
telemetry = {"monkey_guid": GUID, "log": json.dumps(log)} monkey_guid = get_agent_id()
self._island_api_client.send_log(GUID, json.dumps(telemetry)) log_contents = json.dumps(log)
self._island_api_client.send_log(monkey_guid, log_contents)
except Exception as exc: except Exception as exc:
logger.warning(f"Error connecting to control server {self.server_address}: {exc}") logger.warning(f"Error connecting to control server {self.server_address}: {exc}")