';
- if (!empty($breadcrumbs))
+ if (!empty($breadcrumbs)) {
$buffer .= '
__('Network'),
+ 'id' => 'Network',
+ 'type' => 'direct',
+ 'subtype' => 'nolink',
+ 'refr' => 0,
+ ];
+
+ // Initialize the submenu.
+ $netflow_sub = [];
+
+ if ($config['activate_netflow']) {
+ $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',
+ ],
+ ]
+ );
+ }
+
+ if ($config['activate_nta']) {
+ $netflow_sub = array_merge(
+ $netflow_sub,
+ [
+ 'operation/network/network_explorer' => [
+ 'text' => __('Network explorer'),
+ 'id' => 'Network explorer',
+ ],
+ ]
+ );
+ }
+
+ if ($config['activate_nta'] || $config['activate_netflow']) {
+ $netflow_sub = array_merge(
+ $netflow_sub,
+ [
+ 'operation/network/network_usage_map' => [
+ 'text' => __('Network usage map'),
+ 'id' => 'Network usage map',
+ ],
+ ]
+ );
+ }
+
+ $sub['network']['sub2'] = $netflow_sub;
}
if ($config['log_collector'] == 1) {
enterprise_hook('log_collector_menu');
}
- // End of view agents
+ // End of view agents.
}
-// SNMP Console
+// SNMP Console.
$sub2 = [];
if (check_acl($config['id_user'], 0, 'AR') || check_acl($config['id_user'], 0, 'AW')) {
$sub2['operation/snmpconsole/snmp_view']['text'] = __('SNMP console');
@@ -115,10 +164,10 @@ if (!empty($sub)) {
$menu_operation['estado']['sub'] = $sub;
}
-// Start network view
+// Start network view.
$sub = [];
if (check_acl($config['id_user'], 0, 'MR') || check_acl($config['id_user'], 0, 'MW') || check_acl($config['id_user'], 0, 'MM')) {
- // Network enterprise
+ // Network enterprise.
$sub['operation/agentes/pandora_networkmap']['text'] = __('Network map');
$sub['operation/agentes/pandora_networkmap']['id'] = 'Network map';
$sub['operation/agentes/pandora_networkmap']['refr'] = 0;
@@ -130,17 +179,17 @@ enterprise_hook('services_menu');
if (check_acl($config['id_user'], 0, 'VR') || check_acl($config['id_user'], 0, 'VW') || check_acl($config['id_user'], 0, 'VM')) {
if (!isset($config['vc_favourite_view']) || $config['vc_favourite_view'] == 0) {
- // Visual console
+ // Visual console.
$sub['godmode/reporting/map_builder']['text'] = __('Visual console');
$sub['godmode/reporting/map_builder']['id'] = 'Visual console';
} else {
- // Visual console favorite
+ // Visual console favorite.
$sub['godmode/reporting/visual_console_favorite']['text'] = __('Visual console');
$sub['godmode/reporting/visual_console_favorite']['id'] = 'Visual console';
}
if ($config['vc_menu_items'] != 0) {
- // Set godomode path
+ // Set godomode path.
if (!isset($config['vc_favourite_view']) || $config['vc_favourite_view'] == 0) {
$sub['godmode/reporting/map_builder']['subsecs'] = [
'godmode/reporting/map_builder',
@@ -212,7 +261,7 @@ if (check_acl($config['id_user'], 0, 'VR') || check_acl($config['id_user'], 0, '
if (check_acl($config['id_user'], 0, 'MR') || check_acl($config['id_user'], 0, 'MW') || check_acl($config['id_user'], 0, 'MM')) {
- // INI GIS Maps
+ // INI GIS Maps.
if ($config['activate_gis']) {
$sub['gismaps']['text'] = __('GIS Maps');
$sub['gismaps']['id'] = 'GIS Maps';
@@ -254,7 +303,7 @@ if (check_acl($config['id_user'], 0, 'MR') || check_acl($config['id_user'], 0, '
$sub['gismaps']['sub2'] = $sub2;
}
- // END GIS Maps
+ // END GIS Maps.
}
if (!empty($sub)) {
@@ -265,10 +314,10 @@ if (!empty($sub)) {
$menu_operation['network']['sub'] = $sub;
}
-// End networkview
-// Reports read
+// End networkview.
+// Reports read.
if (check_acl($config['id_user'], 0, 'RR') || check_acl($config['id_user'], 0, 'RW') || check_acl($config['id_user'], 0, 'RM')) {
- // Reporting
+ // Reporting.
$menu_operation['reporting']['text'] = __('Reporting');
$menu_operation['reporting']['sec2'] = 'godmode/reporting/reporting_builder';
$menu_operation['reporting']['id'] = 'oper-reporting';
@@ -278,7 +327,7 @@ if (check_acl($config['id_user'], 0, 'RR') || check_acl($config['id_user'], 0, '
$sub['godmode/reporting/reporting_builder']['text'] = __('Custom reporting');
$sub['godmode/reporting/reporting_builder']['id'] = 'Custom reporting';
- // Set godomode path
+ // Set godomode path.
$sub['godmode/reporting/reporting_builder']['subsecs'] = [
'godmode/reporting/reporting_builder',
'operation/reporting/reporting_viewer',
@@ -287,7 +336,7 @@ if (check_acl($config['id_user'], 0, 'RR') || check_acl($config['id_user'], 0, '
$sub['godmode/reporting/graphs']['text'] = __('Custom graphs');
$sub['godmode/reporting/graphs']['id'] = 'Custom graphs';
- // Set godomode path
+ // Set godomode path.
$sub['godmode/reporting/graphs']['subsecs'] = [
'operation/reporting/graph_viewer',
'godmode/reporting/graph_builder',
@@ -297,15 +346,15 @@ if (check_acl($config['id_user'], 0, 'RR') || check_acl($config['id_user'], 0, '
enterprise_hook('reporting_godmenu');
$menu_operation['reporting']['sub'] = $sub;
- // End reporting
+ // End reporting.
}
-// Events reading
+// Events reading.
if (check_acl($config['id_user'], 0, 'ER')
|| check_acl($config['id_user'], 0, 'EW')
|| check_acl($config['id_user'], 0, 'EM')
) {
- // Events
+ // Events.
$menu_operation['eventos']['text'] = __('Events');
$menu_operation['eventos']['refr'] = 0;
$menu_operation['eventos']['sec2'] = 'operation/events/events';
@@ -318,24 +367,24 @@ if (check_acl($config['id_user'], 0, 'ER')
$sub['operation/events/event_statistics']['text'] = __('Statistics');
$sub['operation/events/event_statistics']['id'] = 'Statistics';
- // If ip doesn't is in list of allowed IP, isn't show this options
+ // If ip doesn't is in list of allowed IP, isn't show this options.
include_once 'include/functions_api.php';
if (isInACL($_SERVER['REMOTE_ADDR'])) {
$pss = get_user_info($config['id_user']);
$hashup = md5($config['id_user'].$pss['password']);
- // RSS
+ // RSS.
$sub['operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0§ion=list&open_filter=0&pure=']['text'] = __('RSS');
$sub['operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0§ion=list&open_filter=0&pure=']['id'] = 'RSS';
$sub['operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0§ion=list&open_filter=0&pure=']['type'] = 'direct';
- // Marquee
+ // Marquee.
$sub['operation/events/events_marquee.php']['text'] = __('Marquee');
$sub['operation/events/events_marquee.php']['id'] = 'Marquee';
$sub['operation/events/events_marquee.php']['type'] = 'direct';
}
- // Sound Events
+ // Sound Events.
$javascript = "javascript: window.open('operation/events/sound_events.php');";
$javascript = 'javascript: alert(111);';
$javascript = 'javascript: openSoundEventWindow();';
@@ -359,31 +408,31 @@ if (check_acl($config['id_user'], 0, 'ER')
$menu_operation['eventos']['sub'] = $sub;
}
-// Workspace
+// Workspace.
$menu_operation['workspace']['text'] = __('Workspace');
$menu_operation['workspace']['sec2'] = 'operation/users/user_edit';
$menu_operation['workspace']['id'] = 'oper-users';
// ANY user can view him/herself !
-// Users
+// Users.
$sub = [];
$sub['operation/users/user_edit']['text'] = __('Edit my user');
$sub['operation/users/user_edit']['id'] = 'Edit my user';
$sub['operation/users/user_edit']['refr'] = 0;
-// Users
+// Users.
$sub['operation/users/user_edit_notifications']['text'] = __('Configure user notifications');
$sub['operation/users/user_edit_notifications']['id'] = 'Configure user notifications';
$sub['operation/users/user_edit_notifications']['refr'] = 0;
// ANY user can chat with other user and dogs.
-// Users
+// Users.
$sub['operation/users/webchat']['text'] = __('WebChat');
$sub['operation/users/webchat']['id'] = 'WebChat';
$sub['operation/users/webchat']['refr'] = 0;
-// Incidents
+// Incidents.
if (check_acl($config['id_user'], 0, 'IR')
|| check_acl($config['id_user'], 0, 'IW')
|| check_acl($config['id_user'], 0, 'IM')
@@ -410,7 +459,7 @@ if (check_acl($config['id_user'], 0, 'IR')
}
-// Messages
+// Messages.
$sub['message_list']['text'] = __('Messages');
$sub['message_list']['id'] = 'Messages';
$sub['message_list']['refr'] = 0;
@@ -427,7 +476,7 @@ $menu_operation['workspace']['sub'] = $sub;
// End Workspace
// Rest of options, all with AR privilege (or should events be with incidents?)
// ~ if (check_acl ($config['id_user'], 0, "AR")) {
-// Extensions menu additions
+// Extensions menu additions.
if (is_array($config['extensions'])) {
$sub = [];
$sub2 = [];
@@ -450,12 +499,12 @@ if (is_array($config['extensions'])) {
}
foreach ($config['extensions'] as $extension) {
- // If no operation_menu is a godmode extension
+ // If no operation_menu is a godmode extension.
if ($extension['operation_menu'] == '') {
continue;
}
- // Check the ACL for this user
+ // Check the ACL for this user.
if (! check_acl($config['id_user'], 0, $extension['operation_menu']['acl'])) {
continue;
}
@@ -469,7 +518,7 @@ if (is_array($config['extensions'])) {
continue;
}
- // Check if was displayed inside other menu
+ // Check if was displayed inside other menu.
if ($extension['operation_menu']['fatherId'] == '') {
if ($extension_menu['name'] == 'Update manager') {
continue;
@@ -480,7 +529,7 @@ if (is_array($config['extensions'])) {
$sub[$extension_menu['sec2']]['refr'] = 0;
} else {
if (array_key_exists('fatherId', $extension_menu)) {
- // Check that extension father ID exists previously on the menu
+ // Check that extension father ID exists previously on the menu.
if ((strlen($extension_menu['fatherId']) > 0)) {
if (array_key_exists('subfatherId', $extension_menu)) {
if ((strlen($extension_menu['subfatherId']) > 0)) {
diff --git a/pandora_console/operation/netflow/netflow_explorer.php b/pandora_console/operation/netflow/netflow_explorer.php
new file mode 100644
index 0000000000..318b6dd5f1
--- /dev/null
+++ b/pandora_console/operation/netflow/netflow_explorer.php
@@ -0,0 +1,42 @@
+ $id]);
- // Decode HTML entities
+ // Decode HTML entities.
$filter_values['advanced_filter'] = io_safe_output($filter_values['advanced_filter']);
@@ -68,12 +75,11 @@ if (is_ajax()) {
return;
}
-// Read filter configuration
+// Read filter configuration.
$filter_id = (int) get_parameter('filter_id', 0);
$filter['id_name'] = get_parameter('name', '');
$filter['id_group'] = (int) get_parameter('assign_group', 0);
$filter['aggregate'] = get_parameter('aggregate', '');
-$filter['output'] = get_parameter('output', 'bytes');
$filter['ip_dst'] = get_parameter('ip_dst', '');
$filter['ip_src'] = get_parameter('ip_src', '');
$filter['dst_port'] = get_parameter('dst_port', '');
@@ -81,30 +87,38 @@ $filter['src_port'] = get_parameter('src_port', '');
$filter['advanced_filter'] = get_parameter('advanced_filter', '');
$filter['router_ip'] = get_parameter('router_ip');
-// Read chart configuration
+// Read chart configuration.
$chart_type = get_parameter('chart_type', 'netflow_area');
-$max_aggregates = (int) get_parameter('max_aggregates', 1);
-$period = (int) get_parameter('period', SECONDS_1DAY);
+$max_aggregates = (int) get_parameter('max_aggregates', 10);
$update_date = (int) get_parameter('update_date', 0);
-$date = get_parameter_post('date', date(DATE_FORMAT, get_system_time()));
-$time = get_parameter_post('time', date(TIME_FORMAT, get_system_time()));
$connection_name = get_parameter('connection_name', '');
-$interval_length = (int) get_parameter('interval_length', 300);
+$interval_length = get_parameter('interval_length', NETFLOW_RES_MEDD);
$address_resolution = (int) get_parameter('address_resolution', $config['netflow_get_ip_hostname']);
$filter_selected = (int) get_parameter('filter_selected', 0);
-// Read buttons
+// Read time values.
+$date = get_parameter_post('date', date(DATE_FORMAT, get_system_time()));
+$time = get_parameter_post('time', date(TIME_FORMAT, get_system_time()));
+$end_date = strtotime($date.' '.$time);
+$is_period = (bool) get_parameter('is_period', false);
+$period = (int) get_parameter('period', SECONDS_1DAY);
+$time_lower = get_parameter('time_lower', date(TIME_FORMAT, ($end_date - $period)));
+$date_lower = get_parameter('date_lower', date(DATE_FORMAT, ($end_date - $period)));
+$start_date = ($is_period) ? ($end_date - $period) : strtotime($date_lower.' '.$time_lower);
+if (!$is_period) {
+ $period = ($end_date - $start_date);
+} else {
+ $time_lower = date(TIME_FORMAT, $start_date);
+ $date_lower = date(DATE_FORMAT, $start_date);
+}
+
+// Read buttons.
$draw = get_parameter('draw_button', '');
$save = get_parameter('save_button', '');
$update = get_parameter('update_button', '');
-
-// Calculate start and end dates
-$end_date = strtotime($date.' '.$time);
-$start_date = ($end_date - $period);
-
if (!is_metaconsole()) {
- // Header
+ // Header.
ui_print_page_header(
__('Netflow live view'),
'images/op_netflow.png',
@@ -118,22 +132,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 = [
@@ -152,9 +151,9 @@ if (!is_metaconsole()) {
ui_meta_print_header(__('Netflow live view'));
}
-// Save user defined filter
+// Save user defined filter.
if ($save != '' && check_acl($config['id_user'], 0, 'AW')) {
- // Save filter args
+ // Save filter args.
$filter['filter_args'] = netflow_get_filter_arguments($filter);
$filter_id = db_process_sql_insert('tnetflow_filter', $filter);
@@ -164,15 +163,14 @@ if ($save != '' && check_acl($config['id_user'], 0, 'AW')) {
} else {
ui_print_success_message(__('Filter created successfully'));
}
-}
-// Update current filter
-else if ($update != '' && check_acl($config['id_user'], 0, 'AW')) {
- // Do not update the filter name and group
+} else if ($update != '' && check_acl($config['id_user'], 0, 'AW')) {
+ // Update current filter.
+ // Do not update the filter name and group.
$filter_copy = $filter;
unset($filter_copy['id_name']);
unset($filter_copy['id_group']);
- // Save filter args
+ // Save filter args.
$filter_copy['filter_args'] = netflow_get_filter_arguments($filter_copy);
$result = db_process_sql_update(
@@ -188,7 +186,7 @@ else if ($update != '' && check_acl($config['id_user'], 0, 'AW')) {
}
-// The filter name will not be needed anymore
+// The filter name will not be needed anymore.
$filter['id_name'] = '';
$netflow_disable_custom_lvfilters = false;
@@ -223,7 +221,7 @@ if (is_metaconsole()) {
}
foreach ($servers as $server) {
- // If connection was good then retrieve all data server
+ // If connection was good then retrieve all data server.
if (metaconsole_load_external_db($server)) {
$connection = true;
} else {
@@ -241,7 +239,7 @@ if (is_metaconsole()) {
}
echo '
';
- echo ''.''.__('Connection').''.' | ';
+ echo ''.__('Connection').' | ';
echo ''.html_print_select(
$list_servers,
'connection_name',
@@ -258,23 +256,59 @@ if (is_metaconsole()) {
echo ' |
';
- echo ''.''.__('Date').''.' | ';
+ $class_not_period = ($is_period) ? 'nf_hidden' : 'nf_display';
+ $class_period = ($is_period) ? 'nf_display' : 'nf_hidden';
+ echo '';
+ echo ''.__('Interval').'';
+ echo ''.__('Start date').'';
+ echo ' | ';
+ echo '';
+ echo html_print_extended_select_for_time('period', $period, '', '', 0, false, true, false, true, $class_period);
+ echo html_print_input_text('date_lower', $date_lower, false, 13, 10, true, false, false, '', $class_not_period);
+ echo html_print_image(
+ 'images/calendar_view_day.png',
+ true,
+ [
+ 'alt' => 'calendar',
+ 'class' => $class_not_period,
+ ]
+ ).html_print_input_text('time_lower', $time_lower, false, 10, 8, true, false, false, '', $class_not_period);
+ echo html_print_checkbox(
+ 'is_period',
+ 1,
+ ($is_period === true) ? 1 : 0,
+ true,
+ false,
+ 'nf_view_click_period(event)'
+ );
+ echo ui_print_help_tip(__('Select this checkbox to write interval instead a date.'), true);
+ echo ' | ';
+
+ echo ''.__('End date').' | ';
echo ''.html_print_input_text('date', $date, false, 13, 10, true).html_print_image(
'images/calendar_view_day.png',
true,
['alt' => 'calendar']
- ).ui_print_help_tip(__('Date format is YY/MM/DD'), true).html_print_input_text('time', $time, false, 10, 8, true).ui_print_help_tip(__('Watch format is hours (24h):minutes:seconds'), true).' | ';
+ ).ui_print_help_tip(__('Date format is YY/MM/DD'), true).html_print_input_text('time', $time, false, 10, 8, true).ui_print_help_tip(__('Watch format is hours (24h):minutes:seconds'), true);
+ echo '';
- echo ''.''.__('Interval').''.' | ';
- echo ''.html_print_select(netflow_get_valid_intervals(), 'period', $period, '', '', 0, true, false, false).' | ';
-
- echo ''.''.__('Resolution').ui_print_help_tip(__('The interval will be divided in chunks the length of the resolution.'), true).''.' | ';
- echo ''.html_print_select(netflow_get_valid_subintervals(), 'interval_length', $interval_length, '', '', 0, true, false, false).' | ';
+ echo ''.__('Resolution').ui_print_help_tip(__('The interval will be divided in chunks the length of the resolution.'), true).' | ';
+ echo ''.html_print_select(
+ netflow_resolution_select_params(),
+ 'interval_length',
+ $interval_length,
+ '',
+ '',
+ 0,
+ true,
+ false,
+ false
+ ).' | ';
echo '
';
echo '
';
- echo ''.''.__('Type').''.' | ';
+ echo ''.__('Type').' | ';
echo ''.html_print_select(
netflow_get_chart_types(),
'chart_type',
@@ -285,7 +319,7 @@ if (is_metaconsole()) {
true
).' | ';
- echo ''.''.__('Max. values').''.' | ';
+ echo ''.__('Max. values').' | ';
$max_values = [
'2' => '2',
'5' => '5',
@@ -299,6 +333,134 @@ if (is_metaconsole()) {
echo ''.html_print_select($max_values, 'max_aggregates', $max_aggregates, '', '', 0, true).''.html_print_image('images/pencil.png', true, ['id' => 'pencil']).'';
echo ' | ';
+ echo ''.__('Aggregate by').''.ui_print_help_icon('aggregate_by', true).' | ';
+ $aggregate_list = [];
+ $aggregate_list = [
+ 'srcip' => __('Src Ip Address'),
+ 'dstip' => __('Dst Ip Address'),
+ 'srcport' => __('Src Port'),
+ 'dstport' => __('Dst Port'),
+ ];
+ echo ''.html_print_select($aggregate_list, 'aggregate', $filter['aggregate'], '', '', 0, true, false, true, '', false).' | ';
+
+ echo '
';
+
+ // Read filter type.
+ if ($filter['advanced_filter'] != '') {
+ $filter_type = 1;
+ } else {
+ $filter_type = 0;
+ }
+
+ echo "
";
+
+ echo "".ui_print_error_message('Define a name for the filter and click on Save as new filter again', '', true).' | ';
+
+ echo '
';
+ echo "
";
+
+ echo ''.__('Name').' | ';
+ echo "".html_print_input_text(
+ 'name',
+ $filter['id_name'],
+ false,
+ 20,
+ 80,
+ true
+ ).' | ';
+ $own_info = get_user_info($config['id_user']);
+ echo ''.__('Group').' | ';
+ echo "".html_print_select_groups($config['id_user'], 'IW', $own_info['is_admin'], 'assign_group', $filter['id_group'], '', '', -1, true, false, false).' | ';
+ echo '
';
+
+ echo '
';
+ echo '';
+ html_print_image(
+ 'images/darrowdown.png',
+ false,
+ [
+ 'onclick' => 'toggleFilters(event)',
+ 'style' => 'cursor: pointer;',
+ 'id' => 'nf-toggle-button',
+ ]
+ );
+ echo __('Advanced');
+ echo ' | ';
+ echo '
';
+
+ echo '
';
+ if ($netflow_disable_custom_lvfilters) {
+ echo ' | ';
+ echo ' | ';
+ } else {
+ echo ''.__('Filter').' | ';
+ echo ''.__('Normal').' '.html_print_radio_button_extended('filter_type', 0, '', $filter_type, false, 'displayNormalFilter();', 'style="margin-right: 40px;"', true).__('Custom').' '.html_print_radio_button_extended('filter_type', 1, '', $filter_type, false, 'displayAdvancedFilter();', 'style="margin-right: 40px;"', true).' | ';
+ }
+
+
+
+ echo ''.__('Load filter').' | ';
+ $user_groups = users_get_groups($config['id_user'], 'AR', $own_info['is_admin'], true);
+ $user_groups[0] = 0;
+ // Add all groups.
+ $sql = 'SELECT *
+ FROM tnetflow_filter
+ WHERE id_group IN ('.implode(',', array_keys($user_groups)).')';
+ echo "".html_print_select_from_sql($sql, 'filter_id', $filter_id, '', __('Select a filter'), 0, true);
+ html_print_input_hidden('filter_selected', $filter_selected, false);
+ echo ' | ';
+ echo '
';
+
+ echo "
";
+ if ($netflow_disable_custom_lvfilters) {
+ echo ' | ';
+ echo ' | ';
+ } else {
+ echo "".__('Dst Ip').ui_print_help_tip(__('Destination IP. A comma separated list of destination ip. If we leave the field blank, will show all ip. Example filter by ip: 25.46.157.214,160.253.135.249'), true).' | ';
+ echo ''.html_print_input_text('ip_dst', $filter['ip_dst'], false, 40, 80, true).' | ';
+ }
+
+ if ($netflow_disable_custom_lvfilters) {
+ echo ' | ';
+ echo ' | ';
+ } else {
+ echo "".__('Src Ip').ui_print_help_tip(__('Source IP. A comma separated list of source ip. If we leave the field blank, will show all ip. Example filter by ip: 25.46.157.214,160.253.135.249'), true).' | ';
+ echo ''.html_print_input_text('ip_src', $filter['ip_src'], false, 40, 80, true).' | ';
+ }
+
+ echo '
';
+
+ echo "
";
+ if ($netflow_disable_custom_lvfilters) {
+ echo ' | ';
+ echo ' | ';
+ } else {
+ echo "".__('Dst Port').ui_print_help_tip(__('Destination port. A comma separated list of destination ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22: 80,22'), true).' | ';
+ echo ''.html_print_input_text('dst_port', $filter['dst_port'], false, 40, 80, true).' | ';
+ }
+
+ if ($netflow_disable_custom_lvfilters) {
+ echo ' | ';
+ echo ' | ';
+ } else {
+ echo "".__('Src Port').ui_print_help_tip(__('Source port. A comma separated list of source ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22: 80,22'), true).' | ';
+ echo ''.html_print_input_text('src_port', $filter['src_port'], false, 40, 80, true).' | ';
+ }
+
+ echo '
';
+
+ echo "
";
+ if ($netflow_disable_custom_lvfilters) {
+ echo ' | ';
+ echo ' | ';
+ } else {
+ echo ''.ui_print_help_icon('pcap_filter', true).' | ';
+ echo "".html_print_textarea('advanced_filter', 4, 40, $filter['advanced_filter'], "style='min-height: 0px; width: 90%;'", true).' | ';
+ }
+
+ echo '
';
+ echo '
';
+
$onclick = "if (!confirm('".__('Warning').'. '.__('IP address resolution can take a lot of time')."')) return false;";
$radio_buttons = __('Yes').' '.html_print_radio_button_extended(
'address_resolution',
@@ -317,141 +479,11 @@ if (is_metaconsole()) {
$address_resolution,
true
);
- echo ''.''.__('IP address resolution').''.ui_print_help_tip(__('Resolve the IP addresses to get their hostnames.'), true).' | ';
- echo "$radio_buttons | ";
+ echo ''.__('IP address resolution').''.ui_print_help_tip(__('Resolve the IP addresses to get their hostnames.'), true).' | ';
+ echo ''.$radio_buttons.' | ';
- echo '
';
-
- // Read filter type
- if ($filter['advanced_filter'] != '') {
- $filter_type = 1;
- } else {
- $filter_type = 0;
- }
-
- echo "
";
-
- echo "".ui_print_error_message('Define a name for the filter and click on Save as new filter again', '', true).' | ';
-
- echo '
';
- echo "
";
-
- echo ''.''.__('Name').''.' | ';
- echo "".html_print_input_text(
- 'name',
- $filter['id_name'],
- false,
- 20,
- 80,
- true
- ).' | ';
- $own_info = get_user_info($config['id_user']);
- echo ''.''.__('Group').''.' | ';
- echo "".html_print_select_groups($config['id_user'], 'IW', $own_info['is_admin'], 'assign_group', $filter['id_group'], '', '', -1, true, false, false).' | ';
-
- echo '
';
- echo '
';
-
- if ($netflow_disable_custom_lvfilters) {
- echo ' | ';
- echo ' | ';
- } else {
- echo ''.''.__('Filter').''.' | ';
- echo ''.__('Normal').' '.html_print_radio_button_extended('filter_type', 0, '', $filter_type, false, 'displayNormalFilter();', 'style="margin-right: 40px;"', true).__('Advanced').' '.html_print_radio_button_extended('filter_type', 1, '', $filter_type, false, 'displayAdvancedFilter();', 'style="margin-right: 40px;"', true).' | ';
- }
-
-
-
- echo ''.''.__('Load filter').''.' | ';
- $user_groups = users_get_groups($config['id_user'], 'AR', $own_info['is_admin'], true);
- $user_groups[0] = 0;
- // Add all groups.
- $sql = 'SELECT *
- FROM tnetflow_filter
- WHERE id_group IN ('.implode(',', array_keys($user_groups)).')';
- echo "".html_print_select_from_sql($sql, 'filter_id', $filter_id, '', __('Select a filter'), 0, true);
- html_print_input_hidden('filter_selected', $filter_selected, false);
- echo ' | ';
- echo '
';
-
-
-
- echo "
";
-
- if ($netflow_disable_custom_lvfilters) {
- echo ' | ';
- echo ' | ';
- } else {
- echo "".__('Dst Ip').ui_print_help_tip(__('Destination IP. A comma separated list of destination ip. If we leave the field blank, will show all ip. Example filter by ip: 25.46.157.214,160.253.135.249'), true).' | ';
- echo ''.html_print_input_text('ip_dst', $filter['ip_dst'], false, 30, 80, true).' | ';
- }
-
- if ($netflow_disable_custom_lvfilters) {
- echo ' | ';
- echo ' | ';
- } else {
- echo "".__('Src Ip').ui_print_help_tip(__('Source IP. A comma separated list of source ip. If we leave the field blank, will show all ip. Example filter by ip: 25.46.157.214,160.253.135.249'), true).' | ';
- echo ''.html_print_input_text('ip_src', $filter['ip_src'], false, 30, 80, true).' | ';
- }
-
- echo '
';
- echo "
";
-
- if ($netflow_disable_custom_lvfilters) {
- echo ' | ';
- echo ' | ';
- } else {
- echo "".__('Dst Port').ui_print_help_tip(__('Destination port. A comma separated list of destination ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22: 80,22'), true).' | ';
- echo ''.html_print_input_text('dst_port', $filter['dst_port'], false, 30, 80, true).' | ';
- }
-
- if ($netflow_disable_custom_lvfilters) {
- echo ' | ';
- echo ' | ';
- } else {
- echo "".__('Src Port').ui_print_help_tip(__('Source port. A comma separated list of source ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22: 80,22'), true).' | ';
- echo ''.html_print_input_text('src_port', $filter['src_port'], false, 30, 80, true).' | ';
- }
-
- echo '
';
- echo "
";
-
- if ($netflow_disable_custom_lvfilters) {
- echo ' | ';
- echo ' | ';
- } else {
- echo ''.ui_print_help_icon('pcap_filter', true).' | ';
- echo "".html_print_textarea('advanced_filter', 4, 40, $filter['advanced_filter'], "style='min-height: 0px; width: 90%;'", true).' | ';
- }
-
- echo '
';
- echo '
';
-
- echo ''.''.__('Aggregate by').''.ui_print_help_icon('aggregate_by', true).' | ';
- $aggregate_list = [];
- $aggregate_list = [
- 'none' => __('None'),
- 'proto' => __('Protocol'),
- 'srcip' => __('Src Ip Address'),
- 'dstip' => __('Dst Ip Address'),
- 'srcport' => __('Src Port'),
- 'dstport' => __('Dst Port'),
- ];
- echo ''.html_print_select($aggregate_list, 'aggregate', $filter['aggregate'], '', '', 0, true, false, true, '', false).' | ';
-
- echo ''.''.__('Router ip').''.' | ';
- echo ''.html_print_input_text('router_ip', $filter['router_ip'], false, 30, 80, true).' | ';
-
- echo ''.''.__('Output format').''.' | ';
- $show_output = [
- 'bytes' => __('Bytes'),
- 'bytespersecond' => __('Bytes per second'),
- 'kilobytes' => __('Kilobytes'),
- 'megabytes' => __('Megabytes'),
- 'kilobytespersecond' => __('Kilobytes per second'),
- 'megabytespersecond' => __('Megabytes per second'),
- ];
- echo ''.html_print_select($show_output, 'output', $filter['output'], '', '', 0, true, false, true, '', false).' | ';
+ echo ''.__('Source ip').' | ';
+ echo ''.html_print_input_text('router_ip', $filter['router_ip'], false, 40, 80, true).' | ';
echo '
';
@@ -473,15 +505,14 @@ if (is_metaconsole()) {
echo '';
if ($draw != '') {
- // Draw
+ // Draw.
echo '
';
- // No filter selected
+ // No filter selected.
if ($netflow_disable_custom_lvfilters && $filter_selected == 0) {
ui_print_error_message(__('No filter selected'));
- }
- // Draw the netflow chart
- else {
+ } else {
+ // Draw the netflow chart.
echo netflow_draw_item(
$start_date,
$end_date,
@@ -569,7 +600,22 @@ if (is_metaconsole()) {
return true;
};
-
+
+ function toggleFilters (event) {
+ // Display or show the items.
+ var is_advanced = $("#radiobtn0001").is(':checked');
+ var class_name = is_advanced ? ".filter_advance" : ".filter_normal";
+ $(".nf_filter").not(class_name).toggle();
+
+ // Change the image.
+ $('#' + event.target.id).attr(
+ 'src',
+ $(".nf_filter").not(class_name).first().is(':visible')
+ ? 'images/darrowup.png'
+ : 'images/darrowdown.png'
+ );
+ }
+
// Display the appropriate filter
var filter_type = ;
if (filter_type == 0) {
@@ -600,7 +646,6 @@ if (is_metaconsole()) {
$("#text-router_ip").val('');
$("#textarea_advanced_filter").val('');
$("#aggregate").val('');
- $("#output").val('');
// Hide update filter button
$("#submit-update_button").hide();
@@ -669,8 +714,6 @@ if (is_metaconsole()) {
$("#textarea_advanced_filter").val(val);
if (i == 'aggregate')
$("#aggregate").val(val);
- if (i == 'output')
- $("#output").val(val);
});
},
"json");
@@ -704,7 +747,7 @@ if (is_metaconsole()) {
});
});
- $("#text-time").timepicker({
+ $("#text-time, #text-time_lower").timepicker({
showSecond: true,
timeFormat: '',
timeOnlyTitle: '',
@@ -715,7 +758,17 @@ if (is_metaconsole()) {
currentText: '',
closeText: ''});
- $("#text-date").datepicker({dateFormat: ""});
+ $("#text-date, #text-date_lower").datepicker({dateFormat: ""});
$.datepicker.regional[""];
+
+ function nf_view_click_period(event) {
+ $(".nf_display").toggle();
+ $(".nf_hidden").toggle();
+ }
+
\ No newline at end of file
diff --git a/pandora_console/operation/network/network_explorer.php b/pandora_console/operation/network/network_explorer.php
new file mode 100644
index 0000000000..ced3706172
--- /dev/null
+++ b/pandora_console/operation/network/network_explorer.php
@@ -0,0 +1,40 @@
+class = 'databox';
+$table->styleTable = 'width: 100%';
+$table->data['0']['0'] = __('Data to show').' ';
+$table->data['0']['0'] .= html_print_select(
+ network_get_report_actions($is_network),
+ 'action',
+ $action,
+ '',
+ '',
+ 0,
+ true
+);
+
+$table->data['0']['1'] = __('Number of result to show').' ';
+$table->data['0']['1'] .= html_print_select(
+ [
+ '5' => 5,
+ '10' => 10,
+ '15' => 15,
+ '20' => 20,
+ '25' => 25,
+ '50' => 50,
+ '100' => 100,
+ '250' => 250,
+ ],
+ 'top',
+ $top,
+ '',
+ '',
+ 0,
+ true
+);
+
+$table->data['0']['2'] = '';
+
+$table->data['1']['0'] = '
';
+$table->data['1']['0'] .= '
';
+$table->data['1']['0'] .= __('Start date').' ';
+$table->data['1']['0'] .= html_print_input_text('date_lower', $date_lower, '', 10, 7, true);
+$table->data['1']['0'] .= ' ';
+$table->data['1']['0'] .= html_print_input_text('time_lower', $time_lower, '', 7, 8, true);
+$table->data['1']['0'] .= '
';
+
+$table->data['1']['0'] .= '
';
+$table->data['1']['0'] .= __('Time Period').' ';
+$table->data['1']['0'] .= html_print_extended_select_for_time('period', $period, '', '', 0, false, true);
+$table->data['1']['0'] .= '
';
+$table->data['1']['0'] .= html_print_checkbox(
+ 'is_period',
+ 1,
+ ($is_period === true) ? 1 : 0,
+ true,
+ false,
+ 'network_report_click_period(event)'
+);
+$table->data['1']['0'] .= ui_print_help_tip(
+ __('Select this checkbox to write interval instead a date.'),
+ true
+);
+$table->data['1']['0'] .= '
';
+
+$table->data['1']['1'] = __('End date').' ';
+$table->data['1']['1'] .= html_print_input_text('date_greater', $date_greater, '', 10, 7, true);
+$table->data['1']['1'] .= ' ';
+$table->data['1']['1'] .= html_print_input_text('time_greater', $time_greater, '', 7, 8, true);
+
+$table->data['1']['2'] = html_print_submit_button(
+ __('Update'),
+ 'update',
+ false,
+ 'class="sub upd"',
+ true
+);
+$table->data['1']['2'] .= ' ';
+$table->data['1']['2'] .= html_print_submit_button(
+ __('Export to CSV'),
+ 'export_csv',
+ false,
+ 'class="sub next"',
+ true
+);
+
+echo '
';
+
+// Print the data.
+$data = [];
+if ($is_network) {
+ $data = network_matrix_get_top(
+ $top,
+ $action === 'talkers',
+ $utimestamp_lower,
+ $utimestamp_greater,
+ $main_value,
+ $order_by !== 'pkts'
+ );
+} else {
+ $data = netflow_get_top_summary(
+ $top,
+ $action,
+ $utimestamp_lower,
+ $utimestamp_greater,
+ $main_value,
+ $order_by
+ );
+}
+
+// Get the params to return the builder.
+$hidden_main_link = [
+ 'time_greater' => $time_greater,
+ 'date_greater' => $date_greater,
+ 'is_period' => $is_period,
+ 'period' => $period,
+ 'time_lower' => $time_lower,
+ 'date_lower' => $date_lower,
+ 'top' => $top,
+ 'action' => $action,
+];
+
+unset($table);
+$table = new stdClass();
+$table->styleTable = 'width: 60%';
+// Print the header.
+$table->head = [];
+$table->head['main'] = __('IP');
+if (!$is_network) {
+ $table->head['flows'] = network_print_explorer_header(
+ __('Flows'),
+ 'flows',
+ $order_by,
+ array_merge(
+ $hidden_main_link,
+ ['main_value' => $main_value]
+ )
+ );
+}
+
+$table->head['pkts'] = network_print_explorer_header(
+ __('Packets'),
+ 'pkts',
+ $order_by,
+ array_merge(
+ $hidden_main_link,
+ ['main_value' => $main_value]
+ )
+);
+$table->head['bytes'] = network_print_explorer_header(
+ __('Bytes'),
+ 'bytes',
+ $order_by,
+ array_merge(
+ $hidden_main_link,
+ ['main_value' => $main_value]
+ )
+);
+
+// Add the order.
+$hidden_main_link['order_by'] = $order_by;
+
+if (get_parameter('export_csv')) {
+ // Clean the buffer.
+ while (ob_get_level()) {
+ ob_end_clean();
+ }
+
+ // Write metadata.
+ header('Content-type: text/csv;');
+ header('Content-Disposition: attachment; filename="network_data.csv"');
+
+ $div = $config['csv_divider'];
+ $nl = "\n";
+
+ // Print the header.
+ echo reset($table->head).$div;
+ if (!$is_network) {
+ echo __('Flows').$div;
+ }
+
+ echo __('Packets').$div;
+ echo __('Bytes').$div;
+ echo $nl;
+
+ // Print the data.
+ foreach ($data as $row) {
+ echo $row['host'].$div;
+ if (isset($row['sum_flows'])) {
+ echo $row['sum_flows'].$div;
+ }
+
+ echo $row['sum_pkts'].$div;
+ echo $row['sum_bytes'].$nl;
+ }
+
+ exit;
+}
+
+// Print the filter remove link.
+if (!empty($main_value)) {
+ echo html_print_link_with_params(
+ in_array($action, ['udp', 'tcp']) ? __('Filtered by port %s. Click here to remove the filter.', $main_value) : __('Filtered by IP %s. Click here to remove the filter.', $main_value),
+ array_merge(
+ $hidden_main_link,
+ [
+ 'main_value' => $main_value,
+ 'remove_filter' => 1,
+ ]
+ )
+ );
+}
+
+// Print the data and build the chart.
+$table->data = [];
+$chart_data = [];
+$hide_filter = !empty($main_value) && ($action === 'udp' || $action === 'tcp');
+foreach ($data as $item) {
+ $row = [];
+ $row['main'] = '
';
+ $row['main'] .= $item['host'];
+ if (!$hide_filter) {
+ $row['main'] .= html_print_link_with_params(
+ 'images/filter.png',
+ array_merge($hidden_main_link, ['main_value' => $item['host']]),
+ 'image'
+ );
+ }
+
+ $row['main'] .= '
';
+ if (!$is_network) {
+ $row['flows'] = format_for_graph($item['sum_flows'], 2);
+ $row['flows'] .= ' ('.$item['pct_flows'].'%)';
+ }
+
+ $row['pkts'] = format_for_graph($item['sum_pkts'], 2);
+ if (!$is_network) {
+ $row['pkts'] .= ' ('.$item['pct_pkts'].'%)';
+ }
+
+ $row['bytes'] = network_format_bytes($item['sum_bytes']);
+ if (!$is_network) {
+ $row['bytes'] .= ' ('.$item['pct_bytes'].'%)';
+ }
+
+ $table->data[] = $row;
+
+ // Build the pie graph data structure.
+ switch ($order_by) {
+ case 'pkts':
+ $chart_data[$item['host']] = $item['sum_bytes'];
+ break;
+
+ case 'flows':
+ $chart_data[$item['host']] = $item['sum_flows'];
+ break;
+
+ case 'bytes':
+ default:
+ $chart_data[$item['host']] = $item['sum_bytes'];
+ break;
+ }
+}
+
+if (empty($data)) {
+ ui_print_info_message(__('No data found'));
+} else {
+ echo '
';
+ html_print_table($table);
+
+ // Print the graph.
+ echo '
';
+ echo pie_graph(
+ $chart_data,
+ 320,
+ 200,
+ __('Others')
+ );
+ echo '
';
+ echo '
';
+}
+
+?>
+
diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php
new file mode 100644
index 0000000000..046cc1fcc4
--- /dev/null
+++ b/pandora_console/operation/network/network_usage_map.php
@@ -0,0 +1,236 @@
+class = 'databox';
+$table->styleTable = 'width: 100%';
+
+$table->data['0']['0'] = '
';
+$table->data['0']['0'] .= '
';
+$table->data['0']['0'] .= __('Start date').' ';
+$table->data['0']['0'] .= html_print_input_text('date_lower', $date_lower, '', 10, 7, true);
+$table->data['0']['0'] .= ' ';
+$table->data['0']['0'] .= html_print_input_text('time_lower', $time_lower, '', 7, 8, true);
+$table->data['0']['0'] .= '
';
+
+$table->data['0']['0'] .= '
';
+$table->data['0']['0'] .= __('Time Period').' ';
+$table->data['0']['0'] .= html_print_extended_select_for_time('period', $period, '', '', 0, false, true);
+$table->data['0']['0'] .= '
';
+$table->data['0']['0'] .= html_print_checkbox(
+ 'is_period',
+ 1,
+ ($is_period === true) ? 1 : 0,
+ true,
+ false,
+ 'network_report_click_period(event)'
+);
+$table->data['0']['0'] .= ui_print_help_tip(
+ __('Select this checkbox to write interval instead a date.'),
+ true
+);
+$table->data['0']['0'] .= '
';
+
+$table->data['0']['1'] = __('End date').' ';
+$table->data['0']['1'] .= html_print_input_text('date_greater', $date_greater, '', 10, 7, true);
+$table->data['0']['1'] .= ' ';
+$table->data['0']['1'] .= html_print_input_text('time_greater', $time_greater, '', 7, 8, true);
+
+$table->data['0']['2'] = __('Number of result to show').' ';
+$table->data['0']['2'] .= html_print_select(
+ [
+ '5' => 5,
+ '10' => 10,
+ '15' => 15,
+ '20' => 20,
+ '25' => 25,
+ '50' => 50,
+ '100' => 100,
+ '250' => 250,
+ ],
+ 'top',
+ $top,
+ '',
+ '',
+ 0,
+ true
+);
+
+
+$table->data['1']['0'] = __('Data to show').' ';
+$table->data['1']['0'] .= html_print_select(
+ network_get_report_actions(),
+ 'action',
+ $action,
+ '',
+ '',
+ 0,
+ true
+);
+$table->data['1']['1'] = '';
+
+$netflow_button = '';
+if ((bool) $config['activate_netflow'] === true) {
+ $netflow_button = html_print_submit_button(
+ __('Show netflow map'),
+ 'update_netflow',
+ false,
+ 'class="sub upd"',
+ true
+ );
+}
+
+$nta_button = '';
+if ((bool) $config['activate_nta'] === true) {
+ $nta_button = html_print_submit_button(
+ __('Show NTA map'),
+ 'update_nta',
+ false,
+ 'class="sub upd"',
+ true
+ );
+}
+
+$table->data['1']['2'] .= implode(
+ ' ',
+ [
+ $netflow_button,
+ $nta_button,
+ ]
+);
+
+echo '
';
+
+$has_data = false;
+$first_load = true;
+if ((bool) get_parameter('update_netflow') === true) {
+ $map_data = netflow_build_map_data(
+ $utimestamp_lower,
+ $utimestamp_greater,
+ $top,
+ ($action === 'talkers') ? 'srcip' : 'dstip'
+ );
+ $has_data = !empty($map_data['nodes']);
+ $first_load = false;
+} else if ((bool) get_parameter('update_nta') === true) {
+ $map_data = network_build_map_data(
+ $utimestamp_lower,
+ $utimestamp_greater,
+ $top,
+ $action === 'talkers'
+ );
+ $has_data = !empty($map_data['nodes']);
+ $first_load = false;
+}
+
+if ($has_data === true) {
+ $map_manager = new NetworkMap($map_data);
+ $map_manager->printMap();
+} else if (!$first_load) {
+ ui_print_info_message(__('No data retrieved'));
+}
+
+?>
+
+
+
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 332eb72629..8eafad0535 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -2,8 +2,8 @@
# Pandora FMS Console
#
%define name pandorafms_console
-%define version 7.0NG.732
-%define release 190327
+%define version 7.0NG.733
+%define release 1
# User and Group under which Apache is running
%define httpd_name httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index ba7fe5cea9..dd16641878 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -2,8 +2,8 @@
# Pandora FMS Console
#
%define name pandorafms_console
-%define version 7.0NG.732
-%define release 190327
+%define version 7.0NG.733
+%define release 1
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2
diff --git a/pandora_console/pandora_console_install b/pandora_console/pandora_console_install
index 1e11c575bf..d81843bc2f 100644
--- a/pandora_console/pandora_console_install
+++ b/pandora_console/pandora_console_install
@@ -9,7 +9,7 @@
# This code is licensed under GPL 2.0 license.
# **********************************************************************
-PI_VERSION="7.0NG.732"
+PI_VERSION="7.0NG.733"
FORCE=0
DESTDIR=""
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index 87a502753b..0ecc9b8f5d 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -3491,6 +3491,20 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` (
PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
+-- -----------------------------------------------------
+-- Table `tnetwork_matrix`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `tnetwork_matrix` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `source` varchar(60) default '',
+ `destination` varchar(60) default '',
+ `utimestamp` bigint(20) default 0,
+ `bytes` int(18) unsigned default 0,
+ `pkts` int(18) unsigned default 0,
+ PRIMARY KEY (`id`),
+ UNIQUE (`source`, `destination`, `utimestamp`)
+) ENGINE = InnoDB DEFAULT CHARSET=utf8 ;
+
-- ---------------------------------------------------------------------
-- Table `user_task`
-- ---------------------------------------------------------------------
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 50ea9711ab..1f6a7162fa 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
package: pandorafms-server
-Version: 7.0NG.732-190327
+Version: 7.0NG.733
Architecture: all
Priority: optional
Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 469e967975..6ac168b436 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/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.732-190327"
+pandora_version="7.0NG.733"
package_cpan=0
package_pandora=1
diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new
index 933613ef82..3dad8a139f 100644
--- a/pandora_server/conf/pandora_server.conf.new
+++ b/pandora_server/conf/pandora_server.conf.new
@@ -1,7 +1,7 @@
#############################################################################
# Pandora FMS Server Parameters
# Pandora FMS, the Flexible Monitoring System.
-# Version 7.0NG.732
+# Version 7.0NG.733
# Licensed under GPL license v2,
# (c) 2003-2017 Artica Soluciones Tecnologicas
# http://www.pandorafms.com
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 2ebdc9068d..fa3e51af4a 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -44,7 +44,7 @@ our @EXPORT = qw(
);
# version: Defines actual version of Pandora Server for this module only
-my $pandora_version = "7.0NG.732";
+my $pandora_version = "7.0NG.733";
my $pandora_build = "190327";
our $VERSION = $pandora_version." ".$pandora_build;
diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm
index 43092c0f40..bc66eb2d72 100644
--- a/pandora_server/lib/PandoraFMS/DataServer.pm
+++ b/pandora_server/lib/PandoraFMS/DataServer.pm
@@ -29,6 +29,8 @@ use XML::Parser::Expat;
use XML::Simple;
use POSIX qw(setsid strftime);
use IO::Uncompress::Unzip;
+use JSON qw(decode_json);
+use MIME::Base64;
# Required for file names with accents
use Encode qw(decode);
@@ -222,6 +224,10 @@ sub data_consumer ($$) {
process_xml_server ($self->getConfig (), $file_name, $xml_data, $self->getDBH ());
} elsif (defined($xml_data->{'connection_source'})) {
enterprise_hook('process_xml_connections', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]);
+ } elsif (defined($xml_data->{'network_matrix'})){
+ process_xml_matrix_network(
+ $self->getConfig(), $xml_data, $self->getDBH()
+ );
} else {
process_xml_data ($self->getConfig (), $file_name, $xml_data, $self->getServerID (), $self->getDBH ());
}
@@ -326,6 +332,7 @@ sub process_xml_data ($$$$$) {
# Get agent id
my $agent_id = get_agent_id ($dbh, $agent_name);
+ my $group_id = 0;
if ($agent_id < 1) {
if ($pa_config->{'autocreate'} == 0) {
logger($pa_config, "ERROR: There is no agent defined with name $agent_name", 3);
@@ -334,7 +341,7 @@ sub process_xml_data ($$$$$) {
# Get OS, group and description
my $os = pandora_get_os ($dbh, $data->{'os_name'});
- my $group_id = $pa_config->{'autocreate_group'};
+ $group_id = $pa_config->{'autocreate_group'};
if (! defined (get_group_name ($dbh, $group_id))) {
if (defined ($data->{'group_id'}) && $data->{'group_id'} ne '') {
$group_id = $data->{'group_id'};
@@ -600,6 +607,9 @@ sub process_xml_data ($$$$$) {
# Process snmptrapd modules
enterprise_hook('process_snmptrap_data', [$pa_config, $data, $server_id, $dbh]);
+ # Process events
+ process_events_dataserver($pa_config, $data, $agent_id, $group_id, $dbh);
+
# Process disovery modules
enterprise_hook('process_discovery_data', [$pa_config, $data, $server_id, $dbh]);
}
@@ -970,5 +980,84 @@ sub unlink_modules {
db_do($dbh, "UPDATE tagente_modulo SET parent_module_id = 0 WHERE id_agente_modulo = ?", $child_id);
}
+##########################################################################
+# Process events in the XML.
+##########################################################################
+sub process_events_dataserver {
+ my ($pa_config, $data, $agent_id, $group_id, $dbh) = @_;
+
+ return unless defined($data->{'events'}->[0]->{'event'});
+
+ foreach my $event (@{$data->{'events'}->[0]->{'event'}}) {
+ next unless defined($event);
+
+ # Try to decode the base64 inside
+ my $event_info;
+ eval {
+ $event_info = decode_json(decode_base64($event));
+ };
+
+ if ($@) {
+ logger($pa_config, "Error processing base64 event data '$event'.", 5);
+ next;
+ }
+ next unless defined($event_info->{'data'});
+
+ pandora_event(
+ $pa_config,
+ $event_info->{'data'},
+ $group_id,
+ $agent_id,
+ defined($event_info->{'severity'}) ? $event_info->{'severity'} : 0,
+ 0,
+ 0,
+ 'system',
+ 0,
+ $dbh
+ );
+ }
+
+ return;
+}
+
+
+##########################################################################
+# Process events in the XML.
+##########################################################################
+sub process_xml_matrix_network {
+ my ($pa_config, $data, $dbh) = @_;
+
+ my $utimestamp = $data->{'network_matrix'}->[0]->{'utimestamp'};
+ my $content = $data->{'network_matrix'}->[0]->{'content'};
+ return unless defined($utimestamp) && defined($content);
+
+ # Try to decode the base64 inside
+ my $matrix_info;
+ eval {
+ $matrix_info = decode_json(decode_base64($content));
+ };
+
+ if ($@) {
+ logger($pa_config, "Error processing base64 matrix data '$content'.", 5);
+ return;
+ }
+ foreach my $source (keys %$matrix_info) {
+ foreach my $destination (keys %{$matrix_info->{$source}}) {
+ my $matrix_single_data = $matrix_info->{$source}->{$destination};
+ $matrix_single_data->{'source'} = $source;
+ $matrix_single_data->{'destination'} = $destination;
+ $matrix_single_data->{'utimestamp'} = $utimestamp;
+ eval {
+ db_process_insert($dbh, 'id', 'tnetwork_matrix', $matrix_single_data);
+ };
+ if ($@) {
+ logger($pa_config, "Error inserted matrix data. Source: $source, destination: $destination, utimestamp: $utimestamp.", 5);
+ }
+ }
+ }
+
+ return;
+}
+
1;
__END__
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 2101c3e895..f7c883ad75 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -31,7 +31,7 @@ use base 'Exporter';
our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
-my $pandora_version = "7.0NG.732";
+my $pandora_version = "7.0NG.733";
my $pandora_build = "190327";
our $VERSION = $pandora_version." ".$pandora_build;
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index ac50fb7e4e..a99d2963a4 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -2,8 +2,8 @@
# Pandora FMS Server
#
%define name pandorafms_server
-%define version 7.0NG.732
-%define release 190327
+%define version 7.0NG.733
+%define release 1
Summary: Pandora FMS Server
Name: %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index ebe2f3afb5..ae7863c306 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -2,8 +2,8 @@
# Pandora FMS Server
#
%define name pandorafms_server
-%define version 7.0NG.732
-%define release 190327
+%define version 7.0NG.733
+%define release 1
Summary: Pandora FMS Server
Name: %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index e38650eeb3..151f0da31c 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -8,7 +8,7 @@
# This code is licensed under GPL 2.0 license.
# **********************************************************************
-PI_VERSION="7.0NG.732"
+PI_VERSION="7.0NG.733"
PI_BUILD="190327"
MODE=$1
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 9a1058b755..c08dd06bab 100644
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -34,7 +34,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
-my $version = "7.0NG.732 PS190327";
+my $version = "7.0NG.733 PS190327";
# Pandora server configuration
my %conf;
@@ -340,7 +340,7 @@ sub pandora_purgedb ($$) {
} else {
my @blacklist_types = ("'SLA_services'", "'custom_graph'", "'sql_graph_vbar'", "'sql_graph_hbar'",
"'sql_graph_pie'", "'database_serialized'", "'sql'", "'inventory'", "'inventory_changes'",
- "'netflow_area'", "'netflow_pie'", "'netflow_data'", "'netflow_statistics'", "'netflow_summary'");
+ "'netflow_area'", "'netflow_data'", "'netflow_summary'");
my $blacklist_types_str = join(',', @blacklist_types);
# Deleted modules
@@ -429,10 +429,17 @@ sub pandora_purgedb ($$) {
WHERE date < CURDATE() - $conf->{'_num_past_special_days'} AND date > '0001-01-01'");
}
}
-
+
# Delete old tgraph_source data
db_do ($dbh,"DELETE FROM tgraph_source WHERE id_graph NOT IN (SELECT id_graph FROM tgraph)");
+ # Delete network traffic old data.
+ log_message ('PURGE', 'Deleting old network matrix data.');
+ if ($conf->{'_delete_old_network_matrix'} > 0) {
+ my $matrix_limit = time() - 86400 * $conf->{'_delete_old_network_matrix'};
+ db_do ($dbh, "DELETE FROM tnetwork_matrix WHERE utimestamp < ?", $matrix_limit);
+ }
+
# Delete old messages
log_message ('PURGE', "Deleting old messages.");
if ($conf->{'_delete_old_messages'} > 0) {
@@ -659,6 +666,7 @@ sub pandora_load_config_pdb ($) {
$conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'");
$conf->{'_inventory_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'inventory_purge'");
$conf->{'_delete_old_messages'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_old_messages'");
+ $conf->{'_delete_old_network_matrix'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_old_network_matrix'");
$conf->{'_enterprise_installed'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'enterprise_installed'");
$conf->{'_metaconsole'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole'");
$conf->{'_metaconsole_events_history'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole_events_history'");
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 59ea5d85b0..5a2154aed2 100644
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
-my $version = "7.0NG.732 PS190327";
+my $version = "7.0NG.733 PS190327";
# save program name for logging
my $progname = basename($0);