diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index df0bd80ef1..64bb89a565 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -535,7 +535,7 @@ $table_advanced->data[0][1] = html_print_input_text( ); $table_advanced->data[0][3] = __('Unit'); -$table_advanced->data[0][4] = html_print_input_text ( +$table_advanced->data[0][4] = html_print_input_text( 'unit', $unit, '', @@ -548,17 +548,17 @@ $table_advanced->data[0][4] = html_print_input_text ( $classdisabledBecauseInPolicy ); // $table_advanced->colspan[1][4] = 3; -//$table_advanced->data[0][4] = html_print_extended_select_for_unit( -// 'unit', -// $unit, -// '', -// '', -// '0', -// false, -// true, -// false, -// false -//); +// $table_advanced->data[0][4] = html_print_extended_select_for_unit( +// 'unit', +// $unit, +// '', +// '', +// '0', +// false, +// true, +// false, +// false +// ); $table_advanced->colspan[0][4] = 3; $module_id_policy_module = 0; diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 893823576b..2d14003ba2 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -86,17 +86,17 @@ class ConsoleSupervisor * * @var boolean */ - public $verbose; + public $interactive; /** * Constructor. * - * @param boolean $verbose Show output while executing or not. + * @param boolean $interactive Show output while executing or not. * * @return class This object */ - public function __construct(bool $verbose=true) + public function __construct(bool $interactive=true) { $source = db_get_row( 'tnotification_source', @@ -104,16 +104,16 @@ class ConsoleSupervisor io_safe_input('System status') ); - $this->verbose = $verbose; + $this->interactive = $interactive; if ($source === false) { - $this->notificationsEnabled = false; + $this->enabled = false; $this->sourceId = null; $this->targetGroups = null; $this->targetUsers = null; } else { - $this->notificationsEnabled = (bool) $source['enabled']; + $this->enabled = (bool) $source['enabled']; $this->sourceId = $source['id']; // Assign targets. @@ -191,7 +191,7 @@ class ConsoleSupervisor * NOTIF.CRON.CONFIGURED */ - if ((bool) enterprise_installed() === true) { + if (enterprise_installed()) { $this->checkCronRunning(); } @@ -254,7 +254,7 @@ class ConsoleSupervisor $this->maintenanceOperations(); - if ($this->notificationsEnabled === false) { + if ($this->enabled === false) { // Notifications not enabled. return; } @@ -512,13 +512,13 @@ class ConsoleSupervisor * Update targets for given notification using object targets. * * @param array $notification Current notification. - * @param boolean $update Only update db targets, no email. + * @param boolean $send_mails Only update db targets, no email. * * @return void */ public function updateTargets( array $notification, - bool $update=false + bool $send_mails=true ) { $notification_id = $notification['id_mensaje']; $blacklist = []; @@ -537,7 +537,7 @@ class ConsoleSupervisor ); $insertion_string .= ','; - if ($update === false) { + if ($send_mails === true) { // Send mail. if (isset($user['also_mail']) && $user['also_mail'] == 1) { enterprise_hook( @@ -571,7 +571,7 @@ class ConsoleSupervisor ); $insertion_string .= ','; - if ($update === false) { + if ($send_mails === true) { // Send mail. if (isset($group['also_mail']) && $group['also_mail'] == 1) { enterprise_hook( @@ -612,7 +612,7 @@ class ConsoleSupervisor public function notify( array $data, int $source_id=0, - int $max_age=86400 + int $max_age=SECONDS_1DAY ) { // Uses 'check failed' logic. if (is_array($data) === false) { @@ -681,8 +681,8 @@ class ConsoleSupervisor // NOTIF.SERVER.MASTER. // NOTIF.SERVER.STATUS.ID_SERVER. if (preg_match('/^NOTIF.SERVER/', $data['type']) === true) { - // Component notifications require be inmediate. - $max_age = 0; + // Send notification once a day. + $max_age = SECONDS_1DAY; } // Else ignored. @@ -693,7 +693,9 @@ class ConsoleSupervisor $prev = db_get_row( 'tmensajes', 'subtype', - $data['type'] + $data['type'], + false, + false ); if ($prev !== false @@ -712,7 +714,7 @@ class ConsoleSupervisor ], ['id_mensaje' => $prev['id_mensaje']] ); - $this->updateTargets($prev, true); + $this->updateTargets($prev, false); return; } @@ -963,9 +965,9 @@ class ConsoleSupervisor $remote_config_dir = (string) io_safe_output($config['remote_config']); - if ((bool) enterprise_installed() === true - && isset($config['license_nms']) === true - && (int) $config['license_nms'] !== 1 + if (enterprise_installed() + && isset($config['license_nms']) + && $config['license_nms'] != 1 ) { if (is_readable($remote_config_dir) !== true) { $this->notify( @@ -1242,8 +1244,29 @@ class ConsoleSupervisor $this->cleanNotifications('NOTIF.SERVER.STATUS%'); return; } else { - // Clean notifications. Only show notif for down servers. - $this->cleanNotifications('NOTIF.SERVER.STATUS%'); + // Clean notifications. Only show notif for down servers + // ONLY FOR RECOVERED ONES. + $servers_working = db_get_all_rows_sql( + 'SELECT + id_server, + name, + server_type, + server_keepalive, + status, + unix_timestamp() - unix_timestamp(keepalive) as downtime + FROM tserver + WHERE + unix_timestamp() - unix_timestamp(keepalive) <= server_keepalive + OR status != 0' + ); + + if (is_array($servers_working) === true) { + foreach ($servers_working as $server) { + $this->cleanNotifications( + 'NOTIF.SERVER.STATUS'.$server['id_server'] + ); + } + } } foreach ($servers as $server) {