2010-07-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php: Updated reporting functions to work with uncompressed data. * include/fgraph.php, include/functions.php: Added a generic function to check whether a module has compressed data. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3077 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
4176fcd2b5
commit
09f8c72aed
|
@ -1,3 +1,11 @@
|
|||
2010-07-29 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* include/functions_reporting.php: Updated reporting functions to work
|
||||
with uncompressed data.
|
||||
|
||||
* include/fgraph.php, include/functions.php: Added a generic
|
||||
function to check whether a module has compressed data.
|
||||
|
||||
2010-07-28 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_html.php: Improved the print_select function
|
||||
|
|
|
@ -159,11 +159,9 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
$module_name_list[$i] = $agent_name." / ".substr ($module_name, 0, 20);
|
||||
$id_module_type = get_agentmodule_type ($agent_module_id);
|
||||
$module_type = get_moduletype_name ($id_module_type);
|
||||
if (strstr($module_type, 'async') !== false || strstr($module_type, 'log4x') !== false) {
|
||||
$async_module = true;
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
if ($uncompressed_module) {
|
||||
$avg_only = 1;
|
||||
} else {
|
||||
$async_module = false;
|
||||
}
|
||||
|
||||
// Get event data (contains alert data too)
|
||||
|
@ -191,7 +189,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
}
|
||||
|
||||
// Uncompressed module data
|
||||
if ($async_module) {
|
||||
if ($uncompressed_module) {
|
||||
$min_necessary = 1;
|
||||
|
||||
// Compressed module data
|
||||
|
@ -294,7 +292,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
$previous_data = $total;
|
||||
// Compressed data
|
||||
} else {
|
||||
if ($async_module) {
|
||||
if ($uncompressed_module) {
|
||||
$graph_values[$i][$timestamp] = 0;
|
||||
} else {
|
||||
$graph_values[$i][$timestamp] = $previous_data * $weight_list[$i];
|
||||
|
@ -1294,11 +1292,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$module_name = get_agentmodule_name ($agent_module_id);
|
||||
$id_module_type = get_agentmodule_type ($agent_module_id);
|
||||
$module_type = get_moduletype_name ($id_module_type);
|
||||
if (strstr($module_type, 'async') !== false || strstr($module_type, 'log4x') !== false) {
|
||||
$async_module = true;
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
if ($uncompressed_module) {
|
||||
$avg_only = 1;
|
||||
} else {
|
||||
$async_module = false;
|
||||
}
|
||||
|
||||
// Get event data (contains alert data too)
|
||||
|
@ -1326,7 +1322,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
}
|
||||
|
||||
// Uncompressed module data
|
||||
if ($async_module) {
|
||||
if ($uncompressed_module) {
|
||||
$min_necessary = 1;
|
||||
|
||||
// Compressed module data
|
||||
|
@ -1443,7 +1439,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$previous_data = $total;
|
||||
// Compressed data
|
||||
} else {
|
||||
if ($async_module) {
|
||||
if ($uncompressed_module) {
|
||||
$chart[$timestamp]['sum'] = 0;
|
||||
$chart[$timestamp]['min'] = 0;
|
||||
$chart[$timestamp]['max'] = 0;
|
||||
|
@ -1538,11 +1534,9 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
|||
$module_name = get_agentmodule_name ($agent_module_id);
|
||||
$id_module_type = get_agentmodule_type ($agent_module_id);
|
||||
$module_type = get_moduletype_name ($id_module_type);
|
||||
if (strstr($module_type, 'async') !== false || strstr($module_type, 'log4x') !== false) {
|
||||
$async_module = true;
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
if ($uncompressed_module) {
|
||||
$avg_only = 1;
|
||||
} else {
|
||||
$async_module = false;
|
||||
}
|
||||
|
||||
// Get event data (contains alert data too)
|
||||
|
@ -1570,7 +1564,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
|||
}
|
||||
|
||||
// Uncompressed module data
|
||||
if ($async_module) {
|
||||
if ($uncompressed_module) {
|
||||
$min_necessary = 1;
|
||||
|
||||
// Compressed module data
|
||||
|
@ -1687,7 +1681,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
|||
$previous_data = $total;
|
||||
// Compressed data
|
||||
} else {
|
||||
if ($async_module) {
|
||||
if ($uncompressed_module) {
|
||||
$chart[$timestamp]['sum'] = 0;
|
||||
} else {
|
||||
$chart[$timestamp]['sum'] = $previous_data;
|
||||
|
@ -1800,11 +1794,9 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
|
|||
$module_name = get_agentmodule_name ($agent_module_id);
|
||||
$id_module_type = get_agentmodule_type ($agent_module_id);
|
||||
$module_type = get_moduletype_name ($id_module_type);
|
||||
if (strstr($module_type, 'async') !== false || strstr($module_type, 'log4x') !== false) {
|
||||
$async_module = true;
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
if ($uncompressed_module) {
|
||||
$avg_only = 1;
|
||||
} else {
|
||||
$async_module = false;
|
||||
}
|
||||
|
||||
// Get event data (contains alert data too)
|
||||
|
@ -1832,7 +1824,7 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
|
|||
}
|
||||
|
||||
// Uncompressed module data
|
||||
if ($async_module) {
|
||||
if ($uncompressed_module) {
|
||||
$min_necessary = 1;
|
||||
|
||||
// Compressed module data
|
||||
|
|
|
@ -746,6 +746,21 @@ function is_module_data_string ($module_name) {
|
|||
return preg_match ('/\_string$/', $module_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a module data is uncompressed according
|
||||
* to the module type.
|
||||
*
|
||||
* @param string module_type Type of the module.
|
||||
*
|
||||
* @return bool true if the module data is uncompressed.
|
||||
*/
|
||||
function is_module_uncompressed ($module_type) {
|
||||
if (strstr($module_type, 'async') !== false || strstr($module_type, 'log4x') !== false) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all event types in an array
|
||||
*
|
||||
|
|
|
@ -44,6 +44,10 @@ function get_agentmodule_data_average ($id_agent_module, $period, $date = 0) {
|
|||
if ((empty ($period)) OR ($period == 0)) $period = $config["sla_period"];
|
||||
$datelimit = $date - $period;
|
||||
|
||||
$id_module_type = get_agentmodule_type ($id_agent_module);
|
||||
$module_type = get_moduletype_name ($id_module_type);
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
|
||||
// Get module data
|
||||
$interval_data = get_db_all_rows_sql ('SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
|
@ -52,43 +56,70 @@ function get_agentmodule_data_average ($id_agent_module, $period, $date = 0) {
|
|||
' ORDER BY utimestamp ASC', true);
|
||||
if ($interval_data === false) $interval_data = array ();
|
||||
|
||||
// Get previous data
|
||||
$previous_data = get_previous_data ($id_agent_module, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
$previous_data['utimestamp'] = $datelimit;
|
||||
array_unshift ($interval_data, $previous_data);
|
||||
}
|
||||
// Uncompressed module data
|
||||
if ($uncompressed_module) {
|
||||
$min_necessary = 1;
|
||||
|
||||
// Get next data
|
||||
$next_data = get_next_data ($id_agent_module, $date);
|
||||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
// Compressed module data
|
||||
} else {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
// Get previous data
|
||||
$previous_data = get_previous_data ($id_agent_module, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
$previous_data['utimestamp'] = $datelimit;
|
||||
array_unshift ($interval_data, $previous_data);
|
||||
}
|
||||
|
||||
// Get next data
|
||||
$next_data = get_next_data ($id_agent_module, $date);
|
||||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
} else {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
}
|
||||
|
||||
$min_necessary = 2;
|
||||
}
|
||||
|
||||
if (count ($interval_data) < 2) {
|
||||
if (count ($interval_data) < $min_necessary) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set initial conditions
|
||||
$total = 0;
|
||||
$previous_data = array_shift ($interval_data);
|
||||
$count = 0;
|
||||
if (! $uncompressed_module) {
|
||||
$previous_data = array_shift ($interval_data);
|
||||
}
|
||||
foreach ($interval_data as $data) {
|
||||
$total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']);
|
||||
$previous_data = $data;
|
||||
if (! $uncompressed_module) {
|
||||
$total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']);
|
||||
$previous_data = $data;
|
||||
} else {
|
||||
$total += $data['datos'];
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($period == 0) {
|
||||
// Compressed module data
|
||||
if (! $uncompressed_module) {
|
||||
if ($period == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $total / $period;
|
||||
}
|
||||
|
||||
// Uncompressed module data
|
||||
if ($count == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $total / $period;
|
||||
return $total / $count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,6 +139,10 @@ function get_agentmodule_data_max ($id_agent_module, $period, $date = 0) {
|
|||
if ((empty ($period)) OR ($period == 0)) $period = $config["sla_period"];
|
||||
$datelimit = $date - $period;
|
||||
|
||||
$id_module_type = get_agentmodule_type ($id_agent_module);
|
||||
$module_type = get_moduletype_name ($id_module_type);
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
|
||||
// Get module data
|
||||
$interval_data = get_db_all_rows_sql ('SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
|
@ -116,36 +151,46 @@ function get_agentmodule_data_max ($id_agent_module, $period, $date = 0) {
|
|||
' ORDER BY utimestamp ASC', true);
|
||||
if ($interval_data === false) $interval_data = array ();
|
||||
|
||||
// Get previous data
|
||||
$previous_data = get_previous_data ($id_agent_module, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
$previous_data['utimestamp'] = $datelimit;
|
||||
array_unshift ($interval_data, $previous_data);
|
||||
}
|
||||
// Uncompressed module data
|
||||
if ($uncompressed_module) {
|
||||
$min_necessary = 1;
|
||||
|
||||
// Get next data
|
||||
$next_data = get_next_data ($id_agent_module, $date);
|
||||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
// Compressed module data
|
||||
} else {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
// Get previous data
|
||||
$previous_data = get_previous_data ($id_agent_module, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
$previous_data['utimestamp'] = $datelimit;
|
||||
array_unshift ($interval_data, $previous_data);
|
||||
}
|
||||
|
||||
// Get next data
|
||||
$next_data = get_next_data ($id_agent_module, $date);
|
||||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
} else {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
}
|
||||
|
||||
$min_necessary = 2;
|
||||
}
|
||||
|
||||
if (count ($interval_data) < 2) {
|
||||
if (count ($interval_data) < $min_necessary) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set initial conditions
|
||||
$previous_data = array_shift ($interval_data);
|
||||
if ($previous_data['utimestamp'] == $datelimit) {
|
||||
$max = $previous_data['datos'];
|
||||
} else {
|
||||
$max = 0;
|
||||
$max = 0;
|
||||
if (! $uncompressed_module) {
|
||||
$previous_data = array_shift ($interval_data);
|
||||
if ($previous_data['utimestamp'] == $datelimit) {
|
||||
$max = $previous_data['datos'];
|
||||
}
|
||||
}
|
||||
foreach ($interval_data as $data) {
|
||||
if ($data['datos'] > $max) {
|
||||
|
@ -173,6 +218,10 @@ function get_agentmodule_data_min ($id_agent_module, $period, $date = 0) {
|
|||
if ((empty ($period)) OR ($period == 0)) $period = $config["sla_period"];
|
||||
$datelimit = $date - $period;
|
||||
|
||||
$id_module_type = get_agentmodule_type ($id_agent_module);
|
||||
$module_type = get_moduletype_name ($id_module_type);
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
|
||||
// Get module data
|
||||
$interval_data = get_db_all_rows_sql ('SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
|
@ -181,36 +230,46 @@ function get_agentmodule_data_min ($id_agent_module, $period, $date = 0) {
|
|||
' ORDER BY utimestamp ASC', true);
|
||||
if ($interval_data === false) $interval_data = array ();
|
||||
|
||||
// Get previous data
|
||||
$previous_data = get_previous_data ($id_agent_module, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
$previous_data['utimestamp'] = $datelimit;
|
||||
array_unshift ($interval_data, $previous_data);
|
||||
}
|
||||
// Uncompressed module data
|
||||
if ($uncompressed_module) {
|
||||
$min_necessary = 1;
|
||||
|
||||
// Get next data
|
||||
$next_data = get_next_data ($id_agent_module, $date);
|
||||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
// Compressed module data
|
||||
} else {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
// Get previous data
|
||||
$previous_data = get_previous_data ($id_agent_module, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
$previous_data['utimestamp'] = $datelimit;
|
||||
array_unshift ($interval_data, $previous_data);
|
||||
}
|
||||
|
||||
// Get next data
|
||||
$next_data = get_next_data ($id_agent_module, $date);
|
||||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
} else {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
}
|
||||
|
||||
$min_necessary = 2;
|
||||
}
|
||||
|
||||
if (count ($interval_data) < 2) {
|
||||
if (count ($interval_data) < $min_necessary) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set initial conditions
|
||||
$previous_data = array_shift ($interval_data);
|
||||
if ($previous_data['utimestamp'] == $datelimit) {
|
||||
$min = $previous_data['datos'];
|
||||
} else {
|
||||
$min = 0;
|
||||
$min = 0;
|
||||
if (! $uncompressed_module) {
|
||||
$previous_data = array_shift ($interval_data);
|
||||
if ($previous_data['utimestamp'] == $datelimit) {
|
||||
$min = $previous_data['datos'];
|
||||
}
|
||||
}
|
||||
foreach ($interval_data as $data) {
|
||||
if ($data['datos'] < $min) {
|
||||
|
@ -240,6 +299,7 @@ function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) {
|
|||
$id_module_type = get_db_value ('id_tipo_modulo', 'tagente_modulo','id_agente_modulo', $id_agent_module);
|
||||
$module_name = get_db_value ('nombre', 'ttipo_modulo', 'id_tipo', $id_module_type);
|
||||
$module_interval = get_module_interval ($id_agent_module);
|
||||
$uncompressed_module = is_module_uncompressed ($module_name);
|
||||
|
||||
// Wrong module type
|
||||
if (is_module_data_string ($module_name)) {
|
||||
|
@ -257,35 +317,49 @@ function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) {
|
|||
' ORDER BY utimestamp ASC', true);
|
||||
if ($interval_data === false) $interval_data = array ();
|
||||
|
||||
// Get previous data
|
||||
$previous_data = get_previous_data ($id_agent_module, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
$previous_data['utimestamp'] = $datelimit;
|
||||
array_unshift ($interval_data, $previous_data);
|
||||
}
|
||||
// Uncompressed module data
|
||||
if ($uncompressed_module) {
|
||||
$min_necessary = 1;
|
||||
|
||||
// Get next data
|
||||
$next_data = get_next_data ($id_agent_module, $date);
|
||||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
// Compressed module data
|
||||
} else {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
// Get previous data
|
||||
$previous_data = get_previous_data ($id_agent_module, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
$previous_data['utimestamp'] = $datelimit;
|
||||
array_unshift ($interval_data, $previous_data);
|
||||
}
|
||||
|
||||
// Get next data
|
||||
$next_data = get_next_data ($id_agent_module, $date);
|
||||
if ($next_data !== false) {
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
} else {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$next_data = array_pop ($interval_data);
|
||||
array_push ($interval_data, $next_data);
|
||||
$next_data['utimestamp'] = $date;
|
||||
array_push ($interval_data, $next_data);
|
||||
}
|
||||
|
||||
$min_necessary = 2;
|
||||
}
|
||||
|
||||
if (count ($interval_data) < 2) {
|
||||
if (count ($interval_data) < $min_necessary) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set initial conditions
|
||||
$total = 0;
|
||||
$previous_data = array_shift ($interval_data);
|
||||
if (! $uncompressed_module) {
|
||||
$previous_data = array_shift ($interval_data);
|
||||
}
|
||||
|
||||
foreach ($interval_data as $data) {
|
||||
if ($module_inc) {
|
||||
if ($uncompressed_module) {
|
||||
$total += $data['datos'];
|
||||
} else if ($module_inc) {
|
||||
$total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']);
|
||||
} else {
|
||||
$total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']) / $module_interval;
|
||||
|
|
Loading…
Reference in New Issue