#11326 added top n agents with worst score

This commit is contained in:
Daniel Cebrian 2023-07-27 13:21:57 +02:00
parent 001ffc1799
commit d44df2ea6b
5 changed files with 58 additions and 1 deletions

View File

@ -1019,6 +1019,11 @@ switch ($action) {
$idAgent = $item['id_agent'];
break;
case 'top_n_agents_sh':
$group = $item['id_group'];
$top_n_value = (empty($item['top_n_value']) === true) ? 10 : $item['top_n_value'];
break;
default:
// It's not possible.
break;
@ -7412,6 +7417,10 @@ function chooseType() {
$("#row_agent").show();
break;
case 'top_n_agents_sh':
$("#row_group").show();
$("#row_max_items").show();
break;
}
switch (type) {

View File

@ -1987,6 +1987,12 @@ switch ($action) {
$good_format = true;
break;
case 'top_n_agents_sh':
$values['id_group'] = get_parameter('combo_group');
$values['top_n_value'] = get_parameter('max_items');
$good_format = true;
break;
default:
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter(
@ -2863,6 +2869,12 @@ switch ($action) {
$good_format = true;
break;
case 'top_n_agents_sh':
$values['id_group'] = get_parameter('combo_group');
$values['top_n_value'] = get_parameter('max_items');
$good_format = true;
break;
default:
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter(

View File

@ -935,6 +935,13 @@ function reporting_make_reporting_data(
);
break;
case 'top_n_agents_sh':
$report['contents'][] = reporting_top_n_agents_sh(
$report,
$content
);
break;
default:
// Default.
break;

View File

@ -463,6 +463,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
case 'ncm':
reporting_html_ncm_config($table, $item);
break;
case 'top_n_agents_sh':
reporting_html_top_n_agents_sh($table, $item);
break;
}
if ($item['type'] == 'agent_module') {
@ -478,6 +482,24 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
}
function reporting_html_top_n_agents_sh($table, $item)
{
global $config;
$table->data[1][0] = '<b>'.__('Agent').'</b>';
$table->data[1][1] = '<b>'.__('Last audit scan').'</b>';
$table->data[1][2] = '<b>'.__('Score').'</b>';
$row = 2;
foreach ($item['data'] as $key => $agent) {
$table->data[$row][0] = $agent['alias'];
$table->data[$row][1] = date($config['date_format'], $agent['utimestamp']);
$table->data[$row][2] = $agent['datos'].' %';
$row++;
}
}
/**
* Function to print to HTML SLA report.
*

View File

@ -963,6 +963,13 @@ function reports_get_report_types($template=false, $not_editor=false)
'name' => __('Network configuration changes'),
];
if (enterprise_installed() === true) {
$types['top_n_agents_sh'] = [
'optgroup' => __('Security hardening'),
'name' => __('Top-N agents with the worst score'),
];
}
return $types;
}