diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 4677a5755a..678b08438e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2014-03-01 Miguel de Dios + + * include/functions_modules.php, operation/agentes/exportdata.php: + fixed the export data from modules with string data. + + Incident: #707 + 2014-04-01 Alejandro Gallardo * include/functions_networkmap.php: Modified the L2 diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 1fb0e71d04..59ccf90401 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1254,7 +1254,8 @@ function modules_get_moduletypes ($type = "all", $rows = "nombre") { return array_merge (range (1,4), range (19,24)); } - $sql = sprintf ("SELECT id_tipo, %s FROM ttipo_modulo", implode (",", $rows)); + $sql = sprintf ("SELECT id_tipo, %s + FROM ttipo_modulo", implode (",", $rows)); $result = db_get_all_rows_sql ($sql); if ($result === false) { return $return; @@ -1481,18 +1482,49 @@ function modules_get_next_data ($id_agent_module, $utimestamp = 0, $string = 0) * @return array The module value and the timestamp */ function modules_get_agentmodule_data ($id_agent_module, $period, $date = 0) { + $module = db_get_row('tagente_modulo', 'id_agente_modulo', + $id_agent_module); + if ($date < 1) { $date = get_system_time (); } $datelimit = $date - $period; - $sql = sprintf ("SELECT datos AS data, utimestamp - FROM tagente_datos - WHERE id_agente_modulo = %d - AND utimestamp > %d AND utimestamp <= %d - ORDER BY utimestamp ASC", - $id_agent_module, $datelimit, $date); + switch ($module['id_tipo_modulo']) { + //generic_data_string + case 3: + //remote_tcp_string + case 10: + //remote_snmp_string + case 17: + //async_string + case 23: + $sql = sprintf ("SELECT datos AS data, utimestamp + FROM tagente_datos_string + WHERE id_agente_modulo = %d + AND utimestamp > %d AND utimestamp <= %d + ORDER BY utimestamp ASC", + $id_agent_module, $datelimit, $date); + break; + //log4x + case 24: + $sql = sprintf ("SELECT datos AS data, utimestamp + FROM tagente_datos_log4x + WHERE id_agente_modulo = %d + AND utimestamp > %d AND utimestamp <= %d + ORDER BY utimestamp ASC", + $id_agent_module, $datelimit, $date); + break; + default: + $sql = sprintf ("SELECT datos AS data, utimestamp + FROM tagente_datos + WHERE id_agente_modulo = %d + AND utimestamp > %d AND utimestamp <= %d + ORDER BY utimestamp ASC", + $id_agent_module, $datelimit, $date); + break; + } $values = db_get_all_rows_sql ($sql, true, false); diff --git a/pandora_console/operation/agentes/exportdata.php b/pandora_console/operation/agentes/exportdata.php index 2e67698c43..ee21ae0364 100644 --- a/pandora_console/operation/agentes/exportdata.php +++ b/pandora_console/operation/agentes/exportdata.php @@ -41,10 +41,12 @@ $agentName = get_parameter_post ('agent', 0); switch ($config["dbtype"]) { case "mysql": case "postgresql": - $agents = agents_get_agents (array('nombre LIKE "' . $agentName . '"'), array ('id_agente')); + $agents = agents_get_agents( + array('nombre LIKE "' . $agentName . '"'), array ('id_agente')); break; case "oracle": - $agents = agents_get_agents (array('nombre LIKE \'%' . $agentName . '%\''), array ('id_agente')); + $agents = agents_get_agents( + array('nombre LIKE \'%' . $agentName . '%\''), array ('id_agente')); break; } $agent = $agents[0]['id_agente']; @@ -65,8 +67,8 @@ if (!empty ($export_btn) && !empty ($module)) { //Convert start time and end time to unix timestamps - $start = strtotime ($start_date." ".$start_time); - $end = strtotime ($end_date." ".$end_time); + $start = strtotime ($start_date . " " . $start_time); + $end = strtotime ($end_date . " " . $end_time); $period = $end - $start; $data = array (); @@ -84,7 +86,13 @@ if (!empty ($export_btn) && !empty ($module)) { case "avg": default: //HTML output - don't style or use XHTML just in case somebody needs to copy/paste it. (Office doesn't handle and ) - $datastart = ''; + $datastart = '
'.__('Agent').''.__('Module').''.__('Data').''.__('Timestamp').'
' . + '' . + '' . + '' . + '' . + '' . + ''; $rowstart = ''; @@ -116,6 +124,7 @@ if (!empty ($export_btn) && !empty ($module)) { while ($work_end <= $end) { $data = array (); // Reinitialize array for each module chunk + if ($export_type == "avg") { $arr = array (); $arr["data"] = reporting_get_agentmodule_data_average ($selected, $work_period, $work_end); @@ -129,7 +138,9 @@ if (!empty ($export_btn) && !empty ($module)) { array_push ($data, $arr); } else { - $data_single = modules_get_agentmodule_data ($selected, $work_period, $work_end); + $data_single = modules_get_agentmodule_data( + $selected, $work_period, $work_end); + if (!empty ($data_single)) { $data = array_merge ($data, $data_single); }
' . __('Agent') . '' . __('Module') . '' . __('Data') . '' .__('Timestamp') . '
'; $divider = ''; $rowend = '