Fixed agent event graph bar and link to event list

This commit is contained in:
Luis 2019-12-10 11:28:56 +01:00 committed by vgilc
parent 7d64eabd45
commit 2b03b00223
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;
$top = ($datelimit + ($periodtime * ($i + 1)));
$event = db_get_row_filter(
$events = db_get_all_rows_filter(
'tevento',
['id_agente' => $id_agent,
'utimestamp > '.$bottom,
'utimestamp < '.$top
'utimestamp < '.$top,
],
'criticity, utimestamp'
);
if (!empty($event['utimestamp'])) {
if (!empty($events)) {
$data[$cont]['utimestamp'] = $periodtime;
switch ($event['criticity']) {
case EVENT_CRIT_WARNING:
$data[$cont]['data'] = 2;
break;
case EVENT_CRIT_CRITICAL:
$data[$cont]['data'] = 3;
break;
default:
$data[$cont]['data'] = 1;
break;
$event_criticity = array_column($events, 'criticity');
if (array_search(EVENT_CRIT_CRITICAL, $event_criticity) !== false) {
$data[$cont]['data'] = EVENT_CRIT_CRITICAL;
} else if (array_search(EVENT_CRIT_WARNING, $event_criticity) !== false) {
$data[$cont]['data'] = EVENT_CRIT_WARNING;
} else {
$data[$cont]['data'] = EVENT_CRIT_NORMAL;
}
} else {
$data[$cont]['utimestamp'] = $periodtime;
$data[$cont]['data'] = 1;
$data[$cont]['data'] = EVENT_CRIT_NORMAL;
}
$cont++;
}
$colors = [
1 => COL_NORMAL,
2 => COL_WARNING,
3 => COL_CRITICAL,
4 => COL_UNKNOWN,
1 => COL_UNKNOWN,
EVENT_CRIT_NORMAL => COL_NORMAL,
EVENT_CRIT_WARNING => COL_WARNING,
EVENT_CRIT_CRITICAL => COL_CRITICAL,
];
// Draw slicebar graph