Merge branch 'ent-7774-13106-Deshabilitar-modulos-mediante-paradas-planificada' into 'develop'
implemented disable modules scheduled downtime See merge request artica/pandorafms!5075
This commit is contained in:
commit
deb7fa54ec
|
@ -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']) {
|
||||
|
|
|
@ -1000,6 +1000,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] .= '<em class="disabled_module">'.ui_print_truncate_text(
|
||||
$module['nombre'],
|
||||
'module_medium',
|
||||
|
@ -1008,7 +1026,7 @@ foreach ($modules as $module) {
|
|||
true,
|
||||
'[…]',
|
||||
'font-size: 7.2pt'
|
||||
).'</em>';
|
||||
).$dt_disabled_icon.'</em>';
|
||||
} else {
|
||||
$data[0] .= ui_print_truncate_text(
|
||||
$module['nombre'],
|
||||
|
|
|
@ -861,6 +861,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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -2426,15 +2426,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
|
||||
|
@ -2466,12 +2473,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
|
||||
|
|
Loading…
Reference in New Issue