From 401620e8fa2649ce97963adcaaaf7ddf0639c86a Mon Sep 17 00:00:00 2001 From: esanchezm Date: Thu, 17 Jul 2008 12:21:17 +0000 Subject: [PATCH] 2008-07-17 Esteban Sanchez * godmode/reporting/map_builder.php: Check background existance to avoid warnings. * include/functions.php: Added Giga magnitude in format_for_graph(), thansk to tono user in openideas. * include/functions_db.php: Check database result on return_status_layout(). Deleted "LIMIT 1" on get_previous_data() which was causing SQL failures. Style correction. * include/functions_reporting.php: Check database result on get_agent_module_sla(). * operation/agentes/datos_agente.php: Removed useless code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@961 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 17 +++++++++++++++++ .../godmode/reporting/map_builder.php | 5 ++++- pandora_console/include/functions.php | 5 +++++ pandora_console/include/functions_db.php | 13 ++++++++----- pandora_console/include/functions_reporting.php | 2 +- .../operation/agentes/datos_agente.php | 7 +------ 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c53033b949..f5a31acba5 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,20 @@ +2008-07-17 Esteban Sanchez + + * godmode/reporting/map_builder.php: Check background existance to + avoid warnings. + + * include/functions.php: Added Giga magnitude in format_for_graph(), + thansk to tono user in openideas. + + * include/functions_db.php: Check database result on + return_status_layout(). Deleted "LIMIT 1" on get_previous_data() which + was causing SQL failures. Style correction. + + * include/functions_reporting.php: Check database result on + get_agent_module_sla(). + + * operation/agentes/datos_agente.php: Removed useless code. + 2008-07-17 Raul Mateos * operation/agentes/status_monitor.php: Closed html tags. diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 7a6c223301..1b198d5a73 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -94,7 +94,10 @@ if ($update_layout) { $width = (int) get_parameter ('width'); $height = (int) get_parameter ('height'); $background = (string) get_parameter ('background'); - $bg_info = getimagesize ('images/console/background/'.$background); + $bg_info = array (0, 0); + if (file_exists ('images/console/background/'.$background)) + $bg_info = getimagesize ('images/console/background/'.$background); + if (! $width) $width = $bg_info[0]; if (! $height) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 7046436c87..1296804429 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -422,6 +422,11 @@ function format_numeric ($number, $decimals = 1, $dec_point = ".", $thousands_se * @return A number rendered to be displayed gently on a graph. */ function format_for_graph ($number , $decimals = 1, $dec_point = ".", $thousands_sep = ",") { + if ($number > 1000000000) { + if (fmod ($number, 1000000000) > 0){ + return number_format ($number / 1000000000, $decimals, $dec_point, $thousands_sep)." G"; + } + } if ($number > 1000000) { if (fmod ($number, 1000000) > 0) return number_format ($number / 1000000, $decimals, $dec_point, $thousands_sep)." M"; diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index b644178a4c..591882aa71 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -21,7 +21,7 @@ */ function check_login () { global $config; - if (!isset($config["homedir"])){ + if (! isset ($config["homedir"])) { // No exists $config. Exit inmediatly include("general/noaccess.php"); exit; @@ -32,7 +32,7 @@ function check_login () { return 0; } } - audit_db("N/A", getenv("REMOTE_ADDR"), "No session", "Trying to access without a valid session"); + audit_db ("N/A", getenv ("REMOTE_ADDR"), "No session", "Trying to access without a valid session"); include ($config["homedir"]."/general/noaccess.php"); exit; } @@ -1438,6 +1438,9 @@ function return_status_layout ($id_layout = 0) { $temp_total = 0; $sql = sprintf ("SELECT id_agente_modulo, parent_item, id_layout_linked FROM `tlayout_data` WHERE `id_layout` = '%d'",$id_layout); $result = get_db_all_rows_sql ($sql); + if ($result === false) + return 0; + foreach ($result as $rownum => $data) { if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) { $temp_status += return_status_layout ($data["id_layout_linked"]); @@ -1449,9 +1452,9 @@ function return_status_layout ($id_layout = 0) { } if ($temp_status == $temp_total) { return 1; - } else { - return 0; } + + return 0; } /** @@ -1506,7 +1509,7 @@ function get_previous_data ($id_agent_module, $utimestamp) { WHERE id_agente_modulo = %d AND utimestamp <= %d AND utimestamp > %d - ORDER BY utimestamp DESC LIMIT 1', + ORDER BY utimestamp DESC', $id_agent_module, $utimestamp, $utimestamp - $interval); return get_db_row_sql ($sql); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 0e396263c0..92b48e372d 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -53,7 +53,7 @@ function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value array_unshift ($datas, $previous_data); $previous_data_timestamp = $previous_data['utimestamp']; } - if (sizeof ($datas) == 0) { + if ($datas === false) { return false; } diff --git a/pandora_console/operation/agentes/datos_agente.php b/pandora_console/operation/agentes/datos_agente.php index c0df7c9336..45867f0081 100644 --- a/pandora_console/operation/agentes/datos_agente.php +++ b/pandora_console/operation/agentes/datos_agente.php @@ -91,12 +91,7 @@ function datos_raw($id_agente_modulo, $periodo){ echo "".$row["timestamp"].""; echo ""; if (is_numeric($row["datos"])) { - $mytempdata = fmod($row["datos"], 1); - if ($mytempdata == 0) - $myvalue = intval($row["datos"]); - else - $myvalue = $row["datos"]; - echo format_for_graph($myvalue ); + echo format_for_graph ($row["datos"]); } else { echo salida_limpia($row["datos"]); }