From d92dc1a2b09eb8c3529f0ef9a0082bb771fc3843 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Fri, 27 Apr 2018 11:06:29 +0200 Subject: [PATCH] Change API and flags in cluster manager - #2007 --- pandora_console/godmode/agentes/modificar_agente.php | 2 +- pandora_console/include/functions_api.php | 8 ++++++-- pandora_console/pandoradb.sql | 6 +----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index a7935f564a..8e66d50d4e 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -680,7 +680,7 @@ if ($agents !== false) { echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; } else{ - echo ' onClick="if (!confirm(\' '.__('You are going to delete a cluster agent. Are you sure?').'\')) return false;">'; + echo ' onClick="if (!confirm(\' '.__('WARNING! - You are going to delete a cluster agent. Are you sure?').'\')) return false;">'; } echo html_print_image('images/cross.png', true, array("border" => '0')) . ""; diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index ed31438a91..a4a737b280 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -10271,7 +10271,7 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) { $id_parent_modulo = db_process_sql('select id_agente_modulo from tagente_modulo where id_agente = '.$id_agent[0]['id_agent'].' and nombre = "Cluster status"'); - $get_module_type = db_process_sql('select id_tipo_modulo,descripcion,min_warning,min_critical,module_interval from tagente_modulo where nombre = "'.$element["name"].'" limit 1'); + $get_module_type = db_process_sql('select id_tipo_modulo,descripcion,min_warning,min_critical,module_interval from tagente_modulo where nombre = "'.io_safe_input($element["name"]).'" limit 1'); $get_module_type_value = $get_module_type[0]['id_tipo_modulo']; @@ -10302,6 +10302,8 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) { $id_module = modules_create_agent_module($values_module['id_agente'],$values_module['nombre'],$values_module); + $launch_cluster = db_process_sql('update tagente_modulo set flag = 1 where custom_integer_1 = '.$element["id_cluster"].' and nombre = "Cluster status"'); + if ($tcluster_module !== false){ db_pandora_audit("Report management", "Module #".$element["name"]." assigned to cluster #".$element["id_cluster"]); } @@ -10319,7 +10321,7 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) { $tcluster_balanced_module = db_process_sql_insert('tcluster_item',array('name'=>$element["name"],'id_cluster'=>$element["id_cluster"],'item_type'=>"AP",'is_critical'=>$element["is_critical"])); - $get_module_type = db_process_sql('select id_tipo_modulo,descripcion,min_warning,min_critical,module_interval from tagente_modulo where nombre = "'.$element["name"].'" limit 1'); + $get_module_type = db_process_sql('select id_tipo_modulo,descripcion,min_warning,min_critical,module_interval from tagente_modulo where nombre = "'.io_safe_input($element["name"]).'" limit 1'); $get_module_type_value = $get_module_type[0]['id_tipo_modulo']; @@ -10369,6 +10371,8 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) { ); $id_module = modules_create_agent_module($values_module['id_agente'],$values_module['nombre'],$values_module); + + $launch_cluster = db_process_sql('update tagente_modulo set flag = 1 where custom_integer_1 = '.$element["id_cluster"].' and nombre = "Cluster status"'); if ($tcluster_balanced_module !== false){ db_pandora_audit("Report management", "Module #".$element["name"]." assigned to cluster #".$element["id_cluster"]); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 400562ba32..7c78e72903 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3048,9 +3048,7 @@ create table IF NOT EXISTS `tcluster`( `description` text not null default '', `group` int(10) unsigned NOT NULL default '0', `id_agent` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`) - ON UPDATE CASCADE + PRIMARY KEY (`id`) ) engine=InnoDB DEFAULT CHARSET=utf8; -- --------------------------------------------------------------------- @@ -3078,8 +3076,6 @@ create table IF NOT EXISTS `tcluster_agent`( `id_cluster` int unsigned not null, `id_agent` int(10) unsigned not null, PRIMARY KEY (`id_cluster`,`id_agent`), - FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`) - ON UPDATE CASCADE, FOREIGN KEY (`id_cluster`) REFERENCES tcluster(`id`) ON UPDATE CASCADE ) engine=InnoDB DEFAULT CHARSET=utf8;