diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d9a451bfaa..b3a16ccf11 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2013-02-14 Miguel de Dios + + * godmode/massive/massive_operations.php, + godmode/massive/massive_enable_disable_alerts.php, + godmode/massive/massive_standby_alerts.php, + godmode/tag/edit_tag.php, include/functions_graph.php, + include/functions_io.php, include/functions_ui.php: cleaned source + code style. + + * include/functions_modules.php: erased deprecated function + "modules_give_modulecategory_name". + 2013-02-13 Miguel de Dios * extensions/module_groups.php, diff --git a/pandora_console/godmode/massive/massive_enable_disable_alerts.php b/pandora_console/godmode/massive/massive_enable_disable_alerts.php index 5dd0186591..6793d8dbf9 100644 --- a/pandora_console/godmode/massive/massive_enable_disable_alerts.php +++ b/pandora_console/godmode/massive/massive_enable_disable_alerts.php @@ -67,7 +67,7 @@ $recursion = get_parameter ('recursion'); $result = false; -switch($action) { +switch ($action) { case 'enable_alerts': $id_alert_templates = (int) get_parameter ('id_alert_template_disabled', 0); $id_disabled_alerts = get_parameter_post ('id_disabled_alerts', array()); @@ -77,7 +77,7 @@ switch($action) { ui_print_result_message ($result, __('Successfully enabled'), __('Could not be enabled')); - $info = 'Alert: ' . json_encode($id_disabled_alerts); + $info = 'Alert: ' . json_encode($id_disabled_alerts); if ($result) { db_pandora_audit("Masive management", "Enable alert", false, false, $info); } diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index 11b2e92191..e2d541f7a6 100644 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -199,7 +199,7 @@ echo ''; "; -echo '
'; +echo ''; echo '
'; echo __("Action"); echo ''; diff --git a/pandora_console/godmode/massive/massive_standby_alerts.php b/pandora_console/godmode/massive/massive_standby_alerts.php index b1f3c75325..8bd4598d88 100644 --- a/pandora_console/godmode/massive/massive_standby_alerts.php +++ b/pandora_console/godmode/massive/massive_standby_alerts.php @@ -77,7 +77,7 @@ switch($action) { ui_print_result_message ($result, __('Successfully set off standby'), __('Could not be set off standby')); - $info = 'Alert: ' . json_encode($id_standby_alerts); + $info = 'Alert: ' . json_encode($id_standby_alerts); if ($result) { db_pandora_audit("Masive management", "Set off standby alerts", false, false, $info); } @@ -95,7 +95,7 @@ switch($action) { ui_print_result_message ($result, __('Successfully set standby'), __('Could not be set standby')); - $info = 'Alert: ' . json_encode($id_not_standby_alerts); + $info = 'Alert: ' . json_encode($id_not_standby_alerts); if ($result) { db_pandora_audit("Masive management", "Set on standby alerts", false, false, $info); } diff --git a/pandora_console/godmode/tag/edit_tag.php b/pandora_console/godmode/tag/edit_tag.php index d87e9ce264..90d05084c6 100644 --- a/pandora_console/godmode/tag/edit_tag.php +++ b/pandora_console/godmode/tag/edit_tag.php @@ -52,10 +52,10 @@ $buttons[$tab]['active'] = true; if (defined('METACONSOLE')) { // Print header - ui_meta_print_header(__('Tags'), "", $buttons); + ui_meta_print_header(__('Tags'), "", $buttons); } else { - + // Header ui_print_page_header (__('Tags configuration'), "images/setup.png", false, "", true, $buttons); @@ -63,11 +63,11 @@ else { // Two actions can performed in this page: update and create tags // Update tag: update an existing tag -if ($update_tag && $id_tag != 0) { - +if ($update_tag && $id_tag != 0) { + // Erase comma characters on tag name $name_tag = str_replace(',', '', $name_tag); - + $values = array(); $values['name'] = $name_tag; $values['description'] = $description_tag; @@ -143,7 +143,7 @@ echo ''; echo ""; - echo ""; + echo ""; echo ""; @@ -156,7 +156,7 @@ echo "
"; html_print_label (__("Name"),'name'); echo "
"; html_print_label (__("Description"),'name'); echo ""; echo ""; echo ""; echo ""; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 2e3fb674ef..b232d255c1 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -440,13 +440,13 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i } }*/ - if(!empty($event_ids)) { + if (!empty($event_ids)) { $chart_extra_data[count($chart)-1]['events'] = implode(',',$event_ids); } - if(!empty($alert_ids)) { + if (!empty($alert_ids)) { $chart_extra_data[count($chart)-1]['alerts'] = implode(',',$alert_ids); } - } + } } @@ -503,13 +503,13 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, "utimestamp < $date", 'order' => 'utimestamp ASC'), array ('id_evento', 'evento', 'utimestamp', 'event_type')); - + // Get the last event after inverval to know if graph start on unknown $prev_event = db_get_row_filter ('tevento', array ('id_agentmodule' => $agent_module_id, "utimestamp <= $datelimit", 'order' => 'utimestamp DESC')); - if(isset($prev_event['event_type']) && $prev_event['event_type'] == 'going_unknown') { + if (isset($prev_event['event_type']) && $prev_event['event_type'] == 'going_unknown') { $start_unknown = true; } @@ -529,7 +529,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, // Get module warning_min and critical_min $warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$agent_module_id); $critical_min = db_get_value('min_critical','tagente_modulo','id_agente_modulo',$agent_module_id); - + if ($data === false) { $data = array (); } @@ -611,14 +611,14 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $projection, $avg_only, $uncompressed_module, $show_events, $show_alerts, $show_unknown, $baseline, $baseline_data, $events, $series_suffix, $start_unknown); - + // Return chart data and don't draw if ($return_data == 1) { return $chart; } $graph_stats = get_statwin_graph_statistics($chart, $series_suffix); - + // Fix event and alert scale $event_max = 2 + (float)$max_value * 1.05; foreach ($chart as $timestamp => $chart_data) { @@ -749,10 +749,10 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, return $data_returned; } - if($compare === 'overlapped') { + if ($compare === 'overlapped') { $i = 0; - foreach($chart as $k=>$v) { - if(!isset($chart_prev[$i])) { + foreach ($chart as $k=>$v) { + if (!isset($chart_prev[$i])) { continue; } $chart[$k] = array_merge($v,$chart_prev[$i]); @@ -1214,38 +1214,42 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $ $fixed_font_size = $config['font_size'] - 1; //Set graph color - + $color = array(); - + $color[0] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50); - $color[1] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50); - $color[2] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50); - + $color[1] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50); + $color[2] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50); + switch ($stacked) { case GRAPH_AREA: - return area_graph($flash_charts, $graph_values, $width, $height, - $color, $module_name_list, $long_index, ui_get_full_url("images/image_problem.opaque.png"), - "", "", $homeurl, $water_mark, - $config['fontpath'], $fixed_font_size, "", $ttl); + return area_graph($flash_charts, $graph_values, $width, + $height, $color, $module_name_list, $long_index, + ui_get_full_url("images/image_problem.opaque.png"), "", + "", $homeurl, $water_mark, $config['fontpath'], + $fixed_font_size, "", $ttl); break; default: case GRAPH_STACKED_AREA: - return stacked_area_graph($flash_charts, $graph_values, $width, $height, - $color, $module_name_list, $long_index, ui_get_full_url("images/image_problem.opaque.png"), - "", "", $water_mark, - $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl); + return stacked_area_graph($flash_charts, $graph_values, + $width, $height, $color, $module_name_list, $long_index, + ui_get_full_url("images/image_problem.opaque.png"), "", + "", $water_mark, $config['fontpath'], $fixed_font_size, + "", $ttl, $homeurl); break; case GRAPH_LINE: - return line_graph($flash_charts, $graph_values, $width, $height, - $color, $module_name_list, $long_index, ui_get_full_url("images/image_problem.opaque.png"), - "", "", $water_mark, - $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl); + return line_graph($flash_charts, $graph_values, $width, + $height, $color, $module_name_list, $long_index, + ui_get_full_url("images/image_problem.opaque.png"), "", + "", $water_mark, $config['fontpath'], $fixed_font_size, + "", $ttl, $homeurl); break; case GRAPH_STACKED_LINE: - return stacked_line_graph($flash_charts, $graph_values, $width, $height, - $color, $module_name_list, $long_index, ui_get_full_url("images/image_problem.opaque.png"), - "", "", $water_mark, - $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl); + return stacked_line_graph($flash_charts, $graph_values, + $width, $height, $color, $module_name_list, $long_index, + ui_get_full_url("images/image_problem.opaque.png"), "", + "", $water_mark, $config['fontpath'], $fixed_font_size, + "", $ttl, $homeurl); break; } } @@ -2133,11 +2137,11 @@ function graph_custom_sql_graph ($id, $width, $height, $type = 'sql_graph_vbar', if (enterprise_hook('metaconsole_load_external_db', array($metaconsole_connection)) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); return false; - } + } } - + $data_result = db_get_all_rows_sql ($sql); - + if (($config['metaconsole'] == 1) && defined('METACONSOLE')) enterprise_hook('metaconsole_restore_db'); diff --git a/pandora_console/include/functions_io.php b/pandora_console/include/functions_io.php index 3f66c99ce9..024499d31d 100755 --- a/pandora_console/include/functions_io.php +++ b/pandora_console/include/functions_io.php @@ -274,9 +274,9 @@ function io_safe_output_html($value, $utf8 = true) //Revert html entities to chars for ($i=0;$i<33;$i++) { $value = str_ireplace("&#x".dechex($i).";",io_html_to_ascii(dechex($i)), $value); - } + } - return $value; + return $value; } /** diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 5b730e6b7f..52b8ab4acf 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -998,8 +998,8 @@ function modules_get_monitors_in_agent ($id_agent) { AND ttipo_modulo.nombre LIKE '%%_proc' AND tagente.id_agente = %d", $id_agent); break; - } - + } + return db_get_all_rows_sql ($sql); } @@ -1016,14 +1016,16 @@ function modules_get_monitors_in_agent ($id_agent) { */ function modules_get_monitors_down ($monitors, $period = 0, $date = 0) { $monitors_down = array (); + if (empty ($monitors)) - return $monitors_down; - + return $monitors_down; + foreach ($monitors as $monitor) { $down = modules_get_monitor_downs_in_period ($monitor['id_agente_modulo'], $period, $date); if ($down > 0) array_push ($monitors_down, $monitor); } + return $monitors_down; } @@ -1069,13 +1071,13 @@ function modules_get_moduletypes ($type = "all", $rows = "nombre") { elseif ($type == "agent") { return array_merge (range (1,4), range (19,24)); } - + $sql = sprintf ("SELECT id_tipo, %s FROM ttipo_modulo", implode (",", $rows)); $result = db_get_all_rows_sql ($sql); if ($result === false) { return $return; } - + foreach ($result as $type) { if ($row_cnt > 1) { $return[$type["id_tipo"]] = $type; @@ -1084,6 +1086,7 @@ function modules_get_moduletypes ($type = "all", $rows = "nombre") { $return[$type["id_tipo"]] = $type[reset ($rows)]; } } + return $return; } @@ -1119,32 +1122,6 @@ function modules_show_icon_type ($id_type) { return (string) db_get_value ('icon', 'ttipo_modulo', 'id_tipo', $id_type); } -/** - * Get a module category name - * - * @param int Id category - * - * @return Name of the given category - */ -function modules_give_modulecategory_name ($id_category) { - switch ($id_category) { - case 0: - return __('Software agent data'); - break; - case 1: - return __('Software agent monitor'); - break; - case 2: - return __('Network agent data'); - break; - case 3: - return __('Network agent monitor'); - break; - } - - return __('Unknown'); -} - /** * Get agent id from an agent module. * diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index a34823f9f6..abf5518a60 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2873,11 +2873,11 @@ function ui_print_agent_autocomplete_input($parameters) { var term = input_value; //Word to search - ' . $javascript_change_ajax_params_text . ' - + ' . $javascript_change_ajax_params_text . ' + if (' . ((int) !$metaconsole_enabled) . ') { data_params[\'force_local\'] = 1; - } + } jQuery.ajax ({ data: data_params,
"; - html_print_input_text ('description_tag', $description_tag); + html_print_input_text ('description_tag', $description_tag); echo "