2014-03-01 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_modules.php, operation/agentes/exportdata.php:
	fixed the export data from modules with string data.
	
	Incident: #707




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9695 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2014-04-01 13:50:58 +00:00
parent af9cf1f51a
commit e3f38440d3
3 changed files with 63 additions and 13 deletions

View File

@ -1,3 +1,10 @@
2014-03-01 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_modules.php, operation/agentes/exportdata.php:
fixed the export data from modules with string data.
Incident: #707
2014-04-01 Alejandro Gallardo <alejandro.gallardo@artica.es> 2014-04-01 Alejandro Gallardo <alejandro.gallardo@artica.es>
* include/functions_networkmap.php: Modified the L2 * include/functions_networkmap.php: Modified the L2

View File

@ -1254,7 +1254,8 @@ function modules_get_moduletypes ($type = "all", $rows = "nombre") {
return array_merge (range (1,4), range (19,24)); 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); $result = db_get_all_rows_sql ($sql);
if ($result === false) { if ($result === false) {
return $return; 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 * @return array The module value and the timestamp
*/ */
function modules_get_agentmodule_data ($id_agent_module, $period, $date = 0) { 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) { if ($date < 1) {
$date = get_system_time (); $date = get_system_time ();
} }
$datelimit = $date - $period; $datelimit = $date - $period;
$sql = sprintf ("SELECT datos AS data, utimestamp switch ($module['id_tipo_modulo']) {
FROM tagente_datos //generic_data_string
WHERE id_agente_modulo = %d case 3:
AND utimestamp > %d AND utimestamp <= %d //remote_tcp_string
ORDER BY utimestamp ASC", case 10:
$id_agent_module, $datelimit, $date); //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); $values = db_get_all_rows_sql ($sql, true, false);

View File

@ -41,10 +41,12 @@ $agentName = get_parameter_post ('agent', 0);
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
case "postgresql": 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; break;
case "oracle": 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; break;
} }
$agent = $agents[0]['id_agente']; $agent = $agents[0]['id_agente'];
@ -65,8 +67,8 @@ if (!empty ($export_btn) && !empty ($module)) {
//Convert start time and end time to unix timestamps //Convert start time and end time to unix timestamps
$start = strtotime ($start_date." ".$start_time); $start = strtotime ($start_date . " " . $start_time);
$end = strtotime ($end_date." ".$end_time); $end = strtotime ($end_date . " " . $end_time);
$period = $end - $start; $period = $end - $start;
$data = array (); $data = array ();
@ -84,7 +86,13 @@ if (!empty ($export_btn) && !empty ($module)) {
case "avg": case "avg":
default: default:
//HTML output - don't style or use XHTML just in case somebody needs to copy/paste it. (Office doesn't handle <thead> and <tbody>) //HTML output - don't style or use XHTML just in case somebody needs to copy/paste it. (Office doesn't handle <thead> and <tbody>)
$datastart = '<table style="width:98%;"><tr><th>'.__('Agent').'</th><th>'.__('Module').'</th><th>'.__('Data').'</th><th>'.__('Timestamp').'</th></tr>'; $datastart = '<table style="width:98%;">' .
'<tr>' .
'<th>' . __('Agent') . '</th>' .
'<th>' . __('Module') . '</th>' .
'<th>' . __('Data') . '</th>' .
'<th>' .__('Timestamp') . '</th>' .
'</tr>';
$rowstart = '<tr><td style="text-align: center">'; $rowstart = '<tr><td style="text-align: center">';
$divider = '</td><td style="text-align: center">'; $divider = '</td><td style="text-align: center">';
$rowend = '</td></tr>'; $rowend = '</td></tr>';
@ -116,6 +124,7 @@ if (!empty ($export_btn) && !empty ($module)) {
while ($work_end <= $end) { while ($work_end <= $end) {
$data = array (); // Reinitialize array for each module chunk $data = array (); // Reinitialize array for each module chunk
if ($export_type == "avg") { if ($export_type == "avg") {
$arr = array (); $arr = array ();
$arr["data"] = reporting_get_agentmodule_data_average ($selected, $work_period, $work_end); $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); array_push ($data, $arr);
} }
else { 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)) { if (!empty ($data_single)) {
$data = array_merge ($data, $data_single); $data = array_merge ($data, $data_single);
} }