diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c4b98e28d4..36c04b89b8 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,23 @@ +2008-06-20 Esteban Sanchez + + * include/functions_reporting.php: Deleted reference to localhost. Align + times fired colum. Show priority string instead on alerts. + + * include/functions.php: Show only one decimal by default on + format_numeric() and format_for_graph(). Cut alert name, agent name + and module name. Style correction. + + * include/functions_db.php: Function give_moduleinterval() renamed to + get_module_interval() and fixed a typo with variable name. On + get_previous_data() get the data if it's not older than the interval. + Order datas on min, max and sum calculation by the timestamp. Fixed and + improved the sumatory calculation. + + * operation/agentes/status_monitor.php: Ignore disabled modules. + + * operation/reporting/reporting_viewer.php: Do not use format_for_graph(), + but format_numeric() instead. + 2008-06-19 Sancho Lerena * Fixed some typos. diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index e7600fdbe0..3765252591 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -386,13 +386,13 @@ function pagination ($count, $url, $offset) { * shown. Otherwise, the number of decimals are given in the call. * * @param number Number to be rendered - * @param decimals Number of decimals to be shown. Default value: 2 + * @param decimals Number of decimals to be shown. Default value: 1 * @param dec_point Decimal separator string. Default value: . * @param thousands_sep Thousands separator string. Default value: , * * @return */ -function format_numeric ($number, $decimals = 2, $dec_point = ".", $thousands_sep = ",") { +function format_numeric ($number, $decimals = 1, $dec_point = ".", $thousands_sep = ",") { if ($number == 0) return 0; @@ -408,23 +408,23 @@ function format_numeric ($number, $decimals = 2, $dec_point = ".", $thousands_se * It adds magnitude suffix to the number (M for millions, K for thousands...) * * @param number Number to be rendered - * @param decimals Number of decimals to display + * @param decimals Number of decimals to display. Default value: 1 * @param dec_point Decimal separator character. Default value: . * @param thousands_sep Thousands separator character. Default value: , * * @return A number rendered to be displayed gently on a graph. */ -function format_for_graph ($number , $decimals = 2, $dec_point = ".", $thousands_sep = ",") { - if ($number > "1000000") { +function format_for_graph ($number , $decimals = 1, $dec_point = ".", $thousands_sep = ",") { + if ($number > 1000000) { if (fmod ($number, 1000000) > 0) return number_format ($number / 1000000, $decimals, $dec_point, $thousands_sep)." M"; return number_format ($number / 1000000, 0, $dec_point, $thousands_sep)." M"; } - if ($number > "1000") { + if ($number > 1000) { if (fmod ($number, 1000) > 0) return number_format ($number / 1000, $decimals, $dec_point, $thousands_sep )." K"; - return number_format ($number/1000, 0, $dec_point, $thousands_sep )." K"; + return number_format ($number / 1000, 0, $dec_point, $thousands_sep )." K"; } /* If it has decimals */ if (fmod ($number , 1)) @@ -854,16 +854,16 @@ function show_alert_show_view ($data, $tdcolor = "datos", $combined = 0) { } $alert_name = get_db_sql ("SELECT nombre FROM talerta WHERE id_alerta = ".$data["id_alerta"]); - echo "".$alert_name.""; + echo "".substr($alert_name,0,15).""; if ($combined == 0) { - echo "".substr($module_name,0,21).""; + echo "".substr($module_name,0,12).""; } else { echo ""; // More details EYE tooltip (combined) echo " "; echo show_alert_row_mini ($data["id_aam"]); echo " "; - echo substr($agent_name,0,21).""; + echo substr($agent_name,0,16).""; } // Description diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 9b19ce214e..bb23997c59 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -825,17 +825,16 @@ function event_insert ($evento, $id_grupo, $id_agente, $status = 0, * * If the module interval is not set, the agent interval is returned * - * @param id_agentmodule Id agent module to get the interval value. + * @param id_agent_module Id agent module to get the interval value. * * @return */ -function give_moduleinterval ($id_agentmodule) { +function get_module_interval ($id_agent_module) { $interval = (int) get_db_value ('module_interval', 'tagente_modulo', 'id_agente_modulo', $id_agent_module); - if ($interval) return $interval; + $id_agent = get_db_value ('id_agente', 'tagente_modulo', 'id_agente_modulo', (int) $id_agent_module); - $id_agent = (int) give_agentinterval ($id_agent);get_db_value ('id_agente', 'tagente_modulo', 'id_agente_modulo', $id_agent_module); return (int) give_agentinterval ($id_agent); } @@ -1383,7 +1382,9 @@ function return_coordinate_y_layoutdata ($id_layoutdata){ * Get the previous data to the timestamp provided. * * It's useful to know the first value of a module in an interval, - * since it will be the last value in the + * since it will be the last value in the table which has a timestamp + * before the beginning of the interval. All this calculation is due + * to the data compression algorithm. * * @param $id_agent_module Agent module id * @param $utimestamp The timestamp to look backwards from and get the data. @@ -1391,11 +1392,14 @@ function return_coordinate_y_layoutdata ($id_layoutdata){ * @return The row of tagente_datos of the last period. NULL if there were no data. */ function get_previous_data ($id_agent_module, $utimestamp) { + $interval = get_module_interval ($id_agent_module); $sql = sprintf ('SELECT * FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp <= %d - ORDER by utimestamp DESC LIMIT 1', - $id_agent_module, $utimestamp); + AND utimestamp > %d + ORDER BY utimestamp DESC LIMIT 1', + $id_agent_module, $utimestamp, $utimestamp - $interval); + return get_db_row_sql ($sql); } @@ -1445,8 +1449,7 @@ function return_moduledata_max_value ($id_agent_module, $period, $date = 0) { $sql = sprintf ("SELECT MAX(datos) FROM tagente_datos WHERE id_agente_modulo = %d - AND utimestamp > %d AND utimestamp <= %d - ORDER BY utimestamp ASC", + AND utimestamp > %d AND utimestamp <= %d", $id_agent_module, $datelimit, $date); $max = (float) get_db_sql ($sql); @@ -1474,8 +1477,7 @@ function return_moduledata_min_value ($id_agent_module, $period, $date = 0) { $sql = sprintf ("SELECT MIN(datos) FROM tagente_datos WHERE id_agente_modulo = %d - AND utimestamp > %d AND utimestamp <= %d - ORDER BY utimestamp ASC", + AND utimestamp > %d AND utimestamp <= %d", $id_agent_module, $datelimit, $date); $min = (float) get_db_sql ($sql); @@ -1504,12 +1506,12 @@ function return_moduledata_sum_value ($id_agent_module, $period, $date = 0) { if (is_module_data_string ($module_name)) { return lang_string ('wrong_module_type'); } - $interval = get_db_value ('current_interval', 'tagente_estado', 'id_agente_modulo', $id_agent_module); // Get the whole interval of data - $sql = sprintf ('SELECT * FROM tagente_datos + $sql = sprintf ('SELECT utimestamp, datos FROM tagente_datos WHERE id_agente_modulo = %d - AND utimestamp > %d AND utimestamp <= %d', + AND utimestamp > %d AND utimestamp <= %d + ORDER BY utimestamp ASC', $id_agent_module, $datelimit, $date); $datas = get_db_all_rows_sqlfree ($sql); @@ -1519,40 +1521,39 @@ function return_moduledata_sum_value ($id_agent_module, $period, $date = 0) { /* Add data to the beginning */ array_unshift ($datas, $previous_data); } - $last_data = ""; - $total_badtime = 0; - $interval_begin = 0; - $interval_last = 0; - if (sizeof ($datas) == 0) { return 0; } + + $last_data = ""; + $total_badtime = 0; + $module_interval = get_module_interval ($id_agent_module); + $timestamp_begin = $datelimit + module_interval; + $timestamp_end = 0; $sum = 0; - $previous_data = 0; + $data_value = 0; foreach ($datas as $data) { - if ($interval_begin != 0) { - $interval_last = $data["utimestamp"]; - $elapsed = $interval_last - $interval_begin; - $times = intval ($elapsed / $interval); + $timestamp_end = $data["utimestamp"]; + $elapsed = $timestamp_end - $timestamp_begin; + $times = intval ($elapsed / $module_interval); + + if (is_module_inc ($module_name)) { + $data_value = $data['datos'] * $module_interval; } else { - $times = 1; - } - if (is_module_proc ($module_name)) { - $previous_data = $data['datos'] * $interval; - } else { - $previous_data = $data['datos']; + $data_value = $data['datos']; } - $interval_begin = $data["utimestamp"]; + $sum += $times * $data_value; + $timestamp_begin = $data["utimestamp"]; } - /* The last interval value must be get from tagente_estado, but + /* The last value must be get from tagente_estado, but it will count only if it's not older than date demanded */ - $interval_last = get_db_value ('utimestamp', 'tagente_estado', 'id_agente_modulo', $id_agent_module); - if ($interval_last <= $datelimit) { - $elapsed = $interval_last - $interval_begin; - $times = intval ($elapsed / $interval); + $timestamp_end = get_db_value ('utimestamp', 'tagente_estado', 'id_agente_modulo', $id_agent_module); + if ($timestamp_end <= $datelimit) { + $elapsed = $timestamp_end - $timestamp_begin; + $times = intval ($elapsed / $module_interval); $sum += $times * $previous_data; } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 64d7704bce..cc9008bcdb 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -291,7 +291,7 @@ function alert_reporting ($id_group, $period = 0, $date = 0, $return = false) { } $fired_percentage = round (sizeof ($alerts_fired) / sizeof ($alerts) * 100, 2); $not_fired_percentage = 100 - $fired_percentage; - $output .= ''; $output .= ''.lang_string ('agents_with_fired_alerts').': '.sizeof ($agents).'
'; @@ -308,6 +308,8 @@ function alert_reporting ($id_group, $period = 0, $date = 0, $return = false) { $table->head[1] = lang_string ('alert_description'); $table->head[2] = lang_string ('times_fired'); $table->head[3] = lang_string ('priority'); + $table->align = array (); + $table->align[2] = 'center'; foreach ($agents as $alerts) { $data = array (); @@ -318,7 +320,7 @@ function alert_reporting ($id_group, $period = 0, $date = 0, $return = false) { $data[0] = ''; $data[1] = $alert['descripcion']; $data[2] = $alerts_fired[$alert['id_aam']]; - $data[3] = $alert['priority']; + $data[3] = get_alert_priority ($alert['priority']); array_push ($table->data, $data); } } @@ -375,7 +377,7 @@ function monitor_health_reporting ($id_group, $period = 0, $date = 0, $return = } $down_percentage = round ($monitors_down / sizeof ($monitors) * 100, 2); $not_down_percentage = 100 - $down_percentage; - $output .= ''; $output .= ''.lang_string ('total_monitors').': '.sizeof ($monitors).'
'; diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index bd1b9a3e21..84006c9f19 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -128,7 +128,7 @@ $SQL_pre = "SELECT tagente_modulo.id_agente_modulo, tagente.nombre, tagente_modu $SQL_pre_count = "SELECT count(tagente_modulo.id_agente_modulo) "; -$SQL = " FROM tagente, tagente_modulo, tagente_estado WHERE tagente.id_agente = tagente_modulo.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_tipo_modulo in (2, 9, 12, 18, 6, 100) AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo "; +$SQL = " FROM tagente, tagente_modulo, tagente_estado WHERE tagente.id_agente = tagente_modulo.id_agente AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND tagente_modulo.id_tipo_modulo in (2, 9, 12, 18, 6, 100) AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo "; // Agent group selector if ($ag_group > 1) diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 55b114232e..fe3ac6cb98 100644 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -261,7 +261,7 @@ foreach ($contents as $content) { $table->rowclass[$n - 1] = 'datos3'; $data = array (); - $monitor_value = $sla_result = format_numeric (return_module_SLA ($content['id_agent_module'], $content['period'], 1, 1, $datetime)); + $monitor_value = format_numeric (return_module_SLA ($content['id_agent_module'], $content['period'], 1, 1, $datetime)); $data[0] = '

'; $data[0] .= $monitor_value.' %

'; $monitor_value2 = format_numeric (100 - $monitor_value, 2) ; @@ -281,7 +281,7 @@ foreach ($contents as $content) { $data = array (); $table->colspan[$n][0] = 2; - $value = format_for_graph (return_moduledata_avg_value ($content['id_agent_module'], $content['period'], $datetime)); + $value = format_numeric (return_moduledata_avg_value ($content['id_agent_module'], $content['period'], $datetime)); $data[0] = '

'.$value.'

'; array_push ($table->data, $data); @@ -297,7 +297,7 @@ foreach ($contents as $content) { $data = array (); $table->colspan[$n][0] = 2; - $value = format_for_graph (return_moduledata_max_value ($content['id_agent_module'], $content['period'], $datetime)); + $value = format_numeric (return_moduledata_max_value ($content['id_agent_module'], $content['period'], $datetime)); $data[0] = '

'.$value.'

'; array_push ($table->data, $data); @@ -313,7 +313,7 @@ foreach ($contents as $content) { $data = array (); $table->colspan[$n][0] = 2; - $value = format_for_graph (return_moduledata_min_value ($content['id_agent_module'], $content['period'], $datetime)); + $value = format_numeric (return_moduledata_min_value ($content['id_agent_module'], $content['period'], $datetime)); $data[0] = '

'.$value.'

'; array_push ($table->data, $data); @@ -329,7 +329,7 @@ foreach ($contents as $content) { $data = array (); $table->colspan[$n][0] = 2; - $value = format_for_graph (return_moduledata_sum_value ($content['id_agent_module'], $content['period'], $datetime)); + $value = format_numeric (return_moduledata_sum_value ($content['id_agent_module'], $content['period'], $datetime)); $data[0] = '

'.$value.'

'; array_push ($table->data, $data); @@ -344,7 +344,7 @@ foreach ($contents as $content) { $data = array (); $table->colspan[$n][0] = 2; - $value = format_for_graph (return_moduledata_sum_value ($content['id_agent_module'], $content['period'], $datetime)); + $value = format_numeric (return_moduledata_sum_value ($content['id_agent_module'], $content['period'], $datetime)); $data[0] = general_group_reporting ($report['id_group'], true); array_push ($table->data, $data);