diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1e2a32a3dd..165c294a6f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2013-09-27 Ramon Novoa + + * include/functions_netflow.php, + operation/netflow/nf_live_view.php: Show an error if nfdump version + older than 1.6.8 is installed (this is the minimum version required + to work with Pandora FMS). + 2013-09-27 Miguel de Dios * include/javascript/jquery.pandora.js: the button to close in the diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 237b71cca1..a951581355 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1345,4 +1345,47 @@ function netflow_format_aggregate ($aggregate) { } } +/** + * Check the nfdump binary for compatibility. + * + * @param string nfdump binary full path. + * + * @return 1 if the binary does not exist or is not executable, 2 if a + * version older than 1.6.8 is installed or the version cannot be + * determined, 0 otherwise. + */ +function netflow_check_nfdump_binary ($nfdump_binary) { + + // Check that the binary exists and is executable + if (! is_executable ($nfdump_binary)) { + return 1; + } + + // Check at least version 1.6.8 + $output = ''; + $rc = -1; + exec ($nfdump_binary . ' -V', $output, $rc); + if ($rc != 0) { + return 2; + } + + $matches = array(); + foreach ($output as $line) { + if (preg_match ('/Version:\s*(\d+)\.(\d+)\.(\d+)/', $line, $matches) === 1) { + if ($matches[1] < 1) { + return 2; + } + if ($matches[2] < 6) { + return 2; + } + if ($matches[3] < 8) { + return 2; + } + return 0; + } + } + + return 2; +} + ?> diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 95459c3546..7709dd2479 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -104,11 +104,20 @@ $start_date = $end_date - $period; if (! defined ('METACONSOLE')) { //Header ui_print_page_header (__('Netflow live view'), "images/op_netflow.png", false, "", false, array ()); - if (! is_executable ($config['netflow_nfdump'])) { + + // 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!'))); + } } else { $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')),