From 4c4a89ecf12c90ea70f6cd0f4132fbbae55c3a37 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Fri, 22 Sep 2017 15:01:17 +0200 Subject: [PATCH] update info of state in events --- .../include/functions_reporting_html.php | 83 +++++++++---------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 22fb6dafac..8d56a42918 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3886,15 +3886,16 @@ function reporting_get_event_histogram_meta ($width) { $user_groups_ids = array_keys($user_groups); if (empty($user_groups)) { - $groups_condition = ' 1 = 0 '; + $groups_condition = ' AND 1 = 0 '; } else { - $groups_condition = ' id_grupo IN (' . implode(',', $user_groups_ids) . ') '; + $groups_condition = ' AND id_grupo IN (' . implode(',', $user_groups_ids) . ') '; } if (!check_acl ($config['id_user'], 0, "PM")) { $groups_condition .= " AND id_grupo != 0"; } + $status_condition = " AND estado = 0 "; $cont = 0; for ($i = 0; $i < $interval; $i++) { @@ -3923,49 +3924,45 @@ function reporting_get_event_histogram_meta ($width) { $full_legend[$cont] = $name; $top = $datelimit + ($periodtime * ($i + 1)); - $event = db_get_row_filter ('tmetaconsole_event', - array ( - 'utimestamp > '.$bottom, - 'utimestamp < '.$top, - $groups_condition), - 'criticity, utimestamp'); - if (!empty($event['utimestamp'])) { - $data[$cont]['utimestamp'] = $periodtime; - switch ($event['criticity']) { - case 0: - $data[$cont]['data'] = EVENT_CRIT_MAINTENANCE; - break; - case 1: - $data[$cont]['data'] = EVENT_CRIT_INFORMATIONAL; - break; - case 2: - $data[$cont]['data'] = EVENT_CRIT_NORMAL; - break; - case 3: - $data[$cont]['data'] = EVENT_CRIT_WARNING; - break; - case 4: - $data[$cont]['data'] = EVENT_CRIT_CRITICAL; - break; - case 5: - $data[$cont]['data'] = EVENT_CRIT_MINOR; - break; - case 6: - $data[$cont]['data'] = EVENT_CRIT_MAJOR; - break; - case 20: - $data[$cont]['data'] = EVENT_CRIT_NOT_NORMAL; - break; - case 34: - $data[$cont]['data'] = EVENT_CRIT_WARNING_OR_CRITICAL; - break; - default: - $data[$cont]['data'] = 1; - break; - } + $time_condition = 'utimestamp > '.$bottom . ' AND utimestamp < '.$top; + $sql = sprintf('SELECT criticity,utimestamp + FROM tmetaconsole_event + WHERE %s %s %s + ORDER BY criticity DESC', + $time_condition, $groups_condition, $status_condition); + + $events = db_get_all_rows_sql($sql); + + $events_criticity = array(); + foreach ($events as $key => $value) { + array_push($events_criticity,$value['criticity']); } - else { + + if (!empty($events)) { + if(array_search('4',$events_criticity) !== false){ + $data[$cont]['data'] = EVENT_CRIT_CRITICAL; + }else if (array_search('3',$events_criticity) !== false){ + $data[$cont]['data'] = EVENT_CRIT_WARNING; + }else if(array_search('6',$events_criticity) !== false){ + $data[$cont]['data'] = EVENT_CRIT_MAJOR; + }else if(array_search('5',$events_criticity) !== false){ + $data[$cont]['data'] = EVENT_CRIT_MINOR; + }else if(array_search('20',$events_criticity) !== false){ + $data[$cont]['data'] = EVENT_CRIT_NOT_NORMAL; + }else if(array_search('34',$events_criticity) !== false){ + $data[$cont]['data'] = EVENT_CRIT_WARNING_OR_CRITICAL; + }else if(array_search('2',$events_criticity) !== false){ + $data[$cont]['data'] = EVENT_CRIT_NORMAL; + }else if(array_search('0',$events_criticity) !== false){ + $data[$cont]['data'] = EVENT_CRIT_MAINTENANCE; + }else { + $data[$cont]['data'] = EVENT_CRIT_INFORMATIONAL; + } + + $data[$cont]['utimestamp'] = $periodtime; + + } else { $data[$cont]['utimestamp'] = $periodtime; $data[$cont]['data'] = 1; }