#9624 added support sflow
This commit is contained in:
parent
8f393cea12
commit
ca78f069f6
|
@ -364,6 +364,11 @@ if ($access_console_node === true) {
|
|||
$sub2['godmode/setup/setup§ion=net']['text'] = __('Netflow');
|
||||
$sub2['godmode/setup/setup§ion=net']['refr'] = 0;
|
||||
}
|
||||
|
||||
if ((bool) $config['activate_sflow'] === true) {
|
||||
$sub2['godmode/setup/setup§ion=sflow']['text'] = __('Sflow');
|
||||
$sub2['godmode/setup/setup§ion=sflow']['refr'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sub2['godmode/setup/setup§ion=ehorus']['text'] = __('eHorus');
|
||||
|
|
|
@ -154,6 +154,20 @@ if (check_acl($config['id_user'], 0, 'AW')) {
|
|||
).'</a>',
|
||||
];
|
||||
}
|
||||
|
||||
if ($config['activate_sflow']) {
|
||||
$buttons['sflow'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=sflow').'">'.html_print_image(
|
||||
'images/op_netflow.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Sflow'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$buttons['integria'] = [
|
||||
|
@ -272,6 +286,12 @@ switch ($section) {
|
|||
$help_header = 'setup_netflow_tab';
|
||||
break;
|
||||
|
||||
case 'sflow':
|
||||
$buttons['sflow']['active'] = true;
|
||||
$subpage = ' » '.__('Sflow');
|
||||
$help_header = 'setup_flow_tab';
|
||||
break;
|
||||
|
||||
case 'ehorus':
|
||||
$buttons['ehorus']['active'] = true;
|
||||
$subpage = ' » '.__('eHorus');
|
||||
|
@ -381,6 +401,10 @@ switch ($section) {
|
|||
include_once $config['homedir'].'/godmode/setup/setup_netflow.php';
|
||||
break;
|
||||
|
||||
case 'sflow':
|
||||
include_once $config['homedir'].'/godmode/setup/setup_sflow.php';
|
||||
break;
|
||||
|
||||
case 'vis':
|
||||
include_once $config['homedir'].'/godmode/setup/setup_visuals.php';
|
||||
break;
|
||||
|
|
|
@ -246,7 +246,31 @@ $table->data[$i++][1] = html_print_checkbox_switch_extended(
|
|||
true
|
||||
);
|
||||
|
||||
$table->data[$i][0] = __('Enable Sflow');
|
||||
$rbt_disabled = false;
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
$rbt_disabled = true;
|
||||
}
|
||||
|
||||
$table->data[$i++][1] = html_print_checkbox_switch_extended(
|
||||
'activate_sflow',
|
||||
1,
|
||||
$config['activate_sflow'],
|
||||
$rbt_disabled,
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[$i][0] = __('General network path');
|
||||
$table->data[$i++][1] = html_print_input_text(
|
||||
'general_network_path',
|
||||
$config['general_network_path'],
|
||||
'',
|
||||
40,
|
||||
255,
|
||||
true
|
||||
);
|
||||
$zone_name = [
|
||||
'Africa' => __('Africa'),
|
||||
'America' => __('America'),
|
||||
|
|
|
@ -45,7 +45,8 @@ $table->class = 'databox filters';
|
|||
$table->data = [];
|
||||
|
||||
$table->data[0][0] = '<b>'.__('Data storage path').'</b>';
|
||||
$table->data[0][1] = html_print_input_text('netflow_path', $config['netflow_path'], false, 50, 200, true);
|
||||
$table->data[0][1] = html_print_input_text('netflow_name_dir', $config['netflow_name_dir'], false, 50, 200, true);
|
||||
$table->data[0][1] .= '<script>$("input[name=netflow_name_dir]").on("input", function() {$(this).val($(this).val().replace(/[^a-z0-9]/gi, ""));});</script>';
|
||||
|
||||
$table->data[1][0] = '<b>'.__('Daemon interval').'</b>';
|
||||
$table->data[1][1] = html_print_input_text('netflow_interval', $config['netflow_interval'], false, 50, 200, true);
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Setup view for Netflow
|
||||
*
|
||||
* @category Setup
|
||||
* @package Pandora FMS
|
||||
* @subpackage Configuration
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
require_once 'include/functions_ui.php';
|
||||
|
||||
check_login();
|
||||
|
||||
$update = (bool) get_parameter('update');
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->border = 0;
|
||||
$table->cellspacing = 3;
|
||||
$table->cellpadding = 5;
|
||||
$table->class = 'databox filters';
|
||||
|
||||
$table->data = [];
|
||||
|
||||
$table->data[0][0] = '<b>'.__('Data storage path').'</b>';
|
||||
$table->data[0][1] = html_print_input_text('sflow_name_dir', $config['sflow_name_dir'], false, 50, 200, true);
|
||||
$table->data[0][1] .= '<script>$("input[name=sflow_name_dir]").on("input", function() {$(this).val($(this).val().replace(/[^a-z0-9]/gi, ""));});</script>';
|
||||
|
||||
|
||||
$table->data[1][0] = '<b>'.__('Daemon interval').'</b>';
|
||||
$table->data[1][1] = html_print_input_text('sflow_interval', $config['sflow_interval'], false, 50, 200, true);
|
||||
|
||||
$table->data[2][0] = '<b>'.__('Daemon binary path').'</b>';
|
||||
$table->data[2][1] = html_print_input_text('sflow_daemon', $config['sflow_daemon'], false, 50, 200, true);
|
||||
|
||||
$table->data[3][0] = '<b>'.__('Nfdump binary path').'</b>';
|
||||
$table->data[3][1] = html_print_input_text('sflow_nfdump', $config['sflow_nfdump'], false, 50, 200, true);
|
||||
|
||||
$table->data[4][0] = '<b>'.__('Nfexpire binary path').'</b>';
|
||||
$table->data[4][1] = html_print_input_text('sflow_nfexpire', $config['sflow_nfexpire'], false, 50, 200, true);
|
||||
|
||||
$table->data[5][0] = '<b>'.__('Maximum chart resolution').'</b>';
|
||||
$table->data[5][1] = html_print_input_text('sflow_max_resolution', $config['sflow_max_resolution'], false, 50, 200, true);
|
||||
|
||||
$table->data[6][0] = '<b>'.__('Disable custom live view filters').'</b>';
|
||||
$table->data[6][1] = html_print_checkbox_switch('sflow_disable_custom_lvfilters', 1, $config['sflow_disable_custom_lvfilters'], true);
|
||||
$table->data[7][0] = '<b>'.__('Max. sflow lifetime').'</b>';
|
||||
$table->data[7][1] = html_print_input_text('sflow_max_lifetime', $config['sflow_max_lifetime'], false, 50, 200, true);
|
||||
|
||||
$table->data[8][0] = '<b>'.__('Name resolution for IP address').'</b>';
|
||||
$onclick = "if (!confirm('".__('Warning').'. '.__('IP address resolution can take a lot of time')."')) return false;";
|
||||
$table->data[8][1] = html_print_checkbox_switch_extended('sflow_get_ip_hostname', 1, $config['sflow_get_ip_hostname'], false, $onclick, '', true);
|
||||
|
||||
echo '<form id="netflow_setup" method="post">';
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
// Update button.
|
||||
echo '<div class="action-buttons w100p">';
|
||||
html_print_input_hidden('update_config', 1);
|
||||
html_print_submit_button(__('Update'), 'upd_button', false, 'class="sub upd"');
|
||||
echo '</div></form>';
|
|
@ -260,6 +260,24 @@ 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('general_network_path', get_parameter('general_network_path'), true) === false) {
|
||||
$error_update[] = __('General network path');
|
||||
} else {
|
||||
if (empty($config['netflow_name_dir']) === false && $config['netflow_name_dir'] !== '') {
|
||||
$path = get_parameter('general_network_path');
|
||||
config_update_value('netflow_path', $path.$config['netflow_name_dir']);
|
||||
}
|
||||
|
||||
if (empty($config['sflow_name_dir']) === false && $config['sflow_name_dir'] !== '') {
|
||||
$path = get_parameter('general_network_path');
|
||||
config_update_value('sflow_path', $path.$config['sflow_name_dir']);
|
||||
}
|
||||
}
|
||||
|
||||
$timezone = (string) get_parameter('timezone');
|
||||
if (empty($timezone) === true || config_update_value('timezone', $timezone, true) === false) {
|
||||
$error_update[] = __('Timezone setup');
|
||||
|
@ -1501,8 +1519,13 @@ function config_update_config()
|
|||
break;
|
||||
|
||||
case 'net':
|
||||
if (config_update_value('netflow_path', get_parameter('netflow_path'), true) === false) {
|
||||
$error_update[] = __('Data storage path');
|
||||
if (config_update_value('netflow_name_dir', get_parameter('netflow_name_dir'), true) === false) {
|
||||
$error_update[] = __('Name storage path');
|
||||
} else {
|
||||
if (empty($config['general_network_path']) === false && $config['general_network_path'] !== '') {
|
||||
$name = get_parameter('netflow_name_dir');
|
||||
config_update_value('netflow_path', $config['general_network_path'].$name);
|
||||
}
|
||||
}
|
||||
|
||||
if (config_update_value('netflow_interval', (int) get_parameter('netflow_interval'), true) === false) {
|
||||
|
@ -1538,6 +1561,49 @@ function config_update_config()
|
|||
}
|
||||
break;
|
||||
|
||||
case 'sflow':
|
||||
if (config_update_value('sflow_name_dir', get_parameter('sflow_name_dir'), true) === false) {
|
||||
$error_update[] = __('Sflow name dir');
|
||||
} else {
|
||||
if (empty($config['general_network_path']) === false && $config['general_network_path'] !== '') {
|
||||
$name = get_parameter('sflow_name_dir');
|
||||
config_update_value('sflow_path', $config['general_network_path'].$name);
|
||||
}
|
||||
}
|
||||
|
||||
if (config_update_value('sflow_interval', (int) get_parameter('sflow_interval'), true) === false) {
|
||||
$error_update[] = __('Daemon interval');
|
||||
}
|
||||
|
||||
if (config_update_value('sflow_daemon', get_parameter('sflow_daemon'), true) === false) {
|
||||
$error_update[] = __('Daemon binary path');
|
||||
}
|
||||
|
||||
if (config_update_value('sflow_nfdump', get_parameter('sflow_nfdump'), true) === false) {
|
||||
$error_update[] = __('Nfdump binary path');
|
||||
}
|
||||
|
||||
if (config_update_value('sflow_nfexpire', get_parameter('sflow_nfexpire'), true) === false) {
|
||||
$error_update[] = __('Nfexpire binary path');
|
||||
}
|
||||
|
||||
if (config_update_value('sflow_max_resolution', (int) get_parameter('sflow_max_resolution'), true) === false) {
|
||||
$error_update[] = __('Maximum chart resolution');
|
||||
}
|
||||
|
||||
if (config_update_value('sflow_disable_custom_lvfilters', get_parameter('sflow_disable_custom_lvfilters'), true) === false) {
|
||||
$error_update[] = __('Disable custom live view filters');
|
||||
}
|
||||
|
||||
if (config_update_value('sflow_max_lifetime', (int) get_parameter('sflow_max_lifetime'), true) === false) {
|
||||
$error_update[] = __('Sflow max lifetime');
|
||||
}
|
||||
|
||||
if (config_update_value('sflow_get_ip_hostname', (int) get_parameter('sflow_get_ip_hostname'), true) === false) {
|
||||
$error_update[] = __('Name resolution for IP address');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'log':
|
||||
if (config_update_value('elasticsearch_ip', get_parameter('elasticsearch_ip'), true) === false) {
|
||||
$error_update[] = __('IP ElasticSearch server');
|
||||
|
@ -2768,6 +2834,28 @@ function config_process_config()
|
|||
config_update_value('activate_netflow', 0);
|
||||
}
|
||||
|
||||
if (!isset($config['activate_sflow'])) {
|
||||
config_update_value('activate_sflow', 0);
|
||||
}
|
||||
|
||||
if (!isset($config['general_network_path'])) {
|
||||
if ($is_windows) {
|
||||
$default = 'C:\PandoraFMS\Pandora_Server\data_in\\';
|
||||
} else {
|
||||
$default = '/var/spool/pandora/data_in/';
|
||||
}
|
||||
|
||||
config_update_value('general_network_path', $default);
|
||||
}
|
||||
|
||||
if (!isset($config['netflow_name_dir'])) {
|
||||
config_update_value('netflow_name_dir', 'netflow');
|
||||
}
|
||||
|
||||
if (!isset($config['sflow_name_dir'])) {
|
||||
config_update_value('sflow_name_dir', 'sflow');
|
||||
}
|
||||
|
||||
if (!isset($config['netflow_path'])) {
|
||||
if ($is_windows) {
|
||||
$default = 'C:\PandoraFMS\Pandora_Server\data_in\netflow';
|
||||
|
@ -2806,6 +2894,48 @@ function config_process_config()
|
|||
config_update_value('netflow_max_lifetime', '5');
|
||||
}
|
||||
|
||||
if (!isset($config['sflow_interval'])) {
|
||||
config_update_value('sflow_interval', SECONDS_10MINUTES);
|
||||
}
|
||||
|
||||
if (!isset($config['sflow_daemon'])) {
|
||||
config_update_value('sflow_daemon', '/usr/bin/nfcapd');
|
||||
}
|
||||
|
||||
if (!isset($config['sflow_nfdump'])) {
|
||||
config_update_value('sflow_nfdump', '/usr/bin/nfdump');
|
||||
}
|
||||
|
||||
if (!isset($config['sflow_nfexpire'])) {
|
||||
config_update_value('sflow_nfexpire', '/usr/bin/nfexpire');
|
||||
}
|
||||
|
||||
if (!isset($config['sflow_max_resolution'])) {
|
||||
config_update_value('sflow_max_resolution', '50');
|
||||
}
|
||||
|
||||
if (!isset($config['sflow_disable_custom_lvfilters'])) {
|
||||
config_update_value('sflow_disable_custom_lvfilters', 0);
|
||||
}
|
||||
|
||||
if (!isset($config['sflow_max_lifetime'])) {
|
||||
config_update_value('sflow_max_lifetime', '5');
|
||||
}
|
||||
|
||||
if (!isset($config['sflow_name_dir'])) {
|
||||
config_update_value('sflow_name_dir', 'sflow');
|
||||
}
|
||||
|
||||
if (!isset($config['sflow_path'])) {
|
||||
if ($is_windows) {
|
||||
$default = 'C:\PandoraFMS\Pandora_Server\data_in\sflow';
|
||||
} else {
|
||||
$default = '/var/spool/pandora/data_in/sflow';
|
||||
}
|
||||
|
||||
config_update_value('sflow_path', $default);
|
||||
}
|
||||
|
||||
if (!isset($config['auth'])) {
|
||||
config_update_value('auth', 'mysql');
|
||||
}
|
||||
|
|
|
@ -1025,9 +1025,29 @@ function netflow_get_command($options, $filter)
|
|||
// Build command.
|
||||
$command = io_safe_output($config['netflow_nfdump']).' -N';
|
||||
|
||||
// Netflow data path.
|
||||
if (isset($config['netflow_path']) && $config['netflow_path'] != '') {
|
||||
$command .= ' -R. -M '.$config['netflow_path'];
|
||||
if ($config['activate_sflow'] && $config['activate_netflow']) {
|
||||
if (isset($config['sflow_name_dir']) && $config['sflow_name_dir'] !== ''
|
||||
&& isset($config['netflow_name_dir']) && $config['netflow_name_dir'] !== ''
|
||||
&& isset($config['general_network_path']) && $config['general_network_path'] !== ''
|
||||
) {
|
||||
$command .= ' -R. -M '.$config['general_network_path'].$config['netflow_name_dir'].':'.$config['sflow_name_dir'];
|
||||
}
|
||||
} else {
|
||||
if ($config['activate_sflow']) {
|
||||
if (isset($config['sflow_name_dir']) && $config['sflow_name_dir'] !== ''
|
||||
&& isset($config['general_network_path']) && $config['general_network_path'] !== ''
|
||||
) {
|
||||
$command .= ' -R. -M '.$config['general_network_path'].$config['sflow_name_dir'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($config['activate_netflow']) {
|
||||
if (isset($config['netflow_name_dir']) && $config['netflow_name_dir'] !== ''
|
||||
&& isset($config['general_network_path']) && $config['general_network_path'] !== ''
|
||||
) {
|
||||
$command .= ' -R. -M '.$config['general_network_path'].$config['netflow_name_dir'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add options.
|
||||
|
@ -1035,7 +1055,7 @@ function netflow_get_command($options, $filter)
|
|||
|
||||
// Filter options.
|
||||
$command .= ' '.netflow_get_filter_arguments($filter);
|
||||
|
||||
hd($command, true);
|
||||
return $command;
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ if ($access_console_node === true) {
|
|||
$sub['operation/inventory/inventory']['refr'] = 0;
|
||||
}
|
||||
|
||||
if ($config['activate_netflow']) {
|
||||
if ($config['activate_netflow'] || $config['activate_sflow']) {
|
||||
$sub['network_traffic'] = [
|
||||
'text' => __('Network'),
|
||||
'id' => 'Network',
|
||||
|
@ -213,34 +213,20 @@ if ($access_console_node === true) {
|
|||
'subtype' => 'nolink',
|
||||
'refr' => 0,
|
||||
];
|
||||
|
||||
// Initialize the submenu.
|
||||
$netflow_sub = [];
|
||||
|
||||
$netflow_sub = array_merge(
|
||||
$netflow_sub,
|
||||
[
|
||||
'operation/netflow/netflow_explorer' => [
|
||||
'text' => __('Netflow explorer'),
|
||||
'id' => 'Netflow explorer',
|
||||
],
|
||||
'operation/netflow/nf_live_view' => [
|
||||
'text' => __('Netflow Live View'),
|
||||
'id' => 'Netflow Live View',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$netflow_sub = array_merge(
|
||||
$netflow_sub,
|
||||
[
|
||||
'operation/network/network_usage_map' => [
|
||||
'text' => __('Network usage map'),
|
||||
'id' => 'Network usage map',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$netflow_sub = [
|
||||
'operation/netflow/netflow_explorer' => [
|
||||
'text' => __('Netflow explorer'),
|
||||
'id' => 'Netflow explorer',
|
||||
],
|
||||
'operation/netflow/nf_live_view' => [
|
||||
'text' => __('Netflow Live View'),
|
||||
'id' => 'Netflow Live View',
|
||||
],
|
||||
'operation/network/network_usage_map' => [
|
||||
'text' => __('Network usage map'),
|
||||
'id' => 'Network usage map',
|
||||
],
|
||||
];
|
||||
$sub['network_traffic']['sub2'] = $netflow_sub;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,8 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
|||
('stats_interval', '60'),
|
||||
('activate_gis', '0'),
|
||||
('activate_netflow', '0'),
|
||||
('activate_sflow', '0'),
|
||||
('general_network_path', '/var/spool/pandora/data_in/'),
|
||||
('timezone', 'Europe/Berlin'),
|
||||
('string_purge', 7),
|
||||
('audit_purge', 15),
|
||||
|
@ -87,6 +89,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
|||
('netflow_daemon', '/usr/bin/nfcapd'),
|
||||
('netflow_nfdump', '/usr/bin/nfdump'),
|
||||
('netflow_max_resolution', '50'),
|
||||
('sflow_interval', '3600'),
|
||||
('sflow_daemon', '/usr/bin/nfcapd'),
|
||||
('sflow_nfdump', '/usr/bin/nfdump'),
|
||||
('sflow_max_resolution', '50'),
|
||||
('event_fields', 'mini_severity,evento,estado,agent_name,timestamp'),
|
||||
('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,last_status_change,graph,warn,data,timestamp'),
|
||||
('list_ACL_IPs_for_API', '127.0.0.1'),
|
||||
|
|
Loading…
Reference in New Issue