2012-07-10 Miguel de Dios <miguel.dedios@artica.es>

* include/constants.php: added more constants into the constants
	block of time conversion to seconds.
	
	* godmode/alerts/alert_commands.php, godmode/setup/performance.php,
	include/help/en/help_date_format.php, include/functions_netflow.php,
	include/functions_tags.php, include/graphs/functions_pchart.php,
	include/functions_modules.php, extensions/agents_modules.php,
	extensions/update_manager.php, extensions/resource_exportation.php,
	extensions/module_groups.php,
	extensions/update_manager/lib/libupdate_manager_client.php,
	extensions/system_info.php, operation/events/events_rss.php,
	operation/events/export_csv.php, mobile/operation/events/events.php,
	mobile/include/system.class.php: used the new constants time instead
	the magic numbers, and cleaned source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6762 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-07-10 13:31:34 +00:00
parent 9f3f620015
commit 8270ef2bb6
19 changed files with 440 additions and 413 deletions

View File

@ -1,3 +1,20 @@
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* include/constants.php: added more constants into the constants
block of time conversion to seconds.
* godmode/alerts/alert_commands.php, godmode/setup/performance.php,
include/help/en/help_date_format.php, include/functions_netflow.php,
include/functions_tags.php, include/graphs/functions_pchart.php,
include/functions_modules.php, extensions/agents_modules.php,
extensions/update_manager.php, extensions/resource_exportation.php,
extensions/module_groups.php,
extensions/update_manager/lib/libupdate_manager_client.php,
extensions/system_info.php, operation/events/events_rss.php,
operation/events/export_csv.php, mobile/operation/events/events.php,
mobile/include/system.class.php: used the new constants time instead
the magic numbers, and cleaned source code style.
2012-07-10 Miguel de Dios <miguel.dedios@artica.es> 2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_ui.php: moved the constants for the status * include/functions_ui.php: moved the constants for the status

View File

@ -70,7 +70,6 @@ if (is_ajax ()) {
html_print_table ($table); html_print_table ($table);
echo '</div>'; echo '</div>';
} }
} }
return; return;

View File

@ -80,14 +80,14 @@ $table_other->data[1][0] = __('Compact interpolation in hours (1 Fine-20 bad)');
$table_other->data[1][1] = html_print_input_text ('step_compact', $config["step_compact"], '', 5, 5, true); $table_other->data[1][1] = html_print_input_text ('step_compact', $config["step_compact"], '', 5, 5, true);
$intervals = array (); $intervals = array ();
$intervals[3600] = "1 ".__('hour'); $intervals[SECONDS_1HOUR] = __('1 hour');
$intervals[43200] = "12 ".__('hours'); $intervals[SECONDS_12HOURS] = __('12 hours');
$intervals[86400] = __('Last day'); $intervals[SECONDS_1DAY] = __('Last day');
$intervals[172800] = "2 ". __('days'); $intervals[SECONDS_2DAY] = __('2 days');
$intervals[864000] = "10 ". __('days'); $intervals[SECONDS_10DAY] = __('10 days');
$intervals[604800] = __('Last week'); $intervals[SECONDS_1WEEK] = __('Last week');
$intervals[1209600] = "2 " . __('weeks'); $intervals[SECONDS_2WEEK] = __('2 weeks');
$intervals[2592000] = __('Last month'); $intervals[SECONDS_1MONTH] = __('Last month');
$table_other->data[2][0] = __('SLA period (seconds)') . ui_print_help_tip(__('You can see this in SLA agent tab.'), true); $table_other->data[2][0] = __('SLA period (seconds)') . ui_print_help_tip(__('You can see this in SLA agent tab.'), true);
$table_other->data[2][1] = html_print_select ($intervals, 'sla_period', $config["sla_period"], '', '', '0', true); $table_other->data[2][1] = html_print_select ($intervals, 'sla_period', $config["sla_period"], '', '', '0', true);

View File

@ -54,14 +54,25 @@ define ('ERR_CONNECTION', -80000);
/* Seconds in a time unit constants */ /* Seconds in a time unit constants */
define('SECONDS_1MINUTE', 60); define('SECONDS_1MINUTE', 60);
define('SECONDS_5MINUTES', 300); define('SECONDS_5MINUTES', 300);
define('SECONDS_10MINUTES', 600);
define('SECONDS_15MINUTES', 900);
define('SECONDS_30MINUTES', 1800); define('SECONDS_30MINUTES', 1800);
define('SECONDS_1HOUR', 3600); define('SECONDS_1HOUR', 3600);
define('SECONDS_2HOUR', 7200);
define('SECONDS_3HOUR', 10800);
define('SECONDS_5HOUR', 18000);
define('SECONDS_6HOURS', 21600); define('SECONDS_6HOURS', 21600);
define('SECONDS_12HOURS', 43200); define('SECONDS_12HOURS', 43200);
define('SECONDS_1DAY', 86400); define('SECONDS_1DAY', 86400);
define('SECONDS_2DAY', 172800);
define('SECONDS_4DAY', 345600);
define('SECONDS_5DAY', 432000);
define('SECONDS_1WEEK', 604800); define('SECONDS_1WEEK', 604800);
define('SECONDS_10DAY', 864000);
define('SECONDS_2WEEK', 1209600);
define('SECONDS_15DAYS', 1296000); define('SECONDS_15DAYS', 1296000);
define('SECONDS_1MONTH', 2592000); define('SECONDS_1MONTH', 2592000);
define('SECONDS_2MONTHS', 5184000);
define('SECONDS_3MONTHS', 7776000); define('SECONDS_3MONTHS', 7776000);
define('SECONDS_6MONTHS', 15552000); define('SECONDS_6MONTHS', 15552000);
define('SECONDS_1YEAR', 31104000); define('SECONDS_1YEAR', 31104000);

View File

@ -1065,14 +1065,13 @@ function modules_get_previous_data ($id_agent_module, $utimestamp = 0, $string =
$table = 'tagente_datos'; $table = 'tagente_datos';
} }
// 172800 = 60×60×24*2 Search up to 2 days before utimestamp
$sql = sprintf ('SELECT * $sql = sprintf ('SELECT *
FROM ' . $table . ' FROM ' . $table . '
WHERE id_agente_modulo = %d WHERE id_agente_modulo = %d
AND utimestamp <= %d AND utimestamp <= %d
AND utimestamp >= %d AND utimestamp >= %d
ORDER BY utimestamp DESC', ORDER BY utimestamp DESC',
$id_agent_module, $utimestamp, $utimestamp - 172800); $id_agent_module, $utimestamp, $utimestamp - SECONDS_2DAY);
return db_get_row_sql ($sql, true); return db_get_row_sql ($sql, true);
} }

View File

@ -772,18 +772,21 @@ function netflow_load_cache (&$data, $cache_file, $start_date, $end_date, $aggre
$last_timestamp = $cache_timestamp; $last_timestamp = $cache_timestamp;
} }
unset ($cache_data[$cache_timestamp]); unset ($cache_data[$cache_timestamp]);
} else { }
else {
break; break;
} }
} }
if ($interval_count > 0) { if ($interval_count > 0) {
$data[$timestamp]['data'] = (int) ($interval_total / $interval_count); $data[$timestamp]['data'] = (int) ($interval_total / $interval_count);
} else { }
else {
$data[$timestamp]['data'] = 0; $data[$timestamp]['data'] = 0;
} }
} }
} else { }
else {
for ($i = 0; $i < $num_intervals; $i++) { for ($i = 0; $i < $num_intervals; $i++) {
$timestamp = $start_date + ($interval_length * $i); $timestamp = $start_date + ($interval_length * $i);
$interval_count = array (); $interval_count = array ();
@ -810,8 +813,7 @@ function netflow_get_chart_types () {
__('Area graph'), __('Area graph'),
__('Pie graph'), __('Pie graph'),
__('Data table'), __('Data table'),
__('Statistics table') __('Statistics table'));
);
} }
/** /**
@ -823,25 +825,25 @@ function netflow_get_chart_types () {
* *
*/ */
function netflow_get_valid_intervals () { function netflow_get_valid_intervals () {
return array ('600' => __('10 mins'), return array (
'900' => __('15 mins'), (string)SECONDS_10MINUTES => __('10 mins'),
'1800' => __('30 mins'), (string)SECONDS_15MINUTES => __('15 mins'),
'3600' => __('1 hour'), (string)SECONDS_30MINUTES => __('30 mins'),
'7200' => __('2 hours'), (string)SECONDS_1HOUR => __('1 hour'),
'18000' => __('5 hours'), (string)SECONDS_2HOUR => __('2 hours'),
'43200' => __('12 hours'), (string)SECONDS_5HOUR => __('5 hours'),
'86400' => __('1 day'), (string)SECONDS_12HOURS => __('12 hours'),
'172800' => __('2 days'), (string)SECONDS_1DAY => __('1 day'),
'432000' => __('5 days'), (string)SECONDS_2DAY => __('2 days'),
'1296000' => __('15 days'), (string)SECONDS_5DAY => __('5 days'),
'604800' => __('Last week'), (string)SECONDS_15DAYS => __('15 days'),
'2592000' => __('Last month'), (string)SECONDS_1WEEK => __('Last week'),
'5184000' => __('2 months'), (string)SECONDS_1MONTH => __('Last month'),
'7776000' => __('3 months'), (string)SECONDS_2MONTHS => __('2 months'),
'15552000' => __('6 months'), (string)SECONDS_3MONTHS => __('3 months'),
'31104000' => __('Last year'), (string)SECONDS_6MONTHS => __('6 months'),
'62208000' => __('2 years') (string)SECONDS_1YEAR => __('Last year'),
); (string)SECONDS_2YEARS => __('2 years'));
} }
/** /**
@ -868,7 +870,8 @@ function netflow_draw_item ($start_date, $end_date, $type, $filter, $command, $f
$data = netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max_aggregates, $unit); $data = netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max_aggregates, $unit);
if ($aggregate != 'none') { if ($aggregate != 'none') {
echo graph_netflow_aggregate_area($data, $interval, 660, 320, 0); echo graph_netflow_aggregate_area($data, $interval, 660, 320, 0);
} else { }
else {
echo graph_netflow_total_area($data, $interval, 660, 320, 0); echo graph_netflow_total_area($data, $interval, 660, 320, 0);
} }
break; break;

View File

@ -449,7 +449,6 @@ function tags_get_policy_module_tags ($id_policy_module){
* @return mixed Array with tags. * @return mixed Array with tags.
*/ */
function tags_get_all_tags (){ function tags_get_all_tags (){
$tags = db_get_all_fields_in_table('ttag', 'name'); $tags = db_get_all_fields_in_table('ttag', 'name');
if ($tags === false) if ($tags === false)
@ -462,5 +461,4 @@ function tags_get_all_tags (){
return $return; return $return;
} }
?> ?>

View File

@ -108,7 +108,7 @@ class EventsView {
if ($search != "") if ($search != "")
$sqlFreeSearch .= " AND evento LIKE '%".$search."%'"; $sqlFreeSearch .= " AND evento LIKE '%".$search."%'";
$unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds $unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); //Put hours in seconds
$sqlTimestamp = " AND utimestamp > ".$unixtime; $sqlTimestamp = " AND utimestamp > ".$unixtime;
$sql = 'SELECT * $sql = 'SELECT *

View File

@ -77,7 +77,7 @@ $event_view_hr = (int) get_parameter ("event_view_hr", 0);
$sql_post = ""; $sql_post = "";
if ($event_view_hr > 0) { if ($event_view_hr > 0) {
$unixtime = (int) (get_system_time () - ($event_view_hr * 3600)); //Put hours in seconds $unixtime = (int) (get_system_time () - ($event_view_hr * SECONDS_1HOUR)); //Put hours in seconds
$sql_post .= " AND tevento.utimestamp > ".$unixtime; $sql_post .= " AND tevento.utimestamp > ".$unixtime;
} }
if ($ev_group > 1) if ($ev_group > 1)

View File

@ -113,7 +113,7 @@ if ($id_event != -1)
$timestamp_filter = ''; $timestamp_filter = '';
if ($event_view_hr > 0) { if ($event_view_hr > 0) {
$unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds $unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); //Put hours in seconds
$timestamp_filter = " AND (utimestamp > $unixtime OR estado = 2)"; $timestamp_filter = " AND (utimestamp > $unixtime OR estado = 2)";
} }