mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
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
0ababc37d4
commit
6fa9a71836
@ -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>
|
2008-11-07 Esteban Sanchez <estebans@artica.es>
|
||||||
|
|
||||||
* include/functions_db.php: Style corrections ins give_acl(). Show
|
* include/functions_db.php: Style corrections ins give_acl(). Show
|
||||||
|
@ -390,7 +390,7 @@ if ($edit_sla_report_content) {
|
|||||||
$periods[12] = '12 '.__('hours');
|
$periods[12] = '12 '.__('hours');
|
||||||
$periods[24] = __('1 day');
|
$periods[24] = __('1 day');
|
||||||
$periods[48] = __('2 days');
|
$periods[48] = __('2 days');
|
||||||
$periods[180] = __('1 week');
|
$periods[168] = __('1 week');
|
||||||
$periods[360] = __('2 weeks');
|
$periods[360] = __('2 weeks');
|
||||||
$periods[720] = __('1 month');
|
$periods[720] = __('1 month');
|
||||||
$periods[4320] = __('6 months');
|
$periods[4320] = __('6 months');
|
||||||
|
@ -481,6 +481,18 @@ function human_time_comparation ($timestamp) {
|
|||||||
|
|
||||||
$seconds = time () - $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)
|
if ($seconds < 60)
|
||||||
return format_numeric ($seconds, 0)." ".__('seconds');
|
return format_numeric ($seconds, 0)." ".__('seconds');
|
||||||
|
|
||||||
@ -504,25 +516,6 @@ function human_time_comparation ($timestamp) {
|
|||||||
return " +6 ".__('months');
|
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.
|
* 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);
|
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.
|
* 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))
|
if (empty ($period))
|
||||||
return false; //We can't calculate a 0 period (division by zero)
|
return false; //We can't calculate a 0 period (division by zero)
|
||||||
|
|
||||||
|
|
||||||
$datelimit = $date - $period; // start date
|
$datelimit = $date - $period; // start date
|
||||||
|
|
||||||
$id_agent = get_db_value ('id_agente', 'tagente_modulo', 'id_agente_modulo', (int) $id_agent_module);
|
$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',
|
ORDER BY utimestamp ASC',
|
||||||
$id_agent, $id_agent_module, $datelimit, $date);
|
$id_agent, $id_agent_module, $datelimit, $date);
|
||||||
$datas = get_db_all_rows_sql ($sql);
|
$datas = get_db_all_rows_sql ($sql);
|
||||||
|
|
||||||
if ($datas === false) {
|
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 = "";
|
$last_data = "";
|
||||||
@ -247,7 +259,6 @@ function event_reporting ($id_group, $period, $date = 0, $return = false) {
|
|||||||
|
|
||||||
if (! $date)
|
if (! $date)
|
||||||
$date = time ();
|
$date = time ();
|
||||||
$datelimit = $date - $period;
|
|
||||||
|
|
||||||
$table->data = array ();
|
$table->data = array ();
|
||||||
$table->head = 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[2] = __('User ID');
|
||||||
$table->head[3] = __('Timestamp');
|
$table->head[3] = __('Timestamp');
|
||||||
|
|
||||||
$sql = sprintf ('SELECT * FROM tevento
|
$events = get_events_in_group ($id_group, $period, $date);
|
||||||
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);
|
|
||||||
if ($events === false) {
|
if ($events === false) {
|
||||||
if (!$return)
|
if (!$return)
|
||||||
print_table ($table);
|
print_table ($table);
|
||||||
|
@ -147,7 +147,7 @@ foreach ($contents as $content) {
|
|||||||
$data = array ();
|
$data = array ();
|
||||||
$data[0] = '<h4>'.__('Simple graph').'</h4>';
|
$data[0] = '<h4>'.__('Simple graph').'</h4>';
|
||||||
$data[1] = '<h4>'.$agent_name.' - '.$module_name.'</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);
|
array_push ($table->data, $data);
|
||||||
|
|
||||||
$data = array ();
|
$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));
|
$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] = '<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>';
|
$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] = '<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);
|
array_push ($table->data, $data);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user