correction ntfy send
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user