Merge branch 'ent-9676-modulos-de-inventario-se-actualicen-datos-cuando-venga-el-xml-con-nombre-y-sin-datos' into 'develop'

Process inventory modules with correct xml and empty data

See merge request artica/pandorafms!5593
This commit is contained in:
Matias Didier 2023-04-04 07:24:44 +00:00
commit e7d71cf99c
4 changed files with 31 additions and 29 deletions

View File

@ -756,10 +756,8 @@ function inventory_get_datatable(
foreach ($rows as $row) {
$data_rows = explode(PHP_EOL, $row['data']);
foreach ($data_rows as $data_key => $data_value) {
if (empty($data_value) === false) {
$row['data'] = $data_value;
$modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row;
}
$row['data'] = $data_value;
$modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row;
}
}

View File

@ -218,7 +218,7 @@ foreach ($rows as $row) {
}
if ($idModuleInventory != $row['id_module_inventory']) {
if (isset($table) === true && $rowTable > 1) {
if (isset($table) === true && $rowTable >= 1) {
html_print_table($table);
unset($table);
$rowTable = 1;
@ -320,7 +320,7 @@ foreach ($rows as $row) {
$idModuleInventory = $row['id_module_inventory'];
}
if (isset($table) === true && $rowTable > 1) {
if (isset($table) === true && $rowTable >= 1) {
html_print_table($table);
$printedTables++;
}

View File

@ -30,7 +30,7 @@ use PandoraFMS\Enterprise\Metaconsole\Node;
global $config;
require_once $config['homedir'].'/include/functions_gis.php';
require_once 'include/functions_gis.php';
require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_groups.php';
require_once $config['homedir'].'/include/functions_modules.php';
@ -1442,13 +1442,22 @@ $alerttab['active'] = ($tab === 'alert');
// Inventory.
$inventoryCount = db_get_num_rows('SELECT id_agent_module_inventory FROM tagent_module_inventory WHERE id_agente = '.$agent['id_agente']);
$inventorytab['text'] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=inventory&id_agente='.$id_agente.'">'.html_print_image(
'images/hardware-software-component@svg.svg',
true,
[
'class' => 'main_menu_icon invert_filter',
'title' => __('Inventory'),
]
).'</a>';
$inventorytab = enterprise_hook('inventory_tab');
if ($inventorytab === ENTERPRISE_NOT_HOOK || $inventoryCount === 0) {
$inventorytab = '';
if ($tab == 'inventory') {
$inventorytab['active'] = true;
} else {
$inventorytab['active'] = false;
}
// Collection.
if ((int) $config['license_nms'] !== 1) {
$collectiontab = enterprise_hook('collection_tab');
@ -1468,13 +1477,12 @@ if ($policyTab === ENTERPRISE_NOT_HOOK) {
// Omnishell.
if (function_exists('count_tasks_agent')) {
$tasks = count_tasks_agent($id_agente);
if ($tasks === true) {
$omnishellTab = enterprise_hook('omnishell_tab');
if ($omnishellTab == -1) {
$omnishellTab = '';
}
$tasks = count_tasks_agent($id_agente);
if ($tasks === true) {
$omnishellTab = enterprise_hook('omnishell_tab');
if ($omnishellTab == -1) {
$omnishellTab = '';
}
}
@ -1579,7 +1587,7 @@ if (enterprise_installed() === true && (bool) $config['log_collector'] === true)
$log_viewer_tab['text'] = html_print_menu_button(
[
'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=log_viewer&id_agente='.$id_agente,
'image' => 'images/gm_log@svg.svg',
'image' => 'images/gm_log.png',
'title' => __('Log Viewer'),
],
true
@ -1909,7 +1917,7 @@ switch ($tab) {
if ((bool) $config['pure'] === false) {
ui_print_standard_header(
__('Agent main view').' ( '.strtolower(agents_get_alias($id_agente)).' )',
__('Agent main view'),
$icon,
false,
($help_header ?? ''),
@ -1928,12 +1936,6 @@ if ((bool) $config['pure'] === false) {
'link' => '',
'label' => $tab_name,
],
],
[
'id_element' => $id_agente,
'url' => 'operation/agentes/ver_agente&id_agente='.$id_agente,
'label' => agents_get_alias($id_agente),
'section' => 'Agents',
]
);
}

View File

@ -7269,13 +7269,15 @@ sub process_inventory_data ($$$$$$$) {
# Empty list
next unless defined ($list->{'data'});
foreach my $data (@{$list->{'data'}}) {
#Empty data.
next if (ref($data) eq 'HASH');
$data_list .= $data . "\n";
}
}
next if ($data_list eq '');
process_inventory_module_data ($pa_config, $data_list, $server_id, $agent_name, $module_name, $interval, $timestamp, $dbh);
}
}