Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/swf_fastmon_agent/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,21 @@ def start_continuous_monitoring(self):
NOTE: Intended for development and testing purposes.
"""
self.logger.info("Starting continuous fast monitoring (DEV MODE)...")


# Connect to ActiveMQ
# TODO: abstract the connection with the message queue (check methods in swf-common-lib)
self.conn.connect(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, now I get it! This part is implemented in the run() of the base agent, that is why it is missing here. Thanks for the catch!
It would be cleaner to abstract the connection with the message queue in a method of the base agent, and use it in both run() and here. We can discuss it with @wenaus.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will address it in a upcoming PR, following the discussion with @buddhasystem

self.mq_user,
self.mq_password,
wait=True,
version='1.1',
headers={
'client-id': self.agent_name,
'heart-beat': '30000,30000' # Send heartbeat every 30sec, expect server every 30sec
}
)
self.mq_connected = True

try:
while True:
tf_files_created = self._emulate_stf_registration_and_sampling()
Expand Down
7 changes: 6 additions & 1 deletion src/swf_fastmon_client/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import json
import time
import signal
import logging
from datetime import datetime
from typing import Optional, Dict, Any
from pathlib import Path
Expand All @@ -28,6 +29,10 @@ def __init__(self, monitor_base_url=None, api_token=None):
"""Initialize the fast monitoring client."""
# Setup environment variables from ~/.env file if present
self._setup_environment()

self.logger = logging.getLogger(__name__)
#TODO: add a command-line option to specify the log level
self.logger.setLevel(logging.DEBUG)

# Monitor configuration
self.monitor_base_url = monitor_base_url or os.getenv('SWF_MONITOR_URL', 'http://localhost:8002').rstrip('/')
Expand Down Expand Up @@ -344,7 +349,7 @@ def start_monitoring(self, msg_types=None, agents=None):

@app.command()
def start(
monitor_url: str = typer.Option("http://localhost:8002", "--monitor-url", "-m", help="Monitor base URL"),
monitor_url: Optional[str] = typer.Option(None, "--monitor-url", "-m", help="Monitor base URL (Overwrites SWF_MONITOR_URL)"),
api_token: Optional[str] = typer.Option(None, "--api-token", "-t", help="API token for authentication"),
message_types: Optional[str] = typer.Option(None, "--message-types", help="Filter by message types (comma-separated)"),
agents: Optional[str] = typer.Option(None, "--agents", help="Filter by agent names (comma-separated)")
Expand Down