diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index a84bf918f8..3b714c277b 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -754,7 +754,8 @@ if ($agents !== false) { $in_planned_downtime = db_get_sql( 'SELECT executed FROM tplanned_downtime INNER JOIN tplanned_downtime_agents ON tplanned_downtime.id = tplanned_downtime_agents.id_downtime - WHERE tplanned_downtime_agents.id_agent = '.$agent['id_agente'].' AND tplanned_downtime.executed = 1' + WHERE tplanned_downtime_agents.id_agent = '.$agent['id_agente'].' AND tplanned_downtime.executed = 1 + AND tplanned_downtime.type_downtime <> "disable_agent_modules"' ); if ($agent['disabled']) { diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index dd1427af17..862308d747 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -993,6 +993,24 @@ foreach ($modules as $module) { } if ($module['disabled']) { + $dt_disabled_icon = ''; + + $in_planned_downtime = db_get_sql( + 'SELECT executed FROM tplanned_downtime + INNER JOIN tplanned_downtime_modules ON tplanned_downtime.id = tplanned_downtime_modules.id_downtime + WHERE tplanned_downtime.executed = 1 + AND tplanned_downtime.type_downtime = "disable_agent_modules" + AND tplanned_downtime_modules.id_agent_module = '.$module['id_agente_modulo'] + ); + + if ($in_planned_downtime !== false) { + $dt_disabled_icon = ui_print_help_tip( + __('Module in scheduled downtime'), + true, + 'images/minireloj-16.png' + ); + } + $data[0] .= ''.ui_print_truncate_text( $module['nombre'], 'module_medium', @@ -1001,7 +1019,7 @@ foreach ($modules as $module) { true, '[…]', 'font-size: 7.2pt' - ).''; + ).$dt_disabled_icon.''; } else { $data[0] .= ui_print_truncate_text( $module['nombre'], diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index dd4a8c29b0..52cfac4e4e 100644 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -593,6 +593,7 @@ $table->data[3][1] = html_print_select( [ 'quiet' => __('Quiet'), 'disable_agents' => __('Disabled Agents'), + 'disable_agent_modules' => __('Disable Modules'), 'disable_agents_alerts' => __('Disabled only Alerts'), ], 'type_downtime', diff --git a/pandora_console/include/functions_planned_downtimes.php b/pandora_console/include/functions_planned_downtimes.php index 796f09ab72..e8c4344c05 100644 --- a/pandora_console/include/functions_planned_downtimes.php +++ b/pandora_console/include/functions_planned_downtimes.php @@ -539,6 +539,8 @@ function planned_downtimes_migrate_malformed_downtimes_copy_items($original_down */ function planned_downtimes_stop($downtime) { + global $config; + $result = false; $message = ''; @@ -672,6 +674,21 @@ function planned_downtimes_stop($downtime) } break; + case 'disable_agent_modules': + $update_sql = sprintf( + 'UPDATE tagente_modulo tam, tagente ta, tplanned_downtime_modules tpdm + SET tam.disabled = 0, ta.update_module_count = 1 + WHERE tpdm.id_agent_module = tam.id_agente_modulo AND + ta.id_agente = tam.id_agente AND + tpdm.id_downtime = %d', + $id_downtime + ); + + db_process_sql($update_sql); + + $count = ''; + break; + case 'disable_agents_alerts': $agents = db_get_all_rows_filter( 'tplanned_downtime_agents', diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 168dd1ed63..27206bf696 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -2322,15 +2322,22 @@ sub pandora_planned_downtime_set_disabled_elements($$$) { } if ($only_alerts == 0) { - db_do($dbh,'UPDATE tplanned_downtime_agents tp, tagente ta - SET tp.manually_disabled = ta.disabled - WHERE tp.id_agent = ta.id_agente AND tp.id_downtime = ?',$downtime->{'id'}); + if ($downtime->{'type_downtime'} eq 'disable_agent_modules') { + db_do($dbh,'UPDATE tagente_modulo tam, tagente ta, tplanned_downtime_modules tpdm + SET tam.disabled = 1, ta.update_module_count = 1 + WHERE tpdm.id_agent_module = tam.id_agente_modulo AND + ta.id_agente = tam.id_agente AND + tpdm.id_downtime = ?', $downtime->{'id'}); + } else { + db_do($dbh,'UPDATE tplanned_downtime_agents tp, tagente ta + SET tp.manually_disabled = ta.disabled + WHERE tp.id_agent = ta.id_agente AND tp.id_downtime = ?',$downtime->{'id'}); - db_do($dbh,'UPDATE tagente ta, tplanned_downtime_agents tpa - SET ta.disabled = 1, ta.update_module_count = 1 - WHERE tpa.id_agent = ta.id_agente AND - tpa.id_downtime = ?',$downtime->{'id'}); - + db_do($dbh,'UPDATE tagente ta, tplanned_downtime_agents tpa + SET ta.disabled = 1, ta.update_module_count = 1 + WHERE tpa.id_agent = ta.id_agente AND + tpa.id_downtime = ?',$downtime->{'id'}); + } } else { my @downtime_agents = get_db_rows($dbh, 'SELECT * FROM tplanned_downtime_agents @@ -2362,12 +2369,20 @@ sub pandora_planned_downtime_unset_disabled_elements($$$) { $only_alerts = 1; } } - + if ($only_alerts == 0) { - db_do($dbh,'UPDATE tagente ta, tplanned_downtime_agents tpa - set ta.disabled = 0, ta.update_module_count = 1 - WHERE tpa.id_agent = ta.id_agente AND - tpa.manually_disabled = 0 AND tpa.id_downtime = ?',$downtime->{'id'}); + if ($downtime->{'type_downtime'} eq 'disable_agent_modules') { + db_do($dbh,'UPDATE tagente_modulo tam, tagente ta, tplanned_downtime_modules tpdm + SET tam.disabled = 0, ta.update_module_count = 1 + WHERE tpdm.id_agent_module = tam.id_agente_modulo AND + ta.id_agente = tam.id_agente AND + tpdm.id_downtime = ?', $downtime->{'id'}); + } else { + db_do($dbh,'UPDATE tagente ta, tplanned_downtime_agents tpa + set ta.disabled = 0, ta.update_module_count = 1 + WHERE tpa.id_agent = ta.id_agente AND + tpa.manually_disabled = 0 AND tpa.id_downtime = ?',$downtime->{'id'}); + } } else { my @downtime_agents = get_db_rows($dbh, 'SELECT * FROM tplanned_downtime_agents