diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 08218e7f51..487f1b476d 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -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'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; } 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'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; } else { $fullscreen['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; + 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']).''; } } + // Type show. + $show_select = [ + 0 => __('Show module status'), + 1 => __('Show module data'), + ]; + + $filter_type_label = ''.__('Information to be shown').''; + $filter_type = html_print_select($show_select, 'show_type', $show_type, '', '', 0, true, false, false, '', false, 'min-width: 180px;'); + // Groups. $filter_groups_label = ''.__('Group').''; $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&pure=0&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&pure=0&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 = '
'; - $show_filters .= ''; + $show_filters .= '
'; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; $show_filters .= ''; $show_filters .= ''; $show_filters .= ''; @@ -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 "
'.$filter_type_label.''.$filter_type.'
'.$filter_groups_label.''.$filter_groups.'   '.$filter_recursion_label.$filter_recursion.'".html_print_image( + echo "".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 "".html_print_image( + echo "".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 ""; $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 ''; @@ -877,22 +928,24 @@ function mainAgentsModules() echo '
'; - $show_legend = "
"; - $show_legend .= "
-
".__('Orange cell when the module has fired alerts').'
'; - $show_legend .= "
-
".__('Red cell when the module has a critical status').' -
'; - $show_legend .= "
-
".__('Yellow cell when the module has a warning status').'
'; - $show_legend .= "
-
".__('Green cell when the module has a normal status').'
'; - $show_legend .= "
-
".__('Grey cell when the module has an unknown status').'
'; - $show_legend .= "
-
".__("Cell turns blue when the module is in 'not initialize' status").'
'; - $show_legend .= '
'; - ui_toggle($show_legend, __('Legend')); + if ($show_type === 0) { + $show_legend = "
"; + $show_legend .= "
+
".__('Orange cell when the module has fired alerts').'
'; + $show_legend .= "
+
".__('Red cell when the module has a critical status').' +
'; + $show_legend .= "
+
".__('Yellow cell when the module has a warning status').'
'; + $show_legend .= "
+
".__('Green cell when the module has a normal status').'
'; + $show_legend .= "
+
".__('Grey cell when the module has an unknown status').'
'; + $show_legend .= "
+
".__("Cell turns blue when the module is in 'not initialize' status").'
'; + $show_legend .= '
'; + ui_toggle($show_legend, __('Legend')); + } $pure_var = $config['pure']; if ($pure_var) { diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 8cd4172daf..901549b253 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -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'; + + + + __('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' + ); + ?> + + + @@ -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(); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index fbad042ef1..7fc89b6267 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -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; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index a53246c071..944733ffd0 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -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;', diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index a9f2f71b3e..5eb016c3b0 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -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; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index b18b2a4b91..9973e9df55 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -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_data .= ''; + $table_data = '
'.__('Agents').' / '.__('Modules').'
'; + $table_data .= ''; + $table_data .= ''; $first = reset($item['data']); $list_modules = $first['modules']; @@ -1823,11 +1823,14 @@ function reporting_html_agent_module($table, $item) false, '...' ); - $table_data .= ''; + + $table_data .= ''; } + $table_data .= ''; + foreach ($item['data'] as $row) { - $table_data .= ""; + $table_data .= ""; 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 .= "'; + $table_data .= ''; foreach ($row['modules'] as $module_name => $module) { if ($module === null) { - $table_data .= ""; + $table_data .= ''; } else { - $table_data .= "'; @@ -1986,18 +1993,19 @@ function reporting_html_agent_module($table, $item) $table_data .= '
'.__('Agents').' / '.__('Modules').''.$file_name.''.$file_name.'
".$file_name.''.$file_name.'"; - 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 .= ""; + 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 .= '
'; - $table_data .= "
"; - - $table_data .= ''; - $table_data .= "'; - $table_data .= "'; - $table_data .= "'; - $table_data .= "'; - $table_data .= "'; - $table_data .= "'; - $table_data .= "'; - $table_data .= '
".__('Legend').'
".__('Orange cell when the module has fired alerts').'
".__('Red cell when the module has a critical status').'
".__('Yellow cell when the module has a warning status').'
".__('Green cell when the module has a normal status').'
".__('Grey cell when the module has an unknown status').'
".__("Cell turns grey when the module is in 'not initialize' status").'
'; - $table_data .= '
'; + if (isset($row['show_type']) === false) { + $table_data .= "
"; + $table_data .= ''; + $table_data .= "'; + $table_data .= "'; + $table_data .= "'; + $table_data .= "'; + $table_data .= "'; + $table_data .= "'; + $table_data .= "'; + $table_data .= '
".__('Legend').'
".__('Orange cell when the module has fired alerts').'
".__('Red cell when the module has a critical status').'
".__('Yellow cell when the module has a warning status').'
".__('Green cell when the module has a normal status').'
".__('Grey cell when the module has an unknown status').'
".__("Cell turns grey when the module is in 'not initialize' status").'
'; + $table_data .= '
'; + } $table->data['agent_module']['cell'] = $table_data; } diff --git a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php index 6a0a71ca1f..dbc0c1dcf5 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php @@ -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 = '
'; $table_data .= ''; @@ -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 .= "'; - } else { - continue; - } - } else { + if ($this->values['mTypeShow'] === '1') { $style = 'text-align: center;'; $style .= ' background-color: transparent;'; $table_data .= "'; + } else { + if ($module === null) { + if (in_array($module_name, $allModules) === true) { + $style = 'background-color: transparent;'; + $table_data .= "'; + } else { + continue; + } + } else { + $style = 'text-align: center;'; + $style .= ' background-color: transparent;'; + $table_data .= "'; + } } } @@ -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 = []; } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index a6ddcd02b9..743568eb46 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -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;
"; - $table_data .= '"; - 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 .= '"; + $table_data .= '"; + 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 .= '