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>
* include/functions_ui.php: moved the constants for the status

View File

@ -70,7 +70,6 @@ if (is_ajax ()) {
html_print_table ($table);
echo '</div>';
}
}
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);
$intervals = array ();
$intervals[3600] = "1 ".__('hour');
$intervals[43200] = "12 ".__('hours');
$intervals[86400] = __('Last day');
$intervals[172800] = "2 ". __('days');
$intervals[864000] = "10 ". __('days');
$intervals[604800] = __('Last week');
$intervals[1209600] = "2 " . __('weeks');
$intervals[2592000] = __('Last month');
$intervals[SECONDS_1HOUR] = __('1 hour');
$intervals[SECONDS_12HOURS] = __('12 hours');
$intervals[SECONDS_1DAY] = __('Last day');
$intervals[SECONDS_2DAY] = __('2 days');
$intervals[SECONDS_10DAY] = __('10 days');
$intervals[SECONDS_1WEEK] = __('Last week');
$intervals[SECONDS_2WEEK] = __('2 weeks');
$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][1] = html_print_select ($intervals, 'sla_period', $config["sla_period"], '', '', '0', true);

View File

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

View File

@ -1065,14 +1065,13 @@ function modules_get_previous_data ($id_agent_module, $utimestamp = 0, $string =
$table = 'tagente_datos';
}
// 172800 = 60×60×24*2 Search up to 2 days before utimestamp
$sql = sprintf ('SELECT *
FROM ' . $table . '
WHERE id_agente_modulo = %d
AND utimestamp <= %d
AND utimestamp >= %d
ORDER BY utimestamp DESC',
$id_agent_module, $utimestamp, $utimestamp - 172800);
$id_agent_module, $utimestamp, $utimestamp - SECONDS_2DAY);
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;
}
unset ($cache_data[$cache_timestamp]);
} else {
}
else {
break;
}
}
if ($interval_count > 0) {
$data[$timestamp]['data'] = (int) ($interval_total / $interval_count);
} else {
}
else {
$data[$timestamp]['data'] = 0;
}
}
} else {
}
else {
for ($i = 0; $i < $num_intervals; $i++) {
$timestamp = $start_date + ($interval_length * $i);
$interval_count = array ();
@ -810,8 +813,7 @@ function netflow_get_chart_types () {
__('Area graph'),
__('Pie graph'),
__('Data table'),
__('Statistics table')
);
__('Statistics table'));
}
/**
@ -823,25 +825,25 @@ function netflow_get_chart_types () {
*
*/
function netflow_get_valid_intervals () {
return array ('600' => __('10 mins'),
'900' => __('15 mins'),
'1800' => __('30 mins'),
'3600' => __('1 hour'),
'7200' => __('2 hours'),
'18000' => __('5 hours'),
'43200' => __('12 hours'),
'86400' => __('1 day'),
'172800' => __('2 days'),
'432000' => __('5 days'),
'1296000' => __('15 days'),
'604800' => __('Last week'),
'2592000' => __('Last month'),
'5184000' => __('2 months'),
'7776000' => __('3 months'),
'15552000' => __('6 months'),
'31104000' => __('Last year'),
'62208000' => __('2 years')
);
return array (
(string)SECONDS_10MINUTES => __('10 mins'),
(string)SECONDS_15MINUTES => __('15 mins'),
(string)SECONDS_30MINUTES => __('30 mins'),
(string)SECONDS_1HOUR => __('1 hour'),
(string)SECONDS_2HOUR => __('2 hours'),
(string)SECONDS_5HOUR => __('5 hours'),
(string)SECONDS_12HOURS => __('12 hours'),
(string)SECONDS_1DAY => __('1 day'),
(string)SECONDS_2DAY => __('2 days'),
(string)SECONDS_5DAY => __('5 days'),
(string)SECONDS_15DAYS => __('15 days'),
(string)SECONDS_1WEEK => __('Last week'),
(string)SECONDS_1MONTH => __('Last month'),
(string)SECONDS_2MONTHS => __('2 months'),
(string)SECONDS_3MONTHS => __('3 months'),
(string)SECONDS_6MONTHS => __('6 months'),
(string)SECONDS_1YEAR => __('Last year'),
(string)SECONDS_2YEARS => __('2 years'));
}
/**
@ -863,12 +865,13 @@ function netflow_draw_item ($start_date, $end_date, $type, $filter, $command, $f
$interval = $end_date - $start_date;
// Process item
switch ($type){
switch ($type) {
case '0':
$data = netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max_aggregates, $unit);
if ($aggregate != 'none') {
echo graph_netflow_aggregate_area($data, $interval, 660, 320, 0);
} else {
}
else {
echo graph_netflow_total_area($data, $interval, 660, 320, 0);
}
break;

View File

@ -381,7 +381,7 @@ function tags_update_policy_module_tag ($id_policy_module, $tags, $autocommit =
$result_tag = db_process_sql_delete ('ttag_policy_module', array('id_policy_module' => $id_policy_module));
$values = array();
foreach ($tags as $tag){
foreach ($tags as $tag) {
//Protect against default insert
if (empty($tag))
continue;
@ -449,7 +449,6 @@ function tags_get_policy_module_tags ($id_policy_module){
* @return mixed Array with tags.
*/
function tags_get_all_tags (){
$tags = db_get_all_fields_in_table('ttag', 'name');
if ($tags === false)
@ -462,5 +461,4 @@ function tags_get_all_tags (){
return $return;
}
?>

View File

@ -594,14 +594,14 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
$rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false,
$legend = array(), $font, $antialiasing, $water_mark = '', $font_size) {
/* CAT:Vertical Charts */
if(!is_array($legend) || empty($legend)) {
if (!is_array($legend) || empty($legend)) {
unset($legend);
}
/*$legend=array('pep1' => 'pep1','pep2' => 'pep2','pep3' => 'pep3','pep4' => 'pep4');
$data=array(array('pep1' => 1, 'pep2' => 1, 'pep3' => 3, 'pep4' => 3), array('pep1' => 1, 'pep2' => 3, 'pep3' => 1,'pep4' => 4), array('pep1' => 3, 'pep2' => 1, 'pep3' => 1,'pep4' =>1), array('pep1' => 1, 'pep2' =>1, 'pep3' =>1,'pep4' =>0));
$index=array(1,2,3,4);
*/
if(is_array(reset($data))) {
if (is_array(reset($data))) {
$data2 = array();
foreach($data as $i =>$values) {
$c = 0;
@ -619,8 +619,8 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
/* Create and populate the pData object */
$MyData = new pData();
foreach($data as $i => $values) {
if(isset($legend)) {
foreach ($data as $i => $values) {
if (isset($legend)) {
$point_id = $legend[$i];
}
else {

View File

@ -108,7 +108,7 @@ class EventsView {
if ($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;
$sql = 'SELECT *

View File

@ -77,7 +77,7 @@ $event_view_hr = (int) get_parameter ("event_view_hr", 0);
$sql_post = "";
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;
}
if ($ev_group > 1)

View File

@ -113,7 +113,7 @@ if ($id_event != -1)
$timestamp_filter = '';
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)";
}