fixed errors in events reports #135

This commit is contained in:
daniel 2017-01-11 13:26:50 +01:00
parent 2224478ed5
commit 993bad314d
7 changed files with 714 additions and 753 deletions

View File

@ -95,17 +95,15 @@ $percentil = false;
$time_compare_overlapped = false;
//Added for events items
$filter_event_validated = false;
$filter_event_no_validated = false;
$filter_event_critical = false;
$filter_event_warning = false;
$filter_event_type = false;
$show_summary_group = false;
$filter_event_severity = false;
$filter_event_type = false;
$filter_event_status = false;
$event_graph_by_agent = false;
$event_graph_by_user_validator = false;
$event_graph_by_criticity = false;
$event_graph_validated_vs_unvalidated = false;
$netflow_filter = 0;
$max_values = 0;
$resolution = 0;
@ -401,33 +399,17 @@ switch ($action) {
$group = $item['id_group'];
break;
case 'event_report_agent':
$description = $item['description'];
$idAgent = $item['id_agent'];
$period = $item['period'];
//Added for events items
$filter_event_no_validated = $style['filter_event_no_validated'];
$filter_event_validated = $style['filter_event_validated'];
$filter_event_critical = $style['filter_event_critical'];
$filter_event_warning = $style['filter_event_warning'];
$filter_event_type = json_decode($style['filter_event_type'], true);
$event_graph_by_agent = $style['event_graph_by_agent'];
$event_graph_by_user_validator = $style['event_graph_by_user_validator'];
$event_graph_by_criticity = $style['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
break;
case 'event_report_group':
$description = $item['description'];
$period = $item['period'];
$group = $item['id_group'];
$idAgent = $item['id_agent'];
//Added for events items
$filter_event_no_validated = $style['filter_event_no_validated'];
$filter_event_validated = $style['filter_event_validated'];
$filter_event_critical = $style['filter_event_critical'];
$filter_event_warning = $style['filter_event_warning'];
$filter_event_type = json_decode($style['filter_event_type'], true);
$show_summary_group = $style['show_summary_group'];
$filter_event_severity = json_decode($style['filter_event_severity'], true);
$filter_event_status = json_decode($style['filter_event_status'], true);
$filter_event_type = json_decode($style['filter_event_type'], true);
$event_graph_by_agent = $style['event_graph_by_agent'];
$event_graph_by_user_validator = $style['event_graph_by_user_validator'];
@ -1338,22 +1320,28 @@ You can of course remove the warnings, that's why we include the source and do n
?>
</td>
</tr>
<tr id="row_event_filter" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Event filter'); ?></td>
<tr id="row_show_summary_group" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Show Summary group'); ?></td>
<td>
<?php
echo __('No Validated');
html_print_checkbox ('filter_event_no_validated', true, $filter_event_no_validated);
echo __('Validated');
html_print_checkbox ('filter_event_validated', true, $filter_event_validated);
echo __('Critical');
html_print_checkbox ('filter_event_critical', true, $filter_event_critical);
echo __('Warning');
html_print_checkbox ('filter_event_warning', true, $filter_event_warning);
html_print_checkbox ('show_summary_group', true, $show_summary_group);
?>
</td>
</tr>
<tr id="row_event_severity" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Severity'); ?></td>
<td>
<?php
$valuesSeverity = get_priorities ();
html_print_select ($valuesSeverity, 'filter_event_severity[]',
$filter_event_severity, '', __('All'), 'all', false, true,
false, '', false, false, false, false, false, '');
?>
</td>
</tr>
<tr id="row_event_type" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Event type'); ?></td>
<td>
@ -1362,11 +1350,22 @@ You can of course remove the warnings, that's why we include the source and do n
html_print_select ($event_types_select, 'filter_event_type[]',
$filter_event_type, '', __('All'), 'all', false, true,
false, '', false, false, false, false, false, '');
?>
</td>
</tr>
<tr id="row_event_status" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Event Status'); ?></td>
<td>
<?php
$fields = events_get_all_status(true);
html_print_select ($fields, 'filter_event_status[]',
$filter_event_status, '', '', '', false, true,
false, '', false, false, false, false, false, '');
?>
</td>
</tr>
<tr id="row_event_graphs" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Event graphs'); ?></td>
<td>
@ -2479,7 +2478,6 @@ function chooseType() {
$("#row_date").hide();
$("#row_agent_multi").hide();
$("#row_module_multi").hide();
$("#row_event_filter").hide();
$("#row_event_graphs").hide();
$("#row_event_graph_by_agent").hide();
$("#row_event_graph_by_user").hide();
@ -2494,7 +2492,10 @@ function chooseType() {
$("#agents_row").hide();
$("#select_agent_modules").hide();
$("#modules_row").hide();
$("#row_show_summary_group").hide();
$("#row_event_severity").hide();
$("#row_event_type").hide();
$("#row_event_status").hide();
// SLA list default state
$("#sla_list").hide();
@ -2510,24 +2511,6 @@ function chooseType() {
$('#agent_autocomplete_events').show();
switch (type) {
case 'event_report_group':
$("#row_description").show();
$("#row_period").show();
$("#row_servers").show();
$("#row_group").show();
$("#row_show_in_two_columns").show();
$("#row_event_filter").show();
$("#row_event_graphs").show();
$("#row_event_graph_by_agent").show();
$("#row_event_graph_by_user").show();
$("#row_event_graph_by_criticity").show();
$("#row_event_graph_by_validated").show();
$("#row_event_type").show();
$("#row_filter_search").show();
break;
case 'simple_graph':
$("#row_time_compare_overlapped").show();
$("#row_only_avg").show();
@ -2782,12 +2765,36 @@ function chooseType() {
$("#row_show_in_two_columns").show();
break;
case 'event_report_group':
$("#row_description").show();
$("#row_period").show();
$("#row_servers").show();
$("#row_group").show();
$("#row_show_in_two_columns").show();
$("#row_event_severity").show();
$("#row_event_status").show();
$("#row_show_summary_group").show();
$("#row_event_graphs").show();
$("#row_event_graph_by_agent").show();
$("#row_event_graph_by_user").show();
$("#row_event_graph_by_criticity").show();
$("#row_event_graph_by_validated").show();
$("#row_event_type").show();
$("#row_filter_search").show();
break;
case 'event_report_agent':
$("#row_description").show();
$("#row_agent").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
$("#row_event_filter").show();
$("#row_event_severity").show();
$("#row_event_status").show();
$("#row_show_summary_group").show();
$("#row_event_graphs").show();
$("#row_event_graph_by_user").show();
@ -2797,6 +2804,7 @@ function chooseType() {
$('#agent_autocomplete').hide();
$('#agent_autocomplete_events').show();
$("#row_filter_search").show();
break;
case 'event_report_module':

View File

@ -1065,15 +1065,14 @@ switch ($action) {
$resultOperationDB = false;
break;
}
$filter_event_validated = get_parameter('filter_event_validated', 0);
$filter_event_no_validated = get_parameter('filter_event_no_validated', 0);
$filter_event_critical = get_parameter('filter_event_critical', 0);
$filter_event_warning = get_parameter('filter_event_warning', 0);
$filter_event_type = get_parameter('filter_event_type', '');
$event_graph_by_agent = get_parameter('event_graph_by_agent', 0);
$event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0);
$event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0);
$show_summary_group = get_parameter('show_summary_group', 0);
$filter_event_severity = get_parameter('filter_event_severity', 0);
$filter_event_type = get_parameter('filter_event_type', '');
$filter_event_status = get_parameter('filter_event_status', 0);
$event_graph_by_agent = get_parameter('event_graph_by_agent', 0);
$event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0);
$event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0);
$event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0);
$event_filter_search = get_parameter('filter_search', '');
@ -1136,11 +1135,11 @@ switch ($action) {
case 'event_report_agent':
case 'event_report_group':
//Added for events items
$style['filter_event_no_validated'] = $filter_event_no_validated;
$style['filter_event_validated'] = $filter_event_validated;
$style['filter_event_critical'] = $filter_event_critical;
$style['filter_event_warning'] = $filter_event_warning;
$style['filter_event_type'] = json_encode($filter_event_type);
$style['show_summary_group'] = $show_summary_group;
$style['filter_event_severity'] = json_encode($filter_event_severity);
$style['filter_event_type'] = json_encode($filter_event_type);
$style['filter_event_status'] = json_encode($filter_event_status);
$style['event_graph_by_agent'] = $event_graph_by_agent;
$style['event_graph_by_user_validator'] = $event_graph_by_user_validator;
$style['event_graph_by_criticity'] = $event_graph_by_criticity;
@ -1148,10 +1147,8 @@ switch ($action) {
switch ($values['type']) {
case 'event_report_group':
$style['event_filter_search'] =
$event_filter_search;
break;
case 'event_report_agent':
$style['event_filter_search'] = $event_filter_search;
if ($label != '')
$style['label'] = $label;
else
@ -1449,38 +1446,35 @@ switch ($action) {
switch ($values['type']) {
case 'event_report_agent':
case 'event_report_group':
$filter_event_no_validated = get_parameter('filter_event_no_validated', 0);
$filter_event_validated = get_parameter('filter_event_validated', 0);
$filter_event_critical = get_parameter('filter_event_critical', 0);
$filter_event_warning = get_parameter('filter_event_warning', 0);
case 'event_report_group':
$show_summary_group = get_parameter('show_summary_group', 0);
$filter_event_severity = get_parameter('filter_event_severity', '');
$filter_event_type = get_parameter('filter_event_type', '');
$filter_event_status = get_parameter('filter_event_status', '');
$event_graph_by_agent = get_parameter('event_graph_by_agent', 0);
$event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0);
$event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0);
$event_graph_by_agent = get_parameter('event_graph_by_agent', 0);
$event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0);
$event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0);
$event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0);
$filter_event_type = get_parameter('filter_event_type', '');
$event_filter_search = get_parameter('filter_search', '');
//Added for events items
$style['filter_event_no_validated'] = $filter_event_no_validated;
$style['filter_event_validated'] = $filter_event_validated;
$style['filter_event_critical'] = $filter_event_critical;
$style['filter_event_warning'] = $filter_event_warning;
$style['filter_event_type'] = json_encode($filter_event_type);
$style['event_graph_by_agent'] = $event_graph_by_agent;
$style['event_graph_by_user_validator'] = $event_graph_by_user_validator;
$style['event_graph_by_criticity'] = $event_graph_by_criticity;
$style['show_summary_group'] = $show_summary_group;
$style['filter_event_severity'] = json_encode($filter_event_severity);
$style['filter_event_type'] = json_encode($filter_event_type);
$style['filter_event_status'] = json_encode($filter_event_status);
$style['event_graph_by_agent'] = $event_graph_by_agent;
$style['event_graph_by_user_validator'] = $event_graph_by_user_validator;
$style['event_graph_by_criticity'] = $event_graph_by_criticity;
$style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated;
switch ($values['type']) {
case 'event_report_group':
$style['event_filter_search'] =
$event_filter_search;
break;
case 'event_report_agent':
$style['event_filter_search'] = $event_filter_search;
if ($label != '')
$style['label'] = $label;
else

View File

@ -109,6 +109,20 @@ function events_get_event ($id, $fields = false) {
return $event;
}
function events_get_events_no_grouped($sql_post, $offset = 0,
$pagination = 1, $meta = false, $history = false, $total = false,
$history_db = false, $order = "ASC") {
global $config;
$table = events_get_events_table($meta, $history);
$sql = "SELECT * FROM $table te WHERE 1=1 " . $sql_post;
$events = db_get_all_rows_sql ($sql, $history_db);
return $events;
}
function events_get_events_grouped($sql_post, $offset = 0,
$pagination = 1, $meta = false, $history = false, $total = false,
@ -124,7 +138,7 @@ function events_get_events_grouped($sql_post, $offset = 0,
else {
$groupby_extra = '';
}
switch ($config["dbtype"]) {
case "mysql":
db_process_sql ('SET group_concat_max_len = 9999999');
@ -136,19 +150,19 @@ function events_get_events_grouped($sql_post, $offset = 0,
}
else {
$sql = "SELECT *, MAX(id_evento) AS id_evento,
GROUP_CONCAT(DISTINCT user_comment SEPARATOR '<br>') AS user_comment,
GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids,
COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
MIN(utimestamp) AS timestamp_rep_min,
(SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user,
(SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario,
(SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente,
(SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity,
(SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp
FROM $table te
WHERE 1=1 " . $sql_post . "
GROUP BY estado, evento, id_agentmodule" . $groupby_extra . "
ORDER BY timestamp_rep " . $order . " LIMIT " . $offset . "," . $pagination;
GROUP_CONCAT(DISTINCT user_comment SEPARATOR '<br>') AS user_comment,
GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids,
COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep,
MIN(utimestamp) AS timestamp_rep_min,
(SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user,
(SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario,
(SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente,
(SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity,
(SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp
FROM $table te
WHERE 1=1 " . $sql_post . "
GROUP BY estado, evento, id_agentmodule" . $groupby_extra . "
ORDER BY timestamp_rep " . $order . " LIMIT " . $offset . "," . $pagination;
}
break;
case "postgresql":
@ -210,7 +224,6 @@ function events_get_events_grouped($sql_post, $offset = 0,
}
break;
}
//Extract the events by filter (or not) from db
$events = db_get_all_rows_sql ($sql, $history_db);
@ -1173,89 +1186,6 @@ function events_print_type_description ($type, $return = false) {
echo $output;
}
/**
* Get all the events happened in a group during a period of time.
*
* The returned events will be in the time interval ($date - $period, $date]
*
* @param mixed $id_group Group id to get events for.
* @param int $period Period of time in seconds to get events.
* @param int $date Beginning date to get events.
*
* @return array An array with all the events happened.
*/
function events_get_group_events ($id_group, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_search = false, $meta = false, $history = false,
$filter_event_type = false) {
global $config;
$id_group = groups_safe_acl ($config["id_user"], $id_group, "ER");
if (empty ($id_group)) {
//An empty array means the user doesn't have access
return false;
}
$datelimit = $date - $period;
$sql_where = ' AND 1 = 1 ';
$criticities = array();
if ($filter_event_critical) {
$criticities[] = 4;
}
if ($filter_event_warning) {
$criticities[] = 3;
}
if (!empty($criticities)) {
$sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')';
}
if ($filter_event_validated) {
$sql_where .= ' AND estado = 1 ';
}
if ($filter_event_no_validated) {
$sql_where .= ' AND estado = 0 ';
}
if (!empty($filter_event_search)) {
$sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_search) . '%"'.
' OR id_evento LIKE "%' . io_safe_input($filter_event_search) . '%")';
}
if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
$sql_where .= ' AND (';
$type = array();
foreach ($filter_event_type as $event_type) {
if ($event_type != "") {
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
// for the user so for him is presented only "warning, critical and normal"
if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
$type[] = " event_type LIKE '%$event_type%' ";
}
else if ($event_type == "not_normal") {
$type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
}
else if ($event_type != "all") {
$type[] = " event_type = '" . $event_type."'";
}
}
}
$sql_where .= implode(' OR ', $type) . ')';
}
$sql_where .= sprintf('
AND id_grupo IN (%s)
AND utimestamp > %d
AND utimestamp <= %d ',
implode (",", $id_group), $datelimit, $date);
return events_get_events_grouped($sql_where, 0, 1000, $meta,
false, false, $history);
}
/**
* Get all the events happened in a group during a period of time.
*
@ -1328,46 +1258,72 @@ function events_get_group_events_steps ($begin, &$result, $id_group, $period, $d
*
* @return array An array with all the events happened.
*/
function events_get_agent ($id_agent, $period, $date = 0,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$history = false, $filter_event_type = false) {
function events_get_agent ($id_agent, $period, $date = 0,
$history = false, $show_summary_group = false, $filter_event_severity = false,
$filter_event_type = false, $filter_event_status = false, $filter_event_filter_search=false,
$id_group = false, $events_group = false) {
global $config;
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
if (empty ($date)) {
$date = get_system_time ();
}
if($events_group){
$id_group = groups_safe_acl ($config["id_user"], $id_group, "ER");
$datelimit = $date - $period;
$sql_where = '';
$criticities = array();
if ($filter_event_critical) {
$criticities[] = 4;
}
if ($filter_event_warning) {
$criticities[] = 3;
}
if (!empty($criticities)) {
$sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')';
}
if ( $filter_event_validated && $filter_event_no_validated ) {
$sql_where .= " AND (estado = 1 OR estado = 0)";
}
else {
if ($filter_event_validated) {
$sql_where .= ' AND estado = 1 ';
} else {
if ($filter_event_no_validated) {
$sql_where .= ' AND estado = 0 ';
}
if (empty ($id_group)) {
//An empty array means the user doesn't have access
return false;
}
}
$datelimit = $date - $period;
$sql_where = '';
$severity_all = 0;
if (!empty($filter_event_severity)) {
foreach ($filter_event_severity as $key => $value) {
switch ($value) {
case 'all':
$severity_all = 1;
break;
case 34:
$filter_event_severity[$key] = '3, 4';
break;
case 20:
$filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
break;
case 21:
$filter_event_severity[$key] = '4, 2';
break;
default:
break;
}
}
if(!$severity_all){
$sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')';
}
}
$status_all = 0;
if(!empty($filter_event_status)){
foreach ($filter_event_status as $key => $value) {
switch ($value) {
case -1:
$status_all = 1;
break;
default:
break;
}
}
if(!$status_all){
$sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')';
}
}
if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
$sql_where .= ' AND (';
$type = array();
@ -1386,15 +1342,31 @@ function events_get_agent ($id_agent, $period, $date = 0,
}
}
}
$sql_where .= implode(' OR ', $type) . ')';
}
if (!empty($filter_event_filter_search)) {
$sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'.
' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
}
$sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d
if(!$events_group){
$sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d
AND utimestamp <= %d ', $id_agent, $datelimit, $date);
}
else{
$sql_where .= sprintf(' AND id_grupo IN (%s) AND utimestamp > %d
AND utimestamp <= %d ', implode (",", $id_group), $datelimit, $date);
}
return events_get_events_grouped($sql_where, 0, 1000,
if($show_summary_group){
return events_get_events_grouped($sql_where, 0, 1000,
is_metaconsole(), false, false, $history);
}
else{
return events_get_events_no_grouped($sql_where, 0, 1000,
is_metaconsole(), false, false, $history);
}
}
/**
@ -1408,7 +1380,7 @@ function events_get_agent ($id_agent, $period, $date = 0,
*
* @return array An array with all the events happened.
*/
function events_get_module ($id_agent_module, $period, $date = 0, $history = false) {
function events_get_module ($id_agent_module, $period, $date = 0, $history = false, $show_summary_group = false) {
global $config;
if (!is_numeric ($date)) {
@ -1549,13 +1521,22 @@ function events_get_severity_types ($severity_id) {
*
* @return array Status description array.
*/
function events_get_all_status () {
function events_get_all_status ($report = false) {
$fields = array ();
$fields[-1] = __('All event');
$fields[0] = __('Only new');
$fields[1] = __('Only validated');
$fields[2] = __('Only in process');
$fields[3] = __('Only not validated');
if(!$report){
$fields[-1] = __('All event');
$fields[0] = __('Only new');
$fields[1] = __('Only validated');
$fields[2] = __('Only in process');
$fields[3] = __('Only not validated');
}
else{
$fields[-1] = __('All event');
$fields[0] = __('New');
$fields[1] = __('Validated');
$fields[2] = __('In process');
$fields[3] = __('Not Validated');
}
return $fields;
}
@ -2643,12 +2624,20 @@ function events_clean_tags ($tags) {
* @return array An array with all the events happened.
*/
function events_get_count_events_by_agent ($id_group, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_search = false) {
$filter_event_severity = false, $filter_event_type = false,
$filter_event_status = false, $filter_event_filter_search = false) {
global $config;
//date
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
if (empty ($date)) {
$date = get_system_time ();
}
//group
$id_group = groups_safe_acl ($config["id_user"], $id_group, "AR");
if (empty ($id_group)) {
@ -2658,30 +2647,74 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
$datelimit = $date - $period;
$sql_where = ' AND 1 = 1 ';
$criticities = array();
if ($filter_event_critical) {
$criticities[] = 4;
$sql_where = '';
$severity_all = 0;
if (!empty($filter_event_severity)) {
foreach ($filter_event_severity as $key => $value) {
switch ($value) {
case 'all':
$severity_all = 1;
break;
case 34:
$filter_event_severity[$key] = '3, 4';
break;
case 20:
$filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
break;
case 21:
$filter_event_severity[$key] = '4, 2';
break;
default:
break;
}
}
if(!$severity_all){
$sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')';
}
}
if ($filter_event_warning) {
$criticities[] = 3;
}
if (!empty($criticities)) {
$sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')';
$status_all = 0;
if(!empty($filter_event_status)){
foreach ($filter_event_status as $key => $value) {
switch ($value) {
case -1:
$status_all = 1;
break;
default:
break;
}
}
if(!$status_all){
$sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')';
}
}
if ($filter_event_validated) {
$sql_where .= ' AND estado = 1 ';
if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
$sql_where .= ' AND (';
$type = array();
foreach ($filter_event_type as $event_type) {
if ($event_type != "") {
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
// for the user so for him is presented only "warning, critical and normal"
if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
$type[] = " event_type LIKE '%$event_type%' ";
}
else if ($event_type == "not_normal") {
$type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
}
else if ($event_type != "all") {
$type[] = " event_type = '" . $event_type."'";
}
}
}
$sql_where .= implode(' OR ', $type) . ')';
}
if ($filter_event_no_validated) {
$sql_where .= ' AND estado = 0 ';
if (!empty($filter_event_filter_search)) {
$sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'.
' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
}
if (!empty($filter_event_search)) {
$sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_search) . '%%"'.
' OR id_evento LIKE "%%' . io_safe_input($filter_event_search) . '%%")';
}
$sql = sprintf ('SELECT id_agente,
(SELECT t2.nombre
FROM tagente t2
@ -2689,9 +2722,9 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
COUNT(*) AS count
FROM tevento t3
WHERE utimestamp > %d AND utimestamp <= %d
AND id_grupo IN (%s) ' . $sql_where . '
AND id_grupo IN (%s) %s
GROUP BY id_agente',
$datelimit, $date, implode (",", $id_group));
$datelimit, $date, implode (",", $id_group), $sql_where);
$rows = db_get_all_rows_sql ($sql);
@ -2722,12 +2755,11 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
* @return array An array with all the events happened.
*/
function events_get_count_events_validated_by_user ($filter, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_search = false) {
$filter_event_severity = false, $filter_event_type = false,
$filter_event_status = false, $filter_event_filter_search = false) {
global $config;
//group
$sql_filter = ' AND 1=1 ';
if (isset($filter['id_group'])) {
$id_group = groups_safe_acl ($config["id_user"], $filter['id_group'], "AR");
@ -2745,30 +2777,82 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
sprintf(' AND id_agente = %d ', $filter['id_agent']);
}
//date
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
if (empty ($date)) {
$date = get_system_time ();
}
$datelimit = $date - $period;
$sql_where = ' AND 1 = 1 ';
$criticities = array();
if ($filter_event_critical) {
$criticities[] = 4;
$sql_where = '';
$severity_all = 0;
if (!empty($filter_event_severity)) {
foreach ($filter_event_severity as $key => $value) {
switch ($value) {
case 'all':
$severity_all = 1;
break;
case 34:
$filter_event_severity[$key] = '3, 4';
break;
case 20:
$filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
break;
case 21:
$filter_event_severity[$key] = '4, 2';
break;
default:
break;
}
}
if(!$severity_all){
$sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')';
}
}
if ($filter_event_warning) {
$criticities[] = 3;
}
if (!empty($criticities)) {
$sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')';
$status_all = 0;
if(!empty($filter_event_status)){
foreach ($filter_event_status as $key => $value) {
switch ($value) {
case -1:
$status_all = 1;
break;
default:
break;
}
}
if(!$status_all){
$sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')';
}
}
if ($filter_event_validated) {
$sql_where .= ' AND estado = 1 ';
if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
$sql_where .= ' AND (';
$type = array();
foreach ($filter_event_type as $event_type) {
if ($event_type != "") {
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
// for the user so for him is presented only "warning, critical and normal"
if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
$type[] = " event_type LIKE '%$event_type%' ";
}
else if ($event_type == "not_normal") {
$type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
}
else if ($event_type != "all") {
$type[] = " event_type = '" . $event_type."'";
}
}
}
$sql_where .= implode(' OR ', $type) . ')';
}
if ($filter_event_no_validated) {
$sql_where .= ' AND estado = 0 ';
}
if (!empty($filter_event_search)) {
$sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_search) . '%%"'.
' OR id_evento LIKE "%%' . io_safe_input($filter_event_search) . '%%")';
if (!empty($filter_event_filter_search)) {
$sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'.
' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
}
$sql = sprintf ('SELECT id_usuario,
@ -2778,10 +2862,10 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
COUNT(*) AS count
FROM tevento t3
WHERE utimestamp > %d AND utimestamp <= %d
%s ' . $sql_where . '
%s %s
GROUP BY id_usuario',
$datelimit, $date, $sql_filter);
$datelimit, $date, $sql_filter, $sql_where);
$rows = db_get_all_rows_sql ($sql);
if ($rows == false)
@ -2811,9 +2895,8 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
* @return array An array with all the events happened.
*/
function events_get_count_events_by_criticity ($filter, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_search = false) {
$filter_event_severity = false, $filter_event_type = false,
$filter_event_status = false, $filter_event_filter_search = false) {
global $config;
@ -2833,40 +2916,91 @@ function events_get_count_events_by_criticity ($filter, $period, $date,
$sql_filter .=
sprintf(' AND id_agente = %d ', $filter['id_agent']);
}
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
if (empty ($date)) {
$date = get_system_time ();
}
$datelimit = $date - $period;
$sql_where = ' AND 1 = 1 ';
$criticities = array();
if ($filter_event_critical) {
$criticities[] = 4;
$sql_where = '';
$severity_all = 0;
if (!empty($filter_event_severity)) {
foreach ($filter_event_severity as $key => $value) {
switch ($value) {
case 'all':
$severity_all = 1;
break;
case 34:
$filter_event_severity[$key] = '3, 4';
break;
case 20:
$filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
break;
case 21:
$filter_event_severity[$key] = '4, 2';
break;
default:
break;
}
}
if(!$severity_all){
$sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')';
}
}
if ($filter_event_warning) {
$criticities[] = 3;
}
if (!empty($criticities)) {
$sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')';
$status_all = 0;
if(!empty($filter_event_status)){
foreach ($filter_event_status as $key => $value) {
switch ($value) {
case -1:
$status_all = 1;
break;
default:
break;
}
}
if(!$status_all){
$sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')';
}
}
if ($filter_event_validated) {
$sql_where .= ' AND estado = 1 ';
if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
$sql_where .= ' AND (';
$type = array();
foreach ($filter_event_type as $event_type) {
if ($event_type != "") {
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
// for the user so for him is presented only "warning, critical and normal"
if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
$type[] = " event_type LIKE '%$event_type%' ";
}
else if ($event_type == "not_normal") {
$type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
}
else if ($event_type != "all") {
$type[] = " event_type = '" . $event_type."'";
}
}
}
$sql_where .= implode(' OR ', $type) . ')';
}
if ($filter_event_no_validated) {
$sql_where .= ' AND estado = 0 ';
if (!empty($filter_event_filter_search)) {
$sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'.
' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
}
if (!empty($filter_event_search)) {
$sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_search) . '%%"'.
' OR id_evento LIKE "%%' . io_safe_input($filter_event_search) . '%%")';
}
$sql = sprintf ('SELECT criticity,
COUNT(*) AS count
FROM tevento
WHERE utimestamp > %d AND utimestamp <= %d
%s ' . $sql_where . '
%s %s
GROUP BY criticity',
$datelimit, $date, $sql_filter);
$datelimit, $date, $sql_filter, $sql_where);
$rows = db_get_all_rows_sql ($sql);
@ -2893,12 +3027,12 @@ function events_get_count_events_by_criticity ($filter, $period, $date,
* @return array An array with all the events happened.
*/
function events_get_count_events_validated ($filter, $period = null, $date = null,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_search = false) {
$filter_event_severity = false, $filter_event_type = false,
$filter_event_status = false, $filter_event_filter_search = false) {
global $config;
//group
$sql_filter = " 1=1 ";
if (isset($filter['id_group'])) {
$id_group = groups_safe_acl ($config["id_user"], $filter['id_group'], "AR");
@ -2916,6 +3050,14 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul
sprintf(" AND id_agente = %d ", $filter['id_agent']);
}
//date
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
if (empty ($date)) {
$date = get_system_time ();
}
$date_filter = '';
if (!empty($date) && !empty($period)) {
$datelimit = $date - $period;
@ -2934,31 +3076,75 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul
$date_filter .= sprintf (" AND utimestamp <= %d ", $date);
}
$sql_where = " AND 1=1 ";
$criticities = array();
if ($filter_event_critical) {
$criticities[] = 4;
}
if ($filter_event_warning) {
$criticities[] = 3;
}
if (!empty($criticities)) {
$sql_where .= " AND criticity IN (" . implode(",", $criticities) . ")";
}
if ($filter_event_validated) {
$sql_where .= " AND estado = 1 ";
}
if ($filter_event_no_validated) {
$sql_where .= " AND estado = 0 ";
}
if (!empty($filter_event_search)) {
$sql_where .= " AND (evento LIKE '%%" . io_safe_input($filter_event_search) . "%%'" .
" OR id_evento LIKE '%%" . io_safe_input($filter_event_search) . "%%')";
$sql_where = '';
$severity_all = 0;
if (!empty($filter_event_severity)) {
foreach ($filter_event_severity as $key => $value) {
switch ($value) {
case 'all':
$severity_all = 1;
break;
case 34:
$filter_event_severity[$key] = '3, 4';
break;
case 20:
$filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
break;
case 21:
$filter_event_severity[$key] = '4, 2';
break;
default:
break;
}
}
if(!$severity_all){
$sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')';
}
}
$sql = sprintf ("SELECT estado, COUNT(*) AS count FROM tevento WHERE %s " . $sql_where . " GROUP BY estado", $sql_filter);
$status_all = 0;
if(!empty($filter_event_status)){
foreach ($filter_event_status as $key => $value) {
switch ($value) {
case -1:
$status_all = 1;
break;
default:
break;
}
}
if(!$status_all){
$sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')';
}
}
if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
$sql_where .= ' AND (';
$type = array();
foreach ($filter_event_type as $event_type) {
if ($event_type != "") {
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
// for the user so for him is presented only "warning, critical and normal"
if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
$type[] = " event_type LIKE '%$event_type%' ";
}
else if ($event_type == "not_normal") {
$type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
}
else if ($event_type != "all") {
$type[] = " event_type = '" . $event_type."'";
}
}
}
$sql_where .= implode(' OR ', $type) . ')';
}
if (!empty($filter_event_filter_search)) {
$sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'.
' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
}
$sql = sprintf ("SELECT estado, COUNT(*) AS count FROM tevento WHERE %s %s GROUP BY estado", $sql_filter, $sql_where);
$rows = db_get_all_rows_sql ($sql);

View File

@ -2926,7 +2926,7 @@ function graph_events_validated($width = 300, $height = 200, $url = "", $meta =
global $config;
global $graphic_type;
$data_graph = reporting_get_count_events_validated(
$data_graph = events_get_count_events_validated(
array('id_group' => array_keys(users_get_groups())));
$colors = array();

View File

@ -405,15 +405,6 @@ function reporting_make_reporting_data($report = null, $id_report,
$report,
$content);
break;
case 'agent_detailed_event':
case 'event_report_agent':
$report['contents'][] = reporting_event_report_agent(
$report,
$content,
$type,
$force_width_chart,
$force_height_chart);
break;
case 'group_report':
$report['contents'][] = reporting_group_report(
$report,
@ -444,6 +435,15 @@ function reporting_make_reporting_data($report = null, $id_report,
$content,
$type);
break;
case 'agent_detailed_event':
case 'event_report_agent':
$report['contents'][] = reporting_event_report_agent(
$report,
$content,
$type,
$force_width_chart,
$force_height_chart);
break;
case 'event_report_module':
$report['contents'][] = reporting_event_report_module(
$report,
@ -1287,26 +1287,25 @@ function reporting_event_report_group($report, $content,
$return["date"] = reporting_get_date_text($report, $content);
$event_filter = $content['style'];
$filter_event_no_validated = $event_filter['filter_event_no_validated'];
$filter_event_validated = $event_filter['filter_event_validated'];
$filter_event_critical = $event_filter['filter_event_critical'];
$filter_event_warning = $event_filter['filter_event_warning'];
$return['show_summary_group'] = $event_filter['show_summary_group'];
//filter
$show_summary_group = $event_filter['show_summary_group'];
$filter_event_severity = json_decode($event_filter['filter_event_severity'],true);
$filter_event_type = json_decode($event_filter['filter_event_type'],true);
$filter_event_status = json_decode($event_filter['filter_event_status'],true);
$filter_event_filter_search = $event_filter['event_filter_search'];
$filter_event_type = json_decode($event_filter['filter_event_type'],true);
$event_graph_by_agent = $event_filter['event_graph_by_agent'];
$event_graph_by_user_validator = $event_filter['event_graph_by_user_validator'];
$event_graph_by_criticity = $event_filter['event_graph_by_criticity'];
//graphs
$event_graph_by_agent = $event_filter['event_graph_by_agent'];
$event_graph_by_user_validator = $event_filter['event_graph_by_user_validator'];
$event_graph_by_criticity = $event_filter['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated'];
$data = reporting_get_group_detailed_event(
$content['id_group'], $content['period'], $report["datetime"],
true, true, $filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search, 'hash', $history, $filter_event_type);
$data = events_get_agent (false, $content['period'], $report["datetime"],
$history, $show_summary_group, $filter_event_severity,
$filter_event_type, $filter_event_status, $filter_event_filter_search,
$content['id_group'], true);
if (empty($data)) {
$return['failed'] = __('No events');
}
@ -1314,8 +1313,6 @@ function reporting_event_report_group($report, $content,
$return['data'] = array_reverse($data);
}
reporting_set_conf_charts($width, $height, $only_image, $type,
$content, $ttl);
@ -1327,22 +1324,16 @@ function reporting_event_report_group($report, $content,
$height = $force_height_chart;
}
$return['chart']['by_agent'] = null;
$return['chart']['by_user_validator'] = null;
$return['chart']['by_criticity'] = null;
$return['chart']['validated_vs_unvalidated'] = null;
if ($event_graph_by_agent) {
$data_graph = reporting_get_count_events_by_agent(
$content['id_group'], $content['period'],
$report["datetime"],
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated,
$filter_event_filter_search);
$data_graph = events_get_count_events_by_agent(
$content['id_group'], $content['period'], $report["datetime"],
$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search);
$return['chart']['by_agent']= pie3d_graph(
false,
@ -1358,15 +1349,10 @@ function reporting_event_report_group($report, $content,
}
if ($event_graph_by_user_validator) {
$data_graph =
reporting_get_count_events_validated_by_user(
array('id_group' => $content['id_group']), $content['period'],
$report["datetime"],
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated,
$filter_event_filter_search);
$data_graph = events_get_count_events_validated_by_user(
array('id_group' => $content['id_group']), $content['period'],
$report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search);
$return['chart']['by_user_validator'] = pie3d_graph(
false,
@ -1382,14 +1368,10 @@ function reporting_event_report_group($report, $content,
}
if ($event_graph_by_criticity) {
$data_graph = reporting_get_count_events_by_criticity(
$data_graph = events_get_count_events_by_criticity(
array('id_group' => $content['id_group']), $content['period'],
$report["datetime"],
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated,
$filter_event_filter_search);
$report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search);
$colors = get_criticity_pie_colors($data_graph);
@ -1409,15 +1391,10 @@ function reporting_event_report_group($report, $content,
}
if ($event_graph_validated_vs_unvalidated) {
$data_graph =
reporting_get_count_events_validated(
array('id_group' => $content['id_group']), $content['period'],
$report["datetime"],
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated,
$filter_event_filter_search);
$data_graph = events_get_count_events_validated(
array('id_group' => $content['id_group']), $content['period'],
$report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search);
$return['chart']['validated_vs_unvalidated'] = pie3d_graph(
false,
@ -1442,8 +1419,9 @@ function reporting_event_report_group($report, $content,
}
function reporting_event_report_module($report, $content) {
global $config;
global $config;
$return['type'] = 'event_report_module';
if (empty($content['name'])) {
@ -2176,38 +2154,39 @@ function reporting_event_report_agent($report, $content,
if ($config['history_event_enabled'])
$history = true;
$return['title'] = $content['name'];
$return['subtitle'] = agents_get_name($content['id_agent']);
$return["description"] = $content["description"];
$return["date"] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$return['title'] = $content['name'];
$return['subtitle'] = agents_get_name($content['id_agent']);
$return["description"] = $content["description"];
$return["date"] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$return['show_summary_group'] = $content['style']['show_summary_group'];
$style = $content['style'];
$filter_event_no_validated = $style['filter_event_no_validated'];
$filter_event_validated = $style['filter_event_validated'];
$filter_event_critical = $style['filter_event_critical'];
$filter_event_warning = $style['filter_event_warning'];
$filter_event_type = json_decode($style['filter_event_type'], true);
$event_graph_by_user_validator = $style['event_graph_by_user_validator'];
$event_graph_by_criticity = $style['event_graph_by_criticity'];
//filter
$show_summary_group = $style['show_summary_group'];
$filter_event_severity = json_decode($style['filter_event_severity'], true);
$filter_event_type = json_decode($style['filter_event_type'], true);
$filter_event_status = json_decode($style['filter_event_status'], true);
$filter_event_filter_search = $style['event_filter_search'];
//graph
$event_graph_by_user_validator = $style['event_graph_by_user_validator'];
$event_graph_by_criticity = $style['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
$return['data'] = reporting_get_agents_detailed_event(
$content['id_agent'],
$content['period'],
$report["datetime"],
true,
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated,
true,
$history,
$filter_event_type);
$show_summary_group,
$filter_event_severity,
$filter_event_type,
$filter_event_status,
$filter_event_filter_search);
reporting_set_conf_charts($width, $height, $only_image, $type,
$content, $ttl);
@ -2220,26 +2199,19 @@ function reporting_event_report_agent($report, $content,
$height = $force_height_chart;
}
$return["chart"]["by_user_validator"] = null;
$return["chart"]["by_criticity"] = null;
$return["chart"]["validated_vs_unvalidated"] = null;
if ($event_graph_by_user_validator) {
$data_chart =
reporting_get_count_events_validated_by_user(
array('id_agent' => $content['id_agent']),
$content['period'],
$report["datetime"],
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated);
$data_graph = events_get_count_events_validated_by_user(
array('id_agent' => $content['id_agent']), $content['period'],
$report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search);
$return["chart"]["by_user_validator"] = pie3d_graph(
false,
$data_chart,
$data_graph,
500,
150,
__("other"),
@ -2251,13 +2223,10 @@ function reporting_event_report_agent($report, $content,
}
if ($event_graph_by_criticity) {
$data_graph = reporting_get_count_events_by_criticity(
$data_graph = events_get_count_events_by_criticity(
array('id_agent' => $content['id_agent']), $content['period'],
$report["datetime"],
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated);
$report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search);
$colors = get_criticity_pie_colors($data_graph);
@ -2277,13 +2246,10 @@ function reporting_event_report_agent($report, $content,
}
if ($event_graph_validated_vs_unvalidated) {
$data_graph = reporting_get_count_events_validated(
$data_graph = events_get_count_events_validated(
array('id_agent' => $content['id_agent']), $content['period'],
$report["datetime"],
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated);
$report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search);
$return["chart"]["validated_vs_unvalidated"] = pie3d_graph(
false,
@ -6036,221 +6002,6 @@ function reporting_set_conf_charts(&$width, &$height, &$only_image, $type,
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/**
* Gets a detailed reporting of groups's events.
*
* @param unknown_type $id_group Id of the group.
* @param unknown_type $period Time period of the report.
* @param unknown_type $date Date of the report.
* @param unknown_type $return Whether to return or not.
* @param unknown_type $html Whether to return HTML code or not.
*
* @return string Report of groups's events
*/
function reporting_get_count_events_validated ($filter, $period = 0,
$date = 0,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_search = false) {
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
if (empty ($date)) {
$date = get_system_time ();
}
return events_get_count_events_validated($filter, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated,
$filter_event_search);
}
/**
* Gets a detailed reporting of groups's events.
*
* @param unknown_type $id_group Id of the group.
* @param unknown_type $period Time period of the report.
* @param unknown_type $date Date of the report.
* @param unknown_type $return Whether to return or not.
* @param unknown_type $html Whether to return HTML code or not.
*
* @return string Report of groups's events
*/
function reporting_get_count_events_by_criticity ($filter, $period = 0,
$date = 0,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_search = false) {
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
if (empty ($date)) {
$date = get_system_time ();
}
return events_get_count_events_by_criticity($filter, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated,
$filter_event_search);
}
/**
* Gets a detailed reporting of groups's events.
*
* @param unknown_type $filter.
* @param unknown_type $period Time period of the report.
* @param unknown_type $date Date of the report.
* @param unknown_type $return Whether to return or not.
* @param unknown_type $html Whether to return HTML code or not.
*
* @return string Report of groups's events
*/
function reporting_get_count_events_validated_by_user ($filter, $period = 0,
$date = 0,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_search = false) {
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
if (empty ($date)) {
$date = get_system_time ();
}
return events_get_count_events_validated_by_user($filter, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated, $filter_event_search);
}
/**
* Gets a detailed reporting of groups's events.
*
* @param unknown_type $id_group Id of the group.
* @param unknown_type $period Time period of the report.
* @param unknown_type $date Date of the report.
* @param unknown_type $return Whether to return or not.
* @param unknown_type $html Whether to return HTML code or not.
*
* @return string Report of groups's events
*/
function reporting_get_group_detailed_event ($id_group, $period = 0,
$date = 0, $return = false, $html = true,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null, $return_type = false,
$history = false, $filter_event_type = false) {
global $config;
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
if (empty ($date)) {
$date = get_system_time ();
}
$table = new stdClass();
$table->width = '99%';
$table->align = array();
$table->align[0] = 'center';
$table->align[2] = 'center';
$table->data = array ();
$table->head = array ();
$table->head[0] = __('Status');
$table->head[1] = __('Name');
$table->head[2] = __('Type');
$table->head[3] = __('Agent');
$table->head[4] = __('Severity');
$table->head[5] = __('Val. by');
$table->head[6] = __('Timestamp');
$events = events_get_group_events($id_group, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search, false, $history, $filter_event_type);
if ($return_type === 'hash') {
return $events;
}
if ($events) {
$note = '';
if (count($events) >= 1000) {
$note .= '* ' . __('Maximum of events shown') . ' (1000)<br>';
}
foreach ($events as $k => $event) {
//First pass along the class of this row
$table->cellclass[$k][1] = $table->cellclass[$k][3] =
$table->cellclass[$k][4] = $table->cellclass[$k][5] =
$table->cellclass[$k][6] =
get_priority_class ($event["criticity"]);
$data = array ();
// Colored box
switch ($event['estado']) {
case 0:
$img_st = "images/star.png";
$title_st = __('New event');
break;
case 1:
$img_st = "images/tick.png";
$title_st = __('Event validated');
break;
case 2:
$img_st = "images/hourglass.png";
$title_st = __('Event in process');
break;
}
$data[] = html_print_image ($img_st, true,
array ("class" => "image_status",
"width" => 16,
"title" => $title_st,
"id" => 'status_img_' . $event["id_evento"]));
$data[] = ui_print_truncate_text(
io_safe_output($event['evento']),
140, false, true);
//$data[1] = $event['event_type'];
$data[] = events_print_type_img ($event["event_type"], true);
if (!empty($event['id_agente']))
$data[] = agents_get_name($event['id_agente']);
else
$data[] = __('Pandora System');
$data[] = get_priority_name ($event['criticity']);
if (empty($event['id_usuario']) && $event['estado'] == EVENT_VALIDATE) {
$data[] = '<i>' . __('System') . '</i>';
}
else {
$user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['id_usuario']);
$data[] = io_safe_output($user_name);
}
$data[] = '<font style="font-size: 6pt;">' .
date($config['date_format'], $event['timestamp_rep']) .
'</font>';
array_push ($table->data, $data);
}
if ($html) {
return html_print_table ($table, $return) . $note;
}
else {
return $table;
}
}
else {
return false;
}
}
/**
* Get a detailed report of summarized events per agent
*
@ -6286,7 +6037,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
$events = array ();
foreach ($id_modules as $id_module) {
$event = events_get_module ($id_module, (int) $period, (int) $date, $history);
$event = events_get_module ($id_module, (int) $period, (int) $date, $history, $show_summary_group);
if (!empty ($event)) {
array_push ($events, $event);
}
@ -6367,10 +6118,10 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
* @return A table object (XHTML)
*/
function reporting_get_agents_detailed_event ($id_agents, $period = 0,
$date = 0, $return = false, $filter_event_validated = false,
$filter_event_critical = false, $filter_event_warning = false,
$filter_event_no_validated = false, $only_data = false,
$history = false, $filter_event_type = false) {
$date = 0, $return = false, $only_data = false, $history = false,
$show_summary_group = false, $filter_event_severity = false,
$filter_event_type = false, $filter_event_status = false,
$filter_event_filter_search = false) {
global $config;
@ -6392,12 +6143,10 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0,
$events = array ();
foreach ($id_agents as $id_agent) {
$event = events_get_agent ($id_agent,
(int)$period,
(int)$date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated,
$history, $filter_event_type);
$event = events_get_agent ($id_agent, (int)$period, (int)$date,
$history, $show_summary_group, $filter_event_severity,
$filter_event_type, $filter_event_status,
$filter_event_filter_search, false, false);
if (empty($event)) {
$event = array();
@ -6406,17 +6155,28 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0,
if ($only_data) {
$nevents = count($event);
for($i=$nevents-1; $i >= 0; $i--) {
$e = $event[$i];
//foreach ($event as $e) {
$return_data[] = array(
'status' => $e['estado'],
'count' => $e['event_rep'],
'name' => $e['evento'],
'type' => $e["event_type"],
'criticity' => $e["criticity"],
'validated_by' => $e['id_usuario'],
'timestamp' => $e['timestamp_rep']
);
$e = $event[$i];
if($show_summary_group){
$return_data[] = array(
'status' => $e['estado'],
'count' => $e['event_rep'],
'name' => $e['evento'],
'type' => $e["event_type"],
'criticity' => $e["criticity"],
'validated_by' => $e['id_usuario'],
'timestamp' => $e['timestamp_rep']
);
}
else{
$return_data[] = array(
'status' => $e['estado'],
'name' => $e['evento'],
'type' => $e["event_type"],
'criticity' => $e["criticity"],
'validated_by' => $e['id_usuario'],
'timestamp' => $e['timestamp']
);
}
}
}
else {
@ -8610,36 +8370,6 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat
return $downtime_dates;
}
/**
* Gets a detailed reporting of groups's events.
*
* @param unknown_type $id_group Id of the group.
* @param unknown_type $period Time period of the report.
* @param unknown_type $date Date of the report.
* @param unknown_type $return Whether to return or not.
* @param unknown_type $html Whether to return HTML code or not.
*
* @return string Report of groups's events
*/
function reporting_get_count_events_by_agent ($id_group, $period = 0,
$date = 0,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null) {
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
if (empty ($date)) {
$date = get_system_time ();
}
return events_get_count_events_by_agent($id_group, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search);
}
/**
* Get the maximum value of an agent module in a period of time.
*

View File

@ -250,10 +250,6 @@ function reporting_html_print_report($report, $mini = false) {
case 'database_serialized':
reporting_html_database_serialized($table, $item);
break;
case 'agent_detailed_event':
case 'event_report_agent':
reporting_html_event_report_agent($table, $item);
break;
case 'group_report':
reporting_html_group_report($table, $item);
break;
@ -269,6 +265,10 @@ function reporting_html_print_report($report, $mini = false) {
case 'inventory_changes':
reporting_html_inventory_changes($table, $item);
break;
case 'agent_detailed_event':
case 'event_report_agent':
reporting_html_event_report_agent($table, $item);
break;
case 'event_report_module':
reporting_html_event_report_module($table, $item);
break;
@ -752,7 +752,6 @@ function reporting_html_top_n($table, $item) {
function reporting_html_event_report_group($table, $item) {
global $config;
if (!empty($item['failed'])) {
$table->colspan['events']['cell'] = 3;
$table->data['events']['cell'] = $item['failed'];
@ -763,26 +762,49 @@ function reporting_html_event_report_group($table, $item) {
$table1->align = array();
$table1->align[0] = 'center';
$table1->align[2] = 'center';
if($item['show_summary_group']){
$table1->align[3] = 'center';
}
else{
$table1->align[2] = 'center';
}
$table1->data = array ();
$table1->head = array ();
$table1->head[0] = __('Status');
$table1->head[1] = __('Name');
$table1->head[2] = __('Type');
$table1->head[3] = __('Agent');
$table1->head[4] = __('Severity');
$table1->head[5] = __('Val. by');
$table1->head[6] = __('Timestamp');
if($item['show_summary_group']){
$table1->head[0] = __('Status');
$table1->head[1] = __('Count');
$table1->head[2] = __('Name');
$table1->head[3] = __('Type');
$table1->head[4] = __('Agent');
$table1->head[5] = __('Severity');
$table1->head[6] = __('Val. by');
$table1->head[7] = __('Timestamp');
}
else{
$table1->head[0] = __('Status');
$table1->head[1] = __('Name');
$table1->head[2] = __('Type');
$table1->head[3] = __('Agent');
$table1->head[4] = __('Severity');
$table1->head[5] = __('Val. by');
$table1->head[6] = __('Timestamp');
}
foreach ($item['data'] as $k => $event) {
//First pass along the class of this row
$table1->cellclass[$k][1] = $table1->cellclass[$k][3] =
$table1->cellclass[$k][4] = $table1->cellclass[$k][5] =
$table1->cellclass[$k][6] =
get_priority_class ($event["criticity"]);
if($item['show_summary_group']){
$table1->cellclass[$k][1] = $table1->cellclass[$k][2] =
$table1->cellclass[$k][4] = $table1->cellclass[$k][5] =
$table1->cellclass[$k][6] = $table1->cellclass[$k][7] =
get_priority_class ($event["criticity"]);
}
else{
$table1->cellclass[$k][1] = $table1->cellclass[$k][3] =
$table1->cellclass[$k][4] = $table1->cellclass[$k][5] =
$table1->cellclass[$k][6] =
get_priority_class ($event["criticity"]);
}
$data = array ();
// Colored box
@ -805,6 +827,10 @@ function reporting_html_event_report_group($table, $item) {
"width" => 16,
"title" => $title_st,
"id" => 'status_img_' . $event["id_evento"]));
if($item['show_summary_group']){
$data[] = $event['event_rep'];
}
$data[] = ui_print_truncate_text(
io_safe_output($event['evento']),
@ -825,17 +851,20 @@ function reporting_html_event_report_group($table, $item) {
$user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['id_usuario']);
$data[] = io_safe_output($user_name);
}
$data[] = '<font style="font-size: 6pt;">' .
date($config['date_format'], $event['timestamp_rep']) .
'</font>';
if($item['show_summary_group']){
$data[] = '<font style="font-size: 6pt;">' . date($config['date_format'], $event['timestamp_rep']) . '</font>';
}
else{
$data[] = '<font style="font-size: 6pt;">' . date($config['date_format'], strtotime($event['timestamp'])) . '</font>';
}
array_push ($table1->data, $data);
}
$table->colspan['events']['cell'] = 3;
$table->data['events']['cell'] = html_print_table($table1, true);
if (!empty($item['chart']['by_agent'])) {
$table1 = new stdClass();
$table1->width = '99%';
@ -1368,10 +1397,8 @@ function reporting_html_group_report($table, $item) {
function reporting_html_event_report_agent($table, $item) {
global $config;
$table1 = new stdClass();
$table1->width = '99%';
$table1->align = array();
$table1->align[0] = 'center';
$table1->align[1] = 'center';
@ -1381,7 +1408,9 @@ function reporting_html_event_report_agent($table, $item) {
$table1->head = array ();
$table1->head[0] = __('Status');
$table1->head[1] = __('Count');
if($item['show_summary_group']){
$table1->head[1] = __('Count');
}
$table1->head[2] = __('Name');
$table1->head[3] = __('Type');
$table1->head[4] = __('Severity');
@ -1389,13 +1418,21 @@ function reporting_html_event_report_agent($table, $item) {
$table1->head[6] = __('Timestamp');
foreach ($item['data'] as $i => $event) {
$table1->cellclass[$i][1] =
$table1->cellclass[$i][2] =
$table1->cellclass[$i][4] =
$table1->cellclass[$i][5] =
$table1->cellclass[$i][6] =
get_priority_class ($event["criticity"]);
if($item['show_summary_group']){
$table1->cellclass[$i][1] =
$table1->cellclass[$i][2] =
$table1->cellclass[$i][4] =
$table1->cellclass[$i][5] =
$table1->cellclass[$i][6] =
get_priority_class ($event["criticity"]);
}
else{
$table1->cellclass[$i][1] =
$table1->cellclass[$i][3] =
$table1->cellclass[$i][4] =
$table1->cellclass[$i][5] =
get_priority_class ($event["criticity"]);
}
$data = array ();
// Colored box
switch ($event['status']) {
@ -1417,8 +1454,10 @@ function reporting_html_event_report_agent($table, $item) {
"width" => 16,
"title" => $title_st));
$data[] = $event['count'];
if($item['show_summary_group']){
$data[] = $event['count'];
}
$data[] = ui_print_truncate_text(
io_safe_output($event['name']),
140, false, true);
@ -1433,8 +1472,12 @@ function reporting_html_event_report_agent($table, $item) {
$user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['validated_by']);
$data[] = io_safe_output($user_name);
}
$data[] = '<font style="font-size: 6pt;">' .
date($config['date_format'], $event['timestamp']) . '</font>';
if($item['show_summary_group']){
$data[] = '<font style="font-size: 6pt;">' . date($config['date_format'], $event['timestamp']) . '</font>';
}
else{
$data[] = '<font style="font-size: 6pt;">' . date($config['date_format'], strtotime($event['timestamp'])) . '</font>';
}
array_push ($table1->data, $data);
}

View File

@ -689,7 +689,7 @@ else {
$main_sec = get_parameter('extension_in_menu');
else
if ($sec == 'gextensions')
+ $main_sec = get_parameter('extension_in_menu');
$main_sec = get_parameter('extension_in_menu');
else
$main_sec = $sec;
$sec = $sec2;