2008-11-08 Esteban Sanchez <estebans@artica.es>
* godmode/reporting/reporting_builder.php: Fixed value of 1 week period. * include/functions.php: Moved all human_time_* functionallity to human_time_description_raw(). * include/functions_reporting.php: Fixed a bug in SLA calculation that affects small periods of time (less than 24 hours) due to data compression in the database. * operation/reporting/reporting_viewer.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1225 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
b12c02225e
commit
351dfc8ee1
|
@ -1,3 +1,17 @@
|
|||
2008-11-08 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* godmode/reporting/reporting_builder.php: Fixed value of 1 week
|
||||
period.
|
||||
|
||||
* include/functions.php: Moved all human_time_* functionallity to
|
||||
human_time_description_raw().
|
||||
|
||||
* include/functions_reporting.php: Fixed a bug in SLA calculation that
|
||||
affects small periods of time (less than 24 hours) due to data
|
||||
compression in the database.
|
||||
|
||||
* operation/reporting/reporting_viewer.php: Style correction.
|
||||
|
||||
2008-11-07 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* include/functions_db.php: Style corrections ins give_acl(). Show
|
||||
|
|
|
@ -390,7 +390,7 @@ if ($edit_sla_report_content) {
|
|||
$periods[12] = '12 '.__('hours');
|
||||
$periods[24] = __('1 day');
|
||||
$periods[48] = __('2 days');
|
||||
$periods[180] = __('1 week');
|
||||
$periods[168] = __('1 week');
|
||||
$periods[360] = __('2 weeks');
|
||||
$periods[720] = __('1 month');
|
||||
$periods[4320] = __('6 months');
|
||||
|
|
|
@ -481,6 +481,18 @@ function human_time_comparation ($timestamp) {
|
|||
|
||||
$seconds = time () - $timestamp;
|
||||
|
||||
return human_time_description_raw ($seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform an amount of time in seconds into a human readable
|
||||
* strings of minutes, hours or days.
|
||||
*
|
||||
* @param seconds Seconds elapsed time
|
||||
*
|
||||
* @return A human readable translation of minutes.
|
||||
*/
|
||||
function human_time_description_raw ($seconds) {
|
||||
if ($seconds < 60)
|
||||
return format_numeric ($seconds, 0)." ".__('seconds');
|
||||
|
||||
|
@ -504,25 +516,6 @@ function human_time_comparation ($timestamp) {
|
|||
return " +6 ".__('months');
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform an amount of time in seconds into a human readable
|
||||
* strings of minutes, hours or days.
|
||||
*
|
||||
* @param seconds Seconds elapsed time
|
||||
*
|
||||
* @return A human readable translation of minutes.
|
||||
*/
|
||||
function human_time_description_raw ($seconds) {
|
||||
global $lang_label;
|
||||
if ($seconds < 3600)
|
||||
return format_numeric ($seconds / 60, 2)." ".__('minutes');
|
||||
|
||||
if ($seconds >= 3600 && $seconds < 86400)
|
||||
return format_numeric ($seconds / 3600, 2)." ".__('hours');
|
||||
|
||||
return format_numeric ($seconds / 86400, 2)." ".__('days');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a human readable label for a period of time.
|
||||
*
|
||||
|
|
|
@ -569,6 +569,36 @@ function get_monitors_in_group ($id_group) {
|
|||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the events happened in a group during a period of time.
|
||||
*
|
||||
* The returned events will be in the time interval ($date - $period, $date]
|
||||
*
|
||||
* @param id_group Group id to get events.
|
||||
* @param period Period of time in seconds to get events.
|
||||
* @param date Beginning date to get events.
|
||||
*
|
||||
* @return An array with all the events happened.
|
||||
*/
|
||||
function get_events_in_group ($id_group, $period, $date) {
|
||||
$datelimit = $date - $period;
|
||||
|
||||
if ($id_group == 1) {
|
||||
$sql = sprintf ('SELECT * FROM tevento
|
||||
WHERE utimestamp > %d AND utimestamp <= %d
|
||||
ORDER BY utimestamp ASC',
|
||||
$datelimit, $date);
|
||||
} else {
|
||||
$sql = sprintf ('SELECT * FROM tevento
|
||||
WHERE utimestamp > %d AND utimestamp <= %d
|
||||
AND id_grupo = %d
|
||||
ORDER BY utimestamp ASC',
|
||||
$datelimit, $date, $id_group);
|
||||
}
|
||||
|
||||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the monitors defined in an agent.
|
||||
*
|
||||
|
|
|
@ -35,7 +35,6 @@ function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value
|
|||
if (empty ($period))
|
||||
return false; //We can't calculate a 0 period (division by zero)
|
||||
|
||||
|
||||
$datelimit = $date - $period; // start date
|
||||
|
||||
$id_agent = get_db_value ('id_agente', 'tagente_modulo', 'id_agente_modulo', (int) $id_agent_module);
|
||||
|
@ -50,10 +49,23 @@ function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value
|
|||
ORDER BY utimestamp ASC',
|
||||
$id_agent, $id_agent_module, $datelimit, $date);
|
||||
$datas = get_db_all_rows_sql ($sql);
|
||||
|
||||
if ($datas === false) {
|
||||
//No data to calculate on so we return 0.
|
||||
return 0;
|
||||
|
||||
/* Try to get data from tagente_estado. It may found nothing because of
|
||||
data compression */
|
||||
$sql = sprintf ('SELECT datos, utimestamp FROM tagente_estado
|
||||
WHERE id_agente = %d AND id_agente_modulo = %d
|
||||
AND utimestamp > %d AND utimestamp <= %d
|
||||
ORDER BY utimestamp ASC',
|
||||
$id_agent, $id_agent_module, $datelimit, $date);
|
||||
$data = get_db_sql ($sql);
|
||||
|
||||
if ($data === false) {
|
||||
//No data to calculate on so we return 0.
|
||||
return 0;
|
||||
}
|
||||
$datas = array ();
|
||||
array_push ($datas, $data);
|
||||
}
|
||||
|
||||
$last_data = "";
|
||||
|
@ -247,7 +259,6 @@ function event_reporting ($id_group, $period, $date = 0, $return = false) {
|
|||
|
||||
if (! $date)
|
||||
$date = time ();
|
||||
$datelimit = $date - $period;
|
||||
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
|
@ -256,13 +267,7 @@ function event_reporting ($id_group, $period, $date = 0, $return = false) {
|
|||
$table->head[2] = __('User ID');
|
||||
$table->head[3] = __('Timestamp');
|
||||
|
||||
$sql = sprintf ('SELECT * FROM tevento
|
||||
WHERE id_agente = %d
|
||||
AND utimestamp > %d AND utimestamp <= %d
|
||||
AND id_grupo = %d
|
||||
ORDER BY utimestamp ASC',
|
||||
$id_group, $datelimit, $date, $id_group);
|
||||
$events = get_db_all_rows_sql ($sql);
|
||||
$events = get_events_in_group ($id_group, $period, $date);
|
||||
if ($events === false) {
|
||||
if (!$return)
|
||||
print_table ($table);
|
||||
|
|
|
@ -147,7 +147,7 @@ foreach ($contents as $content) {
|
|||
$data = array ();
|
||||
$data[0] = '<h4>'.__('Simple graph').'</h4>';
|
||||
$data[1] = '<h4>'.$agent_name.' - '.$module_name.'</h4>';
|
||||
$data[2] = '<h4>'.human_time_description($content['period']).'</h4>';
|
||||
$data[2] = '<h4>'.human_time_description ($content['period']).'</h4>';
|
||||
array_push ($table->data, $data);
|
||||
|
||||
$data = array ();
|
||||
|
@ -293,9 +293,9 @@ foreach ($contents as $content) {
|
|||
$monitor_value = format_numeric (get_agent_module_sla ($content['id_agent_module'], $content['period'], 1, 1, $datetime));
|
||||
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">';
|
||||
$data[0] .= $monitor_value.' % <img src="images/b_green.png" height="32" width="32" /></p>';
|
||||
$monitor_value2 = format_numeric (100 - $monitor_value, 2) ;
|
||||
$monitor_value = format_numeric (100 - $monitor_value, 2) ;
|
||||
$data[1] = '<p style="font: bold 3em Arial, Sans-serif; color: #ff0000;">';
|
||||
$data[1] .= $monitor_value2.' % <img src="images/b_red.png" height="32" width="32" /></p>';
|
||||
$data[1] .= $monitor_value.' % <img src="images/b_red.png" height="32" width="32" /></p>';
|
||||
array_push ($table->data, $data);
|
||||
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue