mirror of
https://forgejo.altau.su/lego/lego-monitoring.git
synced 2026-03-10 04:41:10 +00:00
network monitoring
This commit is contained in:
parent
8af7b683b6
commit
8b18d407d7
21 changed files with 434 additions and 53 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from dataclasses import dataclass
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
|
||||
from .enum import AlertType, Severity
|
||||
|
||||
|
|
@ -8,3 +9,4 @@ class Alert:
|
|||
alert_type: AlertType
|
||||
message: str
|
||||
severity: Severity
|
||||
created: datetime = field(default_factory=datetime.now)
|
||||
|
|
|
|||
|
|
@ -3,13 +3,16 @@ from enum import IntEnum, StrEnum
|
|||
|
||||
class AlertType(StrEnum):
|
||||
BOOT = "BOOT"
|
||||
CPU = "CPU"
|
||||
ERROR = "ERROR"
|
||||
TEST = "TEST"
|
||||
REMIND = "REMIND"
|
||||
|
||||
CPU = "CPU"
|
||||
NET = "NET"
|
||||
RAM = "RAM"
|
||||
TEMP = "TEMP"
|
||||
TEST = "TEST"
|
||||
|
||||
VULN = "VULN"
|
||||
REMIND = "REMIND"
|
||||
# LOGIN = "LOGIN"
|
||||
# SMART = "SMART" # TODO
|
||||
# RAID = "RAID"
|
||||
|
|
|
|||
|
|
@ -18,8 +18,12 @@ async def get_client() -> TelegramClient:
|
|||
|
||||
def format_message(alert: Alert, note: str) -> str:
|
||||
severity_emoji = SEVERITY_TO_EMOJI[alert.severity]
|
||||
note_formatted = f" - <i>{note}</i>" if note else ""
|
||||
message = f"{severity_emoji} {alert.alert_type} Alert{note_formatted}\n{alert.message}"
|
||||
note_formatted = f"{note}, " if note else ""
|
||||
if "ongoing" in note_formatted:
|
||||
note_formatted += f"since {alert.created.isoformat()}"
|
||||
else:
|
||||
note_formatted += f"at {alert.created.isoformat()}"
|
||||
message = f"{severity_emoji} {alert.alert_type} Alert - <i>{note_formatted}</i>\n{alert.message}"
|
||||
return message
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue