diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 71d39485ed..c104f867eb 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.760-220317 +Version: 7.0NG.760-220318 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index f627389151..51a877b552 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.760-220317" +pandora_version="7.0NG.760-220318" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 548782e68a..0a3c69e139 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.760'; -use constant AGENT_BUILD => '220317'; +use constant AGENT_BUILD => '220318'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index df24b57257..f88da41fcf 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.760 -%define release 220317 +%define release 220318 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 3d1a313bf9..a25b2becc9 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.760 -%define release 220317 +%define release 220318 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index a5fbc23732..f0f48a4f04 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.760" -PI_BUILD="220317" +PI_BUILD="220318" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 7cec88850a..136f60476b 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{220317} +{220318} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index f07ea9b4da..9409b970c1 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.760 Build 220317") +#define PANDORA_VERSION ("7.0NG.760 Build 220318") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index e9d0760a44..9a4f535899 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.760(Build 220317))" + VALUE "ProductVersion", "(7.0NG.760(Build 220318))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 4728c03770..095280db25 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.760-220317 +Version: 7.0NG.760-220318 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 42b77bfe0e..d6be5cbe87 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.760-220317" +pandora_version="7.0NG.760-220318" package_pear=0 package_pandora=1 diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index d57d930b6a..719eda6e46 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -868,6 +868,7 @@ switch ($action) { case 'netflow_area': case 'netflow_data': case 'netflow_summary': + case 'netflow_top_N': $netflow_filter = $item['text']; // Filter. $period = $item['period']; @@ -6583,6 +6584,16 @@ function chooseType() { $("#row_historical_db_check").hide(); break; + case 'netflow_top_N': + $("#row_netflow_filter").show(); + $("#row_description").show(); + $("#row_period").show(); + $("#row_max_values").show(); + $("#row_resolution").show(); + $("#row_servers").show(); + $("#row_historical_db_check").hide(); + break; + case 'IPAM_network': $("#row_network_filter").show(); $("#row_alive_ip").show(); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 079b132ba2..fbad042ef1 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1753,6 +1753,7 @@ switch ($action) { case 'netflow_area': case 'netflow_data': case 'netflow_summary': + case 'netflow_top_N': $values['text'] = get_parameter( 'netflow_filter' ); @@ -2553,6 +2554,7 @@ switch ($action) { case 'netflow_area': case 'netflow_data': case 'netflow_summary': + case 'netflow_top_N': $values['text'] = get_parameter( 'netflow_filter' ); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 92482c4d2c..fc13615116 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC220317'; +$build_version = 'PC220318'; $pandora_version = 'v7.0NG.760'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 55f9a1ce02..5bf3dfe5c0 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13630,7 +13630,7 @@ function api_get_netflow_get_stats($discard_1, $discard_2, $params) return; } - // Parse function parameters + // Parse function parameters. $start_date = $params['data'][0]; $end_date = $params['data'][1]; $filter = json_decode(base64_decode($params['data'][2]), true); @@ -13647,10 +13647,38 @@ function api_get_netflow_get_stats($discard_1, $discard_2, $params) } +/** + * + * @param $trash1 Don't use. + * @param $trash2 Don't use. + * @param array $params Call parameters. + * @return void + */ +function api_get_netflow_get_top_N($trash1, $trash2, $params) +{ + if (is_metaconsole() === true) { + return; + } + + // Parse function parameters. + $start_date = $params['data'][0]; + $end_date = $params['data'][1]; + $filter = json_decode(base64_decode($params['data'][2]), true); + $max = $params['data'][3]; + + // Get netflow data. + $data = netflow_get_top_N($start_date, $end_date, $filter, $max, ''); + + returnData('json', $data); + + return; +} + + // http://localhost/pandora_console/include/api.php?op=get&op2=netflow_get_summary&other=1348562410|1348648810|_base64_encode(json_encode($filter))&other_mode=url_encode_separator_|&apipass=pandora&user=pandora&pass=pandora' function api_get_netflow_get_summary($discard_1, $discard_2, $params) { - if (defined('METACONSOLE')) { + if (is_metaconsole() === true) { return; } diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 60229d79ae..f88f6b751d 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -321,6 +321,72 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate) } +/** + * Show a table with netflow top N data. + * + * @param array $data Netflow data. + * @param integer $total_bytes Total bytes count to calculate percent data. + * + * @return string HTML data table. + */ +function netflow_top_n_table(array $data, int $total_bytes) +{ + global $nfdump_date_format; + + $values = []; + $table = new stdClass(); + $table->class = 'w100p'; + $table->cellspacing = 0; + $table->data = []; + + $table->head = []; + $table->head[0] = ''.__('Source IP').''; + $table->head[1] = ''.__('Destination IP').''; + $table->head[2] = ''.__('Bytes').''; + $table->head[3] = ''.__('% Traffic').''; + $table->head[4] = ''.__('Avg. Throughput').''; + $table->style[0] = 'padding: 4px'; + + $i = 0; + + foreach ($data as $value) { + $table->data[$i][0] = $value['ip_src']; + $table->data[$i][1] = $value['ip_dst']; + $table->data[$i][2] = network_format_bytes($value['bytes']); + + $traffic = '-'; + + if ($total_bytes > 0) { + $traffic = sprintf( + '%.2f', + (($value['bytes'] / $total_bytes) * 100) + ); + } + + $table->data[$i][3] = $traffic.' %'; + + $units = [ + 'bps', + 'Kbps', + 'Mbps', + 'Gbps', + 'Tbps', + ]; + + $pow = floor((($value['bps'] > 0) ? log($value['bps']) : 0) / log(1024)); + $pow = min($pow, (count($units) - 1)); + + $value['bps'] /= pow(1024, $pow); + + $table->data[$i][4] = round($value['bps'], 2).' '.$units[$pow]; + + $i++; + } + + return html_print_table($table, true); +} + + /** * Show a table with a traffic summary. * @@ -395,6 +461,67 @@ function netflow_is_net($address) } +/** + * Returns netflow top N connections for the given period in an array (based on total traffic). + * + * @param string $start_date Period start date. + * @param string $end_date Period end date. + * @param array $filter Netflow filter. + * @param integer $max Maximum number of aggregates. + * @param string $connection_name Node name when data is get in meta. + * + * @return array An array with netflow stats. + */ +function netflow_get_top_N( + string $start_date, + string $end_date, + array $filter, + int $max, + string $connection_name='' +) { + global $nfdump_date_format; + + // Requesting remote data. + if (is_metaconsole() === true && empty($connection_name) === false) { + $data = metaconsole_call_remote_api( + $connection_name, + 'netflow_get_top_N', + $start_date.'|'.$end_date.'|'.base64_encode(json_encode($filter)).'|'.$max + ); + + return json_decode($data, true); + } + + $options = '-o "fmt:%sap,%dap,%ibyt,%bps" -q -n '.$max.' -s record/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); + + $command = netflow_get_command($options, $filter); + + // Execute nfdump. + exec($command, $lines); + + if (is_array($lines) === false) { + return []; + } + + $values = []; + $i = 0; + + foreach ($lines as $line) { + $parsed_line = explode(',', $line); + $parsed_line = array_map('trim', $parsed_line); + + $values[$i]['ip_src'] = $parsed_line[0]; + $values[$i]['ip_dst'] = $parsed_line[1]; + $values[$i]['bytes'] = $parsed_line[2]; + $values[$i]['bps'] = $parsed_line[3]; + + $i++; + } + + return $values; +} + + /** * Returns netflow data for the given period in an array. * @@ -707,7 +834,7 @@ function netflow_get_summary($start_date, $end_date, $filter, $connection_name=' global $config; // Requesting remote data. - if (defined('METACONSOLE') && $connection_name != '') { + if (is_metaconsole() === true && $connection_name != '') { $data = metaconsole_call_remote_api($connection_name, 'netflow_get_summary', "$start_date|$end_date|".base64_encode(json_encode($filter))); return json_decode($data, true); } @@ -1051,6 +1178,7 @@ function netflow_get_chart_types() 'netflow_area' => __('Area graph'), 'netflow_summary' => __('Summary'), 'netflow_data' => __('Data table'), + 'netflow_top_N' => __('Top-N connections'), 'netflow_mesh' => __('Circular mesh'), 'netflow_host_treemap' => __('Host detailed traffic'), ]; @@ -1218,6 +1346,54 @@ function netflow_draw_item( } break; + case 'netflow_top_N': + $data_summary = netflow_get_summary( + $start_date, + $end_date, + $filter, + $connection_name + ); + + if (empty($data_summary) === true) { + break; + } + + $data_top_n = netflow_get_top_N( + $start_date, + $end_date, + $filter, + $max_aggregates, + $connection_name + ); + + if (empty($data_top_n) === true) { + break; + } + + if ($output === 'HTML' || $output === 'PDF') { + $html = '
"; + $html .= netflow_summary_table($data_summary); + $html .= ' | '; + $html .= '
"; + $html .= netflow_top_n_table($data_top_n, $data_summary['totalbytes']); + $html .= ' | '; + $html .= '