preserve previous disabled or quiet condition when downtime is over
This commit is contained in:
parent
8f04fbec4d
commit
68525f0a12
|
@ -70,6 +70,10 @@ ALTER TABLE `tlayout_template`
|
||||||
ADD COLUMN `grid_color` VARCHAR(45) NOT NULL DEFAULT '#cccccc' AFTER `maintenance_mode`,
|
ADD COLUMN `grid_color` VARCHAR(45) NOT NULL DEFAULT '#cccccc' AFTER `maintenance_mode`,
|
||||||
ADD COLUMN `grid_size` VARCHAR(45) NOT NULL DEFAULT '10' AFTER `grid_color`;
|
ADD COLUMN `grid_size` VARCHAR(45) NOT NULL DEFAULT '10' AFTER `grid_color`;
|
||||||
|
|
||||||
|
ALTER TABLE `tagente_modulo` ADD COLUMN `quiet_by_downtime` TINYINT NOT NULL DEFAULT 0;
|
||||||
|
ALTER TABLE `tagente_modulo` ADD COLUMN `disabled_by_downtime` TINYINT NOT NULL DEFAULT 0;
|
||||||
|
ALTER TABLE `talert_template_modules` ADD COLUMN `disabled_by_downtime` TINYINT NOT NULL DEFAULT 0;
|
||||||
|
ALTER TABLE `tagente` ADD COLUMN `disabled_by_downtime` TINYINT NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
DELETE FROM tconfig WHERE token = 'refr';
|
DELETE FROM tconfig WHERE token = 'refr';
|
||||||
|
|
||||||
|
|
|
@ -645,9 +645,13 @@ function planned_downtimes_stop($downtime)
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
$result = db_process_sql_update(
|
$result = db_process_sql_update(
|
||||||
'tagente_modulo',
|
'tagente_modulo',
|
||||||
['quiet' => 0],
|
|
||||||
[
|
[
|
||||||
'id_agente_modulo' => $module['id_agent_module'],
|
'quiet' => 0,
|
||||||
|
'quiet_by_downtime' => 0,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'quiet_by_downtime' => 1,
|
||||||
|
'id_agente_modulo' => $module['id_agent_module'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -673,20 +677,31 @@ function planned_downtimes_stop($downtime)
|
||||||
$result = db_process_sql_update(
|
$result = db_process_sql_update(
|
||||||
'tagente',
|
'tagente',
|
||||||
[
|
[
|
||||||
'disabled' => 0,
|
|
||||||
'update_module_count' => 1,
|
'update_module_count' => 1,
|
||||||
],
|
],
|
||||||
['id_agente' => $agent['id_agent']]
|
['id_agente' => $agent['id_agent']]
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result) {
|
$result_disabled = db_process_sql_update(
|
||||||
|
'tagente',
|
||||||
|
[
|
||||||
|
'disabled' => 0,
|
||||||
|
'disabled_by_downtime' => 0,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'disabled_by_downtime' => 1,
|
||||||
|
'id_agente' => $agent['id_agent'],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result !== false && $result_disabled !== false) {
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'disable_agent_modules':
|
case 'disable_agent_modules':
|
||||||
$update_sql = sprintf(
|
/*$update_sql = sprintf(
|
||||||
'UPDATE tagente_modulo tam, tagente ta, tplanned_downtime_modules tpdm
|
'UPDATE tagente_modulo tam, tagente ta, tplanned_downtime_modules tpdm
|
||||||
SET tam.disabled = 0, ta.update_module_count = 1
|
SET tam.disabled = 0, ta.update_module_count = 1
|
||||||
WHERE tpdm.id_agent_module = tam.id_agente_modulo AND
|
WHERE tpdm.id_agent_module = tam.id_agente_modulo AND
|
||||||
|
@ -697,7 +712,46 @@ function planned_downtimes_stop($downtime)
|
||||||
|
|
||||||
db_process_sql($update_sql);
|
db_process_sql($update_sql);
|
||||||
|
|
||||||
$count = '';
|
$count = '';*/
|
||||||
|
$agents = db_get_all_rows_filter(
|
||||||
|
'tplanned_downtime_agents',
|
||||||
|
['id_downtime' => $id_downtime]
|
||||||
|
);
|
||||||
|
if (empty($agents)) {
|
||||||
|
$agents = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
foreach ($agents as $agent) {
|
||||||
|
$modules = db_get_all_rows_filter(
|
||||||
|
'tplanned_downtime_modules',
|
||||||
|
[
|
||||||
|
'id_agent' => $agent['id_agent'],
|
||||||
|
'id_downtime' => $id_downtime,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if (empty($modules)) {
|
||||||
|
$modules = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($modules as $module) {
|
||||||
|
$result = db_process_sql_update(
|
||||||
|
'tagente_modulo',
|
||||||
|
[
|
||||||
|
'disabled' => 0,
|
||||||
|
'disabled_by_downtime' => 0,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'disabled_by_downtime' => 1,
|
||||||
|
'id_agente_modulo' => $module['id_agent_module'],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result !== false) {
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'disable_agents_alerts':
|
case 'disable_agents_alerts':
|
||||||
|
@ -722,13 +776,17 @@ function planned_downtimes_stop($downtime)
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
$result = db_process_sql_update(
|
$result = db_process_sql_update(
|
||||||
'talert_template_modules',
|
'talert_template_modules',
|
||||||
['disabled' => 0],
|
|
||||||
[
|
[
|
||||||
'id_agent_module' => $module['id_agente_modulo'],
|
'disabled' => 0,
|
||||||
|
'disabled_by_downtime' => 0,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'disabled_by_downtime' => 1,
|
||||||
|
'id_agent_module' => $module['id_agente_modulo'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result) {
|
if ($result !== false) {
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,7 @@ CREATE TABLE IF NOT EXISTS `tagente` (
|
||||||
`cps` INT NOT NULL DEFAULT 0,
|
`cps` INT NOT NULL DEFAULT 0,
|
||||||
`satellite_server` INT NOT NULL DEFAULT 0,
|
`satellite_server` INT NOT NULL DEFAULT 0,
|
||||||
`fixed_ip` TINYINT NOT NULL DEFAULT 0,
|
`fixed_ip` TINYINT NOT NULL DEFAULT 0,
|
||||||
|
`disabled_by_downtime` TINYINT NOT NULL DEFAULT 0,
|
||||||
PRIMARY KEY (`id_agente`),
|
PRIMARY KEY (`id_agente`),
|
||||||
KEY `nombre` (`nombre`(255)),
|
KEY `nombre` (`nombre`(255)),
|
||||||
KEY `direccion` (`direccion`),
|
KEY `direccion` (`direccion`),
|
||||||
|
@ -274,6 +275,8 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` (
|
||||||
`percentage_critical` TINYINT UNSIGNED DEFAULT 0,
|
`percentage_critical` TINYINT UNSIGNED DEFAULT 0,
|
||||||
`percentage_warning` TINYINT UNSIGNED DEFAULT 0,
|
`percentage_warning` TINYINT UNSIGNED DEFAULT 0,
|
||||||
`warning_time` INT UNSIGNED DEFAULT 0,
|
`warning_time` INT UNSIGNED DEFAULT 0,
|
||||||
|
`quiet_by_downtime` TINYINT NOT NULL DEFAULT 0,
|
||||||
|
`disabled_by_downtime` TINYINT NOT NULL DEFAULT 0,
|
||||||
PRIMARY KEY (`id_agente_modulo`),
|
PRIMARY KEY (`id_agente_modulo`),
|
||||||
KEY `main_idx` (`id_agente_modulo`,`id_agente`),
|
KEY `main_idx` (`id_agente_modulo`,`id_agente`),
|
||||||
KEY `tam_agente` (`id_agente`),
|
KEY `tam_agente` (`id_agente`),
|
||||||
|
@ -550,6 +553,7 @@ CREATE TABLE IF NOT EXISTS `talert_template_modules` (
|
||||||
`standby` TINYINT DEFAULT 0,
|
`standby` TINYINT DEFAULT 0,
|
||||||
`priority` TINYINT DEFAULT 0,
|
`priority` TINYINT DEFAULT 0,
|
||||||
`force_execution` TINYINT DEFAULT 0,
|
`force_execution` TINYINT DEFAULT 0,
|
||||||
|
`disabled_by_downtime` TINYINT NOT NULL DEFAULT 0,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `idx_template_module` (`id_agent_module`),
|
KEY `idx_template_module` (`id_agent_module`),
|
||||||
FOREIGN KEY (`id_agent_module`) REFERENCES tagente_modulo(`id_agente_modulo`)
|
FOREIGN KEY (`id_agent_module`) REFERENCES tagente_modulo(`id_agente_modulo`)
|
||||||
|
|
|
@ -2544,6 +2544,12 @@ sub pandora_planned_downtime_set_disabled_elements($$$) {
|
||||||
|
|
||||||
if ($only_alerts == 0) {
|
if ($only_alerts == 0) {
|
||||||
if ($downtime->{'type_downtime'} eq 'disable_agent_modules') {
|
if ($downtime->{'type_downtime'} eq 'disable_agent_modules') {
|
||||||
|
db_do($dbh,'UPDATE tagente_modulo tam, tagente ta, tplanned_downtime_modules tpdm
|
||||||
|
SET tam.disabled_by_downtime = 1
|
||||||
|
WHERE tam.disabled = 0 AND tpdm.id_agent_module = tam.id_agente_modulo AND
|
||||||
|
ta.id_agente = tam.id_agente AND
|
||||||
|
tpdm.id_downtime = ?', $downtime->{'id'});
|
||||||
|
|
||||||
db_do($dbh,'UPDATE tagente_modulo tam, tagente ta, tplanned_downtime_modules tpdm
|
db_do($dbh,'UPDATE tagente_modulo tam, tagente ta, tplanned_downtime_modules tpdm
|
||||||
SET tam.disabled = 1, ta.update_module_count = 1
|
SET tam.disabled = 1, ta.update_module_count = 1
|
||||||
WHERE tpdm.id_agent_module = tam.id_agente_modulo AND
|
WHERE tpdm.id_agent_module = tam.id_agente_modulo AND
|
||||||
|
@ -2553,7 +2559,12 @@ sub pandora_planned_downtime_set_disabled_elements($$$) {
|
||||||
db_do($dbh,'UPDATE tplanned_downtime_agents tp, tagente ta
|
db_do($dbh,'UPDATE tplanned_downtime_agents tp, tagente ta
|
||||||
SET tp.manually_disabled = ta.disabled
|
SET tp.manually_disabled = ta.disabled
|
||||||
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
|
||||||
|
SET ta.disabled_by_downtime = 1
|
||||||
|
WHERE ta.disabled = 0 AND tpa.id_agent = ta.id_agente AND
|
||||||
|
tpa.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, ta.update_module_count = 1
|
SET ta.disabled = 1, ta.update_module_count = 1
|
||||||
WHERE tpa.id_agent = ta.id_agente AND
|
WHERE tpa.id_agent = ta.id_agente AND
|
||||||
|
@ -2565,6 +2576,11 @@ sub pandora_planned_downtime_set_disabled_elements($$$) {
|
||||||
WHERE id_downtime = ' . $downtime->{'id'});
|
WHERE id_downtime = ' . $downtime->{'id'});
|
||||||
|
|
||||||
foreach my $downtime_agent (@downtime_agents) {
|
foreach my $downtime_agent (@downtime_agents) {
|
||||||
|
db_do ($dbh, 'UPDATE talert_template_modules tat, tagente_modulo tam
|
||||||
|
SET tat.disabled_by_downtime = 1
|
||||||
|
WHERE tat.disabled = 0 AND tat.id_agent_module = tam.id_agente_modulo
|
||||||
|
AND tam.id_agente = ?', $downtime_agent->{'id_agent'});
|
||||||
|
|
||||||
db_do ($dbh, 'UPDATE talert_template_modules tat, tagente_modulo tam
|
db_do ($dbh, 'UPDATE talert_template_modules tat, tagente_modulo tam
|
||||||
SET tat.disabled = 1
|
SET tat.disabled = 1
|
||||||
WHERE tat.id_agent_module = tam.id_agente_modulo
|
WHERE tat.id_agent_module = tam.id_agente_modulo
|
||||||
|
@ -2645,6 +2661,13 @@ sub pandora_planned_downtime_set_quiet_elements($$$) {
|
||||||
AND id_downtime = ' . $downtime_id);
|
AND id_downtime = ' . $downtime_id);
|
||||||
|
|
||||||
foreach my $downtime_module (@downtime_modules) {
|
foreach my $downtime_module (@downtime_modules) {
|
||||||
|
# If traversed module was already quiet, do not set quiet_by_downtime flag.
|
||||||
|
# quiet_by_downtime is used to avoid setting the module back to quiet=0 when downtime is over for those modules that were quiet before the downtime.
|
||||||
|
db_do ($dbh, 'UPDATE tagente_modulo
|
||||||
|
SET quiet_by_downtime = 1
|
||||||
|
WHERE quiet = 0 && id_agente_modulo = ?',
|
||||||
|
$downtime_module->{'id_agent_module'});
|
||||||
|
|
||||||
db_do ($dbh, 'UPDATE tagente_modulo
|
db_do ($dbh, 'UPDATE tagente_modulo
|
||||||
SET quiet = 1
|
SET quiet = 1
|
||||||
WHERE id_agente_modulo = ?',
|
WHERE id_agente_modulo = ?',
|
||||||
|
@ -2667,7 +2690,7 @@ sub pandora_planned_downtime_unset_quiet_elements($$$) {
|
||||||
my @downtime_agents = get_db_rows($dbh, 'SELECT *
|
my @downtime_agents = get_db_rows($dbh, 'SELECT *
|
||||||
FROM tplanned_downtime_agents
|
FROM tplanned_downtime_agents
|
||||||
WHERE id_downtime = ' . $downtime_id);
|
WHERE id_downtime = ' . $downtime_id);
|
||||||
|
|
||||||
foreach my $downtime_agent (@downtime_agents) {
|
foreach my $downtime_agent (@downtime_agents) {
|
||||||
if ($downtime_agent->{'all_modules'}) {
|
if ($downtime_agent->{'all_modules'}) {
|
||||||
db_do ($dbh, 'UPDATE tagente
|
db_do ($dbh, 'UPDATE tagente
|
||||||
|
|
Loading…
Reference in New Issue