2013-03-01 Sergio Martin <sergio.martin@artica.es>

* 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.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7767 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2013-03-01 13:22:29 +00:00
parent 985654001e
commit fc5955a551
10 changed files with 188 additions and 106 deletions

View File

@ -1,3 +1,17 @@
2013-03-01 Sergio Martin <sergio.martin@artica.es>
* 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 <mario.pulido@artica.es>
* images/help/service1.png: New file for help.

View File

@ -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');

View File

@ -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 '<div class="nf">'.__('No events').'</div>';
}
@ -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] = "<span title='" . __('Validated') . "'>" . __('V.') . "</span>";
$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 = '<table><tr><td style="width: 90%; padding-right: 10px;">';
$out .= $events_table;
$out .= '</td><td style="width: 250px">';
$out .= '<b>' . __('Events generated -by module-') . '</b><br>';
$out .= graph_event_module (300, 120, $event['id_agente']);
if($agent_id != 0) {
$out .= '</td><td style="width: 250px">';
$out .= '<b>' . __('Events generated -by module-') . '</b><br>';
$out .= graph_event_module (250, 100, $event['id_agente']);
}
else {
$out .= '</td><td style="width: 250px; vertical-align: top;"><br>';
$out .= '<b>' . __('Event graph') . '</b><br>';
$out .= grafico_eventos_total("", 250, 120) . '<br>';
$out .= '<b>' . __('Event graph by agent') . '</b><br>';
$out .= grafico_eventos_grupo(250, 100);
}
$out .= '</td></tr></table>';

View File

@ -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);
}
/**

View File

@ -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) . '<br>';
$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;

View File

@ -28,6 +28,6 @@ echo "<h4 style='margin-top:0px !important;'>".__('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);
?>

View File

@ -55,7 +55,8 @@ if(tags_has_user_acl_tags()) {
ui_print_tags_warning();
}
echo '<div style="width:20%; float:left; padding-right: 5%;" id="leftcolumn">';
echo '<table border=0 style="width:100%;"><tr>';
echo '<td style="vertical-align: top; min-width: 265px; width:30%; padding-right: 5%;" id="leftcolumn">';
// ---------------------------------------------------------------------
// The status horizontal bars (Global health, Monitor sanity...
// ---------------------------------------------------------------------
@ -109,17 +110,17 @@ if ($is_admin) {
html_print_table($table);
}
echo '</div>'; //Left column
echo '</td>'; //Left column
echo '<div style="width: 70%; float:left;" id="rightcolumn">';
echo '<td style="vertical-align: top; width: 70%;" id="rightcolumn">';
// ---------------------------------------------------------------------
// 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 '</div>';
echo '</td>';
echo '</tr></table>';
?>

View File

@ -35,11 +35,21 @@ echo "<tr>";
echo "<td valign='top'>";
echo "<h3>" . __('Event graph') . "</h3>";
echo grafico_eventos_total();
echo "</td>";
echo "<td valign='top'>";
echo "<h3>" . __('Event graph by user') . "</h3>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td valign='top'>";
echo grafico_eventos_total();
echo "</td>";
echo "<td valign='top'>";
echo grafico_eventos_usuario(300, 200);
echo "</td>";
@ -47,13 +57,23 @@ echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<td valign='top'>";
echo "<h3>" . __('Event graph by agent') . "</h3>";
echo "</td>";
echo "<td valign='top'>";
echo "<h3>" . __('Amount events validated') . "</h3>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td valign='top'>";
echo grafico_eventos_grupo(300, 200);
echo "</td>";
echo "<td>";
echo "<h3>" . __('Amount events validated') . "</h3>";
echo "<td valign='top'>";
echo graph_events_validated(300, 200);
echo "</td>";

View File

@ -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)) .
"&amp;id_group=" . $id_group .
"&amp;history=" . (int)$history .
"&amp;section=" . $section .
"&amp;open_filter=" . $open_filter .
"&amp;pure=" . $config["pure"];
if($meta) {

View File

@ -148,8 +148,18 @@ require('events.build_query.php');
$id_name = get_parameter('id_name', '');
echo "<br>";
// 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 '<a href="#" id="tgl_event_control"><b>'.__('Event control filter').'</b>&nbsp;'.html_print_image ("images/go.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'</a><br><br>';
}
else{
@ -308,7 +318,16 @@ echo '<form id="form_filter" method="post" action="index.php?sec=eventos&amp;sec
// Hidden field with the loaded filter name
html_print_input_hidden('id_name', $id_name);
$table->id = 'stat_win_form';
// Hidden open filter flag
// If autoupdate is in use collapse filter
if ($open_filter){
html_print_input_hidden('open_filter', 'true');
}
else{
html_print_input_hidden('open_filter', 'false');
}
$table->id = 'events_filter_form';
$table->width = '98%';
$table->cellspacing = 4;
$table->cellpadding = 4;
@ -387,45 +406,15 @@ $table->rowclass[] = '';
$data = array();
/*
$data[1] = __("Load filter") . '<br>';
$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] = '<div style="width:100%; text-align:left">';
$data[0] .= '<a href="javascript:show_save_filter_dialog();">' . html_print_image("images/disk.png", true, array("border" => '0', "title" => __('Save filter'), "alt" => __('Save filter'))) . '</a> &nbsp;';
$data[0] .= '<a href="javascript:show_load_filter_dialog();">' . html_print_image("images/server_database.png", true, array("border" => '0', "title" => __('Load filter'), "alt" => __('Load filter'))) . '</a>&nbsp;';
$data[0] .= '<a href="javascript:" onclick="show_save_filter_dialog();">' . html_print_image("images/disk.png", true, array("border" => '0', "title" => __('Save filter'), "alt" => __('Save filter'))) . '</a> &nbsp;';
$data[0] .= '<a href="javascript:" onclick="show_load_filter_dialog();">' . html_print_image("images/server_database.png", true, array("border" => '0', "title" => __('Load filter'), "alt" => __('Load filter'))) . '</a>&nbsp;';
if(empty($id_name)) {
$data[0] .= '[<span id="filter_loaded_span" style="font-weight: normal">' . __('No filter loaded') . '</span>]';
}
@ -552,8 +541,8 @@ var text_none = "<?php echo __('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