From 1412480b4dd571b6c80208c75b2215aa5e97960c Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 3 Nov 2023 09:54:56 +0100 Subject: [PATCH 1/4] #12248 change setup netflow tab --- pandora_console/godmode/setup/setup.php | 24 +++++----- .../godmode/setup/setup_general.php | 16 +------ .../godmode/setup/setup_netflow.php | 48 ++++++++++++++++--- pandora_console/include/functions_config.php | 8 ++-- 4 files changed, 57 insertions(+), 39 deletions(-) diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 0fd6bebff8..ac22324c79 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -141,19 +141,17 @@ $buttons['vis'] = [ ]; if (check_acl($config['id_user'], 0, 'AW')) { - if ($config['activate_netflow']) { - $buttons['net'] = [ - 'active' => false, - 'text' => ''.html_print_image( - 'images/op_netflow.png', - true, - [ - 'title' => __('Netflow'), - 'class' => 'invert_filter', - ] - ).'', - ]; - } + $buttons['net'] = [ + 'active' => false, + 'text' => ''.html_print_image( + 'images/op_netflow.png', + true, + [ + 'title' => __('Netflow'), + 'class' => 'invert_filter', + ] + ).'', + ]; if ($config['activate_sflow']) { $buttons['sflow'] = [ diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index aa55893d11..a791b90aa4 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -391,20 +391,6 @@ $table->data[$i][] = html_print_label_input_block( ); $table->data[$i++][] = html_print_label_input_block( - __('Enable Netflow'), - html_print_checkbox_switch_extended( - 'activate_netflow', - 1, - $config['activate_netflow'], - $rbt_disabled, - '', - '', - true - ) -); - - -$table->data[$i][] = html_print_label_input_block( __('Enable Sflow'), html_print_checkbox_switch_extended( 'activate_sflow', @@ -417,7 +403,7 @@ $table->data[$i][] = html_print_label_input_block( ), ); -$table->data[$i++][] = html_print_label_input_block( +$table->data[$i][] = html_print_label_input_block( __('General network path'), html_print_input_text( 'general_network_path', diff --git a/pandora_console/godmode/setup/setup_netflow.php b/pandora_console/godmode/setup/setup_netflow.php index b939a01825..a133a2b531 100644 --- a/pandora_console/godmode/setup/setup_netflow.php +++ b/pandora_console/godmode/setup/setup_netflow.php @@ -36,49 +36,70 @@ check_login(); $update = (bool) get_parameter('update'); $table = new stdClass(); +$table->id = 'table_netflow'; $table->width = '100%'; $table->class = 'databox filter-table-adv'; $table->border = 0; $table->data = []; +// Enable Netflow. +if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { + $rbt_disabled = true; +} else { + $rbt_disabled = false; +} + $table->data[0][] = html_print_label_input_block( + __('Enable Netflow'), + html_print_checkbox_switch_extended( + 'activate_netflow', + 1, + $config['activate_netflow'], + $rbt_disabled, + '', + '', + true + ) +); + +$table->data[1][] = html_print_label_input_block( __('Data storage path'), html_print_input_text('netflow_name_dir', $config['netflow_name_dir'], false, 50, 200, true) ); -$table->data[0][] = html_print_label_input_block( +$table->data[1][] = html_print_label_input_block( __('Daemon binary path'), html_print_input_text('netflow_daemon', $config['netflow_daemon'], false, 50, 200, true) ); -$table->data[1][] = html_print_label_input_block( +$table->data[2][] = html_print_label_input_block( __('Nfdump binary path'), html_print_input_text('netflow_nfdump', $config['netflow_nfdump'], false, 50, 200, true) ); -$table->data[1][] = html_print_label_input_block( +$table->data[2][] = html_print_label_input_block( __('Nfexpire binary path'), html_print_input_text('netflow_nfexpire', $config['netflow_nfexpire'], false, 50, 200, true) ); -$table->data[2][] = html_print_label_input_block( +$table->data[3][] = html_print_label_input_block( __('Maximum chart resolution'), html_print_input_text('netflow_max_resolution', $config['netflow_max_resolution'], false, 50, 200, true) ); -$table->data[2][] = html_print_label_input_block( +$table->data[3][] = html_print_label_input_block( __('Disable custom live view filters'), html_print_checkbox_switch('netflow_disable_custom_lvfilters', 1, $config['netflow_disable_custom_lvfilters'], true) ); -$table->data[3][] = html_print_label_input_block( +$table->data[4][] = html_print_label_input_block( __('Netflow max lifetime'), html_print_input_text('netflow_max_lifetime', $config['netflow_max_lifetime'], false, 50, 200, true) ); $onclick = "if (!confirm('".__('Warning').'. '.__('IP address resolution can take a lot of time')."')) return false;"; -$table->data[3][] = html_print_label_input_block( +$table->data[4][] = html_print_label_input_block( __('Name resolution for IP address'), html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true) ); @@ -98,7 +119,20 @@ html_print_action_buttons( echo ''; ?> \ No newline at end of file diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 1fe38aac0b..456d1c5158 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -245,10 +245,6 @@ function config_update_config() $error_update[] = __('Enable GIS features'); } - if (config_update_value('activate_netflow', (bool) get_parameter('activate_netflow'), true) === false) { - $error_update[] = __('Enable Netflow'); - } - if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { $error_update[] = __('Enable Sflow'); } @@ -1579,6 +1575,10 @@ function config_update_config() break; case 'net': + if (config_update_value('activate_netflow', (bool) get_parameter('activate_netflow'), true) === false) { + $error_update[] = __('Enable Netflow'); + } + if (config_update_value('netflow_name_dir', get_parameter('netflow_name_dir'), true) === false) { $error_update[] = __('Name storage path'); } else { From 1362ff096729abf2ca380e787cd00227c61dd858 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 3 Nov 2023 11:32:54 +0100 Subject: [PATCH 2/4] Revert "#12248 change setup netflow tab" This reverts commit 1412480b4dd571b6c80208c75b2215aa5e97960c. --- pandora_console/godmode/setup/setup.php | 24 +++++----- .../godmode/setup/setup_general.php | 16 ++++++- .../godmode/setup/setup_netflow.php | 48 +++---------------- pandora_console/include/functions_config.php | 8 ++-- 4 files changed, 39 insertions(+), 57 deletions(-) diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index ac22324c79..0fd6bebff8 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -141,17 +141,19 @@ $buttons['vis'] = [ ]; if (check_acl($config['id_user'], 0, 'AW')) { - $buttons['net'] = [ - 'active' => false, - 'text' => ''.html_print_image( - 'images/op_netflow.png', - true, - [ - 'title' => __('Netflow'), - 'class' => 'invert_filter', - ] - ).'', - ]; + if ($config['activate_netflow']) { + $buttons['net'] = [ + 'active' => false, + 'text' => ''.html_print_image( + 'images/op_netflow.png', + true, + [ + 'title' => __('Netflow'), + 'class' => 'invert_filter', + ] + ).'', + ]; + } if ($config['activate_sflow']) { $buttons['sflow'] = [ diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index a791b90aa4..aa55893d11 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -391,6 +391,20 @@ $table->data[$i][] = html_print_label_input_block( ); $table->data[$i++][] = html_print_label_input_block( + __('Enable Netflow'), + html_print_checkbox_switch_extended( + 'activate_netflow', + 1, + $config['activate_netflow'], + $rbt_disabled, + '', + '', + true + ) +); + + +$table->data[$i][] = html_print_label_input_block( __('Enable Sflow'), html_print_checkbox_switch_extended( 'activate_sflow', @@ -403,7 +417,7 @@ $table->data[$i++][] = html_print_label_input_block( ), ); -$table->data[$i][] = html_print_label_input_block( +$table->data[$i++][] = html_print_label_input_block( __('General network path'), html_print_input_text( 'general_network_path', diff --git a/pandora_console/godmode/setup/setup_netflow.php b/pandora_console/godmode/setup/setup_netflow.php index a133a2b531..b939a01825 100644 --- a/pandora_console/godmode/setup/setup_netflow.php +++ b/pandora_console/godmode/setup/setup_netflow.php @@ -36,70 +36,49 @@ check_login(); $update = (bool) get_parameter('update'); $table = new stdClass(); -$table->id = 'table_netflow'; $table->width = '100%'; $table->class = 'databox filter-table-adv'; $table->border = 0; $table->data = []; -// Enable Netflow. -if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { - $rbt_disabled = true; -} else { - $rbt_disabled = false; -} - $table->data[0][] = html_print_label_input_block( - __('Enable Netflow'), - html_print_checkbox_switch_extended( - 'activate_netflow', - 1, - $config['activate_netflow'], - $rbt_disabled, - '', - '', - true - ) -); - -$table->data[1][] = html_print_label_input_block( __('Data storage path'), html_print_input_text('netflow_name_dir', $config['netflow_name_dir'], false, 50, 200, true) ); -$table->data[1][] = html_print_label_input_block( +$table->data[0][] = html_print_label_input_block( __('Daemon binary path'), html_print_input_text('netflow_daemon', $config['netflow_daemon'], false, 50, 200, true) ); -$table->data[2][] = html_print_label_input_block( +$table->data[1][] = html_print_label_input_block( __('Nfdump binary path'), html_print_input_text('netflow_nfdump', $config['netflow_nfdump'], false, 50, 200, true) ); -$table->data[2][] = html_print_label_input_block( +$table->data[1][] = html_print_label_input_block( __('Nfexpire binary path'), html_print_input_text('netflow_nfexpire', $config['netflow_nfexpire'], false, 50, 200, true) ); -$table->data[3][] = html_print_label_input_block( +$table->data[2][] = html_print_label_input_block( __('Maximum chart resolution'), html_print_input_text('netflow_max_resolution', $config['netflow_max_resolution'], false, 50, 200, true) ); -$table->data[3][] = html_print_label_input_block( +$table->data[2][] = html_print_label_input_block( __('Disable custom live view filters'), html_print_checkbox_switch('netflow_disable_custom_lvfilters', 1, $config['netflow_disable_custom_lvfilters'], true) ); -$table->data[4][] = html_print_label_input_block( +$table->data[3][] = html_print_label_input_block( __('Netflow max lifetime'), html_print_input_text('netflow_max_lifetime', $config['netflow_max_lifetime'], false, 50, 200, true) ); $onclick = "if (!confirm('".__('Warning').'. '.__('IP address resolution can take a lot of time')."')) return false;"; -$table->data[4][] = html_print_label_input_block( +$table->data[3][] = html_print_label_input_block( __('Name resolution for IP address'), html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true) ); @@ -119,20 +98,7 @@ html_print_action_buttons( echo ''; ?> \ No newline at end of file diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 456d1c5158..1fe38aac0b 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -245,6 +245,10 @@ function config_update_config() $error_update[] = __('Enable GIS features'); } + if (config_update_value('activate_netflow', (bool) get_parameter('activate_netflow'), true) === false) { + $error_update[] = __('Enable Netflow'); + } + if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { $error_update[] = __('Enable Sflow'); } @@ -1575,10 +1579,6 @@ function config_update_config() break; case 'net': - if (config_update_value('activate_netflow', (bool) get_parameter('activate_netflow'), true) === false) { - $error_update[] = __('Enable Netflow'); - } - if (config_update_value('netflow_name_dir', get_parameter('netflow_name_dir'), true) === false) { $error_update[] = __('Name storage path'); } else { From 54514b043d6039a413f8de583af503fd61b155ed Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 3 Nov 2023 11:35:22 +0100 Subject: [PATCH 3/4] #12248 move nflow to netflow config --- pandora_console/godmode/setup/setup_general.php | 13 ------------- pandora_console/godmode/setup/setup_netflow.php | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index aa55893d11..10ad4d007e 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -405,19 +405,6 @@ $table->data[$i++][] = html_print_label_input_block( $table->data[$i][] = html_print_label_input_block( - __('Enable Sflow'), - html_print_checkbox_switch_extended( - 'activate_sflow', - 1, - $config['activate_sflow'], - $rbt_disabled, - '', - '', - true - ), -); - -$table->data[$i++][] = html_print_label_input_block( __('General network path'), html_print_input_text( 'general_network_path', diff --git a/pandora_console/godmode/setup/setup_netflow.php b/pandora_console/godmode/setup/setup_netflow.php index b939a01825..9e6f6ee180 100644 --- a/pandora_console/godmode/setup/setup_netflow.php +++ b/pandora_console/godmode/setup/setup_netflow.php @@ -83,6 +83,19 @@ $table->data[3][] = html_print_label_input_block( html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true) ); +$table->data[4][] = html_print_label_input_block( + __('Enable Sflow'), + html_print_checkbox_switch_extended( + 'activate_sflow', + 1, + $config['activate_sflow'], + $rbt_disabled, + '', + '', + true + ), +); + echo '
'; html_print_table($table); html_print_input_hidden('update_config', 1); From 495c4d861fe0966cd5ae530db823420280d949cb Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 3 Nov 2023 11:35:30 +0100 Subject: [PATCH 4/4] #12248 move nflow to netflow config --- pandora_console/include/functions_config.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 1fe38aac0b..fb91c3f8fc 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -249,10 +249,6 @@ function config_update_config() $error_update[] = __('Enable Netflow'); } - if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { - $error_update[] = __('Enable Sflow'); - } - if (config_update_value('activate_feedback', (bool) get_parameter('activate_feedback'), true) === false) { $error_update[] = __('Enable Feedback'); } @@ -1615,6 +1611,10 @@ function config_update_config() if (config_update_value('netflow_get_ip_hostname', (int) get_parameter('netflow_get_ip_hostname'), true) === false) { $error_update[] = __('Name resolution for IP address'); } + + if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { + $error_update[] = __('Enable Sflow'); + } break; case 'sflow':