From 2b8c0ca33e8f8b43bc94fd019203aae0254d569f Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Fri, 4 Dec 2009 14:56:34 +0000 Subject: [PATCH] 2009-12-04 Sancho Lerena * operation/agentes/datos_agente.php: fix the bug when you have a large, very large list of data of module. And add the pagination. Fixes: 2908241 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2158 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 + .../operation/agentes/datos_agente.php | 141 ++++++++++++------ 2 files changed, 99 insertions(+), 48 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2df6a7a228..9f0f17b359 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2009-12-04 Sancho Lerena + + * operation/agentes/datos_agente.php: fix the bug when you have a large, + very large list of data of module. And add the pagination. + Fixes: 2908241 + 2009-12-04 Sancho Lerena * include/styles/pandora.css: Modified style for 3.0 diff --git a/pandora_console/operation/agentes/datos_agente.php b/pandora_console/operation/agentes/datos_agente.php index 55ad547624..934df46318 100644 --- a/pandora_console/operation/agentes/datos_agente.php +++ b/pandora_console/operation/agentes/datos_agente.php @@ -43,13 +43,24 @@ if (isset ($_GET["delete"])) { // Different query for string data type if (preg_match ("/string/", get_moduletype_name (get_agentmodule_type ($module_id)))) { - $sql = sprintf ("SELECT * FROM tagente_datos_string WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); + $sql = sprintf ("SELECT * + FROM tagente_datos_string + WHERE id_agente_modulo = %d AND utimestamp > %d + ORDER BY utimestamp DESC + LIMIT %d OFFSET %d", $module_id, get_system_time () - $period, $config['block_size'], get_parameter ('offset')); + $sqlCount = sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); $string_type = 1; } else { - $sql = sprintf ("SELECT * FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); + $sql = sprintf ("SELECT * + FROM tagente_datos + WHERE id_agente_modulo = %d AND utimestamp > %d + ORDER BY utimestamp DESC + LIMIT %d OFFSET %d", $module_id, get_system_time () - $period, $config['block_size'], get_parameter ('offset')); + $sqlCount = sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); $string_type = 0; } - + +$countData = get_db_value_sql($sqlCount); $result = get_db_all_rows_sql ($sql); if ($result === false) { $result = array (); @@ -58,53 +69,87 @@ if ($result === false) { echo "

".__('Received data from')." ".get_agentmodule_agent_name ($module_id)." / ".get_agentmodule_name ($module_id)."

"; echo "

".human_time_description ($period) ."

"; -$table->cellpadding = 3; -$table->cellspacing = 3; -$table->width = 600; -$table->class = "databox"; -$table->head = array (); -$table->data = array (); -$table->align = array (); +//WIP +//echo "
"; +//$intervals = array (); +//$intervals[30] = human_time_description_raw (30); +//$intervals[60] = human_time_description_raw (60); +//$intervals[300] = human_time_description_raw (300); +//$intervals[600] = human_time_description_raw (600); +//$intervals[1200] = human_time_description_raw (1200); +//$intervals[1800] = human_time_description_raw (1800); +//$intervals[3600] = human_time_description_raw (3600); +//$intervals[7200] = human_time_description_raw (7200); +//echo print_extended_select_for_time ($intervals, 'intervalo', $period, '', '', '0', 10) . __(" seconds."); +//echo "

"; -$table->head[0] = __('Delete'); -$table->align[0] = 'center'; - -$table->head[1] = __('Timestamp'); -$table->align[1] = 'center'; -$table->head[2] = __('Data'); -$table->align[2] = 'center'; - -foreach ($result as $row) { - $data = array (); - if (give_acl ($config['id_user'], $group, "AW") ==1) { - if ($string_type == 0) { - $data[0] = ''; - } else { - $data[0] = ''; - } - } else { - $data[0] = ''; - } - - // This returns data with absolute user-defined timestamp format - // and numeric by data managed with 2 decimals, and not using Graph format - // (replacing 1000 by K and 1000000 by G, like version 2.x - - $data[1] = date ($config["date_format"], $row["utimestamp"]); - if (is_numeric ($row["datos"])) { - $data[2] = format_numeric($row["datos"],2); - } else { - $data[2] = safe_input ($row["datos"]); - } - - array_push ($table->data, $data); -} - -if (empty ($table->data)) { +if ($result === false) { echo '

'.__('There was a problem locating the source of the graph').'

'; -} else { - print_table ($table); - unset ($table); +} +else { + pagination ($countData, false) ; + + echo ' + + + + + + + + '; + $count = 0; + foreach ($result as $row) { + + if (($count % 2) == 0) + $classPairOdd = 'rowPair'; + else + $classPairOdd = 'rowOdd'; + + if ($count > 100) break; + $count++; + + echo(''); + + if (give_acl ($config['id_user'], $group, "AW") ==1) { + if ($string_type == 0) { + echo(''); + } + else { + echo(''); + } + } + else { + echo(''); + } + + // This returns data with absolute user-defined timestamp format + // and numeric by data managed with 2 decimals, and not using Graph format + // (replacing 1000 by K and 1000000 by G, like version 2.x + + echo(''); + if (is_numeric ($row["datos"])) { + echo(''); + } + else { + echo(''); + } + echo(''); + } + echo '
' . __('Delete') . '' . __('Timestamp') . '' . __('Data') . '
+ + + + ' . + date ($config["date_format"], $row["utimestamp"]) . + '' . + format_numeric($row["datos"],2) . + '' . + safe_input ($row["datos"]) . + '
'; + + pagination ($countData, false) ; + echo "

" . __('Total') . ' ' . $countData . ' ' . __('Data') . "

"; } ?>