Merge branch 'ent-6531-Bug-en-item-Simple-graph-de-informes-metaconsola' into 'develop'

fixed error report selector modules in metaconsole

See merge request artica/pandorafms!3544
This commit is contained in:
Daniel Rodriguez 2020-10-28 15:18:22 +01:00
commit 8a47210dd5
3 changed files with 47 additions and 72 deletions

View File

@ -223,8 +223,9 @@ switch ($action) {
$server_name = $item['server_name'];
// Metaconsole db connection.
if ($meta && !empty($server_name)) {
if ($meta && empty($server_name) === false) {
$connection = metaconsole_get_connection($server_name);
$server_id = $connection['id'];
if (metaconsole_load_external_db($connection) != NOERR) {
continue;
}
@ -1383,8 +1384,7 @@ $class = 'databox filters';
html_print_input_hidden('id_agent', $idAgent);
html_print_input_hidden('server_name', $server_name);
html_print_input_hidden('server_id', $server_name);
html_print_input_hidden('id_server', '');
html_print_input_hidden('server_id', $server_id);
$params = [];
$params['show_helptip'] = false;

View File

@ -1380,11 +1380,12 @@ switch ($action) {
switch ($action) {
case 'update':
$values = [];
$server_name = get_parameter('server_id');
if (is_metaconsole() && $server_name != '') {
$id_meta = metaconsole_get_id_server($server_name);
$server_id = get_parameter('server_id', 0);
if (is_metaconsole() === true
&& empty($server_id) === false
) {
$connection = metaconsole_get_connection_by_id(
$id_meta
$server_id
);
metaconsole_connect($connection);
$values['server_name'] = $connection['server_name'];
@ -1811,7 +1812,6 @@ switch ($action) {
'combo_modulegroup'
);
$values['id_group'] = get_parameter('combo_group');
$values['server_name'] = get_parameter('server_name');
if ($values['server_name'] == '') {
$values['server_name'] = get_parameter(
@ -1867,9 +1867,7 @@ switch ($action) {
);
// If metaconsole is activated.
if ($config['metaconsole'] == 1
&& defined('METACONSOLE')
) {
if (is_metaconsole() === true) {
if (($values['type'] == 'custom_graph')
|| ($values['type'] == 'automatic_custom_graph')
) {

View File

@ -216,7 +216,7 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
} else if ($search_agents && is_metaconsole()) {
$id_agent = (int) get_parameter('id_agent');
$string = (string) get_parameter('q');
// q is what autocomplete plugin gives
// Q is what autocomplete plugin gives.
$id_group = (int) get_parameter('id_group', -1);
$addedItems = html_entity_decode((string) get_parameter('add'));
$addedItems = json_decode($addedItems);
@ -236,6 +236,7 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
'alias',
'direccion',
'id_tmetaconsole_setup AS id_server',
'server_name',
];
$filter = [];
@ -254,36 +255,33 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
case 'enabled':
$filter['disabled'] = 0;
break;
default:
// Not possible.
break;
}
if (!empty($id_agent)) {
if (empty($id_agent) === false) {
$filter['id_agente'] = $id_agent;
}
if (!empty($string)) {
if (empty($string) === false) {
// Get agents for only the alias.
$filter_alias = $filter;
switch ($config['dbtype']) {
case 'mysql':
$filter_alias[] = '(alias COLLATE utf8_general_ci LIKE "%'.$string.'%")';
break;
case 'postgresql':
$filter_alias[] = '(alias LIKE \'%'.$string.'%\')';
break;
$agents = db_get_all_rows_filter(
'tmetaconsole_agent',
$filter_alias,
$fields
);
case 'oracle':
$filter_alias[] = '(UPPER(alias) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter_alias, $fields);
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = [
'id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'alias' => io_safe_output($agent['alias']).' ('.io_safe_output($agent['server_name']).')',
'ip' => io_safe_output($agent['direccion']),
'id_server' => $agent['id_server'],
'filter' => 'alias',
@ -293,27 +291,20 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
// Get agents for only the name.
$filter_agents = $filter;
switch ($config['dbtype']) {
case 'mysql':
$filter_agents[] = '(alias COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND nombre COLLATE utf8_general_ci LIKE "%'.$string.'%")';
break;
case 'postgresql':
$filter_agents[] = '(alias NOT LIKE \'%'.$string.'%\' AND nombre LIKE \'%'.$string.'%\')';
break;
$agents = db_get_all_rows_filter(
'tmetaconsole_agent',
$filter_agents,
$fields
);
case 'oracle':
$filter_agents[] = '(UPPER(alias) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(nombre) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter_agents, $fields);
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = [
'id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'alias' => io_safe_output($agent['alias']).' ('.io_safe_output($agent['server_name']).')',
'ip' => io_safe_output($agent['direccion']),
'id_server' => $agent['id_server'],
'filter' => 'agent',
@ -321,29 +312,22 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
}
}
// Get agents for only the address
// Get agents for only the address.
$filter_address = $filter;
switch ($config['dbtype']) {
case 'mysql':
$filter_address[] = '(alias COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion LIKE "%'.$string.'%")';
break;
case 'postgresql':
$filter_address[] = '(alias NOT LIKE \'%'.$string.'%\' AND nombre NOT LIKE \'%'.$string.'%\' AND direccion LIKE \'%'.$string.'%\')';
break;
$agents = db_get_all_rows_filter(
'tmetaconsole_agent',
$filter_address,
$fields
);
case 'oracle':
$filter_address[] = '(UPPER(alias) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter_address, $fields);
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = [
'id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'alias' => io_safe_output($agent['alias']).' ('.io_safe_output($agent['server_name']).')',
'ip' => io_safe_output($agent['direccion']),
'id_server' => $agent['id_server'],
'filter' => 'address',
@ -351,29 +335,22 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
}
}
// Get agents for only the description
// Get agents for only the description.
$filter_description = $filter;
switch ($config['dbtype']) {
case 'mysql':
$filter_description[] = '(alias COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion NOT LIKE "%'.$string.'%" AND comentarios LIKE "%'.$string.'%")';
break;
case 'postgresql':
$filter_description[] = '(alias NOT LIKE \'%'.$string.'%\' AND nombre NOT LIKE \'%'.$string.'%\' AND direccion NOT LIKE \'%'.$string.'%\' AND comentarios LIKE \'%'.$string.'%\')';
break;
$agents = db_get_all_rows_filter(
'tmetaconsole_agent',
$filter_description,
$fields
);
case 'oracle':
$filter_description[] = '(UPPER(alias) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter_description, $fields);
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = [
'id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'alias' => io_safe_output($agent['alias']).' ('.io_safe_output($agent['server_name']).')',
'ip' => io_safe_output($agent['direccion']),
'id_server' => $agent['id_server'],
'filter' => 'description',