Merge branch 'ent-5289-9247-Group-Alert-Report-bug' into 'develop'

fix bug in group alert report data visualization

See merge request artica/pandorafms!3031
This commit is contained in:
Daniel Rodriguez 2020-02-04 13:25:29 +01:00
commit 0e9e59efbb
1 changed files with 35 additions and 15 deletions

View File

@ -3679,7 +3679,7 @@ function agents_get_network_interfaces_array(
/**
* reporting alert get fired
*/
function reporting_alert_get_fired($id_agent_module, $id_alert_template_module, $period, $datetime)
function reporting_alert_get_fired($id_agent_module, $id_alert_template_module, $period, $datetime, $return_empty=true)
{
$fired = [];
$firedTimes = get_module_alert_fired(
@ -3709,7 +3709,11 @@ function reporting_alert_get_fired($id_agent_module, $id_alert_template_module,
if ($fireTime['utimestamp'] > $datelimit && $fireTime['utimestamp'] <= $datetime) {
$fired[] = $fireTime['timestamp'];
} else {
$fired[] = $empty;
if ($return_empty === true) {
$fired[] = $empty;
} else {
continue;
}
}
}
@ -3821,10 +3825,15 @@ function reporting_alert_report_group($report, $content)
foreach ($actions['custom'] as $action) {
$data_action[$naction]['name'] = $action['name'];
$fired = $action['fired'];
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)) {
$data_action[$naction]['fired'] = '----------------------------';
} else {
$data_action[$naction]['fired'] = $fired;
if ($fired == 0) {
$data_action[$naction]['fired'] = __('Not triggered');
} else if ($fired > 0) {
if ($fired > $datelimit && $fired < $datetime) {
$data_action[$naction]['fired'] = $fired;
} else {
continue 2;
}
}
$naction++;
@ -3833,10 +3842,15 @@ function reporting_alert_report_group($report, $content)
foreach ($actions['default'] as $action) {
$data_action[$naction]['name'] = $action['name'];
$fired = $action['fired'];
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)) {
$data_action[$naction]['fired'] = '----------------------------';
} else {
$data_action[$naction]['fired'] = $fired;
if ($fired == 0) {
$data_action[$naction]['fired'] = __('Not triggered');
} else if ($fired > 0) {
if ($fired > $datelimit && $fired < $datetime) {
$data_action[$naction]['fired'] = $fired;
} else {
continue 2;
}
}
$naction++;
@ -3845,10 +3859,15 @@ function reporting_alert_report_group($report, $content)
foreach ($actions['unavailable'] as $action) {
$data_action[$naction]['name'] = $action['name'];
$fired = $action['fired'];
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)) {
$data_action[$naction]['fired'] = '----------------------------';
} else {
$data_action[$naction]['fired'] = $fired;
if ($fired == 0) {
$data_action[$naction]['fired'] = __('Not triggered');
} else if ($fired > 0) {
if ($fired > $datelimit && $fired < $datetime) {
$data_action[$naction]['fired'] = $fired;
} else {
continue 2;
}
}
$naction++;
@ -3862,7 +3881,8 @@ function reporting_alert_report_group($report, $content)
$agent_module['id_agent_module'],
$actions['id'],
(int) $content['period'],
(int) $report['datetime']
(int) $report['datetime'],
false
);
$module_actions['actions'] = $data_action;