diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 0c46537780..3bb874fc6e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2012-06-12 Juan Manuel Ramon + + * include/functions_forecast.php + include/ajax/agent.php + include/functions_ui.php + godmode/reporting/reporting_builder.list_items.php + godmode/reporting/reporting_builder.php + godmode/reporting/reporting_builder.item_editor.php: Fixes in + forecasting reports (avoid php timeout) and empty inventory report. + Also fixed bug with autorefresh an referer check. + + Merged from branches. + 2012-06-12 Vanessa Gil * include/functions_config.php: Fixed bug: update password diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index a002583982..050f69f892 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -93,7 +93,7 @@ switch ($action) { $actionParameter = 'update'; $item = db_get_row_filter('treport_content', array('id_rc' => $idItem)); $server_name = $item ['server_name']; - + // Metaconsole db connection if (($config ['metaconsole'] == 1) && ($server_name != '')) { $connection = metaconsole_get_connection($server_name); @@ -482,8 +482,10 @@ html_print_input_hidden('id_item', $idItem); $agent_name = ''; if (metaconsole_load_external_db($connection) == NOERR) - $agent_name = db_get_value_filter('nombre', 'tagente', array('id_agente' => $idAgent)); - + $agent_name = db_get_value_filter('nombre', 'tagente', array('id_agente' => $idAgent)); + // Append server name + if (!empty($agent_name)) + $agent_name .= ' (' . $server_name . ')'; //Restore db connection metaconsole_restore_db(); } @@ -1442,6 +1444,7 @@ function chooseType() { case 'event_report_group': $("#row_description").show(); $("#row_period").show(); + $("#row_servers").show(); $("#row_group").show(); $("#row_show_in_two_columns").show(); break; @@ -1650,6 +1653,7 @@ function chooseType() { break; case 'group_report': $("#row_group").show(); + $("#row_servers").show(); break; case 'top_n': $("#row_description").show(); @@ -1685,7 +1689,7 @@ function chooseType() { $("#row_agent_multi").show(); $("#row_module_multi").show(); $("#row_show_in_two_columns").show(); - + $("#row_servers").show(); $("#id_agents").change(agent_changed_by_multiple_agents_inventory); $("#id_agents").trigger('change'); @@ -1705,6 +1709,8 @@ function chooseType() { $("#id_agents").change(agent_changed_by_multiple_agents_inventory); $("#id_agents").trigger('change'); + $("#row_servers").show(); + $("#combo_group").change(function() { $('#hidden-date_selected').val(''); updateInventoryDates(); diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index b79dc64657..434e995abd 100644 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -273,10 +273,7 @@ foreach ($items as $item) { $connection = metaconsole_get_connection($server_name); if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); - // Don't skip SLA or top N or general report items - if (($item['type'] != 'SLA') and ($item['type'] != 'top_n') and ($item['type'] != 'general') - and ($item['type'] != 'exception') and ($item['type'] != 'group_report')) - continue; + } } @@ -320,7 +317,7 @@ foreach ($items as $item) { $row[6] .= '' . html_print_image("images/wrench_orange.png", true, array("title" => __('Edit'))) . ''; $row[6] .= '  '; - $row[6] .= '' . html_print_image("images/cross.png", true, array("title" => __('Delete'))) .''; + $row[6] .= '' . html_print_image("images/cross.png", true, array("title" => __('Delete'))) .''; $row[7] = ''; //You can sort the items if the filter is not enable. diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 503ad6f655..af6c32825d 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -467,11 +467,33 @@ switch ($action) { // If metaconsole is activated if ($config['metaconsole'] == 1) { - $id_gs = substr ($values['id_gs'], 0, strpos ($values['id_gs'], '|')); - if ($id_gs !== false) { - $server_name = strstr($values ['id_gs'], '|'); - $values ['id_gs'] = $id_gs; - $values['server_name'] = substr ($server_name, 1, strlen($server_name)); + if ($values['type'] == 'custom_graph') { + $id_gs = substr ($values['id_gs'], 0, strpos ($values['id_gs'], '|')); + if ($id_gs !== false) { + $server_name = strstr($values ['id_gs'], '|'); + $values ['id_gs'] = $id_gs; + $values['server_name'] = substr ($server_name, 1, strlen($server_name)); + } + } + + // Get agent and server name + $agent_name_server = io_safe_output(get_parameter('agent')); + + if (isset($agent_name_server)) { + + $separator_pos = strpos($agent_name_server, '('); + + if (($separator_pos != false) and ($separator_pos != 0)) { + + $server_name = substr($agent_name_server, $separator_pos); + $server_name = str_replace('(', '', $server_name); + $server_name = str_replace(')', '', $server_name); + // Will update server_name variable + $values['server_name'] = trim($server_name); + $agent_name = substr($agent_name_server, 0, $separator_pos); + + } + } } @@ -496,7 +518,7 @@ switch ($action) { $style['show_in_two_columns'] = get_parameter('show_in_two_columns', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); $values['style'] = io_safe_input(json_encode($style)); - + if ($good_format){ $resultOperationDB = db_process_sql_update('treport_content', $values, array('id_rc' => $idItem)); } @@ -616,11 +638,16 @@ switch ($action) { $resultOperationDB = false; break; } - $id_gs = substr ($values['id_gs'], 0, strpos ($values['id_gs'], '|')); - if ($id_gs !== false && $id_gs !== '') { - $server_name = strstr($values ['id_gs'], '|'); - $values ['id_gs'] = $id_gs; - $values['server_name'] = substr ($server_name, 1, strlen($server_name)); + + if ($config['metaconsole'] == 1) { + if ($values['type'] == 'custom_graph') { + $id_gs = substr ($values['id_gs'], 0, strpos ($values['id_gs'], '|')); + if ($id_gs !== false && $id_gs !== '') { + $server_name = strstr($values ['id_gs'], '|'); + $values ['id_gs'] = $id_gs; + $values['server_name'] = substr ($server_name, 1, strlen($server_name)); + } + } } if (($values['type'] == 'sql') OR ($values['type'] == 'sql_graph_hbar') diff --git a/pandora_console/include/ajax/agent.php b/pandora_console/include/ajax/agent.php index 1ba6d3920e..196d3fc233 100644 --- a/pandora_console/include/ajax/agent.php +++ b/pandora_console/include/ajax/agent.php @@ -193,6 +193,7 @@ elseif ($search_agents_2 && ($config['metaconsole'] == 1)) { return; } + $data = array(); foreach ($servers as $server) { if (metaconsole_load_external_db ($server) != NOERR) { continue; @@ -227,7 +228,6 @@ elseif ($search_agents_2 && ($config['metaconsole'] == 1)) { if ($agents === false) continue; - $data = array(); foreach ($agents as $agent) { $data[] = array('id' => $agent['id_agente'], 'name' => io_safe_output($agent['nombre']) . " (" . io_safe_output($server['server_name']) . ") ", @@ -235,9 +235,10 @@ elseif ($search_agents_2 && ($config['metaconsole'] == 1)) { } //Restore db connection metaconsole_restore_db(); - - echo json_encode($data); + } + + echo json_encode($data); return; } ?> diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index 214860fcf8..2a82ec89ab 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -60,7 +60,7 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe $agent_interval = 300; $cont = 1; $data = array(); - $table->data = array(); + //$table->data = array(); // Creates data for calculation foreach ($module_data as $utimestamp => $row) { @@ -93,7 +93,7 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe $last_timestamp = $utimestamp; $cont++; - array_push($table->data, $data); + //array_push($table->data, $data); } $cont--; @@ -197,11 +197,12 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe } // Using this function for prediction_date if ($prediction_period == false){ - // These statements stop the prediction when interval is greater than 4 years - if ($current_ts - $last_timestamp >= 126144000){ + // These statements stop the prediction when interval is greater than 2 years + if ($current_ts - $last_timestamp >= 94608000){ return false; } //html_debug_print(" Date " . $timestamp_f . " data: " . $output_data[$timestamp_f]); + // Found it if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]){ return $current_ts; @@ -231,6 +232,6 @@ function forecast_prediction_date ($module_id, $period = 5184000, $max_value = 0 if ($min_value > $max_value){ return false; } - + return forecast_projection_graph($module_id, $period, false, $max_value, $min_value); } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 6dc2852ce0..79f9b89d32 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1023,7 +1023,15 @@ function ui_process_page_head ($string, $bitfield) { if ($config["refr"] > 0) { $query = ui_get_url_refresh (false); - $output .= ''; + + + $HTTP_REFERER = ''; + if (isset($_SERVER['HTTP_REFERER'])) + $HTTP_REFERER = '&HTTP_REFERER=' . $_SERVER['HTTP_REFERER']; + else if (isset($_GET['HTTP_REFERER'])) + $HTTP_REFERER = '&HTTP_REFERER=' . $_GET['HTTP_REFERER']; + + $output .= ''; } $output .= "\n\t"; $output .= 'Pandora FMS - '.__('the Flexible Monitoring System').'