Limit server down notifications once a day

This commit is contained in:
fbsanchez 2020-10-07 18:48:17 +02:00
parent 9f4397a760
commit 2e0321fc6e

View File

@ -45,6 +45,13 @@ enterprise_include_once('include/functions_cron.php');
class ConsoleSupervisor class ConsoleSupervisor
{ {
/**
* Being executed while navigation.
*
* @var boolean
*/
private $quick;
/** /**
* Show if console supervisor is enabled or not. * Show if console supervisor is enabled or not.
* *
@ -149,8 +156,6 @@ class ConsoleSupervisor
*/ */
public function runBasic() public function runBasic()
{ {
global $config;
/* /*
* PHP configuration warnings: * PHP configuration warnings:
* NOTIF.PHP.SAFE_MODE * NOTIF.PHP.SAFE_MODE
@ -213,30 +218,35 @@ class ConsoleSupervisor
* Check if the Server and Console has * Check if the Server and Console has
* the same versions. * the same versions.
*/ */
$this->checkConsoleServerVersions(); $this->checkConsoleServerVersions();
/* /*
* Check if AllowOverride is None or All. * Check if AllowOverride is None or All.
* NOTIF.ALLOWOVERIDE.MESSAGE * NOTIF.ALLOWOVERIDE.MESSAGE
*/ */
$this->checkAllowOverrideEnabled(); $this->checkAllowOverrideEnabled();
/* /*
* Check if AllowOverride is None or All. * Check if AllowOverride is None or All.
* NOTIF.HAMASTER.MESSAGE * NOTIF.HAMASTER.MESSAGE
*/ */
$this->checkHaStatus(); $this->checkHaStatus();
/* /*
* Check if the Pandora Console log * Check if the Pandora Console log
* file remains in old location. * file remains in old location.
*/ */
$this->checkPandoraConsoleLogOldLocation(); $this->checkPandoraConsoleLogOldLocation();
/* /*
* Check if the audit log file * Check if the audit log file
* remains in old location. * remains in old location.
*/ */
$this->checkAuditLogOldLocation(); $this->checkAuditLogOldLocation();
} }
@ -462,16 +472,19 @@ class ConsoleSupervisor
* Check if the Server and Console has * Check if the Server and Console has
* the same versions. * the same versions.
*/ */
$this->checkConsoleServerVersions(); $this->checkConsoleServerVersions();
/* /*
* Check if AllowOverride is None or All. * Check if AllowOverride is None or All.
*/ */
$this->checkAllowOverrideEnabled();
/* $this->checkAllowOverrideEnabled();
* Check if HA status.
*/ /*
* Check if HA status.
*/
if (enterprise_installed()) { if (enterprise_installed()) {
$this->checkHaStatus(); $this->checkHaStatus();
} }
@ -480,11 +493,13 @@ class ConsoleSupervisor
* Check if the audit log file * Check if the audit log file
* remains in old location. * remains in old location.
*/ */
$this->checkAuditLogOldLocation(); $this->checkAuditLogOldLocation();
/* /*
Check if AllowOverride is None or All. * Check if AllowOverride is None or All.
*/ */
$this->checkAllowOverrideEnabled(); $this->checkAllowOverrideEnabled();
} }
@ -594,7 +609,7 @@ class ConsoleSupervisor
public function notify( public function notify(
array $data, array $data,
int $source_id=0, int $source_id=0,
int $max_age=86400 int $max_age=SECONDS_1DAY
) { ) {
// Uses 'check failed' logic. // Uses 'check failed' logic.
if (is_array($data) === false) { if (is_array($data) === false) {
@ -663,8 +678,8 @@ class ConsoleSupervisor
// NOTIF.SERVER.MASTER. // NOTIF.SERVER.MASTER.
// NOTIF.SERVER.STATUS.ID_SERVER. // NOTIF.SERVER.STATUS.ID_SERVER.
if (preg_match('/^NOTIF.SERVER/', $data['type']) === true) { if (preg_match('/^NOTIF.SERVER/', $data['type']) === true) {
// Component notifications require be inmediate. // Send notification once a day.
$max_age = 0; $max_age = SECONDS_1DAY;
} }
// Else ignored. // Else ignored.
@ -943,7 +958,7 @@ class ConsoleSupervisor
{ {
global $config; global $config;
$remote_config_dir = io_safe_output($config['remote_config']); $remote_config_dir = (string) io_safe_output($config['remote_config']);
if (enterprise_installed() if (enterprise_installed()
&& isset($config['license_nms']) && isset($config['license_nms'])
@ -1183,6 +1198,8 @@ class ConsoleSupervisor
*/ */
public function checkPandoraServers() public function checkPandoraServers()
{ {
global $config;
$servers = db_get_all_rows_sql( $servers = db_get_all_rows_sql(
'SELECT 'SELECT
id_server, id_server,
@ -1280,6 +1297,8 @@ class ConsoleSupervisor
*/ */
public function checkPandoraServerMasterAvailable() public function checkPandoraServerMasterAvailable()
{ {
global $config;
$n_masters = db_get_value_sql( $n_masters = db_get_value_sql(
'SELECT 'SELECT
count(*) as n count(*) as n
@ -2524,7 +2543,7 @@ class ConsoleSupervisor
} }
/* /**
* Check if Pandora console log file remains in old location. * Check if Pandora console log file remains in old location.
* *
* @return void * @return void