Added version check on netflow explorer

Former-commit-id: 2786b7a6c0282920d11808e77a2f66fc549d01e9
This commit is contained in:
fermin831 2019-03-07 14:01:50 +01:00
parent 1abe88c375
commit 76422928e8
3 changed files with 33 additions and 17 deletions

View File

@ -1962,3 +1962,32 @@ function netflow_get_top_summary(
return $top_info;
}
/**
* Check the netflow version and print an error message if there is not correct.
*
* @return boolean True if version check is correct.
*/
function netflow_print_check_version_error()
{
global $config;
switch (netflow_check_nfdump_binary($config['netflow_nfdump'])) {
case 0:
return true;
case 1:
ui_print_error_message(
__('nfdump binary (%s) not found!', $config['netflow_nfdump'])
);
return false;
case 2:
default:
ui_print_error_message(
__('Make sure nfdump version 1.6.8 or newer is installed!')
);
return false;
}
}

View File

@ -37,4 +37,6 @@ $is_network = false;
ui_print_page_header(__('Netflow explorer'));
require $config['homedir'].'/operation/network/network_report.php';
if (netflow_print_check_version_error()) {
include $config['homedir'].'/operation/network/network_report.php';
}

View File

@ -118,22 +118,7 @@ if (!is_metaconsole()) {
if ($is_windows) {
ui_print_error_message(__('Not supported in Windows systems'));
} else {
// Check the nfdump binary
$check_result = netflow_check_nfdump_binary($config['netflow_nfdump']);
// Not found or not executable
if ($check_result == 1) {
ui_print_error_message(
sprintf(
__('nfdump binary (%s) not found!'),
$config['netflow_nfdump']
)
);
}
// Wrong version
else if ($check_result == 2) {
ui_print_error_message(sprintf(__('Make sure nfdump version 1.6.8 or newer is installed!')));
}
netflow_print_check_version_error();
}
} else {
$nav_bar = [