Fixed downtimes disabled and enabled agents

Former-commit-id: a5c2362e4faf6c0ed9ff2047b6d070aa4d7cdac8
This commit is contained in:
fermin831 2019-02-26 14:44:51 +01:00
parent 9f60d824c5
commit 86509caf6b
3 changed files with 20 additions and 8 deletions

View File

@ -534,9 +534,10 @@ function planned_downtimes_migrate_malformed_downtimes_copy_items($original_down
/** /**
* Stop a planned downtime. * Stop a planned downtime.
* *
* @param array Planned downtime data. * @param array $downtime Planned downtime data.
* *
* @return mixes False on error or an array with the result and a message of the operation. * @return mixed False on error or an array with the result and a message of
* the operation.
*/ */
function planned_downtimes_stop($downtime) function planned_downtimes_stop($downtime)
{ {
@ -566,7 +567,9 @@ function planned_downtimes_stop($downtime)
case 'periodically': case 'periodically':
return false; return false;
break; default:
// Nothing to do.
break;
} }
$message .= ui_print_result_message( $message .= ui_print_result_message(
@ -593,7 +596,7 @@ function planned_downtimes_stop($downtime)
true true
); );
// Reenabled the Agents or Modules or alerts...depends of type // Reenabled the Agents or Modules or alerts...depends of type.
switch ($downtime['type_downtime']) { switch ($downtime['type_downtime']) {
case 'quiet': case 'quiet':
$agents = db_get_all_rows_filter( $agents = db_get_all_rows_filter(
@ -658,7 +661,10 @@ function planned_downtimes_stop($downtime)
foreach ($agents as $agent) { foreach ($agents as $agent) {
$result = db_process_sql_update( $result = db_process_sql_update(
'tagente', 'tagente',
['disabled' => 0], [
'disabled' => 0,
'update_module_count' => 1,
],
['id_agente' => $agent['id_agent']] ['id_agente' => $agent['id_agent']]
); );
@ -702,6 +708,10 @@ function planned_downtimes_stop($downtime)
} }
} }
break; break;
default:
// Nothing to do.
break;
} }
$message .= ui_print_info_message( $message .= ui_print_info_message(

View File

@ -306,7 +306,7 @@ sub pandora_server_tasks ($) {
if (($counter % 30) == 0) { if (($counter % 30) == 0) {
# Update module status and fired alert counts # Update module status and fired alert counts
my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count, update_secondary_groups FROM tagente WHERE disabled = 0 AND (update_module_count=1 OR update_alert_count=1 OR update_secondary_groups=1)'); my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count, update_secondary_groups FROM tagente WHERE (update_module_count=1 OR update_alert_count=1 OR update_secondary_groups=1)');
foreach my $agent (@agents) { foreach my $agent (@agents) {
logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10); logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10);

View File

@ -1820,7 +1820,8 @@ sub pandora_planned_downtime_set_disabled_elements($$$) {
WHERE tp.id_agent = ta.id_agente AND tp.id_downtime = ?',$downtime->{'id'}); WHERE tp.id_agent = ta.id_agente AND tp.id_downtime = ?',$downtime->{'id'});
db_do($dbh,'UPDATE tagente ta, tplanned_downtime_agents tpa db_do($dbh,'UPDATE tagente ta, tplanned_downtime_agents tpa
SET ta.disabled = 1 WHERE tpa.id_agent = ta.id_agente AND SET ta.disabled = 1, ta.update_module_count = 1
WHERE tpa.id_agent = ta.id_agente AND
tpa.id_downtime = ?',$downtime->{'id'}); tpa.id_downtime = ?',$downtime->{'id'});
} else { } else {
@ -1857,7 +1858,8 @@ sub pandora_planned_downtime_unset_disabled_elements($$$) {
if ($only_alerts == 0) { if ($only_alerts == 0) {
db_do($dbh,'UPDATE tagente ta, tplanned_downtime_agents tpa db_do($dbh,'UPDATE tagente ta, tplanned_downtime_agents tpa
set ta.disabled = 0 WHERE tpa.id_agent = ta.id_agente AND 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'}); tpa.manually_disabled = 0 AND tpa.id_downtime = ?',$downtime->{'id'});
} else { } else {
my @downtime_agents = get_db_rows($dbh, 'SELECT * my @downtime_agents = get_db_rows($dbh, 'SELECT *