Skip to content

Commit

Permalink
Agent: Pass Agent ID to Heart
Browse files Browse the repository at this point in the history
Issue #3119
PR #3155
  • Loading branch information
cakekoa authored and mssalvatore committed Mar 28, 2023
1 parent 6cf118b commit a14a01c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions monkey/infection_monkey/heart.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
import time

from common.common_consts import HEARTBEAT_INTERVAL
from common.types import AgentID
from common.utils.code_utils import PeriodicCaller
from infection_monkey.island_api_client import IIslandAPIClient
from infection_monkey.utils.ids import get_agent_id

logger = logging.getLogger(__name__)


class Heart:
def __init__(self, island_api_client: IIslandAPIClient):
def __init__(self, island_api_client: IIslandAPIClient, agent_id: AgentID):
self._island_api_client = island_api_client
self._periodic_caller = PeriodicCaller(
self._send_heartbeats, HEARTBEAT_INTERVAL, "AgentHeart"
)
self._agent_id = get_agent_id()
self._agent_id = agent_id

def start(self):
logger.info("Starting the Agent's heart")
Expand Down
2 changes: 1 addition & 1 deletion monkey/infection_monkey/monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(self, args, ipc_logger_queue: multiprocessing.Queue, log_path: Path
self._island_api_client, self._manager
)

self._heart = Heart(self._island_api_client)
self._heart = Heart(self._island_api_client, self._agent_id)
self._heart.start()

self._current_depth = self._opts.depth
Expand Down

0 comments on commit a14a01c

Please sign in to comment.