Merge branch 'ent-8533-Mostrar-valores-en-elementos-Agents-modules' into 'develop'

Ent 8533 mostrar valores en elementos agents modules

See merge request artica/pandorafms!4764
This commit is contained in:
Daniel Rodriguez 2022-03-31 14:26:51 +00:00
commit 9da8be71bc
8 changed files with 498 additions and 300 deletions

View File

@ -344,6 +344,7 @@ function mainAgentsModules()
$save_serialize = (int) get_parameter('save_serialize', 0);
$full_modules_selected = explode(';', get_parameter('full_modules_selected', 0));
$full_agents_id = explode(';', get_parameter('full_agents_id', 0));
$show_type = (int) get_parameter('show_type', 0);
// In full screen there is no pagination neither filters.
if (( ($config['pure'] == 0 && $save_serialize) && $update_item == '' ) || ( ($config['pure'] == 1 && $save_serialize == 0) && $update_item == '' )) {
@ -361,11 +362,11 @@ function mainAgentsModules()
unserialize_in_temp($config['id_user'].'_agents', true, 1);
}
if ($modules_selected[0]) {
if (isset($modules_selected[0]) === true && $modules_selected[0]) {
serialize_in_temp($modules_selected, $config['id_user'].'_agent_module', 1);
}
if ($agents_id[0] != -1) {
if (isset($agents_id[0]) === true && $agents_id[0] != -1) {
serialize_in_temp($agents_id, $config['id_user'].'_agents', 1);
}
@ -375,21 +376,30 @@ function mainAgentsModules()
$full_agents = urlencode(implode(';', $agents_id));
$fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&amp;sec=extensions&amp;sec2=extensions/agents_modules&amp;pure=1&amp;
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&full_modules_selected='.$full_modules.'
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&full_modules_selected='.$full_modules.'&show_type='.$show_type.'
&full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>';
} else if ($full_modules_selected[0] && $full_agents_id[0]) {
$full_modules = urlencode(implode(';', $full_modules_selected));
$full_agents = urlencode(implode(';', $full_agents_id));
$fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&amp;sec=extensions&amp;sec2=extensions/agents_modules&amp;pure=1&amp;
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&full_modules_selected='.$full_modules.'
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&full_modules_selected='.$full_modules.'&show_type='.$show_type.'
&full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>';
} else {
$fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&amp;sec=extensions&amp;sec2=extensions/agents_modules&amp;pure=1&amp;
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>';
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&show_type='.$show_type.'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>';
}
}
// Type show.
$show_select = [
0 => __('Show module status'),
1 => __('Show module data'),
];
$filter_type_label = '<b>'.__('Information to be shown').'</b>';
$filter_type = html_print_select($show_select, 'show_type', $show_type, '', '', 0, true, false, false, '', false, 'min-width: 180px;');
// Groups.
$filter_groups_label = '<b>'.__('Group').'</b>';
$filter_groups = html_print_select_groups(false, 'AR', true, 'group_id', $group_id, '', '', '', true, false, true, '', false, 'width: auto;');
@ -480,11 +490,29 @@ function mainAgentsModules()
$full_modules = urlencode(implode(';', $full_modules_selected));
$full_agents = urlencode(implode(';', $full_agents_id));
$url = 'index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset
&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr&full_modules_selected=$full_modules
&full_agents_id=$full_agents&selection_agent_module=$selection_a_m';
$url = sprintf(
'index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=%s
&group_id=%s&modulegroup=%s&refresh=%s&full_modules_selected=%s
&full_agents_id=%s&selection_agent_module=%s&show_type=%s',
$offset,
$group_id,
$modulegroup,
$refr,
$full_modules,
$full_agents,
$selection_a_m,
$show_type
);
} else {
$url = 'index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr';
$url = sprintf(
'index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=%s&group_id=%s
&modulegroup=%s&refresh=%s&show_type=%s',
$offset,
$group_id,
$modulegroup,
$refr,
$show_type
);
}
// Floating menu - Start.
@ -546,7 +574,11 @@ function mainAgentsModules()
if ($config['pure'] != 1) {
$show_filters = '<form method="post" action="'.ui_get_url_refresh(['offset' => $offset, 'hor_offset' => $offset, 'group_id' => $group_id, 'modulegroup' => $modulegroup]).'" class="w100p">';
$show_filters .= '<table class="w100p no-border" cellpadding="0" cellspacing="0" border="0">';
$show_filters .= '<table class="w100p no-border" cellpadding="15" cellspacing="0" border="0">';
$show_filters .= '<tr>';
$show_filters .= '<td>'.$filter_type_label.'</td>';
$show_filters .= '<td>'.$filter_type.'</td>';
$show_filters .= '</tr>';
$show_filters .= '<tr>';
$show_filters .= '<td>'.$filter_groups_label.'</td>';
$show_filters .= '<td>'.$filter_groups.'&nbsp;&nbsp;&nbsp;'.$filter_recursion_label.$filter_recursion.'</td>';
@ -574,10 +606,10 @@ function mainAgentsModules()
);
}
if ($agents_id[0] != -1) {
if (isset($agents_id[0]) === true && $agents_id[0] != -1) {
$agents = $agents_id;
} else {
if ($full_agents_id[0]) {
if (isset($full_agents_id[0]) === true && $full_agents_id[0]) {
$agents = $full_agents_id;
} else {
$agents = '';
@ -610,24 +642,34 @@ function mainAgentsModules()
}
$total_pagination = count($agents);
if ($agents_id[0] != -1) {
$all_modules = [];
foreach ($modules_selected as $key => $value) {
$name = modules_get_agentmodule_name($value);
$sql = "SELECT id_agente_modulo
FROM tagente_modulo
WHERE nombre = '".$name."';";
if (isset($agents_id[0]) === true && $agents_id[0] != -1) {
if (isset($modules_selected[0]) === true && $modules_selected[0]) {
$all_modules = [];
foreach ($modules_selected as $key => $value) {
$name = modules_get_agentmodule_name($value);
$sql = "SELECT id_agente_modulo
FROM tagente_modulo
WHERE nombre = '".$name."';";
$result_sql = db_get_all_rows_sql($sql);
$result_sql = db_get_all_rows_sql($sql);
if (is_array($result_sql)) {
foreach ($result_sql as $key => $value) {
$all_modules[$value['id_agente_modulo']] = io_safe_output($name);
if (is_array($result_sql)) {
foreach ($result_sql as $key => $value) {
$all_modules[$value['id_agente_modulo']] = io_safe_output($name);
}
}
}
} else {
$all_modules = agents_get_modules(
$agents,
false,
$filter_module_group,
true,
true
);
}
} else {
if ($full_modules_selected[0]) {
if (isset($full_modules_selected[0]) === true && $full_modules_selected[0]) {
foreach ($full_modules_selected as $key => $value) {
$name = modules_get_agentmodule_name($value);
$sql = "SELECT id_agente_modulo
@ -717,7 +759,7 @@ function mainAgentsModules()
if ($hor_offset > 0) {
$new_hor_offset = ($hor_offset - $block);
echo "<th width='20px' class='vertical_middle center' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&refr=0&save_serialize=1&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
echo "<th width='20px' class='vertical_middle center' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&refr=0&save_serialize=1&show_type='.$show_type.'&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
'images/arrow_left_green.png',
true,
['title' => __('Previous modules')]
@ -743,7 +785,7 @@ function mainAgentsModules()
if (($hor_offset + $block) < $nmodules) {
$new_hor_offset = ($hor_offset + $block);
echo "<th width='20px' class='vertical_middle center' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
echo "<th width='20px' class='vertical_middle center' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&show_type='.$show_type.'&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
'images/arrow_right_green.png',
true,
['title' => __('More modules')]
@ -820,7 +862,6 @@ function mainAgentsModules()
foreach ($module['id'] as $module_id) {
if (!$match && array_key_exists($module_id, $agent_modules)) {
$status = modules_get_agentmodule_status($module_id);
echo "<td class='center'>";
$win_handle = dechex(crc32($module_id.$module['name']));
$graph_type = return_graphtype(modules_get_agentmodule_type($module_id));
@ -833,32 +874,42 @@ function mainAgentsModules()
$module_last_value = htmlspecialchars($module_last_value);
}
switch ($status) {
case AGENT_MODULE_STATUS_NORMAL:
ui_print_status_image('module_ok.png', $module_last_value, false);
break;
if ($show_type === 0) {
$status = modules_get_agentmodule_status($module_id);
switch ($status) {
case AGENT_MODULE_STATUS_NORMAL:
ui_print_status_image('module_ok.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_CRITICAL_BAD:
ui_print_status_image('module_critical.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_CRITICAL_BAD:
ui_print_status_image('module_critical.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_WARNING:
ui_print_status_image('module_warning.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_WARNING:
ui_print_status_image('module_warning.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_UNKNOWN:
ui_print_status_image('module_unknown.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_UNKNOWN:
ui_print_status_image('module_unknown.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
ui_print_status_image('module_alertsfired.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
ui_print_status_image('module_alertsfired.png', $module_last_value, false);
break;
case 4:
ui_print_status_image('module_no_data.png', $module_last_value, false);
break;
case 4:
ui_print_status_image('module_no_data.png', $module_last_value, false);
break;
}
} else {
$module = modules_get_agentmodule($module_id);
$module['datos'] = $module_last_value;
$module_last_value = modules_get_agentmodule_data_for_humans($module);
echo $module_last_value;
}
echo '</a>';
@ -877,22 +928,24 @@ function mainAgentsModules()
echo '</table>';
$show_legend = "<div class='legend_white'>";
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></div>".__('Orange cell when the module has fired alerts').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></div>".__('Red cell when the module has a critical status').'
</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></div>".__('Yellow cell when the module has a warning status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></div>".__('Green cell when the module has a normal status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></div>".__('Grey cell when the module has an unknown status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></div>".__("Cell turns blue when the module is in 'not initialize' status").'</div>';
$show_legend .= '</div>';
ui_toggle($show_legend, __('Legend'));
if ($show_type === 0) {
$show_legend = "<div class='legend_white'>";
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></div>".__('Orange cell when the module has fired alerts').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></div>".__('Red cell when the module has a critical status').'
</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></div>".__('Yellow cell when the module has a warning status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></div>".__('Green cell when the module has a normal status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></div>".__('Grey cell when the module has an unknown status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></div>".__("Cell turns blue when the module is in 'not initialize' status").'</div>';
$show_legend .= '</div>';
ui_toggle($show_legend, __('Legend'));
}
$pure_var = $config['pure'];
if ($pure_var) {

View File

@ -760,6 +760,11 @@ switch ($action) {
);
$selection_a_m = get_parameter('selection');
if (isset($es['show_type']) === true) {
$show_type = $es['show_type'];
}
$recursion = $item['recursion'];
$group = $item['id_group'];
@ -1833,6 +1838,37 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_type_show" class="datos">
<td class="bolder"><?php echo __('Information to be shown'); ?></td>
<td>
<?php
$show_select = [
0 => __('Show module status'),
1 => __('Show module data'),
];
if ($action === 'new' && empty($show_type) === true) {
$show_type = 1;
}
html_print_select(
$show_select,
'show_type',
$show_type,
'',
'',
0,
false,
false,
false,
'',
false,
'min-width: 180px'
);
?>
</td>
</tr>
<tr id="row_alert_templates" class="datos">
<td class="bolder"><?php echo __('Templates'); ?></td>
<td>
@ -5925,6 +5961,7 @@ function chooseType() {
$("#row_agent_not_assigned_to_ip").hide();
$("#row_show_summary").hide();
$("#row_group_by").hide();
$("#row_type_show").hide();
// SLA list default state.
$("#sla_list").hide();
@ -6438,6 +6475,7 @@ function chooseType() {
case 'agent_module':
$("#row_module_group").show();
$("#row_type_show").show();
case 'agent_module_status':
$("#row_description").show();
$("#row_group").show();

View File

@ -1677,6 +1677,7 @@ switch ($action) {
// Encode json modules and agents.
$es['module'] = base64_encode(json_encode($es['module']));
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
$es['show_type'] = get_parameter('show_type', 0);
$values['external_source'] = json_encode($es);
$good_format = true;
@ -2480,6 +2481,7 @@ switch ($action) {
// Encode json modules and agents.
$es['module'] = base64_encode(json_encode($es['module']));
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
$es['show_type'] = get_parameter('show_type', 0);
$values['external_source'] = json_encode($es);
$good_format = true;

View File

@ -1697,13 +1697,19 @@ function html_print_select_multiple_modules_filtered(array $data):string
$all_modules = [];
}
if (is_array($data['mModules']) === false) {
$result = explode(((is_metaconsole() === true) ? SEPARATOR_META_MODULE : ','), $data['mModules']);
} else {
$result = $data['mModules'];
}
$output .= html_print_input(
[
'label' => __('Modules'),
'type' => 'select',
'fields' => $all_modules,
'name' => 'filtered-module-modules-'.$uniqId,
'selected' => explode((is_metaconsole() === true) ? SEPARATOR_META_MODULE : ',', $data['mModules']),
'selected' => $result,
'return' => true,
'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;',

View File

@ -2802,6 +2802,12 @@ function reporting_agent_module($report, $content)
true
);
if (isset($external_source['show_type']) === true) {
$show_type = $external_source['show_type'];
} else {
$show_type = 0;
}
$return['type'] = 'agent_module';
if (empty($content['name'])) {
@ -2838,6 +2844,10 @@ function reporting_agent_module($report, $content)
modules_get_agentmodule_name($modul_id)
);
$modules_by_name[$cont]['id'] = $modul_id;
if ($show_type === '1') {
$modules_by_name[$cont]['unit'] = modules_get_unit($modul_id);
}
$cont++;
}
@ -2853,7 +2863,18 @@ function reporting_agent_module($report, $content)
$row['modules'] = [];
foreach ($modules_by_name as $module) {
if (array_key_exists($module['id'], $agent_modules)) {
$row['modules'][$module['name']] = modules_get_agentmodule_status($module['id']);
if ($show_type === '1') {
$module_last_value = modules_get_last_value($module['id']);
if (!is_numeric($module_last_value)) {
$module_last_value = htmlspecialchars($module_last_value);
}
$module['datos'] = $module_last_value;
$row['modules'][$module['name']] = modules_get_agentmodule_data_for_humans($module);
$row['show_type'] = $show_type;
} else {
$row['modules'][$module['name']] = modules_get_agentmodule_status($module['id']);
}
} else {
if (!array_key_exists($module['name'], $row['modules'])) {
$row['modules'][$module['name']] = null;

View File

@ -1807,9 +1807,9 @@ function reporting_html_agent_module($table, $item)
if (!empty($item['failed'])) {
$table->data['agent_module']['cell'] = $item['failed'];
} else {
$table_data = '<table cellpadding="1" cellspacing="4" cellspacing="0" border="0" class="bg_eee">';
$table_data .= '<th>'.__('Agents').' / '.__('Modules').'</th>';
$table_data = '<table class="border_table" cellpadding="0" cellspacing="0" cellspacing="0">';
$table_data .= '<tr class="border_th">';
$table_data .= '<th class="bg_th">'.__('Agents').' / '.__('Modules').'</th>';
$first = reset($item['data']);
$list_modules = $first['modules'];
@ -1823,11 +1823,14 @@ function reporting_html_agent_module($table, $item)
false,
'...'
);
$table_data .= '<th class="pdd_10px">'.$file_name.'</th>';
$table_data .= '<th class="pdd_10px bg_th">'.$file_name.'</th>';
}
$table_data .= '</tr>';
foreach ($item['data'] as $row) {
$table_data .= "<tr class='height_35px;'>";
$table_data .= "<tr class='height_35px border_tr'>";
switch ($row['agent_status']) {
case AGENT_STATUS_ALERT_FIRED:
$rowcolor = COL_ALERTFIRED;
@ -1865,118 +1868,122 @@ function reporting_html_agent_module($table, $item)
false,
'...'
);
$table_data .= "<td style='background-color: ".$rowcolor.";'>".$file_name.'</td>';
$table_data .= '<td class="pdd_6px left">'.$file_name.'</td>';
foreach ($row['modules'] as $module_name => $module) {
if ($module === null) {
$table_data .= "<td class='bg_dd;'></td>";
$table_data .= '<td></td>';
} else {
$table_data .= "<td class='center bg_ddd'>";
switch ($module) {
default:
case AGENT_STATUS_NORMAL:
$table_data .= ui_print_status_image(
'module_ok.png',
__(
'%s in %s : NORMAL',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
$table_data .= "<td class='center'>";
if (isset($row['show_type']) === true && $row['show_type'] === '1') {
$table_data .= $module;
} else {
switch ($module) {
case AGENT_STATUS_CRITICAL:
$table_data .= ui_print_status_image(
'module_critical.png',
__(
'%s in %s : CRITICAL',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_STATUS_CRITICAL:
$table_data .= ui_print_status_image(
'module_critical.png',
__(
'%s in %s : CRITICAL',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_STATUS_WARNING:
$table_data .= ui_print_status_image(
'module_warning.png',
__(
'%s in %s : WARNING',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_STATUS_WARNING:
$table_data .= ui_print_status_image(
'module_warning.png',
__(
'%s in %s : WARNING',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_STATUS_UNKNOWN:
$table_data .= ui_print_status_image(
'module_unknown.png',
__(
'%s in %s : UNKNOWN',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_STATUS_UNKNOWN:
$table_data .= ui_print_status_image(
'module_unknown.png',
__(
'%s in %s : UNKNOWN',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
$table_data .= ui_print_status_image(
'module_alertsfired.png',
__(
'%s in %s : ALERTS FIRED',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
$table_data .= ui_print_status_image(
'module_alertsfired.png',
__(
'%s in %s : ALERTS FIRED',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case 4:
$table_data .= ui_print_status_image(
'module_no_data.png',
__(
'%s in %s : Not initialize',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case 4:
$table_data .= ui_print_status_image(
'module_no_data.png',
__(
'%s in %s : Not initialize',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
default:
case AGENT_STATUS_NORMAL:
$table_data .= ui_print_status_image(
'module_ok.png',
__(
'%s in %s : NORMAL',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
}
}
$table_data .= '</td>';
@ -1986,18 +1993,19 @@ function reporting_html_agent_module($table, $item)
$table_data .= '</table>';
$table_data .= "<div class='legend_basic w96p'>";
$table_data .= '<table>';
$table_data .= "<tr><td colspan='2' class='pdd_b_10px'><b>".__('Legend').'</b></td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></td><td>".__('Orange cell when the module has fired alerts').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></td><td>".__('Red cell when the module has a critical status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></td><td>".__('Yellow cell when the module has a warning status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></td><td>".__('Green cell when the module has a normal status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></td><td>".__('Grey cell when the module has an unknown status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></td><td>".__("Cell turns grey when the module is in 'not initialize' status").'</td></tr>';
$table_data .= '</table>';
$table_data .= '</div>';
if (isset($row['show_type']) === false) {
$table_data .= "<div class='legend_basic w96p'>";
$table_data .= '<table>';
$table_data .= "<tr><td colspan='2' class='pdd_b_10px'><b>".__('Legend').'</b></td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></td><td>".__('Orange cell when the module has fired alerts').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></td><td>".__('Red cell when the module has a critical status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></td><td>".__('Yellow cell when the module has a warning status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></td><td>".__('Green cell when the module has a normal status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></td><td>".__('Grey cell when the module has an unknown status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></td><td>".__("Cell turns grey when the module is in 'not initialize' status").'</td></tr>';
$table_data .= '</table>';
$table_data .= '</div>';
}
$table->data['agent_module']['cell'] = $table_data;
}

View File

@ -200,6 +200,10 @@ class AgentModuleWidget extends Widget
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['mTypeShow']) === true) {
$values['mTypeShow'] = $decoder['mTypeShow'];
}
if (isset($decoder['mGroup']) === true) {
$values['mGroup'] = $decoder['mGroup'];
}
@ -246,6 +250,29 @@ class AgentModuleWidget extends Widget
'label' => __('Filter modules'),
];
// Type show.
$show_select = [
0 => __('Show module status'),
1 => __('Show module data'),
];
if (empty($this->values['mModules']) === true && empty($this->values['mTypeShow'])) {
$this->values['mTypeShow'] = 1;
}
$inputs[] = [
'class' => 'flex flex-row',
'label' => __('Information to be shown'),
'arguments' => [
'type' => 'select',
'fields' => $show_select,
'name' => 'filtered-type-show-'.$this->cellId,
'return' => true,
'id' => 'filtered-type-show-'.$this->cellId,
'selected' => ($this->values['mTypeShow'] === null) ? 0 : $this->values['mTypeShow'],
],
];
$return_all_group = false;
if (users_can_manage_group_all('RM') || $this->values['mGroup'] == 0) {
@ -285,6 +312,10 @@ class AgentModuleWidget extends Widget
// Retrieve global - common inputs.
$values = parent::getPost();
$values['mTypeShow'] = \get_parameter(
'filtered-type-show-'.$this->cellId
);
$values['mGroup'] = \get_parameter(
'filtered-module-group-'.$this->cellId
);
@ -409,7 +440,7 @@ class AgentModuleWidget extends Widget
array $visualData,
array $allModules
):string {
$style = 'display:flex; width:100%; margin: 10px;';
$style = 'display:flex; width:96%; margin-top: 10px;';
$table_data = '<div style="'.$style.'">';
$table_data .= '<table class="widget_agent_module transparent mrgn_0px" cellpadding="1" cellspacing="0" border="0">';
@ -478,118 +509,126 @@ class AgentModuleWidget extends Widget
}
foreach ($row['modules'] as $module_name => $module) {
if ($module === null) {
if (in_array($module_name, $allModules) === true) {
$style = 'background-color: transparent;';
$table_data .= "<td style='".$style."'>";
$table_data .= '</td>';
} else {
continue;
}
} else {
if ($this->values['mTypeShow'] === '1') {
$style = 'text-align: center;';
$style .= ' background-color: transparent;';
$table_data .= "<td style='".$style."'>";
switch ($module) {
case AGENT_STATUS_NORMAL:
$table_data .= \ui_print_status_image(
'module_ok.png',
__(
'%s in %s : NORMAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_CRITICAL:
$table_data .= \ui_print_status_image(
'module_critical.png',
__(
'%s in %s : CRITICAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_WARNING:
$table_data .= \ui_print_status_image(
'module_warning.png',
__(
'%s in %s : WARNING',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_UNKNOWN:
$table_data .= \ui_print_status_image(
'module_unknown.png',
__(
'%s in %s : UNKNOWN',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case 4:
$table_data .= \ui_print_status_image(
'module_no_data.png',
__(
'%s in %s : Not initialize',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_ALERT_FIRED:
default:
$table_data .= \ui_print_status_image(
'module_alertsfired.png',
__(
'%s in %s : ALERTS FIRED',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
}
$table_data .= $module;
$table_data .= '</td>';
} else {
if ($module === null) {
if (in_array($module_name, $allModules) === true) {
$style = 'background-color: transparent;';
$table_data .= "<td style='".$style."'>";
$table_data .= '</td>';
} else {
continue;
}
} else {
$style = 'text-align: center;';
$style .= ' background-color: transparent;';
$table_data .= "<td style='".$style."'>";
switch ($module) {
case AGENT_STATUS_NORMAL:
$table_data .= \ui_print_status_image(
'module_ok.png',
__(
'%s in %s : NORMAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_CRITICAL:
$table_data .= \ui_print_status_image(
'module_critical.png',
__(
'%s in %s : CRITICAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_WARNING:
$table_data .= \ui_print_status_image(
'module_warning.png',
__(
'%s in %s : WARNING',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_UNKNOWN:
$table_data .= \ui_print_status_image(
'module_unknown.png',
__(
'%s in %s : UNKNOWN',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case 4:
$table_data .= \ui_print_status_image(
'module_no_data.png',
__(
'%s in %s : Not initialize',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_ALERT_FIRED:
default:
$table_data .= \ui_print_status_image(
'module_alertsfired.png',
__(
'%s in %s : ALERTS FIRED',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
}
$table_data .= '</td>';
}
}
}
@ -743,9 +782,11 @@ class AgentModuleWidget extends Widget
}
}
} else {
$modules = $agent->searchModules(
['nombre' => array_keys($reduceAllModules)]
);
if (empty($reduceAllModules) === false) {
$modules = $agent->searchModules(
['nombre' => array_keys($reduceAllModules)]
);
}
}
$visualData[$agent_id]['modules'] = $reduceAllModules;
@ -754,7 +795,14 @@ class AgentModuleWidget extends Widget
continue;
}
$visualData[$agent_id]['modules'][$module->name()] = $module->getStatus()->estado();
if ($this->values['mTypeShow'] === '1') {
$mod = $module->toArray();
$mod['datos'] = $module->lastValue();
$module_last_value = modules_get_agentmodule_data_for_humans($mod);
$visualData[$agent_id]['modules'][$module->name()] = $module_last_value;
} else {
$visualData[$agent_id]['modules'][$module->name()] = $module->getStatus()->estado();
}
}
if ((bool) is_metaconsole() === true) {
@ -765,7 +813,10 @@ class AgentModuleWidget extends Widget
}
}
$allModules = array_keys($reduceAllModules);
if (empty($reduceAllModules) === false) {
$allModules = array_keys($reduceAllModules);
}
if ($allModules === null) {
$allModules = [];
}

View File

@ -1265,6 +1265,25 @@ input.datos {
.bg_caca {
background-color: #cacaca;
}
.bg_th {
background-color: #efeff0 !important;
color: #000;
font-weight: bold;
}
.border_table {
border-collapse: collapse !important;
}
.border_th {
border-bottom: 2px solid #bfbfbf !important;
}
.border_tr {
border: 1px solid #dbdbdb !important;
}
/* margins */
.mgn-lf-50 {
margin-left: 50px;