ecriture en PHP
This commit is contained in:
71
servers/linux/monitoring/conf/alert-engine.conf.php
Normal file
71
servers/linux/monitoring/conf/alert-engine.conf.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Configuration Alert Engine
|
||||
* Copyright (C) 2026 Cédric Abonnel
|
||||
* License: GNU Affero General Public License v3
|
||||
* NE PAS ÉDITER - Utilisez alert-engine.local.conf.php pour vos surcharges
|
||||
* RISQUE D'ECRASEMENT - RISQUE D'EFFACEMENT
|
||||
*/
|
||||
|
||||
// On définit les variables de base (équivalent de l'environnement)
|
||||
$monitoring_state_dir = getenv('MONITORING_STATE_DIR') ?: '/var/lib/monitoring';
|
||||
|
||||
return [
|
||||
// --- Fichiers d'état ---
|
||||
'ALERT_STATE_FILE' => $monitoring_state_dir . '/alert-engine.offset',
|
||||
'ALERT_DEDUP_FILE' => $monitoring_state_dir . '/alert-engine.dedup',
|
||||
|
||||
// --- Activation des canaux ---
|
||||
'ALERT_NTFY_ENABLED' => true,
|
||||
'ALERT_MAIL_ENABLED' => true,
|
||||
|
||||
// --- Configuration Mail ---
|
||||
'ALERT_MAIL_BIN' => '/usr/sbin/sendmail',
|
||||
'ALERT_MAIL_SUBJECT_PREFIX' => '[monitoring]',
|
||||
'DEST' => 'admin@example.com', // N'oubliez pas de définir le destinataire
|
||||
|
||||
// --- Configuration ntfy ---
|
||||
'NTFY_SERVER' => 'https://ntfy.sh',
|
||||
'NTFY_TOPIC' => 'TPOSOB84sBJ6HTZ7',
|
||||
'NTFY_TOKEN' => '',
|
||||
'NTFY_CLICK_URL' => '',
|
||||
|
||||
// --- Déduplication ---
|
||||
'ALERT_DEDUP_WINDOW' => 3600, // en secondes
|
||||
|
||||
// --- Événements à ignorer ---
|
||||
'ALERT_IGNORE_EVENTS' => [
|
||||
'update_not_needed',
|
||||
'alert_sent_ntfy',
|
||||
'alert_sent_mail'
|
||||
],
|
||||
|
||||
// --- Canaux par défaut selon le niveau ---
|
||||
'DEFAULT_CHANNELS' => [
|
||||
'WARNING' => 'ntfy',
|
||||
'ERROR' => 'ntfy,mail',
|
||||
'CRITICAL' => 'ntfy,mail',
|
||||
],
|
||||
|
||||
// --- Tags ntfy par niveau ---
|
||||
'NTFY_TAGS' => [
|
||||
'WARNING' => 'warning',
|
||||
'ERROR' => 'warning,rotating_light',
|
||||
'CRITICAL' => 'skull,warning',
|
||||
],
|
||||
|
||||
// --- Règles spécifiques par événement ---
|
||||
// Si un événement est listé ici, il outrepasse les DEFAULT_CHANNELS
|
||||
'RULES' => [
|
||||
'disk_usage_high' => 'ntfy',
|
||||
'disk_usage_critical' => 'ntfy,mail',
|
||||
'check_failed' => 'ntfy,mail',
|
||||
'internal_error' => 'ntfy,mail',
|
||||
'update_hash_unavailable' => 'ntfy',
|
||||
'update_download_failed' => 'ntfy,mail',
|
||||
'update_hash_mismatch' => 'ntfy,mail',
|
||||
'manifest_download_failed' => 'ntfy,mail',
|
||||
'manifest_invalid' => 'ntfy,mail',
|
||||
'update_finished_with_errors' => 'ntfy,mail',
|
||||
],
|
||||
];
|
||||
54
servers/linux/monitoring/conf/monitoring.conf.php
Normal file
54
servers/linux/monitoring/conf/monitoring.conf.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Configuration globale par défaut
|
||||
* Copyright (C) 2026 Cédric Abonnel
|
||||
* License: GNU Affero General Public License v3
|
||||
* NE PAS ÉDITER - Utilisez monitoring.local.conf.php pour vos surcharges
|
||||
* RISQUE D'ECRASEMENT - RISQUE D'EFFACEMENT
|
||||
*/
|
||||
|
||||
// Détection dynamique du hostname (équivalent de $(hostname -f))
|
||||
$hostname_fqdn = getenv('HOSTNAME_FQDN') ?: (gethostname() ?: 'localhost');
|
||||
|
||||
// On définit les répertoires de base
|
||||
$monitoring_base = '/opt/monitoring';
|
||||
$monitoring_log_dir = '/var/log/monitoring';
|
||||
$monitoring_state_dir = '/var/lib/monitoring';
|
||||
$monitoring_lock_dir = '/var/lock/monitoring';
|
||||
|
||||
// Initialisation automatique des répertoires (équivalent du mkdir -p à la fin du bash)
|
||||
foreach ([$monitoring_log_dir, $monitoring_state_dir, $monitoring_lock_dir] as $dir) {
|
||||
if (!is_dir($dir)) {
|
||||
@mkdir($dir, 0755, true);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
// --- Chemins ---
|
||||
'MONITORING_BASE' => $monitoring_base,
|
||||
'MONITORING_LOG_DIR' => $monitoring_log_dir,
|
||||
'MONITORING_STATE_DIR' => $monitoring_state_dir,
|
||||
'MONITORING_LOCK_DIR' => $monitoring_lock_dir,
|
||||
'LOG_FILE' => $monitoring_log_dir . '/events.jsonl',
|
||||
|
||||
// --- Identification ---
|
||||
'HOSTNAME_FQDN' => $hostname_fqdn,
|
||||
'DEST' => 'root',
|
||||
|
||||
// --- ntfy ---
|
||||
'NTFY_SERVER' => 'https://ntfy.sh', // Correction du nfy.sh en ntfy.sh
|
||||
'NTFY_TOPIC' => 'TPOSOB84sBJ6HTZ7',
|
||||
'NTFY_TOKEN' => '',
|
||||
|
||||
// --- Mises à jour (Update) ---
|
||||
'UPDATE_ENABLED' => true,
|
||||
'UPDATE_BASE_URL' => 'https://git.abonnel.fr/cedricAbonnel/scripts-bash/raw/branch/main/servers/linux/monitoring',
|
||||
'UPDATE_MANIFEST_URL' => 'https://git.abonnel.fr/cedricAbonnel/scripts-bash/raw/branch/main/servers/linux/monitoring/manifest.txt',
|
||||
'UPDATE_TIMEOUT_CONNECT' => 3,
|
||||
'UPDATE_TIMEOUT_TOTAL' => 15,
|
||||
'UPDATE_TMP_DIR' => '/tmp/monitoring-update',
|
||||
'UPDATE_ALLOW_DELETE' => false,
|
||||
|
||||
// --- Logs ---
|
||||
'LOG_LEVEL' => 'INFO', // DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL
|
||||
];
|
||||
Reference in New Issue
Block a user