diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index bf8778cb78..ccb0c72585 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,18 @@ +2014-06-04 Sergio Martin + + * include/constants.php + include/functions_graph.php + include/functions_reporting.php + include/graphs/functions_pchart.php + include/graphs/functions_flot.php + include/functions.php + include/functions_events.php: Fix a lot of errors + on events items on reports using now the same query + as events view, etc. + + * include/styles/pandora.css: Little aesthetic + improvement in focus buttons and unset webfont + 2014-06-04 Miguel de Dios * include/javascript/mergely/*: added mergely javascript library. diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 1f701ba106..5dabafe113 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -126,7 +126,7 @@ define('COL_NORMAL','#6EB432'); define('COL_NOTINIT','#3BA0FF'); define('COL_UNKNOWN','#AAAAAA'); define('COL_ALERTFIRED','#FF8800'); -define('COL_MINOR','#FF92E9'); +define('COL_MINOR','#F099A2'); define('COL_MAJOR','#C97A4A'); define('COL_INFORMATIONAL','#E4E4E4'); define('COL_MAINTENANCE','#3BA0FF'); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 5733ccf919..8a1d015fb6 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1126,6 +1126,45 @@ function get_priority_class($priority) { } } +/** + * Get priority style from priority class (CSS class). + * + * @param string priority class. + * + * @return string CSS priority class. + */ +function get_priority_style($priority_class) { + switch ($priority_class) { + case "datos_blue": + $style_css_criticity = 'background-color: ' . COL_INFORMATIONAL . '; color: #FFFFFF;'; + break; + case "datos_grey": + $style_css_criticity = 'background-color: ' . COL_UNKNOWN . '; color: #FFFFFF;'; + break; + case "datos_green": + $style_css_criticity = 'background-color: ' . COL_NORMAL . '; color: #FFFFFF;'; + break; + case "datos_yellow": + $style_css_criticity = 'background-color: ' . COL_WARNING . ';'; + break; + case "datos_red": + $style_css_criticity = 'background-color: ' . COL_CRITICAL . '; color: #FFFFFF;'; + break; + case "datos_pink": + $style_css_criticity = 'background-color: ' . COL_MINOR . ';'; + break; + case "datos_brown": + $style_css_criticity = 'background-color: ' . COL_MAJOR . '; color: #FFFFFF;'; + break; + case "datos_grey": + default: + $style_css_criticity = 'background-color: ' . COL_UNKNOWN . '; color: #FFFFFF;'; + break; + } + + return $style_css_criticity; +} + /** * Check if the enterprise version is installed. * diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index e4669abc12..eb6c159379 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1102,22 +1102,10 @@ function events_get_group_events ($id_group, $period, $date, if ($filter_event_no_validated) { $sql_where .= ' AND estado = 0 '; } + $sql_where .= sprintf(' AND id_grupo IN (%s) AND utimestamp > %d + AND utimestamp <= %d ', implode (",", $id_group), $datelimit, $date); - - $sql = sprintf ('SELECT *, - (SELECT t2.nombre - FROM tagente AS t2 - WHERE t2.id_agente = t3.id_agente) AS agent_name, - (SELECT t2.fullname - FROM tusuario AS t2 - WHERE t2.id_user = t3.id_usuario) AS user_name - FROM tevento AS t3 - WHERE utimestamp > %d AND utimestamp <= %d - AND id_grupo IN (%s) ' . $sql_where . ' - ORDER BY utimestamp ASC', - $datelimit, $date, implode (",", $id_group)); - - return db_get_all_rows_sql ($sql); + return events_get_events_grouped($sql_where, 0, 1000); } /** @@ -1205,7 +1193,8 @@ function events_get_agent ($id_agent, $period, $date = 0, $datelimit = $date - $period; - $sql_where = ' AND 1 = 1 '; + $sql_where = ''; + $criticities = array(); if ($filter_event_critical) { $criticities[] = 4; @@ -1224,10 +1213,10 @@ function events_get_agent ($id_agent, $period, $date = 0, $sql_where .= ' AND estado = 0 '; } - $sql_where .= sprintf(' id_agente = %d AND utimestamp > %d + $sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d AND utimestamp <= %d ', $id_agent, $datelimit, $date); - return events_get_events_grouped($sql_where); + return events_get_events_grouped($sql_where, 0, 1000); } /** @@ -1251,6 +1240,11 @@ function events_get_module ($id_agent_module, $period, $date = 0) { $datelimit = $date - $period; + $sql_where .= sprintf(' AND id_agentmodule = %d AND utimestamp > %d + AND utimestamp <= %d ', $id_agent_module, $datelimit, $date); + + return events_get_events_grouped($sql_where, 0, 1000); + $sql = sprintf ('SELECT evento, event_type, criticity, count(*) as count_rep, max(timestamp) AS time2 FROM tevento WHERE id_agentmodule = %d AND utimestamp > %d AND utimestamp <= %d diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 99f22fb929..347d2afcb7 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4051,4 +4051,35 @@ function graph_nodata_image($width = 300, $height = 110, $type = 'area', $text = return $div; } + +function get_criticity_pie_colors ($data_graph) { + $colors = array(); + foreach (array_keys($data_graph) as $crit) { + switch ($crit) { + case __('Maintenance'): + $colors[$crit] = COL_MAINTENANCE; + break; + case __('Informational'): + $colors[$crit] = COL_INFORMATIONAL; + break; + case __('Normal'): + $colors[$crit] = COL_NORMAL; + break; + case __('Warning'): + $colors[$crit] = COL_WARNING; + break; + case __('Critical'): + $colors[$crit] = COL_CRITICAL; + break; + case __('Minor'): + $colors[$crit] = COL_MINOR; + break; + case __('Major'): + $colors[$crit] = COL_MAJOR; + break; + } + } + + return $colors; +} ?> diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 3abe4e3b61..42c8e314d3 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -2555,61 +2555,65 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0, } } - if ($events) - foreach ($events as $eventRow) { - foreach ($eventRow as $k => $event) { - //First pass along the class of this row - $table->cellclass[$k][1] = $table->cellclass[$k][2] = - $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; + if ($events) { + $note = ''; + if (count($events) >= 1000) { + $note .= '* ' . __('Maximum of events shown') . ' (1000)
'; + } + foreach ($events as $eventRow) { + foreach ($eventRow as $k => $event) { + //First pass along the class of this row + $table->cellclass[$k][1] = $table->cellclass[$k][2] = + $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)); + + $data[] = $event['event_rep']; + + $data[] = ui_print_truncate_text( + io_safe_output($event['evento']), + 140, false, true); + //$data[] = $event['event_type']; + $data[] = events_print_type_img ($event["event_type"], true); + + $data[] = get_priority_name ($event['criticity']); + if (empty($event['id_usuario']) && $event['estado'] == EVENT_VALIDATE) { + $data[] = '' . __('System') . ''; + } + else { + $user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['id_usuario']); + $data[] = io_safe_output($user_name); + } + $data[] = '' . + date($config['date_format'], $event['timestamp_rep']) . ''; + array_push ($table->data, $data); } - $data[] = html_print_image ($img_st, true, - array ("class" => "image_status", - "width" => 16, - "height" => 16, - "title" => $title_st)); - - $data[] = $event['event_rep']; - - $data[] = ui_print_truncate_text( - io_safe_output($event['evento']), - 140, false, true); - //$data[] = $event['event_type']; - $data[] = events_print_type_img ($event["event_type"], true); - - $data[] = get_priority_name ($event['criticity']); - if (empty($event['id_usuario']) && $event['estado'] == EVENT_VALIDATE) { - $data[] = '' . __('System') . ''; - } - else { - $user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['id_usuario']); - $data[] = io_safe_output($user_name); - } - $data[] = '' . - date($config['date_format'], $event['timestamp_rep']) . ''; - array_push ($table->data, $data); } } if ($events) - return html_print_table ($table, $return); + return html_print_table ($table, $return) . $note; } /** @@ -2627,6 +2631,8 @@ 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) { + + global $config; if (!is_numeric ($date)) { $date = strtotime ($date); @@ -2661,6 +2667,10 @@ function reporting_get_group_detailed_event ($id_group, $period = 0, $filter_event_warning, $filter_event_no_validated); if ($events) { + $note = ''; + if (count($events) >= 1000) { + $note .= '* ' . __('Maximum of events shown') . ' (1000)
'; + } foreach ($events as $k => $event) { //First pass along the class of this row $table->cellclass[$k][1] = $table->cellclass[$k][3] = @@ -2688,7 +2698,6 @@ function reporting_get_group_detailed_event ($id_group, $period = 0, $data[] = html_print_image ($img_st, true, array ("class" => "image_status", "width" => 16, - "height" => 16, "title" => $title_st, "id" => 'status_img_' . $event["id_evento"])); @@ -2699,20 +2708,26 @@ function reporting_get_group_detailed_event ($id_group, $period = 0, //$data[1] = $event['event_type']; $data[] = events_print_type_img ($event["event_type"], true); - if (!empty($event['agent_name'])) - $data[] = $event['agent_name']; + if (!empty($event['id_agente'])) + $data[] = agents_get_name($event['id_agente']); else $data[] = __('Pandora System'); $data[] = get_priority_name ($event['criticity']); - $data[] = io_safe_output($event['user_name']); + if (empty($event['id_usuario']) && $event['estado'] == EVENT_VALIDATE) { + $data[] = '' . __('System') . ''; + } + else { + $user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['id_usuario']); + $data[] = io_safe_output($user_name); + } $data[] = '' . - $event['timestamp'] . + date($config['date_format'], $event['timestamp_rep']) . ''; array_push ($table->data, $data); } if ($html) { - return html_print_table ($table, $return); + return html_print_table ($table, $return) . $note; } else { return $table; @@ -2739,6 +2754,8 @@ function reporting_get_group_detailed_event ($id_group, $period = 0, * @return mixed A table object (XHTML) or object table is false the html. */ function reporting_get_module_detailed_event ($id_modules, $period = 0, $date = 0, $return = false, $html = true) { + global $config; + $id_modules = (array)safe_int ($id_modules, 1); if (!is_numeric ($date)) { @@ -2755,11 +2772,14 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, $date = $table->width = '99%'; $table->data = array (); $table->head = array (); - $table->head[0] = __('Event name'); - $table->head[1] = __('Event type'); - $table->head[2] = __('Criticity'); - $table->head[3] = __('Count'); - $table->head[4] = __('Timestamp'); + $table->head[0] = __('Status'); + $table->head[1] = __('Event name'); + $table->head[2] = __('Event type'); + $table->head[3] = __('Criticity'); + $table->head[4] = __('Count'); + $table->head[5] = __('Timestamp'); + $table->style[0] = 'text-align: center;'; + $table->style[4] = 'text-align: center;'; $events = array (); @@ -2771,20 +2791,51 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, $date = } if ($events) { + $note = ''; + if (count($events) >= 1000) { + $note .= '* ' . __('Maximum of events shown') . ' (1000)
'; + } foreach ($events as $eventRow) { - foreach ($eventRow as $event) { + foreach ($eventRow as $k => $event) { + //$k = count($table->data); + $table->cellclass[$k][1] = $table->cellclass[$k][2] = + $table->cellclass[$k][3] = $table->cellclass[$k][4] = + $table->cellclass[$k][5] = get_priority_class ($event["criticity"]); + $data = array (); - $data[0] = io_safe_output($event['evento']); - $data[1] = $event['event_type']; - $data[2] = get_priority_name ($event['criticity']); - $data[3] = $event['count_rep']; - $data[4] = $event['time2']; + + // 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[0] = html_print_image ($img_st, true, + array ("class" => "image_status", + "width" => 16, + "title" => $title_st, + "id" => 'status_img_' . $event["id_evento"])); + + $data[1] = io_safe_output($event['evento']); + $data[2] = $event['event_type']; + $data[3] = get_priority_name ($event['criticity']); + $data[4] = $event['event_rep']; + $data[5] = date($config['date_format'], $event['timestamp_rep']); array_push ($table->data, $data); } } if ($html) { - return html_print_table ($table, $return); + return html_print_table ($table, $return) . $note; } else { return $table; @@ -3802,6 +3853,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $filter_event_no_validated); $table_event_graph = null; + $table_event_graph->width = '100%'; + $table_event_graph->style[0] = 'text-align: center;'; $table_event_graph->head[0] = __('Events validated by user'); $table_event_graph->data[0][0] = pie3d_graph( @@ -3824,14 +3877,18 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $filter_event_critical, $filter_event_warning, $filter_event_no_validated); + + $colors = get_criticity_pie_colors($data_graph); $table_event_graph = null; + $table_event_graph->width = '100%'; + $table_event_graph->style[0] = 'text-align: center;'; $table_event_graph->head[0] = __('Events by criticity'); $table_event_graph->data[0][0] = pie3d_graph( false, $data_graph, 500, 150, __("other"), "", $config['homedir'] . "/images/logo_vertical_water.png", - $config['fontpath'], $config['font_size']); + $config['fontpath'], $config['font_size'], 1, false, $colors); $data[0] = html_print_table($table_event_graph, true); @@ -3850,6 +3907,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $filter_event_no_validated); $table_event_graph = null; + $table_event_graph->width = '100%'; + $table_event_graph->style[0] = 'text-align: center;'; $table_event_graph->head[0] = __('Amount events validated'); $table_event_graph->data[0][0] = pie3d_graph( @@ -4061,6 +4120,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $filter_event_no_validated); $table_event_graph = null; + $table_event_graph->width = '100%'; + $table_event_graph->style[0] = 'text-align: center;'; $table_event_graph->head[0] = __('Events by agent'); $table_event_graph->data[0][0] = pie3d_graph( @@ -4086,6 +4147,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $table_event_graph = null; $table_event_graph->head[0] = __('Events validated by user'); + $table_event_graph->width = '100%'; + $table_event_graph->style[0] = 'text-align: center;'; $table_event_graph->data[0][0] = pie3d_graph( false, $data_graph, 500, 150, __("other"), "", @@ -4107,14 +4170,18 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $filter_event_critical, $filter_event_warning, $filter_event_no_validated); - + + $colors = get_criticity_pie_colors($data_graph); + $table_event_graph = null; $table_event_graph->head[0] = __('Events by criticity'); + $table_event_graph->width = '100%'; + $table_event_graph->style[0] = 'text-align: center;'; $table_event_graph->data[0][0] = pie3d_graph( false, $data_graph, 500, 150, __("other"), "", $config['homedir'] . "/images/logo_vertical_water.png", - $config['fontpath'], $config['font_size']); + $config['fontpath'], $config['font_size'], 1, false, $colors); $data[0] = html_print_table($table_event_graph, true); @@ -4134,6 +4201,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $table_event_graph = null; $table_event_graph->head[0] = __('Amount events validated'); + $table_event_graph->width = '100%'; + $table_event_graph->style[0] = 'text-align: center;'; $table_event_graph->data[0][0] = pie3d_graph( false, $data_graph, 500, 150, __("other"), "", diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 9b71e1a827..068a021292 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -395,7 +395,7 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark, } $return .= "