diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e6412abe05..37eb41ef03 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2013-03-01 Sergio Martin + + * include/functions_graph.php + include/functions_events.php + include/constants.php + operation/agentes/estado_generalagente.php + operation/agentes/status_events.php + operation/agentes/tactical.php + operation/events/event_statistics.php + operation/events/events_list.php + operation/events/events.php: Improve layouts, graphic + of events near tables, colors of events pies, acl tags, + etc. + 2013-03-01 Mario Pulido * images/help/service1.png: New file for help. diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 3a1029104b..a8267c2ee7 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -121,6 +121,10 @@ define('COL_NORMAL','#38B800'); define('COL_NOTINIT','#3BA0FF'); define('COL_UNKNOWN','#AAAAAA'); define('COL_ALERTFIRED','#FF8800'); +define('COL_MINOR','#FF92E9'); +define('COL_MAJOR','#C97A4A'); +define('COL_INFORMATIONAL','#E4E4E4'); +define('COL_MAINTENANCE','#3BA0FF'); diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 75b1201057..ecd0ef2591 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -733,28 +733,36 @@ function events_tiny_stats ($total_modules, $normal_modules, $critical_modules, * @param int $limit How many events to show * @param int $width How wide the table should be * @param bool $return Prints out HTML if false + * @param int agent id if is the table of one agent. 0 otherwise * * @return string HTML with table element */ -function events_print_event_table ($filter = "", $limit = 10, $width = 440, $return = false) { +function events_print_event_table ($filter = "", $limit = 10, $width = 440, $return = false, $agent_id = 0) { global $config; + if($agent_id == 0) { + $agent_condition = ''; + } + else { + $agent_condition = "id_agente = $agent_id AND"; + } + + if($filter == '') { + $filter = '1 = 1'; + } + switch ($config["dbtype"]) { case "mysql": case "postgresql": - $sql = sprintf ("SELECT * FROM tevento %s ORDER BY timestamp DESC LIMIT %d", $filter, $limit); + $sql = sprintf ("SELECT * FROM tevento WHERE %s %s ORDER BY timestamp DESC LIMIT %d", $agent_condition, $filter, $limit); break; case "oracle": - if ($filter == "") { - $sql = sprintf ("SELECT * FROM tevento WHERE rownum <= %d ORDER BY timestamp DESC", $limit); - } - else { - $sql = sprintf ("SELECT * FROM tevento %s AND rownum <= %d ORDER BY timestamp DESC", $filter, $limit); - } + $sql = sprintf ("SELECT * FROM tevento WHERE %s %s AND rownum <= %d ORDER BY timestamp DESC", $agent_condition, $filter, $limit); break; } + $result = db_get_all_rows_sql ($sql); - + if ($result === false) { echo '
'.__('No events').'
'; } @@ -770,6 +778,8 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret $table->rowclass = array (); $table->data = array (); $table->align = array (); + $table->style[0] = $table->style[1] = $table->style[2] = 'width:25px'; + $table->style[5] = 'width:180px'; $table->head[0] = "" . __('V.') . ""; $table->align[0] = 'center'; @@ -783,7 +793,9 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret $table->head[3] = __('Event name'); - $table->head[4] = __('Agent name'); + if($agent_id == 0) { + $table->head[4] = __('Agent name'); + } $table->head[5] = __('Timestamp'); $table->headclass[5] = "datos3 f9"; @@ -793,6 +805,7 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret if (! check_acl ($config["id_user"], $event["id_grupo"], "ER")) { continue; } + $data = array (); // Colored box @@ -845,7 +858,9 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret /* Event type */ $data[2] = events_print_type_img ($event["event_type"], true); - $data[3] = ui_print_string_substr (io_safe_output($event["evento"]), 75, true, '9'); + if($agent_id == 0) { + $data[3] = ui_print_string_substr (io_safe_output($event["evento"]), 75, true, '9'); + } if ($event["id_agente"] > 0) { // Agent name @@ -874,9 +889,20 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret $events_table = html_print_table ($table, true); $out = '
'; $out .= $events_table; - $out .= ''; - $out .= '' . __('Events generated -by module-') . '
'; - $out .= graph_event_module (300, 120, $event['id_agente']); + + if($agent_id != 0) { + $out .= '
'; + $out .= '' . __('Events generated -by module-') . '
'; + $out .= graph_event_module (250, 100, $event['id_agente']); + } + else { + $out .= '

'; + $out .= '' . __('Event graph') . '
'; + $out .= grafico_eventos_total("", 250, 120) . '
'; + $out .= '' . __('Event graph by agent') . '
'; + $out .= grafico_eventos_grupo(250, 100); + } + $out .= '
'; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 1ec9049f4f..b46fafcfcb 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1442,7 +1442,7 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) { FROM tevento, tagente_modulo WHERE id_agentmodule = id_agente_modulo AND disabled = 0 AND tevento.id_agente = %d - GROUP BY id_agentmodule, nombre LIMIT %d', $id_agent, $max_items); + GROUP BY id_agentmodule, nombre ORDER BY count_number DESC LIMIT %d', $id_agent, $max_items); break; case "oracle": $sql = sprintf ('SELECT COUNT(id_evento) AS count_number, @@ -1450,7 +1450,7 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) { FROM tevento, tagente_modulo WHERE (id_agentmodule = id_agente_modulo AND disabled = 0 AND tevento.id_agente = %d) AND rownum <= %d - GROUP BY id_agentmodule, dbms_lob.substr(nombre,4000,1)', $id_agent, $max_items); + GROUP BY id_agentmodule, dbms_lob.substr(nombre,4000,1) ORDER BY count_number DESC', $id_agent, $max_items); break; } @@ -1982,13 +1982,23 @@ function graph_events_validated($width = 300, $height = 200, $url = "", $meta = $data_graph = reporting_get_count_events_validated( array('id_group' => array_keys(users_get_groups()))); + $colors = array(); + foreach ($data_graph as $k => $v) { + if($k == __('Validated')) { + $colors[$k] = COL_NORMAL; + } + else { + $colors[$k] = COL_CRITICAL; + } + } + $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false, false)); echo pie3d_graph( true, $data_graph, $width, $height, __("other"), "", $water_mark, - $config['fontpath'], $config['font_size']); + $config['fontpath'], $config['font_size'], 1, false, $colors); } /** @@ -2031,6 +2041,9 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = $groupby_extra = ''; } + // Add tags condition to filter + $tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND'); + //This will give the distinct id_agente, give the id_grupo that goes //with it and then the number of times it occured. GROUP BY statement //is required if both DISTINCT() and COUNT() are in the statement @@ -2039,18 +2052,18 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = $sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente, id_grupo, COUNT(id_agente) AS count'.$field_extra.' FROM '.$event_table.' - WHERE 1=1 %s + WHERE 1=1 %s %s GROUP BY id_agente'.$groupby_extra.' - ORDER BY count DESC', $url); + ORDER BY count DESC', $url, $tags_condition); break; case "postgresql": case "oracle": $sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente, id_grupo, COUNT(id_agente) AS count'.$field_extra.' FROM '.$event_table.' - WHERE 1=1 %s + WHERE 1=1 %s %s GROUP BY id_agente, id_grupo'.$groupby_extra.' - ORDER BY count DESC', $url); + ORDER BY count DESC', $url, $tags_condition); break; } @@ -2091,10 +2104,12 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = $data[$name] = $system_events; } + /* if ($other_events > 0) { $name = __('Other')." (".$other_events.")"; $data[$name] = $other_events; } + */ // Sort the data arsort($data); @@ -2104,7 +2119,7 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = return pie3d_graph($config['flash_charts'], $data, $width, $height, __('Other'), '', $water_mark, - $config['fontpath'], $config['font_size']); + $config['fontpath'], $config['font_size'], 1, 'bottom'); } /** @@ -2112,59 +2127,69 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = * * @param string filter Filter for query in DB */ -function grafico_eventos_total($filter = "") { +function grafico_eventos_total($filter = "", $width = 320, $height = 200) { global $config; global $graphic_type; $filter = str_replace ( "\\" , "", $filter); + + // Add tags condition to filter + $tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND'); + $filter .= $tags_condition; + $data = array (); $legend = array (); $total = 0; - $sql = "SELECT COUNT(id_evento) - FROM tevento WHERE criticity = 0 $filter"; - $data[__('Maintenance')] = db_get_sql ($sql); - if ($data[__('Maintenance')] == 0) { - unset($data[__('Maintenance')]); + $sql = "SELECT criticity, COUNT(id_evento) events FROM tevento GROUP BY criticity ORDER BY events DESC"; + + $criticities = db_get_all_rows_sql ($sql); + + if(empty($criticities)) { + $criticities = array(); + $colors = array(); } - $sql = "SELECT COUNT(id_evento) - FROM tevento WHERE criticity = 1 $filter"; - $data[__('Informational')] = db_get_sql ($sql); - if ($data[__('Informational')] == 0) { - unset($data[__('Informational')]); + foreach($criticities as $cr) { + switch($cr['criticity']) { + case EVENT_CRIT_MAINTENANCE: + $data[__('Maintenance')] = $cr['events']; + $colors[__('Maintenance')] = COL_MAINTENANCE; + break; + case EVENT_CRIT_INFORMATIONAL: + $data[__('Informational')] = $cr['events']; + $colors[__('Informational')] = COL_INFORMATIONAL; + break; + case EVENT_CRIT_NORMAL: + $data[__('Normal')] = $cr['events']; + $colors[__('Normal')] = COL_NORMAL; + break; + case EVENT_CRIT_MINOR: + $data[__('Minor')] = $cr['events']; + $colors[__('Minor')] = COL_MINOR; + break; + case EVENT_CRIT_WARNING: + $data[__('Warning')] = $cr['events']; + $colors[__('Warning')] = COL_WARNING; + break; + case EVENT_CRIT_MAJOR: + $data[__('Major')] = $cr['events']; + $colors[__('Major')] = COL_MAJOR; + break; + case EVENT_CRIT_CRITICAL: + $data[__('Critical')] = $cr['events']; + $colors[__('Critical')] = COL_CRITICAL; + break; + } } - $sql = "SELECT COUNT(id_evento) - FROM tevento WHERE criticity = 2 $filter"; - $data[__('Normal')] = db_get_sql ($sql); - if ($data[__('Normal')] == 0) { - unset($data[__('Normal')]); - } - - $sql = "SELECT COUNT(id_evento) - FROM tevento WHERE criticity = 3 $filter"; - $data[__('Warning')] = db_get_sql ($sql); - if ($data[__('Warning')] == 0) { - unset($data[__('Warning')]); - } - - $sql = "SELECT COUNT(id_evento) - FROM tevento WHERE criticity = 4 $filter"; - $data[__('Critical')] = db_get_sql ($sql); - if ($data[__('Critical')] == 0) { - unset($data[__('Critical')]); - } - - asort ($data); - $water_mark = array( 'file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("/images/logo_vertical_water.png")); - return pie3d_graph($config['flash_charts'], $data, 320, 200, + return pie3d_graph($config['flash_charts'], $data, $width, $height, __('Other'), '', $water_mark, - $config['fontpath'], $config['font_size']); + $config['fontpath'], $config['font_size'], 1, false, $colors); } /** diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 750b1a1a07..cdfed96805 100644 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -262,7 +262,7 @@ $table->style = array_fill(0, 3, 'vertical-align: top;'); $data = array(); $data[0] = html_print_table($table_agent, true); $data[1] = html_print_table($table_contact, true) . '
'; -$data[1] .= html_print_table($table_data, true); +$data[1] .= empty($table_data->data) ? '' : html_print_table($table_data, true); $table->rowspan[0][1] = 2; diff --git a/pandora_console/operation/agentes/status_events.php b/pandora_console/operation/agentes/status_events.php index 1d1a5458f4..54796ed6fe 100644 --- a/pandora_console/operation/agentes/status_events.php +++ b/pandora_console/operation/agentes/status_events.php @@ -28,6 +28,6 @@ echo "

".__('Latest events for this agent' $tags_condition = tags_get_acl_tags($config['id_user'], $agent['id_grupo'], 'ER', 'event_condition', 'AND'); -events_print_event_table ("WHERE id_agente = $id_agente $tags_condition", $limit = 10, $width='100%'); +events_print_event_table ("estado <> 1 $tags_condition", 10, '100%', false, $id_agente); ?> diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index bcd3359dd8..96487644f9 100644 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -55,7 +55,8 @@ if(tags_has_user_acl_tags()) { ui_print_tags_warning(); } -echo '
'; +echo ''; +echo ''; //Left column -echo '
'; +echo '
'; +echo '
'; // --------------------------------------------------------------------- // The status horizontal bars (Global health, Monitor sanity... // --------------------------------------------------------------------- @@ -109,17 +110,17 @@ if ($is_admin) { html_print_table($table); } -echo ''; //Left column +echo ''; // --------------------------------------------------------------------- // Last events information // --------------------------------------------------------------------- +$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND'); -events_print_event_table ("WHERE estado<>1 ", 10, "100%"); - +events_print_event_table ("estado<>1 $tags_condition", 10, "100%"); // --------------------------------------------------------------------- // Server information @@ -196,5 +197,6 @@ if ($is_admin) { } -echo ''; +echo '
'; ?> diff --git a/pandora_console/operation/events/event_statistics.php b/pandora_console/operation/events/event_statistics.php index 5f9821ee22..204b094837 100644 --- a/pandora_console/operation/events/event_statistics.php +++ b/pandora_console/operation/events/event_statistics.php @@ -35,11 +35,21 @@ echo ""; echo ""; echo "

" . __('Event graph') . "

"; -echo grafico_eventos_total(); echo ""; echo ""; echo "

" . __('Event graph by user') . "

"; +echo ""; + +echo ""; + +echo ""; + +echo ""; +echo grafico_eventos_total(); +echo ""; + +echo ""; echo grafico_eventos_usuario(300, 200); echo ""; @@ -47,13 +57,23 @@ echo ""; echo ""; -echo ""; +echo ""; echo "

" . __('Event graph by agent') . "

"; +echo ""; + +echo ""; +echo "

" . __('Amount events validated') . "

"; +echo ""; + +echo ""; + +echo ""; + +echo ""; echo grafico_eventos_grupo(300, 200); echo ""; -echo ""; -echo "

" . __('Amount events validated') . "

"; +echo ""; echo graph_events_validated(300, 200); echo ""; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index c7a2acec93..bb5e8d2c63 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -186,6 +186,7 @@ $filter_only_alert = (int) get_parameter('filter_only_alert', -1); $filter_id = (int) get_parameter('filter_id', 0); $id_name = (string) get_parameter('id_name', ''); $id_group = (int) get_parameter('id_group', 0); +$open_filter = (int) get_parameter('open_filter', 0); $text_agent = (string) get_parameter("text_agent", __("All")); @@ -230,6 +231,7 @@ $params = "search=" . rawurlencode(io_safe_input($search)) . "&id_group=" . $id_group . "&history=" . (int)$history . "&section=" . $section . + "&open_filter=" . $open_filter . "&pure=" . $config["pure"]; if($meta) { diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index ff0b7c8a50..a1cfe33558 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -148,8 +148,18 @@ require('events.build_query.php'); $id_name = get_parameter('id_name', ''); echo "
"; + +// Trick to catch if any filter button has been pushed (don't collapse filter) +// or the filter was open before click or autorefresh is in use (collapse filter) +$update_pressed = get_parameter_post('update', ''); +$update_pressed = (int) !empty($update_pressed); + +if ($update_pressed || $open_filter){ + $open_filter = true; +} + //Link to toggle filter -if (!empty($id_name)) { +if ($open_filter) { echo ''.__('Event control filter').' '.html_print_image ("images/go.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'

'; } else{ @@ -308,7 +318,16 @@ echo '
'; -$data[1] .= html_print_select ($filters, "filter_id", $filter_id, '', __('none'), 0, true); -* */ $table->data[] = $data; $table->rowclass[] = ''; - -// Trick to catch if the update button has been pushed (don't collapse filter) -// or autorefresh is in use (collapse filter) -$autorefresh_toogle = get_parameter_get('toogle_filter', 'true'); -$update_pressed = get_parameter_post('toogle_filter', 'true'); -// If autoupdate is in use collapse filter -if ($autorefresh_toogle == 'false'){ - html_print_input_hidden('toogle_filter', 'true'); -} -else{ - // Keeps state with pagination - if ($autorefresh_toogle == 'no') { - html_print_input_hidden('toogle_filter', 'false'); - } - else { - - // If update button has been pushed then don't collapse filter - if ($update_pressed == 'false') { - html_print_input_hidden('toogle_filter', 'false'); - } // Else collapse filter - else { - html_print_input_hidden('toogle_filter', 'true'); - } - } -} - //The buttons $data = array(); $data[0] = '
'; -$data[0] .= '' . html_print_image("images/disk.png", true, array("border" => '0', "title" => __('Save filter'), "alt" => __('Save filter'))) . '  '; -$data[0] .= '' . html_print_image("images/server_database.png", true, array("border" => '0', "title" => __('Load filter'), "alt" => __('Load filter'))) . ' '; +$data[0] .= '' . html_print_image("images/disk.png", true, array("border" => '0', "title" => __('Save filter'), "alt" => __('Save filter'))) . '  '; +$data[0] .= '' . html_print_image("images/server_database.png", true, array("border" => '0', "title" => __('Load filter'), "alt" => __('Load filter'))) . ' '; if(empty($id_name)) { $data[0] .= '[' . __('No filter loaded') . ']'; } @@ -552,8 +541,8 @@ var text_none = ""; $(document).ready( function() { // Don't collapse filter if update button has been pushed - if ($("#hidden-toogle_filter").val() == 'false'){ - $("#event_control").toggle (); + if ($("#hidden-open_filter").val() == 'true'){ + $("#event_control").toggle(); } // If selected is not 'none' show filter name