diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 270549de0a..0c34657cf1 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2013-01-22 Ramon Novoa + + * godmode/setup/setup_netflow.php, + operation/netflow/nf_live_view.php, + include/functions_config.php: Added support for disabling custom + filters in the netflow live viewer. + + * include/functions_graph.php: Added min, max and avg values to + unaggregated netflow charts. + 2013-01-22 Sergio Martin * include/functions_tags.php: Fix a empty value return diff --git a/pandora_console/godmode/setup/setup_netflow.php b/pandora_console/godmode/setup/setup_netflow.php index 82f9a18e9a..e5b1f2fe75 100644 --- a/pandora_console/godmode/setup/setup_netflow.php +++ b/pandora_console/godmode/setup/setup_netflow.php @@ -51,6 +51,9 @@ $table->data[3][0] = ''.__('Nfdump binary path').''; $table->data[3][1] = html_print_input_text ('netflow_nfdump', $config['netflow_nfdump'], false, 50, 200, true); $table->data[4][0] = ''.__('Maximum chart resolution').'' . ui_print_help_tip (__("Maximum number of points that a netflow area chart will display. The higher the resolution the performance. Values between 50 and 100 are recommended."), true); $table->data[4][1] = html_print_input_text ('netflow_max_resolution', $config['netflow_max_resolution'], false, 50, 200, true); +$table->data[5][0] = ''.__('Disable custom live view filters').'' . ui_print_help_tip (__("Disable the definition of custom filters in the live view. Only existing filters can be used."), true); +$table->data[5][1] = __('Yes').'   '.html_print_radio_button ('netflow_disable_custom_lvfilters', 1, '', $config["netflow_disable_custom_lvfilters"], true).'  '; +$table->data[5][1] .= __('No').'   '.html_print_radio_button ('netflow_disable_custom_lvfilters', 0, '', $config["netflow_disable_custom_lvfilters"], true).'  '; echo '
'; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 6fbcf391c0..f4153c9eeb 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -300,6 +300,7 @@ function config_update_config () { config_update_value ('netflow_daemon', get_parameter ('netflow_daemon')); config_update_value ('netflow_nfdump', get_parameter ('netflow_nfdump')); config_update_value ('netflow_max_resolution', get_parameter ('netflow_max_resolution')); + config_update_value ('netflow_disable_custom_lvfilters', get_parameter ('netflow_disable_custom_lvfilters')); break; case 'log': config_update_value ('log_dir', (string)get_parameter('log_dir')); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index c87da02ef1..a8c708adbf 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2835,13 +2835,33 @@ function graph_netflow_total_area ($data, $period, $width, $height, $unit = '', else { $chart_time_format = 'M d H\h'; } + + // Calculate min, max and avg values + $avg = 0; + foreach ($data as $timestamp => $value) { + $max = $value['data']; + $min = $value['data']; + break; + } // Populate chart + $count = 0; $chart = array (); foreach ($data as $timestamp => $value) { $chart[date ($chart_time_format, $timestamp)] = $value; + if ($value['data'] > $max) { + $max = $value['data']; + } + if ($value['data'] < $min) { + $min = $value['data']; + } + $avg += $value['data']; + $count++; } - + if ($count > 0) { + $avg /= $count; + } + $flash_chart = $config['flash_charts']; if ($only_image) { $flash_chart = false; @@ -2856,8 +2876,9 @@ function graph_netflow_total_area ($data, $period, $width, $height, $unit = '', $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("/images/logo_vertical_water.png")); - - return area_graph($flash_chart, $chart, $width, $height, array (), false, + + $legend = array (__('Max.') . ' ' . format_numeric($max) . ' ' . __('Min.') . ' ' . format_numeric($min) . ' ' . __('Avg.') . ' ' . format_numeric ($avg)); + return area_graph($flash_chart, $chart, $width, $height, array (), $legend, array (), ui_get_full_url("images/image_problem.opaque.png"), "", "", $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl); diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 6a4406fe8c..ec8f303e3a 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -57,6 +57,9 @@ if (is_ajax()){ $id = get_parameter('id'); $filter_values = db_get_row_filter ('tnetflow_filter', array('id_sg' => $id)); + + // Decode HTML entities + $filter_values['advanced_filter'] = io_safe_output ($filter_values['advanced_filter']); echo json_encode($filter_values); } @@ -185,6 +188,7 @@ echo ''.__('Name').''; - $table->data[1][1] = html_print_input_text ('name', $filter['id_name'], false, 20, 80, true); + $table->data[$i][0] = ''.__('Name').''; + $table->data[$i][1] = html_print_input_text ('name', $filter['id_name'], false, 20, 80, true); $own_info = get_user_info ($config['id_user']); - $table->data[1][2] = ''.__('Group').''; - $table->data[1][3] = html_print_select_groups($config['id_user'], "IW", $own_info['is_admin'], 'assign_group', $filter['id_group'], '', '', -1, true, false, false); + $table->data[$i][2] = ''.__('Group').''; + $table->data[$i][3] = html_print_select_groups($config['id_user'], "IW", $own_info['is_admin'], 'assign_group', $filter['id_group'], '', '', -1, true, false, false); + $table->rowstyle[$i] = 'display: none'; + $i++; - $table->rowstyle[0] = 'display: none'; - $table->rowstyle[1] = 'display: none'; + + if ($config['netflow_disable_custom_lvfilters'] == 0) { + // Read filter type + if ($filter['advanced_filter'] != '') { + $filter_type = 1; + } + else { + $filter_type = 0; + } + + $table->data[$i][0] = ''.__('Filter').''; + $table->data[$i][1] = __('Normal') . ' ' . html_print_radio_button_extended ('filter_type', 0, '', $filter_type, false, 'displayNormalFilter();', 'style="margin-right: 40px;"', true); + $table->data[$i][1] .= __('Advanced') . ' ' . html_print_radio_button_extended ('filter_type', 1, '', $filter_type, false, 'displayAdvancedFilter();', 'style="margin-right: 40px;"', true); + $table->data[$i][2] = ''.__('Load filter').''; + $user_groups = users_get_groups ($config['id_user'], "AR", $own_info['is_admin'], true); + $sql = "SELECT * FROM tnetflow_filter WHERE id_group IN (".implode(',', array_keys ($user_groups)).")"; + $table->data[$i][3] = html_print_select_from_sql ($sql, 'filter_id', $filter_id, '', __('none'), 0, true); + $i++; + + $table->data[$i][0] = __('Dst Ip'). ui_print_help_tip (__("Destination IP. A comma separated list of destination ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true); + $table->data[$i][1] = html_print_input_text ('ip_dst', $filter['ip_dst'], false, 40, 80, true); + $table->data[$i][2] = __('Src Ip'). ui_print_help_tip (__("Source IP. A comma separated list of source ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true); + $table->data[$i][3] = html_print_input_text ('ip_src', $filter['ip_src'], false, 40, 80, true); + $i++; + + $table->data[$i][0] = __('Dst Port'). ui_print_help_tip (__("Destination port. A comma separated list of destination ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true); + $table->data[$i][1] = html_print_input_text ('dst_port', $filter['dst_port'], false, 40, 80, true); + $table->data[$i][2] = __('Src Port'). ui_print_help_tip (__("Source port. A comma separated list of source ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true); + $table->data[$i][3] = html_print_input_text ('src_port', $filter['src_port'], false, 40, 80, true); + $i++; + + $table->data[$i][0] = ui_print_help_icon ('pcap_filter', true); + $table->data[$i][1] = html_print_textarea ('advanced_filter', 4, 40, $filter['advanced_filter'], "style='min-height: 0px;'", true); + $table->colspan[$i][1] = 3; + $i++; + } else { + $table->data[$i][0] = ''.__('Load filter').''; + $user_groups = users_get_groups ($config['id_user'], "AR", $own_info['is_admin'], true); + $sql = "SELECT * FROM tnetflow_filter WHERE id_group IN (".implode(',', array_keys ($user_groups)).")"; + $table->data[$i][1] = html_print_select_from_sql ($sql, 'filter_id', $filter_id, '', __('none'), 0, true); + $table->data[$i][2] = ''; + $table->data[$i][3] = ''; + $i++; + } - // Read filter type - if ($filter['advanced_filter'] != '') { - $filter_type = 1; - } - else { - $filter_type = 0; - } - - $table->data[2][0] = ''.__('Filter').''; - $table->data[2][1] = __('Normal') . ' ' . html_print_radio_button_extended ('filter_type', 0, '', $filter_type, false, 'displayNormalFilter();', 'style="margin-right: 40px;"', true); - $table->data[2][1] .= __('Advanced') . ' ' . html_print_radio_button_extended ('filter_type', 1, '', $filter_type, false, 'displayAdvancedFilter();', 'style="margin-right: 40px;"', true); - $table->data[2][2] = ''.__('Load filter').''; - $user_groups = users_get_groups ($config['id_user'], "AR", $own_info['is_admin'], true); - $sql = "SELECT * FROM tnetflow_filter WHERE id_group IN (".implode(',', array_keys ($user_groups)).")"; - $table->data[2][3] = html_print_select_from_sql ($sql, 'filter_id', $filter_id, '', __('none'), 0, true); - - - $table->data[3][0] = __('Dst Ip'). ui_print_help_tip (__("Destination IP. A comma separated list of destination ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true); - $table->data[3][1] = html_print_input_text ('ip_dst', $filter['ip_dst'], false, 40, 80, true); - $table->data[3][2] = __('Src Ip'). ui_print_help_tip (__("Source IP. A comma separated list of source ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true); - $table->data[3][3] = html_print_input_text ('ip_src', $filter['ip_src'], false, 40, 80, true); - - $table->data[4][0] = __('Dst Port'). ui_print_help_tip (__("Destination port. A comma separated list of destination ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true); - $table->data[4][1] = html_print_input_text ('dst_port', $filter['dst_port'], false, 40, 80, true); - $table->data[4][2] = __('Src Port'). ui_print_help_tip (__("Source port. A comma separated list of source ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true); - $table->data[4][3] = html_print_input_text ('src_port', $filter['src_port'], false, 40, 80, true); - - $table->data[5][0] = ui_print_help_icon ('pcap_filter', true); - $table->data[5][1] = html_print_textarea ('advanced_filter', 4, 40, $filter['advanced_filter'], "style='min-height: 0px;'", true); - $table->colspan[5][1] = 3; - - $table->data[6][0] = ''.__('Aggregate by').''. ui_print_help_icon ('aggregate_by', true); - + $table->data[$i][0] = ''.__('Aggregate by').''. ui_print_help_icon ('aggregate_by', true); $aggregate_list = array(); $aggregate_list = array ('none' => __('None'), 'proto' => __('Protocol'), 'srcip' =>__('Src Ip Address'), 'dstip' =>__('Dst Ip Address'), 'srcport' =>__('Src Port'), 'dstport' =>__('Dst Port') ); - $table->data[6][1] = html_print_select ($aggregate_list, "aggregate", $filter['aggregate'], '', '', 0, true, false, true, '', false); + $table->data[$i][1] = html_print_select ($aggregate_list, "aggregate", $filter['aggregate'], '', '', 0, true, false, true, '', false); - $table->data[6][2] = ''.__('Output format').''; + $table->data[$i][2] = ''.__('Output format').''; $show_output = array ('bytes' => __('Bytes'), 'bytespersecond' => __('Bytes per second'), 'kilobytes' => __('Kilobytes'), 'megabytes' => __('Megabytes'), 'kilobytespersecond' => __('Kilobytes per second'), 'megabytespersecond' => __('Megabytes per second')); - $table->data[6][3] = html_print_select ($show_output, 'output', $filter['output'], '', '', 0, true, false, true, '', false); - + $table->data[$i][3] = html_print_select ($show_output, 'output', $filter['output'], '', '', 0, true, false, true, '', false); + $i++; + html_print_table ($table); html_print_submit_button (__('Draw'), 'draw_button', false, 'class="sub upd"');