diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_6.1.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_6.1.mysql.sql index 3b37c5d32a..01bcda44c6 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_6.1.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_6.1.mysql.sql @@ -40,3 +40,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); +-- --------------------------------------------------------------------- +-- Table `tplanned_downtime_agents` +-- --------------------------------------------------------------------- +ALTER TABLE tplanned_downtime_agents ADD COLUMN `manually_disabled` tinyint(1) DEFAULT 0; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_6.1.oracle.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_6.1.oracle.sql index 65d6ca5135..40ab03d15b 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_6.1.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_6.1.oracle.sql @@ -35,3 +35,7 @@ INSERT INTO tconfig (token, value) VALUES ('big_operation_step_datos_purge', '10 INSERT INTO tconfig (token, value) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO tconfig (token, value) VALUES ('days_autodisable_deletion', '30'); +-- --------------------------------------------------------------------- +-- Table `tplanned_downtime_agents` +-- --------------------------------------------------------------------- +ALTER TABLE tplanned_downtime_agents ADD COLUMN manually_disabled NUMBER(5, 0) DEFAULT 0; diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index ee5f2b4cf1..5bb3c0bffc 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -277,6 +277,17 @@ $table->data[34][0] = __('Limit parameters massive') . $table->data[34][1] = html_print_input_text('limit_parameters_massive', $config['limit_parameters_massive'], '', 10, 10, true); +$table->data[35][0] = __('Include agents'); +$table->data[35][1] = __('Yes').'   '.html_print_radio_button ('include_agents', 1, '', $config["include_agents"], true).'  '; +$table->data[35][1] .= __('No').'   '.html_print_radio_button ('include_agents', 0, '', $config["include_agents"], true); + /*$row = array(); + $row[0] = __('Include agents'); + + $row[1] = __('Yes') . '   ' . html_print_radio_button ('include_agents', 1, '', $config["include_agents"], true) . '  '; + $row[1] .= __('No') . '   ' . html_print_radio_button ('include_agents', 0, '', $config["include_agents"], true); + + $data['include_agents'] = $row;*/ + echo '
'; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 6eb2d5d3bc..7701809f36 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -203,6 +203,8 @@ function config_update_config () { $error_update[] = __('Limit parameters massive'); if (!config_update_value ('identification_reminder', get_parameter('identification_reminder'))) $error_update[] = __('Identification_reminder'); + if (!config_update_value ('include_agents', (bool)get_parameter('include_agents'))) + $error_update[] = __('Include_agents'); break; case 'enterprise': if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { @@ -901,7 +903,11 @@ function config_process_config () { if (!isset ($config["log_collector"])) { config_update_value ('log_collector', 0); } - + + if (!isset ($config["include_agents"])) { + config_update_value ('include_agents', 0); + } + if (!isset ($config["log_dir"])) { if ($is_windows) $default = 'C:\\PandoraFMS\\Pandora_Server\\data_in\\log'; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 858fdc3b63..325ddf3287 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1338,6 +1338,7 @@ CREATE TABLE IF NOT EXISTS `tplanned_downtime_agents` ( `id_agent` mediumint(8) unsigned NOT NULL default '0', `id_downtime` mediumint(8) NOT NULL default '0', `all_modules` tinyint(1) default 1, + `manually_disabled` tinyint(1) default 0, PRIMARY KEY (`id`), FOREIGN KEY (`id_downtime`) REFERENCES tplanned_downtime(`id`) ON DELETE CASCADE diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index a6da702e5e..ded26395e8 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -415,6 +415,8 @@ sub pandora_load_config { $pa_config->{"warmup_unknown_interval"} = 300; # 6.1 $pa_config->{"warmup_unknown_on"} = 1; # 6.1 + $pa_config->{'include_agents'} = 0; #6.1 + # Check for UID0 if ($pa_config->{"quiet"} != 0){ if ($> == 0){ @@ -929,6 +931,9 @@ sub pandora_load_config { $pa_config->{'warmup_unknown_interval'}= clean_blank($1); $pa_config->{'warmup_unknown_on'} = 0 if ($pa_config->{'warmup_unknown_interval'} == 0); # On by default. } + elsif ($parametro =~ m/^include_agents\s+([0-1])/i) { + $pa_config->{'include_agents'}= safe_input($1); + } } # end of loop for parameter # # Set to RDBMS' standard port diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 1ae0322ba6..36a437d3e7 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1576,6 +1576,13 @@ sub pandora_planned_downtime_set_disabled_elements($$$) { } if ($only_alerts == 0) { + + if($pa_config->{'include_agents'} == 0){ + db_do($dbh, 'UPDATE tplanned_downtime_agents + SET manually_disabled = 1 WHERE id_agent IN (SELECT id_agente FROM tagente WHERE disabled = 1) + AND id_downtime = ' . $downtime->{'id'}); + } + db_do ($dbh, 'UPDATE tagente SET disabled = 1 WHERE id_agente = ?', $downtime_agent->{'id_agent'}); @@ -1619,6 +1626,12 @@ sub pandora_planned_downtime_unset_disabled_elements($$$) { db_do ($dbh, 'UPDATE tagente SET disabled = 0 WHERE id_agente = ?', $downtime_agent->{'id_agent'}); + + if($pa_config->{'include_agents'} == 0){ + db_do ($dbh, 'UPDATE tagente + SET disabled = 1 + WHERE id_agente IN (SELECT id_agent FROM tplanned_downtime_agents WHERE manually_disabled = 1)'); + } } else { db_do ($dbh, 'UPDATE talert_template_modules