Skip to content

Commit

Permalink
Merge pull request #138 from aviate-labs/main
Browse files Browse the repository at this point in the history
Merge branch 'main' into release
  • Loading branch information
louisevelayo authored Aug 29, 2024
2 parents 673047d + 57cb216 commit d45c7b5
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions node_monitor/node_monitor_helpers/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,17 @@ def nodes_compromised_message(nodes: List[ic_api.Node],
def _make_subject() -> str:
datacenters = {node.dc_id.upper() for node in nodes_compromised}
match len(nodes_compromised):
case 0: return "All Systems Healthy"
case _: return "Action Required @ " + ', '.join(sorted(datacenters))
case 0: return "🟒 All Systems Healthy"
case _: return "🟑 Action Required @ " + ', '.join(sorted(datacenters))
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
formatted_nodes_compromised = detailnodes(nodes, labels)
subject = _make_subject()
message = (
f"πŸ›‘ Node(s) Compromised:\n"
f"Node(s) Compromised:\n"
f"\n"
f"{formatted_nodes_compromised}\n"
f"\n"
f"Node Monitor by Aviate Labs\n"
f"Report Generated: {datetime_iso8601()} UTC\n"
f"Help us serve you better! Provide your feedback here: {c.FEEDBACK_FORM_URL}")
f"Report Generated: {datetime_iso8601()} UTC\n")
return (subject, message)


Expand All @@ -102,34 +100,27 @@ def nodes_status_message(nodes: List[ic_api.Node],
def _make_diagnostic_message() -> str:
match len(nodes_down):
case 0: return ""
case _: return (f"πŸ›‘ Node(s) Compromised:\n"
case _: return (f"Node(s) Compromised:\n"
f"\n"
f"{detailnodes(nodes_down, labels)}\n\n")
def _make_subject() -> str:
datacenters = {node.dc_id.upper() for node in nodes_down}
match len(nodes_down):
case 0: return "All Systems Healthy"
case _: return "Action Required @ " + ', '.join(sorted(datacenters))
case 0: return "🟒 All Systems Healthy"
case _: return "🟑 Action Required @ " + ', '.join(sorted(datacenters))
def _render_frac(numerator: int, denominator: int) -> str:
match numerator:
case 0: return "None"
case _: return f"{numerator}/{denominator}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
subject = _make_subject()
message = (
f"\nNode Provider: {nodes[0].node_provider_name}\n"
f"Nodes Total: {total_nodes}\n"
f"Node Health: {len(nodes_degraded) + len(nodes_down)} Unhealthy, {len(nodes_unassigned) + len(nodes_up)} Healthy\n"
f"Node Assignment: {len(nodes_unassigned)} Unassigned, {len(nodes_up)} Assigned\n"
f"\n\n"
f"{_make_diagnostic_message()}"
f"πŸ”Ž Node Status Breakdown:\n"
f"Nodes Up: { _render_frac(len(nodes_up ), total_nodes) }\n"
f"Nodes Down: { _render_frac(len(nodes_down), total_nodes) }\n"
f"Nodes Unassigned: { _render_frac(len(nodes_unassigned), total_nodes) }\n"
f"Nodes Disabled: { _render_frac(len(nodes_disabled), total_nodes) }\n"
f"Nodes Degraded: { _render_frac(len(nodes_degraded), total_nodes) }\n"
f"\n"
f"Total Nodes: {total_nodes}\n"
f"Node Provider: {nodes[0].node_provider_name}\n"
f"\n"
f"Thanks for reviewing today's report. We'll be back tomorrow!\n"
f"Node Monitor by Aviate Labs.\n"
f"Report generated: {datetime_iso8601()} UTC\n"
f"Help us serve you better! Provide your feedback here: {c.FEEDBACK_FORM_URL}")
)
return (subject, message)

0 comments on commit d45c7b5

Please sign in to comment.