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:
parent
ef8f9b995d
commit
eecf04aca5
|
@ -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>
|
||||
|
||||
* include/functions_networkmap.php: Modified the L2
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 <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">';
|
||||
$divider = '</td><td style="text-align: center">';
|
||||
$rowend = '</td></tr>';
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue