From aae0b701062b119f113f36a73abe6bc89274d4c0 Mon Sep 17 00:00:00 2001 From: ramonn Date: Fri, 27 Sep 2013 11:18:04 +0000 Subject: [PATCH] 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). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8820 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 +++ pandora_console/include/functions_netflow.php | 43 +++++++++++++++++++ .../operation/netflow/nf_live_view.php | 11 ++++- 3 files changed, 60 insertions(+), 1 deletion(-) 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')),