Skip to content

Commit

Permalink
add logging messages to class NodeMonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
mourginakis committed Oct 10, 2023
1 parent 47fe16d commit 5ab6970
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion node_monitor/node_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Deque, List, Dict
from toolz import groupby # type: ignore
import schedule
import logging

import node_monitor.ic_api as ic_api
from node_monitor.bot_email import EmailBot
Expand Down Expand Up @@ -67,6 +68,7 @@ def _resync(self, override_data: ic_api.Nodes | None = None) -> None:
override_data: If provided, this arg will be used instead of
live fetching Nodes from the ic-api. Useful for testing.
"""
logging.info("Resyncing node states from ic-api...")
data = override_data if override_data else ic_api.get_nodes()
self.snapshots.append(data)
self.last_update = time.time()
Expand Down Expand Up @@ -99,6 +101,7 @@ def broadcast_alerts(self) -> None:
email_recipients = self.node_provider_db.get_emails_as_dict()
channels = self.node_provider_db.get_channels_as_dict()
for node_provider_id, nodes in self.actionables.items():
logging.info(f"Broadcasting alerts for {node_provider_id}...")
preferences = subscribers[node_provider_id]
subject = f"Node Down Alert"
msg = messages.nodes_down_message(nodes, node_labels)
Expand Down Expand Up @@ -136,6 +139,7 @@ def broadcast_status_report(self) -> None:
if k in subscribers.keys()}
# - - - - - - - - - - - - - - - - -
for node_provider_id, nodes in reportable_nodes.items():
logging.info(f"Broadcasting status report {node_provider_id}...")
preferences = subscribers[node_provider_id]
subject = f"Node Status Report"
msg = messages.nodes_status_message(nodes, node_labels)
Expand All @@ -158,7 +162,7 @@ def step(self) -> None:
self._analyze()
self.broadcast_alerts()
except Exception as e:
print(f"NodeMonitor.step() failed with error: {e}")
logging.error(f"NodeMonitor.step() failed with error: {e}")


def mainloop(self) -> None:
Expand Down

0 comments on commit 5ab6970

Please sign in to comment.