diff --git a/servers/linux/monitoring/bin/alert-engine.php b/servers/linux/monitoring/bin/alert-engine.php index d1a0658..5bf1062 100755 --- a/servers/linux/monitoring/bin/alert-engine.php +++ b/servers/linux/monitoring/bin/alert-engine.php @@ -77,7 +77,6 @@ function cleanup_dedup_file() { } } - /** * Vérifie si une alerte doit être envoyée (Déduplication) * La clé attendue est : "hostname|app|level|event" @@ -171,26 +170,28 @@ function send_mail($subject, $body) { * Traitement d'une ligne de log */ function process_line($line) { - global $CONFIG, $DEDUP_FILE; +global $CONFIG, $DEDUP_FILE; $data = json_decode($line, true); if (!$data || !isset($data['level'], $data['event'])) return; $level = strtoupper($data['level']); $event = $data['event']; - - if (in_array($level, ['DEBUG', 'INFO', 'NOTICE'])) return; + + // On garde uniquement l'ignore list explicite pour les événements if (in_array($event, ($CONFIG['ALERT_IGNORE_EVENTS'] ?? []))) return; // Déduplication $key = "{$data['host']}|{$data['app']}|{$level}|{$event}"; if (!should_notify_dedup($key)) { - log_debug("alert_suppressed_dedup", "Alerte dédupliquée", ["event=$event", "host={$data['host']}"]); return; } - // Détermination des canaux (Règle spécifique puis défaut) + // Détermination des canaux $channels_str = $CONFIG['RULES'][$event] ?? $CONFIG['DEFAULT_CHANNELS'][$level] ?? ''; + + // Si aucun canal n'est défini pour ce niveau, ALORS on s'arrête if (empty($channels_str)) return; + $channels = explode(',', $channels_str); $title = "{$data['host']} [{$data['app']}] $level $event"; diff --git a/servers/linux/monitoring/conf/alert-engine.conf.php b/servers/linux/monitoring/conf/alert-engine.conf.php index a4d50c2..07d9b46 100644 --- a/servers/linux/monitoring/conf/alert-engine.conf.php +++ b/servers/linux/monitoring/conf/alert-engine.conf.php @@ -49,16 +49,18 @@ return [ 'CRITICAL' => 'ntfy,mail', ], - // --- Tags ntfy (Liste exhaustive par niveau) --- + // --- Tags : Une icône pour chaque état possible --- 'NTFY_TAGS' => [ + 'DEBUG' => 'gear', // ⚙️ 'INFO' => 'information_source', // ℹ️ 'NOTICE' => 'bell', // 🔔 'SUCCESS' => 'white_check_mark', // ✅ 'WARNING' => 'warning', // ⚠️ 'ERROR' => 'rotating_light,warning', // 🚨 'CRITICAL' => 'skull,warning', // 💀 + 'ALERT' => 'ambulance,rotating_light',// 🚑 'EMERGENCY' => 'fire,sos,skull', // 🔥 - 'DEBUG' => 'gear', // ⚙️ + 'AUDIT' => 'mag', // 🔍 ], // --- Règles spécifiques par événement --- diff --git a/servers/linux/monitoring/manifest.txt b/servers/linux/monitoring/manifest.txt index 5da4416..2263344 100644 --- a/servers/linux/monitoring/manifest.txt +++ b/servers/linux/monitoring/manifest.txt @@ -1,4 +1,4 @@ -9ff5d272cdda198132cdfc86be2452952523ff5a7efd5a9c5c821ff177ae6a3b 755 bin/alert-engine.php +5b4ea784d2cbe73f6e829e35f23b0b4dbe12df55cc1abc8eba6602da36c724ef 755 bin/alert-engine.php a8361986d8ead0bedcb0e2a5052c6909b4cdfd2d4ce7f3b0d150e65430697354 755 bin/check_disk.sh 3046c0fb3abdc4e99758cbf9279f4d60d86d815e598851ca362e558891118751 755 bin/install-monitoring.sh 97a91b13b0776acb3326010821ffcc163e96a97e3c326ea77f11efdb7baf159a 755 bin/log-cli.php @@ -6,7 +6,7 @@ ea5a5d55bb877ae88da6e1cd1b798026a1de1d9845dc42af4b19685ad6a128c6 755 bin/monitor 97d407d75a26bd2ebbb86a2e5f8dab8b24639e8a9164f42bd554ba7728ab8cb5 755 bin/monitoring-update-config.php a87b67df995f1ad9878fdb9e3f2000eabbcb9a8854e239f9763f33ec7272e047 755 bin/monitoring-update.php 83db39c8d0cfd6f6e9d3cc5b961a67db29dc73666304a91e0d4a6d5831c623cb 644 conf/alert-engine.conf -3a5598d73c52edeff561685ea7f026d77e9151d7445ab57749862a6da1ce7296 644 conf/alert-engine.conf.php +69fc1e3506aec7ad3e5d9fbc74587ab4e6381f3e6840f3e38c526f4752858bd4 644 conf/alert-engine.conf.php caaa8f6031d66bc43a897ac2804124ce2050a64523734195d5505ae863836bf4 644 conf/monitoring.conf 8c40d1c177a40d47c72ba8aab757ca37faa06e64d5fa80e2ba59d9637f62c59e 644 conf/monitoring.conf.php c3794b4d69c772b87d3a61c2f94a3c8bf504257f7d466ee6ce160cd79766365e 644 lib/monitoring-lib.php