mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
Feature. new form of groped data in event list. Tiquet: #3079
(cherry picked from commit 9f772e5091e7e559f875947bf82be4e4c69d5493)
This commit is contained in:
parent
f0c36f2c52
commit
0f175eab72
@ -2951,4 +2951,70 @@ function events_checks_event_tags($event_data, $acltags) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function events_get_events_grouped_by_agent($sql_post, $offset = 0,
|
||||||
|
$pagination = 1, $meta = false, $history = false, $total = false) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$table = events_get_events_table($meta, $history);
|
||||||
|
|
||||||
|
if ($meta) {
|
||||||
|
$groupby_extra = ', server_id';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$groupby_extra = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($config["dbtype"]) {
|
||||||
|
case "mysql":
|
||||||
|
if ($total) {
|
||||||
|
$sql = "SELECT COUNT(*) FROM (select id_agente,
|
||||||
|
event_type, count(*) as total from $table WHERE 1=1
|
||||||
|
$sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente ) AS t";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sql = "select id_agente, event_type, count(*) as total, id_grupo from $table
|
||||||
|
WHERE id_agente > 0 $sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente LIMIT $offset,$pagination";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'postgresql':
|
||||||
|
if ($total) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sql = "select id_agente, event_type, count(*), id_grupo as total from $table
|
||||||
|
WHERE id_agente > 0 $sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente LIMIT $offset,$pagination";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'oracle':
|
||||||
|
if ($total) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$set = array();
|
||||||
|
$set['limit'] = $pagination;
|
||||||
|
$set['offset'] = $offset;
|
||||||
|
|
||||||
|
$sql = "select id_agente, event_type, count(*), id_grupo as total from $table
|
||||||
|
WHERE id_agente > 0 $sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente ";
|
||||||
|
$sql = oracle_recode_query ($sql, $set);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
//Extract the events by filter (or not) from db
|
||||||
|
|
||||||
|
$events = db_get_all_rows_sql ($sql);
|
||||||
|
$result = array();
|
||||||
|
|
||||||
|
if ($events) {
|
||||||
|
foreach ($events as $event) {
|
||||||
|
$id_agente = $event['id_agente'];
|
||||||
|
$result[$id_agente][$event['event_type']] = $event['total'];
|
||||||
|
$result[$id_agente]['id_grupo'] = $event['id_grupo'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
require_once ($config["homedir"] . "/include/functions_ui.php");
|
||||||
|
|
||||||
|
|
||||||
$table = new stdClass();
|
$table = new stdClass();
|
||||||
if(!isset($table->width)) {
|
if(!isset($table->width)) {
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
@ -26,6 +31,119 @@ if(!isset($table->class)) {
|
|||||||
$table->head = array ();
|
$table->head = array ();
|
||||||
$table->data = array ();
|
$table->data = array ();
|
||||||
|
|
||||||
|
if ($group_rep == 2) {
|
||||||
|
$table->class = "databox filters data";
|
||||||
|
$table->head[0] = __('Agent name');
|
||||||
|
$table->head[1] = __('Unknown Monitor');
|
||||||
|
$table->head[2] = __('Monitor Normal');
|
||||||
|
$table->head[3] = __('Monitor Warning');
|
||||||
|
$table->head[4] = __('Monitor Critical');
|
||||||
|
$table->head[5] = __('Alert fired');
|
||||||
|
|
||||||
|
$params = "search=" . rawurlencode(io_safe_input($search)) .
|
||||||
|
"&severity=" . $severity .
|
||||||
|
"&status=" . $status .
|
||||||
|
"&id_group=" . $id_group .
|
||||||
|
"&recursion=" . $recursion .
|
||||||
|
"&refr=" . (int)get_parameter("refr", 0) .
|
||||||
|
"&id_agent_module=" . $id_agent_module .
|
||||||
|
"&pagination=" . $pagination .
|
||||||
|
"&group_rep=0" .
|
||||||
|
"&event_view_hr=" . $event_view_hr .
|
||||||
|
"&id_user_ack=" . $id_user_ack .
|
||||||
|
"&tag_with=". $tag_with_base64 .
|
||||||
|
"&tag_without=" . $tag_without_base64 .
|
||||||
|
"&filter_only_alert" . $filter_only_alert .
|
||||||
|
"&offset=" . $offset .
|
||||||
|
"&toogle_filter=no" .
|
||||||
|
"&filter_id=" . $filter_id .
|
||||||
|
"&id_name=" . $id_name .
|
||||||
|
"&history=" . (int)$history .
|
||||||
|
"&section=" . $section .
|
||||||
|
"&open_filter=" . $open_filter .
|
||||||
|
"&date_from=" . $date_from .
|
||||||
|
"&date_to=" . $date_to .
|
||||||
|
"&pure=" . $config["pure"];
|
||||||
|
if ($meta) {
|
||||||
|
$params .= "&text_agent=" . $text_agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url_agente = "index.php?sec=eventos&sec2=operation/events/events&" . $params;
|
||||||
|
foreach ($result as $key => $res) {
|
||||||
|
$table->data[$key][0] = agents_get_name ($key);
|
||||||
|
$key_result = array_keys($res);
|
||||||
|
$url_agente .= "&id_agent=" . $key;
|
||||||
|
|
||||||
|
$unknown = 0;
|
||||||
|
if (in_array('going_unknown',$key_result))
|
||||||
|
$unknown += $res['going_unknown'];
|
||||||
|
$url_unknown = $url_agente . "&event_type=going_unknown";
|
||||||
|
$table->data[$key][1] = '<a href="'.$url_unknown.'" target="_blank" >' . $unknown . '</a>';
|
||||||
|
|
||||||
|
$normal = 0;
|
||||||
|
if (in_array('going_down_normal',$key_result))
|
||||||
|
$normal += $res['going_down_normal'];
|
||||||
|
if (in_array('going_up_normal',$key_result))
|
||||||
|
$normal += $res['going_up_normal'];
|
||||||
|
$url_normal = $url_agente . "&event_type=normal";
|
||||||
|
$table->data[$key][2] = '<a href="'.$url_normal.'" target="_blank" >' . $normal . '</a>';
|
||||||
|
|
||||||
|
$warning = 0;
|
||||||
|
if (in_array('going_up_warning',$key_result))
|
||||||
|
$warning += $res['going_up_warning'];
|
||||||
|
if (in_array('going_down_warning',$key_result))
|
||||||
|
$warning += $res['going_down_warning'];
|
||||||
|
$url_warning = $url_agente . "&event_type=warning";
|
||||||
|
$table->data[$key][3] = '<a href="'.$url_warning.'" target="_blank" >' . $warning . '</a>';
|
||||||
|
|
||||||
|
$critical = 0;
|
||||||
|
if (in_array('going_up_critical',$key_result))
|
||||||
|
$critical += $res['going_up_critical'];
|
||||||
|
if (in_array('going_down_critical',$key_result))
|
||||||
|
$critical += $res['going_down_critical'];
|
||||||
|
$url_critical = $url_agente . "&event_type=critical";
|
||||||
|
$table->data[$key][4] = '<a href="'.$url_critical.'" target="_blank" >' . $critical . '</a>';
|
||||||
|
|
||||||
|
$alert = 0;
|
||||||
|
if (in_array('alert_fired',$key_result))
|
||||||
|
$alert += $res['alert_fired'];
|
||||||
|
$url_alert = $url_agente . "&event_type=alert_fired";
|
||||||
|
$table->data[$key][5] = '<a href="'.$url_alert.'" target="_blank" >' . $alert . '</a>';
|
||||||
|
|
||||||
|
if ($alert > 0) {
|
||||||
|
$table->rowstyle[$key] = 'background: #FFA631;';
|
||||||
|
}
|
||||||
|
elseif ($critical > 0){
|
||||||
|
$table->rowstyle[$key] = 'background: #FC4444;';
|
||||||
|
}
|
||||||
|
elseif ($warning > 0){
|
||||||
|
$table->rowstyle[$key] = 'background: #FAD403;';
|
||||||
|
}
|
||||||
|
elseif ($normal > 0){
|
||||||
|
$table->rowstyle[$key] = 'background: #80BA27;';
|
||||||
|
}
|
||||||
|
elseif ($unknown > 0){
|
||||||
|
$table->rowstyle[$key] = 'background: #B2B2B2;';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
if ($allow_pagination) {
|
||||||
|
ui_pagination ($total_events, $url, $offset, $pagination);
|
||||||
|
}
|
||||||
|
|
||||||
|
html_print_table ($table);
|
||||||
|
|
||||||
|
if ($allow_pagination) {
|
||||||
|
ui_pagination ($total_events, $url, $offset, $pagination);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo '<div class="nf">' . __('No events') . '</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
//fields that the user has selected to show
|
//fields that the user has selected to show
|
||||||
if ($meta) {
|
if ($meta) {
|
||||||
$show_fields = events_meta_get_custom_fields_user();
|
$show_fields = events_meta_get_custom_fields_user();
|
||||||
@ -679,5 +797,5 @@ else {
|
|||||||
echo '<div class="nf">' . __('No events') . '</div>';
|
echo '<div class="nf">' . __('No events') . '</div>';
|
||||||
}
|
}
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -560,6 +560,7 @@ $data[1] .= html_print_input_text ('event_view_hr', $event_view_hr, '', 5, 255,
|
|||||||
$data[2] = __("Repeated") . $jump;
|
$data[2] = __("Repeated") . $jump;
|
||||||
$repeated_sel[0] = __("All events");
|
$repeated_sel[0] = __("All events");
|
||||||
$repeated_sel[1] = __("Group events");
|
$repeated_sel[1] = __("Group events");
|
||||||
|
$repeated_sel[2] = __("Group agents");
|
||||||
$data[2] .= html_print_select ($repeated_sel, "group_rep", $group_rep, '', '', 0, true);
|
$data[2] .= html_print_select ($repeated_sel, "group_rep", $group_rep, '', '', 0, true);
|
||||||
$table->data[] = $data;
|
$table->data[] = $data;
|
||||||
$table->rowclass[] = '';
|
$table->rowclass[] = '';
|
||||||
@ -680,7 +681,7 @@ if ($group_rep == 0) {
|
|||||||
//Extract the events by filter (or not) from db
|
//Extract the events by filter (or not) from db
|
||||||
$result = db_get_all_rows_sql ($sql);
|
$result = db_get_all_rows_sql ($sql);
|
||||||
}
|
}
|
||||||
else {
|
elseif ($group_rep == 1) {
|
||||||
$result = events_get_events_grouped(
|
$result = events_get_events_grouped(
|
||||||
$sql_post,
|
$sql_post,
|
||||||
$offset,
|
$offset,
|
||||||
@ -688,6 +689,14 @@ else {
|
|||||||
$meta,
|
$meta,
|
||||||
$history);
|
$history);
|
||||||
}
|
}
|
||||||
|
elseif ($group_rep == 2) {
|
||||||
|
$result = events_get_events_grouped_by_agent(
|
||||||
|
$sql_post,
|
||||||
|
$offset,
|
||||||
|
$pagination,
|
||||||
|
$meta,
|
||||||
|
$history);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($result)) {
|
if (!empty($result)) {
|
||||||
if ($group_rep == 0) {
|
if ($group_rep == 0) {
|
||||||
@ -695,7 +704,7 @@ if (!empty($result)) {
|
|||||||
FROM $event_table
|
FROM $event_table
|
||||||
WHERE 1=1 " . $sql_post;
|
WHERE 1=1 " . $sql_post;
|
||||||
}
|
}
|
||||||
else {
|
elseif ($group_rep == 1) {
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
case "postgresql":
|
case "postgresql":
|
||||||
@ -713,6 +722,10 @@ if (!empty($result)) {
|
|||||||
GROUP BY to_char(evento), id_agentmodule) t";
|
GROUP BY to_char(evento), id_agentmodule) t";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
elseif ($group_rep == 2) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$limit = (int) db_get_sql ($sql);
|
$limit = (int) db_get_sql ($sql);
|
||||||
|
|
||||||
@ -745,14 +758,19 @@ if (!empty($result)) {
|
|||||||
//Extract the events by filter (or not) from db
|
//Extract the events by filter (or not) from db
|
||||||
$results_graph = db_get_all_rows_sql ($sql);
|
$results_graph = db_get_all_rows_sql ($sql);
|
||||||
}
|
}
|
||||||
else {
|
elseif ($group_rep == 1) {
|
||||||
$results_graph = events_get_events_grouped($sql_post,
|
$results_graph = events_get_events_grouped($sql_post,
|
||||||
0,
|
0,
|
||||||
$limit,
|
$limit,
|
||||||
$meta,
|
$meta,
|
||||||
$history);
|
$history);
|
||||||
}
|
}
|
||||||
|
elseif ($group_rep == 2) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($group_rep == 1) OR ($group_rep == 0)) {
|
||||||
$graph = '<div style="width: 350px; margin: 0 auto;">' .
|
$graph = '<div style="width: 350px; margin: 0 auto;">' .
|
||||||
grafico_eventos_agente(350, 185,
|
grafico_eventos_agente(350, 185,
|
||||||
$results_graph, $meta, $history, $tags_acls_condition,$limit) .
|
$results_graph, $meta, $history, $tags_acls_condition,$limit) .
|
||||||
@ -760,6 +778,7 @@ if (!empty($result)) {
|
|||||||
html_print_div(array('id' => 'events_graph',
|
html_print_div(array('id' => 'events_graph',
|
||||||
'hidden' => true, 'content' => $graph));
|
'hidden' => true, 'content' => $graph));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!empty($result)) {
|
if (!empty($result)) {
|
||||||
@ -789,7 +808,7 @@ if ($group_rep == 0) {
|
|||||||
FROM $event_table
|
FROM $event_table
|
||||||
WHERE 1=1 $sql_post";
|
WHERE 1=1 $sql_post";
|
||||||
}
|
}
|
||||||
else {
|
elseif ($group_rep == 1) {
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
case "postgresql":
|
case "postgresql":
|
||||||
@ -808,9 +827,13 @@ else {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elseif ($group_rep == 2) {
|
||||||
|
$sql = "SELECT COUNT(*) FROM (select id_agente as total from $event_table WHERE id_agente > 0
|
||||||
|
$sql_post GROUP BY id_agente ORDER BY id_agente ) AS t";
|
||||||
|
}
|
||||||
|
|
||||||
$total_events = (int) db_get_sql ($sql);
|
$total_events = (int) db_get_sql ($sql);
|
||||||
|
|
||||||
if (empty ($result)) {
|
if (empty ($result)) {
|
||||||
$result = array ();
|
$result = array ();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user