Mise en place d'un journal de connexions

This commit is contained in:
2026-04-21 17:14:16 +02:00
parent b00879cdfa
commit 272ad6d80a
6 changed files with 250 additions and 23 deletions

View File

@@ -391,15 +391,22 @@ def depassement_depuis_30min(site: str, sonde: str, seuil: float) -> bool:
# ========= Synology Chat =========
def send_synology_chat(message: str, *, username: str | None = None) -> bool:
webhook = (
_env_str(f"SYNO_CHAT_WEBHOOK_MONITOR_{SITE}") or
_env_str(f"SYNO_CHAT_WEBHOOK_MONITOR_{SITE.upper()}") or
_env_str("SYNO_CHAT_WEBHOOK_MONITOR") or
_env_str(f"SYNO_CHAT_WEBHOOK_{SITE}") or
_env_str(f"SYNO_CHAT_WEBHOOK_MONITOR") or
_env_str(f"SYNO_CHAT_WEBHOOK_{SITE.upper()}") or
_env_str("SYNO_CHAT_WEBHOOK")
)
if not webhook:
log.info("Synology Chat non configuré.")
return False
botname = username or _env_str("SYNO_CHAT_BOTNAME")
botname = (
username
or _env_str("SYNO_CHAT_BOTNAME_MONITOR")
or _env_str("SYNO_CHAT_BOTNAME")
)
timeout = int(_env_str("SYNO_CHAT_TIMEOUT", "10"))
verify_ssl = _env_bool("SYNO_CHAT_VERIFY_SSL", True)
@@ -407,7 +414,9 @@ def send_synology_chat(message: str, *, username: str | None = None) -> bool:
if botname:
chat_payload["username"] = botname
form_data = {"payload": json.dumps(chat_payload, ensure_ascii=False)}
form_data = {
"payload": json.dumps(chat_payload, ensure_ascii=False)
}
try:
response = requests.post(