fixed errors in events reports #135

(cherry picked from commit 993bad314d81f97db207cc502325667b28fd31c7)
This commit is contained in:
daniel 2017-01-11 13:26:50 +01:00
parent 84e3f695ff
commit 36015807f3
7 changed files with 242 additions and 475 deletions

View File

@ -2338,7 +2338,13 @@ function chooseType() {
$("#row_last_value").hide();
$("#row_filter_search").hide();
$("#row_percentil").hide();
$("#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();

View File

@ -1055,15 +1055,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', '');
@ -1126,11 +1125,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;
@ -1138,10 +1137,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
@ -1429,38 +1426,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

@ -1348,22 +1348,16 @@ function events_get_agent ($id_agent, $period, $date = 0,
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 ';
$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;
}
}
}
@ -2334,19 +2328,19 @@ function events_page_custom_data ($event) {
if ($event['custom_data'] == '') {
return '';
}
$table->width = '100%';
$table->data = array ();
$table->head = array ();
$table->style[0] = 'width:35%; font-weight: bold; text-align: left;';
$table->style[1] = 'text-align: left;';
$table->class = "alternate rounded_cells";
$json_custom_data = base64_decode ($event['custom_data']);
$custom_data = json_decode ($json_custom_data);
if ($custom_data === NULL) {
return '<div id="extended_event_custom_data_page" class="extended_event_pages">'.__('Invalid custom data: %s', $json_custom_data).'</div>';
}
}
$i = 0;
foreach ($custom_data as $field => $value) {
@ -2354,7 +2348,7 @@ function events_page_custom_data ($event) {
$table->data[$i][1] = io_safe_output ($value);
$i++;
}
$custom_data = '<div id="extended_event_custom_data_page" class="extended_event_pages">'.html_print_table($table, true).'</div>';
return $custom_data;

View File

@ -2762,7 +2762,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

@ -400,15 +400,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,
@ -439,6 +430,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,
@ -1282,26 +1282,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');
}
@ -1309,8 +1308,6 @@ function reporting_event_report_group($report, $content,
$return['data'] = array_reverse($data);
}
reporting_set_conf_charts($width, $height, $only_image, $type,
$content, $ttl);
@ -1322,22 +1319,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,
@ -1353,15 +1344,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,
@ -1377,14 +1363,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);
@ -1404,15 +1386,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,
@ -1437,8 +1414,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'])) {
@ -2198,38 +2176,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);
@ -2242,26 +2221,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"),
@ -2273,13 +2245,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);
@ -2299,13 +2268,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,
@ -6062,221 +6028,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
*
@ -6312,7 +6063,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);
}
@ -6393,10 +6144,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;
@ -6418,12 +6169,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();
@ -6432,17 +6181,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 {
@ -8636,36 +8396,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

@ -251,10 +251,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;
@ -270,6 +266,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;
@ -753,7 +753,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'];
@ -764,26 +763,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
@ -806,6 +828,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']),
@ -826,17 +852,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%';
@ -1371,10 +1400,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';
@ -1384,7 +1411,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');
@ -1392,13 +1421,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']) {
@ -1420,8 +1457,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);
@ -1436,8 +1475,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

@ -688,7 +688,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;