Merge branch 'ent-5020-barra-de-eventos-muestra-eventos-de-forma-aleatoria' into 'develop'

Fixed agent event graph bar and link to event list

See merge request artica/pandorafms!2923
This commit is contained in:
vgilc 2019-12-10 11:28:56 +01:00
commit 8ebb3a70f0
1 changed files with 16 additions and 20 deletions

View File

@ -3829,43 +3829,39 @@ function graph_graphic_agentevents($id_agent, $width, $height, $period=0, $homeu
$full_legend[$cont] = $name; $full_legend[$cont] = $name;
$top = ($datelimit + ($periodtime * ($i + 1))); $top = ($datelimit + ($periodtime * ($i + 1)));
$event = db_get_row_filter(
$events = db_get_all_rows_filter(
'tevento', 'tevento',
['id_agente' => $id_agent, ['id_agente' => $id_agent,
'utimestamp > '.$bottom, 'utimestamp > '.$bottom,
'utimestamp < '.$top 'utimestamp < '.$top,
], ],
'criticity, utimestamp' 'criticity, utimestamp'
); );
if (!empty($event['utimestamp'])) { if (!empty($events)) {
$data[$cont]['utimestamp'] = $periodtime; $data[$cont]['utimestamp'] = $periodtime;
switch ($event['criticity']) { $event_criticity = array_column($events, 'criticity');
case EVENT_CRIT_WARNING: if (array_search(EVENT_CRIT_CRITICAL, $event_criticity) !== false) {
$data[$cont]['data'] = 2; $data[$cont]['data'] = EVENT_CRIT_CRITICAL;
break; } else if (array_search(EVENT_CRIT_WARNING, $event_criticity) !== false) {
$data[$cont]['data'] = EVENT_CRIT_WARNING;
case EVENT_CRIT_CRITICAL: } else {
$data[$cont]['data'] = 3; $data[$cont]['data'] = EVENT_CRIT_NORMAL;
break;
default:
$data[$cont]['data'] = 1;
break;
} }
} else { } else {
$data[$cont]['utimestamp'] = $periodtime; $data[$cont]['utimestamp'] = $periodtime;
$data[$cont]['data'] = 1; $data[$cont]['data'] = EVENT_CRIT_NORMAL;
} }
$cont++; $cont++;
} }
$colors = [ $colors = [
1 => COL_NORMAL, 1 => COL_UNKNOWN,
2 => COL_WARNING, EVENT_CRIT_NORMAL => COL_NORMAL,
3 => COL_CRITICAL, EVENT_CRIT_WARNING => COL_WARNING,
4 => COL_UNKNOWN, EVENT_CRIT_CRITICAL => COL_CRITICAL,
]; ];
// Draw slicebar graph // Draw slicebar graph