diff --git a/pandora_console/extras/mr/65.sql b/pandora_console/extras/mr/65.sql index 563d00e82c..cb361c36c7 100644 --- a/pandora_console/extras/mr/65.sql +++ b/pandora_console/extras/mr/65.sql @@ -74,6 +74,7 @@ ALTER TABLE `tagente_modulo` ADD COLUMN `quiet_by_downtime` TINYINT NOT NULL DEF 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; +ALTER TABLE `tmetaconsole_agent` ADD COLUMN `disabled_by_downtime` TINYINT NOT NULL DEFAULT 0; DELETE FROM tconfig WHERE token = 'refr'; diff --git a/pandora_console/include/ajax/task_to_perform.php b/pandora_console/include/ajax/task_to_perform.php index a8a13e08f2..53bdf0556a 100644 --- a/pandora_console/include/ajax/task_to_perform.php +++ b/pandora_console/include/ajax/task_to_perform.php @@ -65,8 +65,8 @@ if ($check_web) { __('Agent Web monitoring created on welcome'), ]; - $id_agent = api_set_new_agent(0, '', $array_other, '', true); - if ($id_agent > 0) { + $id_agent = api_set_new_agent(0, '', $array_other, '', true, true); + if (is_integer($id_agent)) { $module_name = get_parameter('module_name', 'Web_monitoring_module'); $text_to_search = get_parameter('text_to_search', ''); $url_goliat = get_parameter('url_goliat', 'https://pandorafms.com/en/'); @@ -76,7 +76,7 @@ if ($check_web) { ui_print_success_message(__('Your check has been created, <a href='.ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agent).'>click here to view the data</a>. Please note that it may take a few seconds to see data if your server is busy')); } } else { - ui_print_error_message(__('The Name is not valid for the modules.')); + ui_print_error_message(__($id_agent)); } } else { ui_print_error_message(__('Web server is not enabled.')); @@ -110,8 +110,8 @@ if ($check_connectivity) { __('Basic connectivity'), ]; - $id_agent = api_set_new_agent(0, '', $array_other, '', true); - if ($id_agent > 0) { + $id_agent = api_set_new_agent(0, '', $array_other, '', true, true); + if (is_integer($id_agent)) { $ip_target = get_parameter('ip_target', '127.0.0.1'); $basic_network = create_module_basic_network($id_agent, $id_group, $ip_target); $latency_network = create_module_latency_network($id_agent, $id_group, $ip_target); @@ -120,7 +120,7 @@ if ($check_connectivity) { ui_print_success_message(__('Your check has been created, <a href='.ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agent).'>click here to view the data</a>. Please note that it may take a few seconds to see data if your server is busy')); } } else { - ui_print_error_message(__('The Name is not valid for the modules.')); + ui_print_error_message(__($id_agent)); } } else { ui_print_error_message(__('Web server is not enabled.')); diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index ea6f4fe92f..5e66268403 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -679,7 +679,7 @@ class WelcomeWindow extends Wizard ) ); echo html_print_label_input_block( - __('Module group'), + __('Agent group'), html_print_select_from_sql( 'SELECT * FROM tgrupo ORDER BY nombre', 'id_group', diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 2a21bed3a6..7e22befbee 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1916,7 +1916,7 @@ function api_set_update_agent_field($id_agent, $use_agent_alias, $params) * * @param $thrash3 Don't use. */ -function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false) +function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false, $message=false) { global $config; @@ -2009,16 +2009,40 @@ function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false) // Check if agent exists (BUG WC-50518-2). if ($alias == '' && $alias_as_name === 0) { + if ($message === true) { + return 'No agent alias specified'; + } + returnError('No agent alias specified'); } else if (agents_get_agent_id($nombre_agente)) { + if ($message === true) { + return 'The agent name already exists in DB.'; + } + returnError('The agent name already exists in DB.'); } else if (db_get_value_sql('SELECT id_grupo FROM tgrupo WHERE id_grupo = '.$grupo) === false) { + if ($message === true) { + return 'The group does not exist.'; + } + returnError('The group does not exist.'); } else if (group_allow_more_agents($grupo, true, 'create') === false) { + if ($message === true) { + return 'Agent cannot be created due to the maximum agent limit for this group'; + } + returnError('Agent cannot be created due to the maximum agent limit for this group'); } else if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = '.$id_os) === false) { + if ($message === true) { + return 'The OS does not exist.'; + } + returnError('The OS does not exist.'); } else if ($server_name === false) { + if ($message === true) { + return 'The '.get_product_name().' Server does not exist.'; + } + returnError('The '.get_product_name().' Server does not exist.'); } else { if ($alias_as_name === 1) { @@ -13122,7 +13146,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) $ack_utimestamp = $val['ack_utimestamp']; $values['id_usuario'] = $val['id_usuario']; } - + api_set_validate_event_by_id($val['id_evento']); } } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index d3f1cd9339..0056868752 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3472,6 +3472,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` ( `cps` INT NOT NULL DEFAULT 0, `satellite_server` INT NOT NULL DEFAULT 0, `fixed_ip` TINYINT NOT NULL DEFAULT 0, + `disabled_by_downtime` TINYINT NOT NULL DEFAULT 0, PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`(255)), KEY `direccion` (`direccion`),