From e5eab4ca677240e1d9956e113a740ae39f8de2c1 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 21 Jan 2019 15:12:46 +0100 Subject: [PATCH 01/94] Added events in DataServer processed XML Former-commit-id: db7be33ef7e6e5f58106dfef2cfb042637624f27 --- pandora_server/lib/PandoraFMS/DataServer.pm | 49 ++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 6ff42d34ed..3db55cc8f0 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; # For Reverse Geocoding use LWP::Simple; @@ -321,6 +323,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); @@ -329,7 +332,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'}; @@ -594,6 +597,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); } ########################################################################## @@ -962,5 +968,46 @@ 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'}); + + foreach my $event (@{$data->{'events'}}) { + next unless defined($event->{'event'}) && defined($event->{'event'}->[0]); + my $event_info_encoded = $event->{'event'}->[0]; + + # Try to decode the base64 inside + my $event_info; + eval { + $event_info = decode_json(decode_base64($event_info_encoded)); + }; + + if ($@) { + logger($pa_config, "Error processing base64 event data '$event_info_encoded'.", 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; +} + 1; __END__ From e0180aeebe0ff7021704e4b937f4656c4e4f4ef1 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 21 Jan 2019 17:42:41 +0100 Subject: [PATCH 02/94] Added tnetwork_matrix data structure Former-commit-id: e42bd0f0a78aab5cc9068270269262cfe7465c7b --- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 14 ++++++++++++++ pandora_console/pandoradb.sql | 16 +++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 5dc7cd70c4..d0d17dfb18 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1868,3 +1868,17 @@ CREATE TABLE IF NOT EXISTS `tgis_map_layer_groups` ( FOREIGN KEY (`group_id`) REFERENCES `tgrupo` (`id_grupo`) ON DELETE CASCADE, FOREIGN KEY (`agent_id`) REFERENCES `tagente` (`id_agente`) ON DELETE CASCADE ) 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 ; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 7f8197540b..42d7ea487c 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3377,4 +3377,18 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( `recursion` int(1) unsigned default '0', `group_search` int(10) unsigned default '0', PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file +) 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 ; \ No newline at end of file From c9e11780bbcfb74e02359b10d604b77f6f9be032 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 21 Jan 2019 18:27:31 +0100 Subject: [PATCH 03/94] Added matrix_data XML Former-commit-id: 8b927f2e3fd2c78058d4a736c371e4274c94bc1a --- pandora_server/lib/PandoraFMS/DataServer.pm | 43 +++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 3db55cc8f0..3c925f7fb7 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -219,6 +219,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 ()); } @@ -1009,5 +1013,44 @@ sub process_events_dataserver { 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__ From 1ecd656513f917a8066dff60d5d70184dc47b767 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 22 Jan 2019 12:59:54 +0100 Subject: [PATCH 04/94] Data server can handle several events from a single agent Former-commit-id: 2f47df007eb27cf181b130aac79d35698de67387 --- pandora_server/lib/PandoraFMS/DataServer.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 3c925f7fb7..70b4461040 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -978,20 +978,19 @@ sub unlink_modules { sub process_events_dataserver { my ($pa_config, $data, $agent_id, $group_id, $dbh) = @_; - return unless defined($data->{'events'}); + return unless defined($data->{'events'}->[0]->{'event'}); - foreach my $event (@{$data->{'events'}}) { - next unless defined($event->{'event'}) && defined($event->{'event'}->[0]); - my $event_info_encoded = $event->{'event'}->[0]; + 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_info_encoded)); + $event_info = decode_json(decode_base64($event)); }; if ($@) { - logger($pa_config, "Error processing base64 event data '$event_info_encoded'.", 5); + logger($pa_config, "Error processing base64 event data '$event'.", 5); next; } next unless defined($event_info->{'data'}); From 775ebfe1d232a522871577ccc585acc3a9c4450f Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 29 Jan 2019 11:24:02 +0100 Subject: [PATCH 05/94] Created dummy Network Traffic Top N report Former-commit-id: 7515d84dd40cc5ef9f50a2922e8a8a8fa5049eeb --- .../reporting/reporting_builder.item_editor.php | 10 ++++++++++ .../godmode/reporting/reporting_builder.php | 12 ++++++++++++ pandora_console/include/functions_reports.php | 5 ++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index a929740e39..3e6c005100 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -579,6 +579,11 @@ switch ($action) { $resolution = $item ['top_n']; // Interval resolution $max_values = $item ['top_n_value']; // Max values break; + case 'nt_top_n': + $period = $item['period']; + $description = $item['description']; + $top_n_value = $item ['top_n_value']; + break; } switch ($type) { case 'event_report_agent': @@ -603,6 +608,7 @@ switch ($action) { case 'simple_baseline_graph': case 'event_report_log': case 'increment': + case 'nt_top_n': $label = (isset($style['label'])) ? $style['label'] : ''; break; default: @@ -3466,6 +3472,10 @@ function chooseType() { $("#row_resolution").show(); $("#row_servers").show(); $("#row_historical_db_check").hide(); + case 'nt_top_n': + $("#row_description").show(); + $("#row_period").show(); + $("#row_quantity").show(); break; } switch (type) { diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index ed503f0eae..e222cc7112 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1105,6 +1105,11 @@ switch ($action) { $values['visual_format'] = get_parameter('visual_format'); $good_format = true; break; + case 'nt_top_n': + $values['period'] = get_parameter('period'); + $values['top_n_value'] = get_parameter('quantity'); + $good_format = true; + break; default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('radiobutton_max_min_avg',0); @@ -1288,6 +1293,7 @@ switch ($action) { case 'MTBF': case 'MTTR': case 'simple_baseline_graph': + case 'nt_top_n': if ($label != '') $style['label'] = $label; else @@ -1452,6 +1458,11 @@ switch ($action) { $values['visual_format'] = get_parameter('visual_format'); $good_format = true; break; + case 'nt_top_n': + $values['top_n_value'] = get_parameter('quantity'); + $values['period'] = get_parameter('period'); + $good_format = true; + break; default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('radiobutton_max_min_avg',0); @@ -1648,6 +1659,7 @@ switch ($action) { case 'MTBF': case 'MTTR': case 'simple_baseline_graph': + case 'nt_top_n': if ($label != '') $style['label'] = $label; else diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index b836f534a2..a6d5957519 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -657,7 +657,10 @@ function reports_get_report_types ($template = false, $not_editor = false) { $types['event_report_log'] = array('optgroup' => __('Log'), 'name' => __('Log report')); } - + + $types['nt_top_n'] = array('optgroup' => __('Network traffic'), + 'name' => __('Network Traffic Top N')); + return $types; } ?> From d7b25fa65d4288fc4b99c20da33ee15cbc071ec8 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 29 Jan 2019 15:47:20 +0100 Subject: [PATCH 06/94] Added nt top N HTML report Former-commit-id: b9151e9eb32f6da305cb9b061746ecbe7c8cb763 --- .../include/functions_reporting.php | 38 +++++++++++++ .../include/functions_reporting_html.php | 57 +++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 3209a61492..66988a3658 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -675,6 +675,12 @@ function reporting_make_reporting_data($report = null, $id_report, $content, $pdf); break; + case 'nt_top_n': + $report['contents'][] = reporting_nt_top_n_report( + $report, + $content, + $pdf); + break; } $index_content++; } @@ -10518,4 +10524,36 @@ function reporting_translate_sla_status_for_graph ($status) { ); return $sts[$status]; } + +/** + * Build the required data to build network traffic top N report + * + * @param int Period (time window). + * @param array Information about the item of report. + * @param bool Pdf or not + * + * @return array With report presentation info and report data. + */ +function reporting_nt_top_n_report ($period, $content, $pdf) { + $return['type'] = 'nt_top_n'; + $return['title'] = $content["name"]; + $return["description"] = $content["description"]; + + // Get the data sent and received + $return["data"] = array(); + $start_time = $period['datetime'] - (int)$content['period']; + $sql = "SELECT SUM(bytes) sum_bytes, SUM(pkts) sum_pkts, %s host + FROM tnetwork_matrix + WHERE utimestamp > {$start_time} AND utimestamp < {$period['datetime']} + GROUP BY %s + ORDER BY sum_bytes DESC + LIMIT {$content['top_n_value']}"; + $return["data"]["send"] = db_get_all_rows_sql( + sprintf($sql, "source", "source") + ); + $return["data"]["recv"] = db_get_all_rows_sql( + sprintf($sql, "destination", "destination") + ); + return $return; +} ?> diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 182977207d..9f505844a5 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -319,6 +319,9 @@ function reporting_html_print_report($report, $mini = false, $report_info = 1) { case 'SLA': reporting_html_SLA($table, $item, $mini); break; + case 'nt_top_n': + reporting_html_nt_top_n($table, $item, $mini); + break; case 'SLA_monthly': reporting_enterprise_html_SLA_monthly($table, $item, $mini); break; @@ -3922,4 +3925,58 @@ function reporting_html_planned_downtimes_table ($planned_downtimes) { return $downtimes_table; } +/** + * Print network traffic data into top n tables + * (one for received data and another for sent) + * + * @param stdClass Table class to paint the report + * @param array Associative array with info about + * @param bool Unused + */ +function reporting_html_nt_top_n ($table, $item, $mini) { + // Prepare the table + $table_top = new stdClass(); + $table_top->cellpadding = 0; + $table_top->cellspacing = 0; + $table_top->width = "100%"; + $table_top->class = "databox data"; + $table_top->cellpadding = 0; + $table_top->cellspacing = 0; + $table_top->width = "100%"; + $table_top->class = "databox data"; + $table_top->head['host'] = __('Agent'); + $table_top->head['bytes'] = __('Bytes'); + $table_top->head['pkts'] = __('Packages'); + + // Build the table for sent packages + if (empty($item["data"]["send"])) { + $table->data["send_title"] = "

" . __("No network traffic sent data") . "

"; + } else { + foreach ($item["data"]["send"] as $s_item) { + $table_top->data[] = array( + 'host' => $s_item["host"], + 'bytes' => $s_item["sum_bytes"], + 'pkts' => $s_item["sum_pkts"] + ); + } + $table->data["send"] = html_print_table($table_top, true); + } + + // Reset the table and build the table for received packages + $table_top->data = array(); + if (empty($item["data"]["send"])) { + $table->data["recv_title"] = "

" . __("No network traffic received data") . "

"; + } else { + foreach ($item["data"]["recv"] as $s_item) { + $table_top->data[] = array( + 'host' => $s_item["host"], + 'bytes' => $s_item["sum_bytes"], + 'pkts' => $s_item["sum_pkts"] + ); + } + $table->data["recv_title"] = "

" . __("Network traffic received") . "

"; + $table->data["recv"] = html_print_table($table_top, true); + } +} + ?> From f2cee941c79d5b1f85eae177f4e08d08d99cab92 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 29 Jan 2019 17:45:19 +0100 Subject: [PATCH 07/94] Fixed Network traffic sent title Former-commit-id: 5d23b96119fae2d03f23e47a304d85b902324a89 --- pandora_console/include/functions_reporting.php | 1 + pandora_console/include/functions_reporting_html.php | 1 + 2 files changed, 2 insertions(+) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 66988a3658..ed9b779c76 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -10535,6 +10535,7 @@ function reporting_translate_sla_status_for_graph ($status) { * @return array With report presentation info and report data. */ function reporting_nt_top_n_report ($period, $content, $pdf) { + $return = array(); $return['type'] = 'nt_top_n'; $return['title'] = $content["name"]; $return["description"] = $content["description"]; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 9f505844a5..767e693fa5 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3959,6 +3959,7 @@ function reporting_html_nt_top_n ($table, $item, $mini) { 'pkts' => $s_item["sum_pkts"] ); } + $table->data["send_title"] = "

" . __("Network traffic sent") . "

"; $table->data["send"] = html_print_table($table_top, true); } From 2995c86a70614ce4e31f008914ec921c466879be Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 30 Jan 2019 13:03:16 +0100 Subject: [PATCH 08/94] Added network matrix purge Former-commit-id: a2b5f8b5662685924835a592ba04e750e4650fd9 --- pandora_server/util/pandora_db.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 076991b5ff..a9f81fd79b 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -434,9 +434,14 @@ 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.'); + my $matrix_limit = time() - 86400 * 7; #FIXME It should be configurable. + db_do ($dbh, "DELETE FROM tnetwork_matrix WHERE utimestamp < ?", $matrix_limit); } ############################################################################### From fb9e801bb69f90d94fb3037404adc9f278130f5e Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 30 Jan 2019 18:10:19 +0100 Subject: [PATCH 09/94] Formatted nt top n data (kbs instead bytes and millars separators) Former-commit-id: 9067cad9e04ef8d485d1535b4c6bff4571776c74 --- pandora_console/include/functions_reporting_html.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 767e693fa5..10784120cc 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3945,7 +3945,7 @@ function reporting_html_nt_top_n ($table, $item, $mini) { $table_top->width = "100%"; $table_top->class = "databox data"; $table_top->head['host'] = __('Agent'); - $table_top->head['bytes'] = __('Bytes'); + $table_top->head['bytes'] = __('Kilobytes'); $table_top->head['pkts'] = __('Packages'); // Build the table for sent packages @@ -3955,8 +3955,8 @@ function reporting_html_nt_top_n ($table, $item, $mini) { foreach ($item["data"]["send"] as $s_item) { $table_top->data[] = array( 'host' => $s_item["host"], - 'bytes' => $s_item["sum_bytes"], - 'pkts' => $s_item["sum_pkts"] + 'bytes' => remove_right_zeros(number_format($s_item["sum_bytes"]/1024, $config['graph_precision'])), + 'pkts' => remove_right_zeros(number_format($s_item["sum_pkts"], $config['graph_precision'])) ); } $table->data["send_title"] = "

" . __("Network traffic sent") . "

"; @@ -3971,8 +3971,8 @@ function reporting_html_nt_top_n ($table, $item, $mini) { foreach ($item["data"]["recv"] as $s_item) { $table_top->data[] = array( 'host' => $s_item["host"], - 'bytes' => $s_item["sum_bytes"], - 'pkts' => $s_item["sum_pkts"] + 'bytes' => remove_right_zeros(number_format($s_item["sum_bytes"]/1024, $config['graph_precision'])), + 'pkts' => remove_right_zeros(number_format($s_item["sum_pkts"], $config['graph_precision'])) ); } $table->data["recv_title"] = "

" . __("Network traffic received") . "

"; From 7b5d585f6d34cc541b246765a4dda2a8e93b8345 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 21 Feb 2019 17:52:56 +0100 Subject: [PATCH 10/94] Removed unwanted close php tags Former-commit-id: 4ac23a202dc247304e5b87ff4e723997eab71f57 --- pandora_console/include/functions_reporting_html.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 832a964d3e..1b7f4f1b4d 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -4800,9 +4800,6 @@ function reporting_html_nt_top_n($table, $item, $mini) } -?> - - function reporting_html_planned_downtimes_table($planned_downtimes) { global $config; From 50155dd10bde4c34240b39c59f109a016a0d2aaf Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 21 Feb 2019 18:44:40 +0100 Subject: [PATCH 11/94] Added tnetwork_matrix table Former-commit-id: c933f5c00d68dd459ca15176dbc1a914f2b7ea32 --- pandora_console/extras/mr/24.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandora_console/extras/mr/24.sql b/pandora_console/extras/mr/24.sql index f93d9c6e6e..ef6b48f2ac 100644 --- a/pandora_console/extras/mr/24.sql +++ b/pandora_console/extras/mr/24.sql @@ -2,4 +2,16 @@ START TRANSACTION; ALTER TABLE `treport` ADD COLUMN `orientation` varchar(25) NOT NULL default 'vertical'; +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 ; + + COMMIT; From 2e9322515d2fb0c26e890a4b9336bc40f13215b0 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 22 Feb 2019 08:45:05 +0100 Subject: [PATCH 12/94] Move network matrix mr Former-commit-id: 18227212ce8961c9dae24939fa364c03e6f7dff8 --- pandora_console/extras/mr/24.sql | 12 ------------ pandora_console/extras/mr/25.sql | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 pandora_console/extras/mr/25.sql diff --git a/pandora_console/extras/mr/24.sql b/pandora_console/extras/mr/24.sql index ef6b48f2ac..f93d9c6e6e 100644 --- a/pandora_console/extras/mr/24.sql +++ b/pandora_console/extras/mr/24.sql @@ -2,16 +2,4 @@ START TRANSACTION; ALTER TABLE `treport` ADD COLUMN `orientation` varchar(25) NOT NULL default 'vertical'; -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 ; - - COMMIT; diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql new file mode 100644 index 0000000000..e73ec95785 --- /dev/null +++ b/pandora_console/extras/mr/25.sql @@ -0,0 +1,14 @@ +START TRANSACTION; + +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 ; + +COMMIT; From 287ce78260751a23fc1c628d33f4c3bfc654ff11 Mon Sep 17 00:00:00 2001 From: Fermin Date: Thu, 28 Feb 2019 18:18:20 +0100 Subject: [PATCH 13/94] Move tnetwork_matrix to mr 26 Former-commit-id: 731ffaeb7253345bc83afe645f788e6a130080b4 --- pandora_console/extras/mr/25.sql | 10 ---------- pandora_console/extras/mr/26.sql | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 pandora_console/extras/mr/26.sql diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql index 3f7c6baffb..0809bc486e 100644 --- a/pandora_console/extras/mr/25.sql +++ b/pandora_console/extras/mr/25.sql @@ -1,15 +1,5 @@ START TRANSACTION; -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 ; UPDATE `twidget` SET `unique_name`='example' WHERE `class_name` LIKE 'WelcomeWidget'; INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); diff --git a/pandora_console/extras/mr/26.sql b/pandora_console/extras/mr/26.sql new file mode 100644 index 0000000000..8a50248618 --- /dev/null +++ b/pandora_console/extras/mr/26.sql @@ -0,0 +1,14 @@ +START TRANSACTION; + +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 ; + +COMMIT; \ No newline at end of file From f0a3f4e9d7d22d4335cb49d2197c7633ea2d870c Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 1 Mar 2019 12:39:55 +0100 Subject: [PATCH 14/94] Added configurable purge tnetwork_matrix Former-commit-id: e5869879c2445c15c8332d245ac2dd0d3f8de5d5 --- pandora_console/godmode/setup/performance.php | 13 +++++++++++++ pandora_console/include/functions_config.php | 8 ++++++++ pandora_server/util/pandora_db.pl | 9 ++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 666dd0b21c..4d4281eec5 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -536,6 +536,19 @@ $table->data[] = [ ), ]; + +$table->data[] = [ + __('Max. days before delete old network matrix data'), + html_print_input_text( + 'delete_old_network_matrix', + $config['delete_old_network_matrix'], + '', + 5, + 5, + true + ), +]; + $table_other = new stdClass(); $table_other->width = '100%'; $table_other->class = 'databox filters'; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index ce69858132..48fe74e014 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -752,6 +752,10 @@ function config_update_config() $error_update[] = __('Max. days before delete old messages'); } + if (!config_update_value('delete_old_network_matrix', get_parameter('delete_old_network_matrix'))) { + $error_update[] = __('Max. days before delete old network matrix data'); + } + if (!config_update_value('max_graph_container', get_parameter('max_graph_container'))) { $error_update[] = __('Graph container - Max. Items'); } @@ -1547,6 +1551,10 @@ function config_process_config() config_update_value('delete_old_messages', 21); } + if (!isset($config['delete_old_network_matrix'])) { + config_update_value('delete_old_network_matrix', 10); + } + if (!isset($config['max_graph_container'])) { config_update_value('max_graph_container', 10); } diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index d9c1f7be1b..f19ba32618 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -433,10 +433,12 @@ sub pandora_purgedb ($$) { # 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 + # Delete network traffic old data. log_message ('PURGE', 'Deleting old network matrix data.'); - my $matrix_limit = time() - 86400 * 7; #FIXME It should be configurable. - db_do ($dbh, "DELETE FROM tnetwork_matrix WHERE utimestamp < ?", $matrix_limit); + 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."); @@ -664,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'"); From 3eef1b3dbe09b1af646139bdaa03faade9f80f23 Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 1 Mar 2019 13:26:15 +0100 Subject: [PATCH 15/94] Minor fix Former-commit-id: 5e0e476822261c99c4c6e14d4be3b87880cce4a2 --- pandora_server/util/pandora_db.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index f19ba32618..e8d9d2a72f 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -666,7 +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->{'_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'"); From 3f53541c5edaaaa7effa5389a54c14f5ac44d5b6 Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 1 Mar 2019 13:38:48 +0100 Subject: [PATCH 16/94] Added switch to enable NTA Former-commit-id: 5fc3b47f8f9f92ac643db6a5dbe4fc320ca141f6 --- pandora_console/godmode/setup/setup_general.php | 8 ++++++++ pandora_console/include/functions_config.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 8f07d3d88d..45cf137bba 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -125,6 +125,14 @@ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $table->data[19][1] = html_print_checkbox_switch_extended('activate_netflow', 1, $config['activate_netflow'], $rbt_disabled, '', '', true); +$table->data[21][0] = __('Enable Network Traffic Analyzer'); +$table->data[21][1] = html_print_switch( + [ + 'name' => 'activate_nta', + 'value' => $config['activate_nta'], + ] +); + $zone_name = [ 'Africa' => __('Africa'), diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 48fe74e014..31277f2b13 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -224,6 +224,10 @@ function config_update_config() $error_update[] = __('Enable Netflow'); } + if (!config_update_value('activate_nta', (bool) get_parameter_switch('activate_nta'))) { + $error_update[] = __('Enable Network Traffic Analyzer'); + } + $timezone = (string) get_parameter('timezone'); if ($timezone != '') { if (!config_update_value('timezone', $timezone)) { @@ -1979,6 +1983,10 @@ function config_process_config() config_update_value('activate_netflow', 0); } + if (!isset($config['activate_nta'])) { + config_update_value('activate_nta', 0); + } + if (!isset($config['netflow_path'])) { if ($is_windows) { $default = 'C:\\PandoraFMS\\Pandora_Server\\data_in\\netflow'; From cbb4f971a2f3319134e564323f3ac43cac016492 Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 1 Mar 2019 14:23:10 +0100 Subject: [PATCH 17/94] Added new network menus Former-commit-id: 885f092dbfcc561cca5bf1bf8c3ba8497d94ffc4 --- pandora_console/operation/menu.php | 53 +++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index bf81ae5110..409566a8c9 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -65,10 +65,55 @@ if (check_acl($config['id_user'], 0, 'AR')) { enterprise_hook('inventory_menu'); - if ($config['activate_netflow']) { - $sub['operation/netflow/nf_live_view']['text'] = __('Netflow Live View'); - $sub['operation/netflow/nf_live_view']['id'] = 'Netflow Live View'; - $sub['operation/netflow/nf_live_view']['refr'] = 0; + if ($config['activate_netflow'] || $config['activate_nta']) { + $sub['network'] = [ + 'text' => __('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/network_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', + ], + 'operation/network/network_usage_map' => [ + 'text' => __('Network usage map'), + 'id' => 'Network usage map', + ], + 'operation/network/network_dashboard' => [ + 'text' => __('Network dashboard'), + 'id' => 'Network dashboard', + ], + ] + ); + } + + $sub['network']['sub2'] = $netflow_sub; } if ($config['log_collector'] == 1) { From 568d187902d36f3515fd97aaca6311dbc14f50d5 Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 1 Mar 2019 14:26:59 +0100 Subject: [PATCH 18/94] Style fix Former-commit-id: d7d8ba5bdc7269496adf6a1caa2ffa0631102cd5 --- pandora_console/operation/menu.php | 70 +++++++++++++++--------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 409566a8c9..e2c40a820e 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -23,7 +23,7 @@ enterprise_include('operation/menu.php'); $menu_operation = []; $menu_operation['class'] = 'operation'; -// Agent read, Server read +// Agent read, Server read. if (check_acl($config['id_user'], 0, 'AR')) { // View agents $menu_operation['estado']['text'] = __('Monitoring'); @@ -120,10 +120,10 @@ if (check_acl($config['id_user'], 0, 'AR')) { 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'); @@ -160,10 +160,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; @@ -175,17 +175,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', @@ -257,7 +257,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'; @@ -299,7 +299,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)) { @@ -310,10 +310,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'; @@ -323,7 +323,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', @@ -332,7 +332,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', @@ -341,16 +341,16 @@ if (check_acl($config['id_user'], 0, 'RR') || check_acl($config['id_user'], 0, ' enterprise_hook('dashboard_menu'); enterprise_hook('reporting_godmenu'); - $menu_operation['reporting']['sub'] = $sub; - // End reporting + $menu_operation['repo.rting']['sub'] = $sub; + // 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'; @@ -363,29 +363,29 @@ 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'; } - // CSV + // CSV. $sub['operation/events/export_csv.php?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'] = __('CSV File'); $sub['operation/events/export_csv.php?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'] = 'CSV File'; $sub['operation/events/export_csv.php?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'; - // Sound Events + // Sound Events. $javascript = "javascript: window.open('operation/events/sound_events.php');"; $javascript = 'javascript: alert(111);'; $javascript = 'javascript: openSoundEventWindow();'; @@ -409,31 +409,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') @@ -460,7 +460,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; @@ -477,7 +477,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 = []; @@ -500,12 +500,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; } @@ -519,7 +519,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; @@ -530,7 +530,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)) { From b11fd8759221440e077ca8ef09d1f52a2e928e72 Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 1 Mar 2019 14:51:13 +0100 Subject: [PATCH 19/94] Added network explorer view Former-commit-id: c34056a1cc0e2b700df8873a0b589d5bbfe36165 --- .../operation/network/network_explorer.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pandora_console/operation/network/network_explorer.php diff --git a/pandora_console/operation/network/network_explorer.php b/pandora_console/operation/network/network_explorer.php new file mode 100644 index 0000000000..af178146f0 --- /dev/null +++ b/pandora_console/operation/network/network_explorer.php @@ -0,0 +1,21 @@ + Date: Mon, 4 Mar 2019 12:43:31 +0100 Subject: [PATCH 20/94] Moved report nt_top_n requesting data to functions_network Former-commit-id: a117a63c1b23c0104ffadb2741d049f02a81d6d4 --- pandora_console/include/functions_network.php | 54 +++++++++++++++++++ .../include/functions_reporting.php | 21 ++++---- 2 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 pandora_console/include/functions_network.php diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php new file mode 100644 index 0000000000..a2bd62fcee --- /dev/null +++ b/pandora_console/include/functions_network.php @@ -0,0 +1,54 @@ + %d AND utimestamp < %d + GROUP BY %s + ORDER BY sum_bytes DESC + LIMIT %d', + $field_to_group, + $start, + $end, + $field_to_group, + $top + ); + + $data = db_get_all_rows_sql($sql); + + return ($data !== false) ? $data : []; +} diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index bfc065e124..5d21e3e02a 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -36,6 +36,7 @@ require_once $config['homedir'].'/include/functions_forecast.php'; require_once $config['homedir'].'/include/functions_ui.php'; require_once $config['homedir'].'/include/functions_netflow.php'; require_once $config['homedir'].'/include/functions_os.php'; +require_once $config['homedir'].'/include/functions_network.php'; // // CONSTANTS DEFINITIONS // @@ -11385,17 +11386,17 @@ function reporting_nt_top_n_report($period, $content, $pdf) // Get the data sent and received $return['data'] = []; $start_time = ($period['datetime'] - (int) $content['period']); - $sql = "SELECT SUM(bytes) sum_bytes, SUM(pkts) sum_pkts, %s host - FROM tnetwork_matrix - WHERE utimestamp > {$start_time} AND utimestamp < {$period['datetime']} - GROUP BY %s - ORDER BY sum_bytes DESC - LIMIT {$content['top_n_value']}"; - $return['data']['send'] = db_get_all_rows_sql( - sprintf($sql, 'source', 'source') + $return['data']['send'] = network_matrix_get_top( + $content['top_n_value'], + true, + $start_time, + $period['datetime'] ); - $return['data']['recv'] = db_get_all_rows_sql( - sprintf($sql, 'destination', 'destination') + $return['data']['recv'] = network_matrix_get_top( + $content['top_n_value'], + false, + $start_time, + $period['datetime'] ); return $return; } From 8480572e5afce8eca6ae44fab6e487b9c9463e2c Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 4 Mar 2019 16:29:08 +0100 Subject: [PATCH 21/94] Added network explorer report filter Former-commit-id: f50d86b3ba226cc8068b3eae0fb5c72f4d30dd0b --- pandora_console/include/functions_network.php | 28 ++++ .../operation/network/network_explorer.php | 7 +- .../operation/network/network_report.php | 158 ++++++++++++++++++ 3 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 pandora_console/operation/network/network_report.php diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index a2bd62fcee..dbdb24a050 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -52,3 +52,31 @@ function network_matrix_get_top($top, $talker, $start, $end) return ($data !== false) ? $data : []; } + + +/** + * Get the possible actions on networking. + * + * @param boolean $network True if network. False if netflow. + * + * @return array With the actions to print in a select. + */ +function network_get_report_actions($network) +{ + $common_actions = [ + 'listeners' => __('Top listeners'), + 'talkers' => __('Top talkers'), + ]; + + if ($network) { + return $common_actions; + } + + return array_merge( + $common_actions, + [ + 'tcp' => __('Top TCP protocols'), + 'udp' => __('Top UDP protocols'), + ] + ); +} diff --git a/pandora_console/operation/network/network_explorer.php b/pandora_console/operation/network/network_explorer.php index af178146f0..921629107c 100644 --- a/pandora_console/operation/network/network_explorer.php +++ b/pandora_console/operation/network/network_explorer.php @@ -18,4 +18,9 @@ * GNU General Public License for more details. */ -// TODOS. +global $config; + +$action = get_parameter('action', 'listeners'); +$is_network = true; + +require $config['homedir'].'/operation/network/network_report.php'; diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php new file mode 100644 index 0000000000..423d82e320 --- /dev/null +++ b/pandora_console/operation/network/network_report.php @@ -0,0 +1,158 @@ +class = 'databox'; +$table->styleTable = 'width: 100%'; +$table->style[0] = 'width: 40%'; +$table->style[1] = 'width: 40%'; +$table->style[2] = 'width: 20%'; +$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'] = __('Select period').'  '; +$table->data['0']['2'] .= html_print_checkbox( + 'is_period', + 1, + ($is_period === true) ? 1 : 0, + true, + false, + 'network_report_click_period(event)' +); + +$table->data['1']['0'] = __('Start date').'  '; +$table->data['1']['0'] .= html_print_input_text('date_greater', $date_greater, '', 10, 7, true); +$table->data['1']['0'] .= '  '; +$table->data['1']['0'] .= html_print_input_text('time_greater', $time_greater, '', 7, 8, true); + +$table->data['1']['1'] = '
'; +$table->data['1']['1'] .= __('End date').'  '; +$table->data['1']['1'] .= html_print_input_text('date_lower', $date_lower, '', 10, 7, true, $is_period); +$table->data['1']['1'] .= '  '; +$table->data['1']['1'] .= html_print_input_text('time_lower', $time_lower, '', 7, 8, true, $is_period); +$table->data['1']['1'] .= '
'; + +$table->data['1']['1'] .= '
'; +$table->data['1']['1'] .= __('Time Period').'  '; +$table->data['1']['1'] .= html_print_input_text('period', $period, '', 7, 8, true, !$is_period); +$table->data['1']['1'] .= '
'; + +$table->data['1']['2'] = html_print_submit_button( + __('Update'), + 'update', + false, + 'class="sub upd"', + true +); + +echo '
'; +html_print_table($table); +echo '
'; + +?> + From 32f14e8fe4215da58c86b446457bc39a0eb4da5a Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 4 Mar 2019 16:31:59 +0100 Subject: [PATCH 22/94] Added header to network explorer Former-commit-id: ba49f7cb158affc89d006c77f64a1448c7da178e --- pandora_console/operation/network/network_explorer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/operation/network/network_explorer.php b/pandora_console/operation/network/network_explorer.php index 921629107c..0608d55e2b 100644 --- a/pandora_console/operation/network/network_explorer.php +++ b/pandora_console/operation/network/network_explorer.php @@ -23,4 +23,6 @@ global $config; $action = get_parameter('action', 'listeners'); $is_network = true; +ui_print_page_header(__('Network explorer')); + require $config['homedir'].'/operation/network/network_report.php'; From c95b057c14a727f63ab5da296f4d0cec449b59c1 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 4 Mar 2019 17:03:10 +0100 Subject: [PATCH 23/94] Added simple table on network explorer Former-commit-id: 9f2cdc58d7fc1f0375e6945c087aafbd521bacc9 --- .../operation/network/network_explorer.php | 12 ++++++ .../operation/network/network_report.php | 39 ++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/pandora_console/operation/network/network_explorer.php b/pandora_console/operation/network/network_explorer.php index 0608d55e2b..ced3706172 100644 --- a/pandora_console/operation/network/network_explorer.php +++ b/pandora_console/operation/network/network_explorer.php @@ -20,6 +20,18 @@ global $config; +check_login(); + +// ACL Check. +if (! check_acl($config['id_user'], 0, 'AR')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access Network explorer' + ); + include 'general/noaccess.php'; + exit; +} + $action = get_parameter('action', 'listeners'); $is_network = true; diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 423d82e320..0509a62ea1 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -24,7 +24,7 @@ check_login(); if (! check_acl($config['id_user'], 0, 'AR')) { db_pandora_audit( 'ACL Violation', - 'Trying to access Network report (Grouped)' + 'Trying to access Network report.' ); include 'general/noaccess.php'; exit; @@ -46,7 +46,7 @@ if (!$is_period) { $period = ($utimestamp_greater - $utimestamp_lower); } -$top = get_parameter('top', 10); +$top = (int) get_parameter('top', 10); $style_end = ($is_period) ? 'display: none;' : ''; $style_period = ($is_period) ? '' : 'display: none;'; @@ -127,6 +127,41 @@ echo '
'; html_print_table($table); echo '
'; +// Print the data. +$data = []; +if ($is_network) { + $data = network_matrix_get_top( + $top, + $action === 'talkers', + $utimestamp_lower, + $utimestamp_greater + ); +} + +unset($table); +$table = new stdClass(); +// Print the header. +$table->head = []; +$table->head[] = __('IP'); +if (!$is_network) { + $table->head[] = __('Flows'); +} + +$table->head[] = __('Packets'); +$table->head[] = __('Bytes'); + +// Print the data. +$table->data = []; +foreach ($data as $item) { + $table->data[] = [ + $item['host'], + $item['sum_bytes'], + $item['sum_pkts'], + ]; +} + +html_print_table($table); + ?> From 2e65301aceb840ca01d8815f2bda389bc67bbd2e Mon Sep 17 00:00:00 2001 From: Fermin Date: Tue, 5 Mar 2019 18:14:38 +0100 Subject: [PATCH 30/94] Make IP filter permanent and added a remove button Former-commit-id: f36766f60881edd7825c7aa992c832f8b74cda38 --- .../operation/network/network_report.php | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 7c3184d735..7dfd5b0b56 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -47,7 +47,7 @@ if (!$is_period) { } $top = (int) get_parameter('top', 10); -$main_value = get_parameter('main_value', ''); +$main_value = ((bool) get_parameter('remove_filter', 0)) ? '' : get_parameter('main_value', ''); $style_end = ($is_period) ? 'display: none;' : ''; $style_period = ($is_period) ? '' : 'display: none;'; @@ -130,6 +130,10 @@ $table->data['1']['2'] .= html_print_submit_button( ); echo '
'; +if (!empty($main_value)) { + html_print_input_hidden('main_value', $main_value); +} + html_print_table($table); echo '
'; @@ -169,8 +173,6 @@ $hidden_main_link = [ 'top' => $top, ]; - - if (get_parameter('export_csv')) { // Clean the buffer. while (ob_get_level()) { @@ -201,6 +203,20 @@ if (get_parameter('export_csv')) { exit; } +// Print the filter remove link. +if (!empty($main_value)) { + echo html_print_link_with_params( + __('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 = []; From ccb8078a5ad686d92736d51c4df1a6dc41ccd989 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 6 Mar 2019 13:31:55 +0100 Subject: [PATCH 31/94] Added listeners and talkers netflow explorer Former-commit-id: aabd4c468ae9163a89447da170861a5ab1dcc2a0 --- pandora_console/include/functions_netflow.php | 88 +++++++++++++++++++ pandora_console/operation/menu.php | 2 +- .../operation/netflow/netflow_explorer.php | 40 +++++++++ .../operation/network/network_report.php | 12 +++ 4 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 pandora_console/operation/netflow/netflow_explorer.php diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 84f3c26169..a5578e42d8 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1866,3 +1866,91 @@ function netflow_check_nfdump_binary($nfdump_binary) return 2; } + + +/** + * Get the netflow datas to build a netflow explorer data structure. + * + * @param integer $max Number of result displayed. + * @param string $top_action Action to do (listeners,talkers,tcp or udp). + * @param integer $start_date In utimestamp. + * @param integer $end_date In utimestamp. + * @param string $filter Ip to filter. + * + * @return array With data (host, sum_bytes, sum_pkts and sum_flows). + */ +function netflow_get_top_summary( + $max, + $top_action, + $start_date, + $end_date, + $filter='' +) { + global $nfdump_date_format; + $netflow_filter = []; + $sort = ''; + switch ($top_action) { + case 'listeners': + if (empty(!$filter)) { + $netflow_filter['ip_src'] = $filter; + } + + $sort = 'dstip'; + break; + + case 'talkers': + if (empty(!$filter)) { + $netflow_filter['ip_dst'] = $filter; + } + + $sort = 'srcip'; + break; + + case 'tcp': + // Todo. + break; + + case 'udp': + // Todo. + break; + + default: + return []; + } + + $command = netflow_get_command($netflow_filter); + + // Execute nfdump. + $command .= " -q -o csv -n $max -s $sort/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); + exec($command, $result); + + if (! is_array($result)) { + return []; + } + + // Remove first line (avoiding slow array_shift). + $result = array_reverse($result); + array_pop($result); + $result = array_reverse($result); + + $top_info = []; + foreach ($result as $line) { + if (empty($line)) { + continue; + } + + $data = explode(',', $line); + if (!isset($data[9])) { + continue; + } + + $top_info[$data[4]] = [ + 'host' => $data[4], + 'sum_bytes' => $data[9], + 'sum_pkts' => $data[7], + 'sum_flows' => $data[5], + ]; + } + + return $top_info; +} diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index e2c40a820e..281faf4c9a 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -81,7 +81,7 @@ if (check_acl($config['id_user'], 0, 'AR')) { $netflow_sub = array_merge( $netflow_sub, [ - 'operation/netflow/network_explorer' => [ + 'operation/netflow/netflow_explorer' => [ 'text' => __('Netflow explorer'), 'id' => 'Netflow explorer', ], diff --git a/pandora_console/operation/netflow/netflow_explorer.php b/pandora_console/operation/netflow/netflow_explorer.php new file mode 100644 index 0000000000..cbb76aa289 --- /dev/null +++ b/pandora_console/operation/netflow/netflow_explorer.php @@ -0,0 +1,40 @@ + $item['host']]) ); + if (!$is_network) { + $row['flows'] = format_for_graph($item['sum_flows'], 2); + } + $row['pkts'] = format_for_graph($item['sum_pkts'], 2); $row['bytes'] = format_for_graph( $item['sum_bytes'], From de35de6689529867d5f8ce8107c050e64577de4d Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 6 Mar 2019 13:36:28 +0100 Subject: [PATCH 32/94] Added flows to CSV Former-commit-id: 2cff3714b1502c3abcb36ec20e5a2fc354242a8b --- pandora_console/operation/network/network_report.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 390d287c88..25e8d22efa 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -204,6 +204,10 @@ if (get_parameter('export_csv')) { // 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; } From 962284f8c54304d748bf4b02690384786aa21b73 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 6 Mar 2019 13:41:13 +0100 Subject: [PATCH 33/94] Added action to hidden params en network explorer Former-commit-id: e87bab9db0bb00a0b13f2bb6e0cc58a000b18c17 --- pandora_console/operation/network/network_report.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 25e8d22efa..3d50db320d 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -179,6 +179,7 @@ $hidden_main_link = [ 'time_lower' => $time_lower, 'date_lower' => $date_lower, 'top' => $top, + 'action' => $action, ]; if (get_parameter('export_csv')) { From 1abe88c375eeef86ecfe9ffd6a0249aff89985bd Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 7 Mar 2019 13:38:03 +0100 Subject: [PATCH 34/94] Show post in first step in netflow explorer Former-commit-id: 21263d2d4ce0e9f5249156345c837f90b5227381 --- pandora_console/include/functions_netflow.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index a5578e42d8..2c13a33f4d 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1907,11 +1907,19 @@ function netflow_get_top_summary( break; case 'tcp': - // Todo. - break; - case 'udp': - // Todo. + $netflow_filter['proto'] = $top_action; + $sort = 'port'; + if (empty(!$filter)) { + $netflow_filter['advanced_filter'] = sprintf( + '((dst port %s) or (src port %s)) and (proto %s)', + $filter, + $filter, + $top_action + ); + // Display ips when filter is set in port. + $sort = 'ip'; + } break; default: From 76422928e8a5b51046dca39cbf7d1ac27e820036 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 7 Mar 2019 14:01:50 +0100 Subject: [PATCH 35/94] Added version check on netflow explorer Former-commit-id: 2786b7a6c0282920d11808e77a2f66fc549d01e9 --- pandora_console/include/functions_netflow.php | 29 +++++++++++++++++++ .../operation/netflow/netflow_explorer.php | 4 ++- .../operation/netflow/nf_live_view.php | 17 +---------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 2c13a33f4d..0596112491 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -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; + } +} diff --git a/pandora_console/operation/netflow/netflow_explorer.php b/pandora_console/operation/netflow/netflow_explorer.php index cbb76aa289..318b6dd5f1 100644 --- a/pandora_console/operation/netflow/netflow_explorer.php +++ b/pandora_console/operation/netflow/netflow_explorer.php @@ -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'; +} diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 62a52d3e77..261747e2f3 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -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 = [ From 1fa4ef45555020bd3902184b21f51a63cf8506a9 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 7 Mar 2019 14:04:29 +0100 Subject: [PATCH 36/94] Change start date by end date and vice versa Former-commit-id: 193fff3013e21d8fc812bd8c6092bbf203fb104e --- pandora_console/operation/network/network_report.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 3d50db320d..8e240f2d18 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -96,13 +96,13 @@ $table->data['0']['2'] .= html_print_checkbox( 'network_report_click_period(event)' ); -$table->data['1']['0'] = __('Start date').'  '; +$table->data['1']['0'] = __('End date').'  '; $table->data['1']['0'] .= html_print_input_text('date_greater', $date_greater, '', 10, 7, true); $table->data['1']['0'] .= '  '; $table->data['1']['0'] .= html_print_input_text('time_greater', $time_greater, '', 7, 8, true); $table->data['1']['1'] = '
'; -$table->data['1']['1'] .= __('End date').'  '; +$table->data['1']['1'] .= __('Start date').'  '; $table->data['1']['1'] .= html_print_input_text('date_lower', $date_lower, '', 10, 7, true); $table->data['1']['1'] .= '  '; $table->data['1']['1'] .= html_print_input_text('time_lower', $time_lower, '', 7, 8, true); From 1f89cccbbeac6dfb355d1510a59ded2f378f69c8 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 7 Mar 2019 15:10:38 +0100 Subject: [PATCH 37/94] Change item link filter by image filter in network/flow explorer Former-commit-id: 521cca18646273361711e75ad85f64a9b9988046 --- pandora_console/include/functions_html.php | 68 ++++++++++++------- pandora_console/include/styles/pandora.css | 5 ++ .../operation/network/network_report.php | 16 +++-- 3 files changed, 61 insertions(+), 28 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index e88b90f351..4b7eebcf87 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2392,12 +2392,21 @@ function html_print_checkbox_switch($name, $value, $checked=false, $return=false /** * Prints an image HTML element. * - * @param string $src Image source filename. - * @param boolean $return Whether to return or print - * @param array $options Array with optional HTML options to set. At this moment, the - * following options are supported: alt, style, title, width, height, class, pos_tree. - * @param boolean $return_src Whether to return src field of image ('images/*.*') or complete html img tag ('...'). - * @param boolean $relative Whether to use relative path to image or not (i.e. $relative= true : /pandora/). + * @param string $src Image source filename. + * @param boolean $return Whether to return or print. + * @param array $options Array with optional HTML options to set. + * At this moment, the following options are supported: + * align, border, hspace, ismap, vspace, style, title, height, + * longdesc, usemap, width, id, class, lang, xml:lang, onclick, + * ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, + * onmouseout, onkeypress, onkeydown, onkeyup, pos_tree, alt. + * @param boolean $return_src Whether to return src field of image + * ('images/*.*') or complete html img tag ('...'). + * @param boolean $relative Whether to use relative path to image or not + * (i.e. $relative= true : /pandora/). + * @param boolean $no_in_meta Do not show on metaconsole folder at first. Go + * directly to the node. + * @param boolean $isExternalLink Do not shearch for images in Pandora. * * @return string HTML code if return parameter is true. */ @@ -2412,9 +2421,9 @@ function html_print_image( ) { global $config; - // If metaconsole is in use then don't use skins + // If metaconsole is in use then don't use skins. if (!is_metaconsole()) { - // Checks if user's skin is available + // Checks if user's skin is available. $isFunctionSkins = enterprise_include_once('include/functions_skins.php'); if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { @@ -2426,11 +2435,11 @@ function html_print_image( } } - // If metaconsole is activated and image doesn't exists try to search on normal console + // If metaconsole is activated and image doesn't exists try to search on normal console. if (is_metaconsole()) { if (!$relative) { $working_dir = str_replace('\\', '/', getcwd()); - // Windows compatibility + // Windows compatibility. if ($no_in_meta) { $src = '../../'.$src; } else if (strstr($working_dir, 'enterprise/meta') === false) { @@ -2468,22 +2477,22 @@ function html_print_image( } } - // Only return src field of image + // Only return src field of image. if ($return_src) { if (!$return) { echo io_safe_input($src); - return; + return null; } return io_safe_input($src); } $output = ' $value) { $html .= html_print_input_hidden($param, $value, true); } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index cd648787bc..49b464481a 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4172,6 +4172,11 @@ form ul.form_flex li ul li { text-align: center; } +.div-v-centered { + display: flex; + align-items: center; +} + .pandora_upper { text-transform: uppercase; } diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 8e240f2d18..66d3ce1b2a 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -233,12 +233,20 @@ if (!empty($main_value)) { // 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'] = html_print_link_with_params( - $item['host'], - array_merge($hidden_main_link, ['main_value' => $item['host']]) - ); + $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); } From aecbdabbe0d4fc41a4125fda85a932fe5af6918d Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 7 Mar 2019 15:15:16 +0100 Subject: [PATCH 38/94] Change period by a module interval input Former-commit-id: 9f1b25e803d62a6ab501ba701083fd823a14bd64 --- pandora_console/operation/network/network_report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 66d3ce1b2a..d2b95ff3f8 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -110,7 +110,7 @@ $table->data['1']['1'] .= '
'; $table->data['1']['1'] .= '
'; $table->data['1']['1'] .= __('Time Period').'  '; -$table->data['1']['1'] .= html_print_input_text('period', $period, '', 7, 8, true); +$table->data['1']['1'] .= html_print_extended_select_for_time('period', $period, '', '', 0, false, true); $table->data['1']['1'] .= '
'; $table->data['1']['2'] = html_print_submit_button( From a191823d8309dc7638f1b010dbc215da27f3eada Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 7 Mar 2019 17:25:18 +0100 Subject: [PATCH 39/94] Added pct to netflow explorer datas Former-commit-id: 63907ccffb70dd2b2fc98cee065b2100d827ed2a --- pandora_console/include/functions_netflow.php | 10 +++++++++- pandora_console/operation/network/network_report.php | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 0596112491..04b10b4712 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1929,7 +1929,7 @@ function netflow_get_top_summary( $command = netflow_get_command($netflow_filter); // Execute nfdump. - $command .= " -q -o csv -n $max -s $sort/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); + $command .= " -o csv -n $max -s $sort/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($command, $result); if (! is_array($result)) { @@ -1940,6 +1940,11 @@ function netflow_get_top_summary( $result = array_reverse($result); array_pop($result); $result = array_reverse($result); + // Get the globals. + $globals = explode(',', array_pop($result)); + // Remove globals header. + array_pop($result); + array_pop($result); $top_info = []; foreach ($result as $line) { @@ -1957,6 +1962,9 @@ function netflow_get_top_summary( 'sum_bytes' => $data[9], 'sum_pkts' => $data[7], 'sum_flows' => $data[5], + 'pct_bytes' => number_format((($data[9] / $globals[1]) * 100), 2), + 'pct_pkts' => number_format((($data[7] / $globals[2]) * 100), 2), + 'pct_flows' => number_format((($data[5] / $globals[0]) * 100), 2), ]; } diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index d2b95ff3f8..1fcfa37a42 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -249,9 +249,14 @@ foreach ($data as $item) { $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'] = format_for_graph( $item['sum_bytes'], 2, @@ -260,6 +265,10 @@ foreach ($data as $item) { 1024, 'B' ); + if (!$is_network) { + $row['bytes'] .= ' ('.$item['pct_bytes'].'%)'; + } + $table->data[] = $row; // Build the pie graph data structure. From 6fc0a4924b16f98ba004834a65e163a53ba52ca5 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 7 Mar 2019 19:11:30 +0100 Subject: [PATCH 40/94] Do not calculate percentages. Catch it from netflow Former-commit-id: b06a18df02d90a29660a34309a9d40c5774816b9 --- pandora_console/include/functions_netflow.php | 15 +++++---------- .../operation/network/network_report.php | 6 +++++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 04b10b4712..7b041eb548 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1929,7 +1929,7 @@ function netflow_get_top_summary( $command = netflow_get_command($netflow_filter); // Execute nfdump. - $command .= " -o csv -n $max -s $sort/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); + $command .= " -q -o csv -n $max -s $sort/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($command, $result); if (! is_array($result)) { @@ -1940,11 +1940,6 @@ function netflow_get_top_summary( $result = array_reverse($result); array_pop($result); $result = array_reverse($result); - // Get the globals. - $globals = explode(',', array_pop($result)); - // Remove globals header. - array_pop($result); - array_pop($result); $top_info = []; foreach ($result as $line) { @@ -1957,14 +1952,14 @@ function netflow_get_top_summary( continue; } - $top_info[$data[4]] = [ + $top_info[(string) $data[4]] = [ 'host' => $data[4], 'sum_bytes' => $data[9], 'sum_pkts' => $data[7], 'sum_flows' => $data[5], - 'pct_bytes' => number_format((($data[9] / $globals[1]) * 100), 2), - 'pct_pkts' => number_format((($data[7] / $globals[2]) * 100), 2), - 'pct_flows' => number_format((($data[5] / $globals[0]) * 100), 2), + 'pct_bytes' => $data[10], + 'pct_pkts' => $data[8], + 'pct_flows' => $data[6], ]; } diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 1fcfa37a42..567e21b403 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -48,6 +48,10 @@ if (!$is_period) { $top = (int) get_parameter('top', 10); $main_value = ((bool) get_parameter('remove_filter', 0)) ? '' : get_parameter('main_value', ''); +if (is_numeric($main_value) && !in_array($action, ['udp', 'tcp'])) { + $main_value = ''; +} + $style_end = ($is_period) ? 'display: none;' : ''; $style_period = ($is_period) ? '' : 'display: none;'; @@ -219,7 +223,7 @@ if (get_parameter('export_csv')) { // Print the filter remove link. if (!empty($main_value)) { echo html_print_link_with_params( - __('Filtered by IP %s. Click here to remove the filter.', $main_value), + 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, [ From 471770ec85c2286ae20d27e9909bc0d708243e63 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 7 Mar 2019 19:16:24 +0100 Subject: [PATCH 41/94] Reduced icon size on netflow explorer Former-commit-id: 6d16a2583dcdbf62386b29662a914a538bae9275 --- pandora_console/include/styles/pandora.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 49b464481a..e71d813cb3 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4177,6 +4177,13 @@ form ul.form_flex li ul li { align-items: center; } +.div-v-centered > form > input[type="image"] { + margin: 0; + padding: 0; + width: 14px; + padding-left: 5px; +} + .pandora_upper { text-transform: uppercase; } From 7b9bbe6b9c934f1527346961b3b3d38c797fb9bb Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 8 Mar 2019 09:29:12 +0100 Subject: [PATCH 42/94] Fixed reporting menu Former-commit-id: efaf4d26e0d48bbdea3df7afb2c462a1b70a6701 --- pandora_console/operation/menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 281faf4c9a..ffeb95bbd3 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -341,7 +341,7 @@ if (check_acl($config['id_user'], 0, 'RR') || check_acl($config['id_user'], 0, ' enterprise_hook('dashboard_menu'); enterprise_hook('reporting_godmenu'); - $menu_operation['repo.rting']['sub'] = $sub; + $menu_operation['reporting']['sub'] = $sub; // End reporting. } From e9061d74b64bdcb3c8dc557b3010f1ec5f0afc17 Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 8 Mar 2019 11:46:47 +0100 Subject: [PATCH 43/94] Added ordering header element Former-commit-id: 11ffbe8c00a8ea9d881321be7c7541eaf0babe92 --- pandora_console/include/functions_html.php | 17 +++++-- pandora_console/include/functions_network.php | 30 ++++++++++++ .../operation/network/network_report.php | 49 ++++++++++++++----- 3 files changed, 80 insertions(+), 16 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 4b7eebcf87..e38e7160ec 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -3132,20 +3132,31 @@ function html_print_switch($attributes=[]) * @param string $text Text to show. * @param array $params Params to be written like inputs hidden. * @param string $text Text of image. + * @param string $style Additional style for the element. * * @return string With HTML code. */ -function html_print_link_with_params($text, $params=[], $type='text') +function html_print_link_with_params($text, $params=[], $type='text', $style='') { $html = '
'; switch ($type) { case 'image': - $html .= html_print_input_image($text, $text, $text, '', true); + $html .= html_print_input_image($text, $text, $text, $style, true); break; case 'text': default: - $html .= html_print_submit_button($text, $text, false, 'class="button-as-link"', true); + if (!empty($style)) { + $style = ' style="'.$style.'"'; + } + + $html .= html_print_submit_button( + $text, + $text, + false, + 'class="button-as-link"'.$style, + true + ); break; } diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index 2c096f173c..60375b6174 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -89,3 +89,33 @@ function network_get_report_actions($network) ] ); } + + +/** + * Print the header of the network + * + * @param string $title Title of header. + * @param string $order Current ordering. + * @param string $selected Selected order. + * @param array $hidden_data All the data to hide into the button. + * + * @return string With HTML data. + */ +function network_print_explorer_header( + $title, + $order, + $selected, + $hidden_data +) { + $cell = '
'; + $cell .= $title; + $cell .= html_print_link_with_params( + 'images/arrow-down-white.png', + array_merge($hidden_data, ['order_by' => $order]), + 'image', + ($selected === $order) ? 'opacity: 0.5' : '' + ); + $cell .= '
'; + + return $cell; +} diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 1fcfa37a42..e4dd539c8e 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -48,6 +48,11 @@ if (!$is_period) { $top = (int) get_parameter('top', 10); $main_value = ((bool) get_parameter('remove_filter', 0)) ? '' : get_parameter('main_value', ''); +$order_by = get_parameter('order_by', 'bytes'); +if (!in_array($order_by, ['bytes', 'pkts', 'flows'])) { + $order_by = 'bytes'; +} + $style_end = ($is_period) ? 'display: none;' : ''; $style_period = ($is_period) ? '' : 'display: none;'; @@ -157,19 +162,6 @@ if ($is_network) { ); } -unset($table); -$table = new stdClass(); -$table->styleTable = 'width: 100%'; -// Print the header. -$table->head = []; -$table->head['main'] = __('IP'); -if (!$is_network) { - $table->head['flows'] = __('Flows'); -} - -$table->head['pkts'] = __('Packets'); -$table->head['bytes'] = __('Bytes'); - // Get the params to return the builder. $hidden_main_link = [ 'time_greater' => $time_greater, @@ -182,6 +174,37 @@ $hidden_main_link = [ 'action' => $action, ]; +unset($table); +$table = new stdClass(); +$table->styleTable = 'width: 100%'; +// Print the header. +$table->head = []; +$table->head['main'] = __('IP'); +if (!$is_network) { + $table->head['flows'] = network_print_explorer_header( + __('Flows'), + 'flows', + $order_by, + $hidden_main_link + ); +} + +$table->head['pkts'] = network_print_explorer_header( + __('Packets'), + 'pkts', + $order_by, + $hidden_main_link +); +$table->head['bytes'] = network_print_explorer_header( + __('Bytes'), + 'bytes', + $order_by, + $hidden_main_link +); + +// Add the order. +$hidden_main_link['order_by'] = $order_by; + if (get_parameter('export_csv')) { // Clean the buffer. while (ob_get_level()) { From ed25536a978c057b873326d2c26698be480840bb Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 8 Mar 2019 11:57:32 +0100 Subject: [PATCH 44/94] Added top by other metric in netflow report Former-commit-id: 48f5b58ea255c59ffaa109805032c1b35de61a48 --- pandora_console/include/functions_netflow.php | 22 +++++++++++++++++-- .../operation/network/network_report.php | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 04b10b4712..f60f476e17 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1876,6 +1876,7 @@ function netflow_check_nfdump_binary($nfdump_binary) * @param integer $start_date In utimestamp. * @param integer $end_date In utimestamp. * @param string $filter Ip to filter. + * @param string $order Select one of bytes,pkts,flow. * * @return array With data (host, sum_bytes, sum_pkts and sum_flows). */ @@ -1884,7 +1885,8 @@ function netflow_get_top_summary( $top_action, $start_date, $end_date, - $filter='' + $filter='', + $order='bytes' ) { global $nfdump_date_format; $netflow_filter = []; @@ -1929,7 +1931,23 @@ function netflow_get_top_summary( $command = netflow_get_command($netflow_filter); // Execute nfdump. - $command .= " -o csv -n $max -s $sort/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); + $order_text = ''; + switch ($order) { + case 'flows': + $order_text = 'flows'; + break; + + case 'pkts': + $order_text = 'packets'; + break; + + case 'bytes': + default: + $order_text = 'bytes'; + break; + } + + $command .= " -o csv -n $max -s $sort/$order_text -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($command, $result); if (! is_array($result)) { diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index e4dd539c8e..bd6fef1725 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -158,7 +158,8 @@ if ($is_network) { $action, $utimestamp_lower, $utimestamp_greater, - $main_value + $main_value, + $order_by ); } From fbd5648d60bd5fdcdcbeb4da817b15cae9c6dc1f Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 8 Mar 2019 12:11:18 +0100 Subject: [PATCH 45/94] Added filter to ntop part in network explorer Former-commit-id: 688f737c26599da309ed414f4291e24e521d74a0 --- pandora_console/include/functions_network.php | 25 +++++++++++++------ .../operation/network/network_report.php | 3 ++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index 60375b6174..186f751426 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -24,17 +24,25 @@ /** * Get the tnetwok_matrix summatory data. * - * @param integer $top Number of hosts to show. - * @param boolean $talker Talker (true) or listetener (false). - * @param integer $start Utimestamp of start time. - * @param integer $end Utimestamp of end time. - * @param string $ip_filter Ip to filter. + * @param integer $top Number of hosts to show. + * @param boolean $talker Talker (true) or listetener (false). + * @param integer $start Utimestamp of start time. + * @param integer $end Utimestamp of end time. + * @param string $ip_filter Ip to filter. + * @param boolean $order_by_bytes True by top by bytes. False by packets. * * @return array With requested data. */ -function network_matrix_get_top($top, $talker, $start, $end, $ip_filter='') -{ +function network_matrix_get_top( + $top, + $talker, + $start, + $end, + $ip_filter='', + $order_by_bytes=true +) { $field_to_group = ($talker === true) ? 'source' : 'destination'; + $field_to_order = ($order_by_bytes === true) ? 'sum_bytes' : 'sum_pkts'; $filter_sql = ''; if (!empty($ip_filter)) { $filter_field = ($talker === true) ? 'destination' : 'source'; @@ -47,13 +55,14 @@ function network_matrix_get_top($top, $talker, $start, $end, $ip_filter='') WHERE utimestamp > %d AND utimestamp < %d %s GROUP BY %s - ORDER BY sum_bytes DESC + ORDER BY %s DESC LIMIT %d', $field_to_group, $start, $end, $filter_sql, $field_to_group, + $field_to_order, $top ); diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index bd6fef1725..93488c5c90 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -150,7 +150,8 @@ if ($is_network) { $action === 'talkers', $utimestamp_lower, $utimestamp_greater, - $main_value + $main_value, + $order_by !== 'pkts' ); } else { $data = netflow_get_top_summary( From 935db452d29c11f483b0145013c633b454f48e2d Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 11 Mar 2019 15:02:22 +0100 Subject: [PATCH 46/94] Network report. Fixed some styles Former-commit-id: 19a181044bae3f5bcec1f873e20ec50c41a73f00 --- .../operation/network/network_report.php | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 7f933e9f28..53428890cc 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -105,22 +105,22 @@ $table->data['0']['2'] .= html_print_checkbox( 'network_report_click_period(event)' ); -$table->data['1']['0'] = __('End date').'  '; -$table->data['1']['0'] .= html_print_input_text('date_greater', $date_greater, '', 10, 7, true); +$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_greater', $time_greater, '', 7, 8, true); +$table->data['1']['0'] .= html_print_input_text('time_lower', $time_lower, '', 7, 8, true); +$table->data['1']['0'] .= '
'; -$table->data['1']['1'] = '
'; -$table->data['1']['1'] .= __('Start date').'  '; -$table->data['1']['1'] .= html_print_input_text('date_lower', $date_lower, '', 10, 7, true); +$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']['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_lower', $time_lower, '', 7, 8, true); -$table->data['1']['1'] .= '
'; - -$table->data['1']['1'] .= '
'; -$table->data['1']['1'] .= __('Time Period').'  '; -$table->data['1']['1'] .= html_print_extended_select_for_time('period', $period, '', '', 0, false, 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'), @@ -182,7 +182,7 @@ $hidden_main_link = [ unset($table); $table = new stdClass(); -$table->styleTable = 'width: 100%'; +$table->styleTable = 'width: 70%'; // Print the header. $table->head = []; $table->head['main'] = __('IP'); @@ -307,18 +307,20 @@ foreach ($data as $item) { 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 '
'; + // Print the graph. + echo '
'; + echo pie_graph( + $chart_data, + 320, + 200, + __('Others') + ); + echo '
'; + echo '
'; +} ?> + \ No newline at end of file From 34379949150b6e9d9f1bea63e89234674deb2159 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 11 Mar 2019 19:36:49 +0100 Subject: [PATCH 52/94] Fixed code style Former-commit-id: 7422b647bb92ecc2d724aa71911a446aff058d3a --- .../operation/netflow/nf_live_view.php | 107 +++++++++--------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 99ff5d7f6c..707b6f59a4 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -1,16 +1,23 @@ $id]); - // Decode HTML entities + // Decode HTML entities. $filter_values['advanced_filter'] = io_safe_output($filter_values['advanced_filter']); @@ -68,7 +75,7 @@ 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); @@ -81,7 +88,7 @@ $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', 10); $period = (int) get_parameter('period', SECONDS_1DAY); @@ -93,18 +100,18 @@ $interval_length = (int) get_parameter('interval_length', 300); $address_resolution = (int) get_parameter('address_resolution', $config['netflow_get_ip_hostname']); $filter_selected = (int) get_parameter('filter_selected', 0); -// Read buttons +// Read buttons. $draw = get_parameter('draw_button', ''); $save = get_parameter('save_button', ''); $update = get_parameter('update_button', ''); -// Calculate start and end dates +// 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', @@ -137,9 +144,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); @@ -149,15 +156,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( @@ -173,7 +179,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; @@ -208,7 +214,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 { @@ -226,7 +232,7 @@ if (is_metaconsole()) { } echo ''; - echo ''.''.__('Connection').''.''; + echo ''.__('Connection').''; echo ''.html_print_select( $list_servers, 'connection_name', @@ -243,23 +249,23 @@ if (is_metaconsole()) { echo ''; - echo ''.''.__('Date').''.''; + echo ''.__('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).''; - echo ''.''.__('Interval').''.''; + 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 ''.__('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 ''; echo ''; - echo ''.''.__('Type').''.''; + echo ''.__('Type').''; echo ''.html_print_select( netflow_get_chart_types(), 'chart_type', @@ -270,7 +276,7 @@ if (is_metaconsole()) { true ).''; - echo ''.''.__('Max. values').''.''; + echo ''.__('Max. values').''; $max_values = [ '2' => '2', '5' => '5', @@ -284,7 +290,7 @@ 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).''; + echo ''.__('Aggregate by').''.ui_print_help_icon('aggregate_by', true).''; $aggregate_list = []; $aggregate_list = [ 'none' => __('None'), @@ -298,7 +304,7 @@ if (is_metaconsole()) { echo ''; - // Read filter type + // Read filter type. if ($filter['advanced_filter'] != '') { $filter_type = 1; } else { @@ -312,7 +318,7 @@ if (is_metaconsole()) { echo ''; echo ""; - echo ''.''.__('Name').''.''; + echo ''.__('Name').''; echo "".html_print_input_text( 'name', $filter['id_name'], @@ -322,7 +328,7 @@ if (is_metaconsole()) { true ).''; $own_info = get_user_info($config['id_user']); - echo ''.''.__('Group').''.''; + 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 ''; @@ -346,13 +352,13 @@ if (is_metaconsole()) { echo ''; echo ''; } else { - echo ''.''.__('Filter').''.''; + 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').''.''; + echo ''.__('Load filter').''; $user_groups = users_get_groups($config['id_user'], 'AR', $own_info['is_admin'], true); $user_groups[0] = 0; // Add all groups. @@ -432,13 +438,13 @@ 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 ''.''.__('Router ip').''.''; + echo ''.__('Router ip').''; echo ''.html_print_input_text('router_ip', $filter['router_ip'], false, 30, 80, true).''; - echo ''.''.__('Output format').''.''; + echo ''.__('Output format').''; $show_output = [ 'bytes' => __('Bytes'), 'bytespersecond' => __('Bytes per second'), @@ -469,15 +475,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, From 8a336d6cfeaaa4c92cfd1d0128a3ac10f101b0d3 Mon Sep 17 00:00:00 2001 From: Fermin Date: Wed, 13 Mar 2019 18:55:16 +0100 Subject: [PATCH 53/94] [Netflow live] Implemented resolution on area graphs and fixed end date Former-commit-id: 86d55ac7645e62fcae6a07cbf1bd50f92d5d37a1 --- pandora_console/include/functions_graph.php | 3 +- pandora_console/include/functions_netflow.php | 104 +++++++++--------- .../operation/netflow/nf_live_view.php | 21 +++- 3 files changed, 72 insertions(+), 56 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 814ad6d1c8..4d9ae9eca6 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4109,7 +4109,7 @@ function fullscale_data( /** * Print an area graph with netflow aggregated */ -function graph_netflow_aggregate_area($data, $period, $width, $height, $unit='', $ttl=1, $only_image=false) +function graph_netflow_aggregate_area($data, $period, $width, $height, $unit='', $ttl=1, $only_image=false, $date=null) { global $config; global $graphic_type; @@ -4165,6 +4165,7 @@ function graph_netflow_aggregate_area($data, $period, $width, $height, $unit='', 'font_size' => $config['font_size'], 'array_data_create' => $chart, 'stacked' => 1, + 'date' => $date, ]; return grafico_modulo_sparse($params); diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 747a4ab17e..6bb23ecc72 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -17,6 +17,13 @@ require_once $config['homedir'].'/include/functions_io.php'; enterprise_include_once($config['homedir'].'/enterprise/include/pdf_translator.php'); enterprise_include_once($config['homedir'].'/enterprise/include/functions_metaconsole.php'); +define('NETFLOW_RES_LOWD', 6); +define('NETFLOW_RES_MEDD', 12); +define('NETFLOW_RES_HID', 24); +define('NETFLOW_RES_ULTRAD', 30); +define('NETFLOW_RES_HOURLY', 'hourly'); +define('NETFLOW_RES_DAILY', 'daily'); + // Date format for nfdump global $nfdump_date_format; $nfdump_date_format = 'Y/m/d.H:i:s'; @@ -461,21 +468,41 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag return json_decode($data, true); } - // Calculate the number of intervals - if ($interval_length <= 0) { - // $num_intervals = $config['graph_res'] * 50; - $num_intervals = 250; - $period = ($end_date - $start_date); - $interval_length = (int) ($period / $num_intervals); - } else { - $period = ($end_date - $start_date); - $num_intervals = (int) ($period / $interval_length); + if ($start_date > $end_date) { + return []; } - // Set a max number of intervals - if ($num_intervals > $config['netflow_max_resolution']) { - $num_intervals = $config['netflow_max_resolution']; - $interval_length = (int) ($period / $num_intervals); + // Calculate the number of intervals. + $multiplier_time = ($end_date - $start_date); + switch ($interval_length) { + case NETFLOW_RES_LOWD: + case NETFLOW_RES_MEDD: + case NETFLOW_RES_HID: + case NETFLOW_RES_ULTRAD: + $multiplier_time = ceil(($end_date - $start_date) / $interval_length); + break; + + case NETFLOW_RES_HOURLY: + $multiplier_time = SECONDS_1HOUR; + break; + + case NETFLOW_RES_DAILY: + $multiplier_time = SECONDS_1DAY; + break; + + default: + $multiplier_time = ($end_date - $start_date); + break; + } + + // Put all points into an array. + $intervals = [($start_date - $multiplier_time)]; + while ((end($intervals) < $end_date) === true) { + $intervals[] = (end($intervals) + $multiplier_time); + } + + if (end($intervals) != $end_date) { + $intervals[] = $end_date; } // If there is aggregation calculate the top n @@ -569,14 +596,15 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag $values['sources'] = $sources; } - // Address resolution end - $interval_start = $start_date; - for ($i = 0; $i < $num_intervals; $i++, $interval_start += ($interval_length + 1)) { - $interval_end = ($interval_start + $interval_length); - if ($interval_end > $end_date) { - $interval_end = $end_date; + // Address resolution end. + foreach ($intervals as $k => $time) { + $interval_start = $time; + if (!isset($intervals[($k + 1)])) { + continue; } + $interval_end = $intervals[($k + 1)]; + if ($aggregate == 'none') { $data = netflow_get_summary($interval_start, $interval_end, $filter, $connection_name); if (! isset($data['totalbytes'])) { @@ -608,7 +636,7 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag } else { // Set default values foreach ($values['sources'] as $source => $discard) { - $values['data'][$interval_start][$source] = 0; + $values['data'][$interval_end][$source] = 0; } $data = netflow_get_stats( @@ -654,7 +682,7 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag continue; } - $values['data'][$interval_start][$line['agg']] = $line['data']; + $values['data'][$interval_end][$line['agg']] = $line['data']; } } } @@ -1144,36 +1172,6 @@ function netflow_get_valid_intervals() } -/** - * Gets valid intervals for a netflow chart in the format: - * - * interval_length => interval_description - * - * @return array of valid intervals. - */ -function netflow_get_valid_subintervals() -{ - return [ - (string) SECONDS_1MINUTE => __('1 min'), - (string) SECONDS_2MINUTES => __('2 mins'), - (string) SECONDS_5MINUTES => __('5 mins'), - (string) SECONDS_10MINUTES => __('10 mins'), - (string) SECONDS_15MINUTES => __('15 mins'), - (string) SECONDS_30MINUTES => __('30 mins'), - (string) SECONDS_1HOUR => __('1 hour'), - (string) SECONDS_2HOUR => __('2 hours'), - (string) SECONDS_5HOUR => __('5 hours'), - (string) SECONDS_12HOURS => __('12 hours'), - (string) SECONDS_1DAY => __('1 day'), - (string) SECONDS_2DAY => __('2 days'), - (string) SECONDS_5DAY => __('5 days'), - (string) SECONDS_15DAYS => __('15 days'), - (string) SECONDS_1WEEK => __('1 week'), - (string) SECONDS_1MONTH => __('1 month'), - ]; -} - - /** * Draw a netflow report item. * @@ -1217,7 +1215,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $html .= ' '._('Resolution').": $interval_length ".__('seconds'); } - $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit)); + $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 1, false, $end_date); return $html; } else if ($output == 'PDF') { $html = ''.__('Unit').': '.netflow_format_unit($unit); @@ -1226,7 +1224,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $html .= ' '._('Resolution').": $interval_length ".__('seconds'); } - $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 2, true); + $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 2, true, $end_date); return $html; } else if ($output == 'XML') { $xml = "$unit\n"; diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 707b6f59a4..f8c27b5954 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -96,7 +96,7 @@ $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); @@ -260,7 +260,24 @@ if (is_metaconsole()) { 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 ''.html_print_select( + [ + NETFLOW_RES_LOWD => __('Low'), + NETFLOW_RES_MEDD => __('Medium'), + NETFLOW_RES_HID => __('High'), + NETFLOW_RES_ULTRAD => __('Ultra High'), + NETFLOW_RES_HOURLY => __('Hourly'), + NETFLOW_RES_DAILY => __('Daily'), + ], + 'interval_length', + $interval_length, + '', + '', + 0, + true, + false, + false + ).''; echo ''; echo ''; From 3d1f1f86edcb86514a853d96f25deb97ff37d9c9 Mon Sep 17 00:00:00 2001 From: Fermin Date: Wed, 13 Mar 2019 19:16:21 +0100 Subject: [PATCH 54/94] [Netflow live] Removed agregate by none Former-commit-id: 4da1581da67c95f29b9b34eb70436e8f68706988 --- .../godmode/netflow/nf_edit_form.php | 5 +- pandora_console/include/functions_netflow.php | 299 +++++++----------- .../operation/netflow/nf_live_view.php | 1 - 3 files changed, 122 insertions(+), 183 deletions(-) diff --git a/pandora_console/godmode/netflow/nf_edit_form.php b/pandora_console/godmode/netflow/nf_edit_form.php index 80f88f709e..643d63f8c0 100644 --- a/pandora_console/godmode/netflow/nf_edit_form.php +++ b/pandora_console/godmode/netflow/nf_edit_form.php @@ -94,7 +94,7 @@ if ($id) { $ip_src = ''; $dst_port = ''; $src_port = ''; - $aggregate = 'none'; + $aggregate = 'dstip'; $output = 'bytes'; $advanced_filter = ''; } @@ -142,7 +142,7 @@ if ($update) { if ($create) { $name = (string) get_parameter('name'); $assign_group = (int) get_parameter('assign_group'); - $aggregate = get_parameter('aggregate', 'none'); + $aggregate = get_parameter('aggregate', 'dstip'); $output = get_parameter('output', 'bytes'); $ip_dst = get_parameter('ip_dst', ''); $ip_src = get_parameter('ip_src', ''); @@ -241,7 +241,6 @@ $table->data[7][1] = html_print_textarea('advanced_filter', 4, 40, $advanced_fil $table->data[8][0] = ''.__('Aggregate by').''.ui_print_help_icon('aggregate_by', true); $aggregate_list = [ - 'none' => __('None'), 'proto' => __('Protocol'), 'srcip' => __('Src Ip Address'), 'dstip' => __('Dst Ip Address'), diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 6bb23ecc72..c5fa32541e 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -506,72 +506,68 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag } // If there is aggregation calculate the top n - if ($aggregate != 'none') { - $values['data'] = []; - $values['sources'] = []; + $values['data'] = []; + $values['sources'] = []; - // Get the command to call nfdump - $command = netflow_get_command($filter); + // Get the command to call nfdump + $command = netflow_get_command($filter); - // Suppress the header line and the statistics at the bottom and configure piped output - $command .= ' -q -o csv'; + // Suppress the header line and the statistics at the bottom and configure piped output + $command .= ' -q -o csv'; - // Call nfdump - $agg_command = $command." -n $max -s $aggregate/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); - exec($agg_command, $string); + // Call nfdump + $agg_command = $command." -n $max -s $aggregate/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); + exec($agg_command, $string); - // Remove the first line - $string[0] = ''; + // Remove the first line + $string[0] = ''; - // Parse aggregates - foreach ($string as $line) { - if ($line == '') { - continue; - } - - $val = explode(',', $line); - if ($aggregate == 'proto') { - $values['sources'][$val[3]] = 1; - } else { - $values['sources'][$val[4]] = 1; - } + // Parse aggregates + foreach ($string as $line) { + if ($line == '') { + continue; } - // Update the filter - switch ($aggregate) { - case 'proto': - $extra_filter = 'proto'; - break; - - default: - case 'srcip': - $extra_filter = 'ip_src'; - break; - case 'srcport': - $extra_filter = 'src_port'; - break; - - case 'dstip': - $extra_filter = 'ip_dst'; - break; - - case 'dstport': - $extra_filter = 'dst_port'; - break; + $val = explode(',', $line); + if ($aggregate == 'proto') { + $values['sources'][$val[3]] = 1; + } else { + $values['sources'][$val[4]] = 1; } - - if (isset($filter[$extra_filter]) && $filter[$extra_filter] != '') { - $filter[$extra_filter] .= ','; - } - - $filter[$extra_filter] = implode( - ',', - array_keys($values['sources']) - ); - } else { - $values = []; } + // Update the filter + switch ($aggregate) { + case 'proto': + $extra_filter = 'proto'; + break; + + default: + case 'srcip': + $extra_filter = 'ip_src'; + break; + case 'srcport': + $extra_filter = 'src_port'; + break; + + case 'dstip': + $extra_filter = 'ip_dst'; + break; + + case 'dstport': + $extra_filter = 'dst_port'; + break; + } + + if (isset($filter[$extra_filter]) && $filter[$extra_filter] != '') { + $filter[$extra_filter] .= ','; + } + + $filter[$extra_filter] = implode( + ',', + array_keys($values['sources']) + ); + // Address resolution start $get_hostnames = false; if ($address_resolution && ($aggregate == 'srcip' || $aggregate == 'dstip')) { @@ -605,89 +601,59 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag $interval_end = $intervals[($k + 1)]; - if ($aggregate == 'none') { - $data = netflow_get_summary($interval_start, $interval_end, $filter, $connection_name); - if (! isset($data['totalbytes'])) { - $values[$interval_start]['data'] = 0; + // Set default values + foreach ($values['sources'] as $source => $discard) { + $values['data'][$interval_end][$source] = 0; + } + + $data = netflow_get_stats( + $interval_start, + $interval_end, + $filter, + $aggregate, + $max, + $unit, + $connection_name + ); + + foreach ($data as $line) { + // Address resolution start + if ($get_hostnames) { + if (!isset($hostnames[$line['agg']])) { + $hostname = false; + // Trying to get something like an IP from the description + if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $line['agg'], $matches) + || preg_match( + "/(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:?)|\2))(?4){5}((?4){2}|(25[0-5]| + (2[0-4]|1\d|[1-9])?\d)(\.(?7)){3})/i", + $line['agg'], + $matches + ) + ) { + if ($matches[0]) { + $hostname = gethostbyaddr($line['agg']); + } + } + + if ($hostname !== false) { + $hostnames[$line['agg']] = $hostname; + $line['agg'] = $hostname; + } + } else { + $line['agg'] = $hostnames[$line['agg']]; + } + } + + // Address resolution end + if (! isset($values['sources'][$line['agg']])) { continue; } - switch ($unit) { - case 'megabytes': - $values[$interval_start]['data'] = ($data['totalbytes'] / 1048576); - break; - - case 'megabytespersecond': - $values[$interval_start]['data'] = ($data['avgbps'] / 1048576 / 8); - break; - - case 'kilobytes': - $values[$interval_start]['data'] = ($data['totalbytes'] / 1024); - break; - - case 'kilobytespersecond': - $values[$interval_start]['data'] = ($data['avgbps'] / 1024 / 8); - break; - - default: - $values[$interval_start]['data'] = $data['totalbytes']; - break; - } - } else { - // Set default values - foreach ($values['sources'] as $source => $discard) { - $values['data'][$interval_end][$source] = 0; - } - - $data = netflow_get_stats( - $interval_start, - $interval_end, - $filter, - $aggregate, - $max, - $unit, - $connection_name - ); - - foreach ($data as $line) { - // Address resolution start - if ($get_hostnames) { - if (!isset($hostnames[$line['agg']])) { - $hostname = false; - // Trying to get something like an IP from the description - if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $line['agg'], $matches) - || preg_match( - "/(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:?)|\2))(?4){5}((?4){2}|(25[0-5]| - (2[0-4]|1\d|[1-9])?\d)(\.(?7)){3})/i", - $line['agg'], - $matches - ) - ) { - if ($matches[0]) { - $hostname = gethostbyaddr($line['agg']); - } - } - - if ($hostname !== false) { - $hostnames[$line['agg']] = $hostname; - $line['agg'] = $hostname; - } - } else { - $line['agg'] = $hostnames[$line['agg']]; - } - } - - // Address resolution end - if (! isset($values['sources'][$line['agg']])) { - continue; - } - - $values['data'][$interval_end][$line['agg']] = $line['data']; - } + $values['data'][$interval_end][$line['agg']] = $line['data']; } } - if (($aggregate != 'none') && (empty($values['data']))) { + if (empty($values['data'])) { return []; } @@ -1207,55 +1173,30 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil break; } - if ($aggregate != 'none') { - if ($output == 'HTML') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); - $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); - if ($interval_length != 0) { - $html .= ' '._('Resolution').": $interval_length ".__('seconds'); - } - - $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 1, false, $end_date); - return $html; - } else if ($output == 'PDF') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); - $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); - if ($interval_length != 0) { - $html .= ' '._('Resolution').": $interval_length ".__('seconds'); - } - - $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 2, true, $end_date); - return $html; - } else if ($output == 'XML') { - $xml = "$unit\n"; - $xml .= "$aggregate\n"; - $xml .= "$interval_length\n"; - $xml .= netflow_aggregate_area_xml($data); - return $xml; + if ($output == 'HTML') { + $html = ''.__('Unit').': '.netflow_format_unit($unit); + $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); + if ($interval_length != 0) { + $html .= ' '._('Resolution').": $interval_length ".__('seconds'); } - } else { - if ($output == 'HTML') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); - if ($interval_length != 0) { - $html .= ' '._('Resolution').": $interval_length ".__('seconds'); - } - $html .= graph_netflow_total_area($data, $interval, 660, 320, netflow_format_unit($unit)); - return $html; - } else if ($output == 'PDF') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); - if ($interval_length != 0) { - $html .= ' '._('Resolution').": $interval_length ".__('seconds'); - } - - $html .= graph_netflow_total_area($data, $interval, 660, 320, netflow_format_unit($unit), 2, true); - return $html; - } else if ($output == 'XML') { - $xml = "$unit\n"; - $xml .= "$interval_length\n"; - $xml .= netflow_total_area_xml($data); - return $xml; + $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 1, false, $end_date); + return $html; + } else if ($output == 'PDF') { + $html = ''.__('Unit').': '.netflow_format_unit($unit); + $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); + if ($interval_length != 0) { + $html .= ' '._('Resolution').": $interval_length ".__('seconds'); } + + $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 2, true, $end_date); + return $html; + } else if ($output == 'XML') { + $xml = "$unit\n"; + $xml .= "$aggregate\n"; + $xml .= "$interval_length\n"; + $xml .= netflow_aggregate_area_xml($data); + return $xml; } break; diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index f8c27b5954..b3b9687552 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -310,7 +310,6 @@ if (is_metaconsole()) { 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'), From c2c8287d3e405a4659cf4b0e0cc9556c4aa4cea1 Mon Sep 17 00:00:00 2001 From: Fermin Date: Wed, 13 Mar 2019 20:15:53 +0100 Subject: [PATCH 55/94] Fixed resolution in netflow reports Former-commit-id: 9900123e9753f9360085a1dff434bc668df7eb70 --- .../reporting_builder.item_editor.php | 8 ++++++-- pandora_console/include/functions_netflow.php | 18 ++++++++++++++++++ .../operation/netflow/nf_live_view.php | 9 +-------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index a422551ee1..174103f0bb 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -110,7 +110,7 @@ $event_graph_validated_vs_unvalidated = false; $netflow_filter = 0; $max_values = 0; -$resolution = 0; +$resolution = NETFLOW_RES_MEDD; $lapse_calc = 0; $lapse = 300; @@ -844,7 +844,11 @@ $class = 'databox filters'; diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index c5fa32541e..6b5314af05 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1951,3 +1951,21 @@ function netflow_print_check_version_error() return false; } } + + +/** + * Returns the array for netflow resolution select. + * + * @return array With all values. + */ +function netflow_resolution_select_params() +{ + return [ + NETFLOW_RES_LOWD => __('Low'), + NETFLOW_RES_MEDD => __('Medium'), + NETFLOW_RES_HID => __('High'), + NETFLOW_RES_ULTRAD => __('Ultra High'), + NETFLOW_RES_HOURLY => __('Hourly'), + NETFLOW_RES_DAILY => __('Daily'), + ]; +} diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index b3b9687552..4724371b0f 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -261,14 +261,7 @@ if (is_metaconsole()) { echo ''.__('Resolution').ui_print_help_tip(__('The interval will be divided in chunks the length of the resolution.'), true).''; echo ''.html_print_select( - [ - NETFLOW_RES_LOWD => __('Low'), - NETFLOW_RES_MEDD => __('Medium'), - NETFLOW_RES_HID => __('High'), - NETFLOW_RES_ULTRAD => __('Ultra High'), - NETFLOW_RES_HOURLY => __('Hourly'), - NETFLOW_RES_DAILY => __('Daily'), - ], + netflow_resolution_select_params(), 'interval_length', $interval_length, '', From 473a40e7d2208205d19b7f9ae55fae47f4b33ed6 Mon Sep 17 00:00:00 2001 From: Fermin Date: Wed, 13 Mar 2019 21:14:43 +0100 Subject: [PATCH 56/94] [Netflow live] Removed unit functionallity from area graph and data table Former-commit-id: 2d60141028e01e1fdf5a9d5716aa69a2cfe08d08 --- pandora_console/include/functions_netflow.php | 86 ++++++++----------- 1 file changed, 38 insertions(+), 48 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 6b5314af05..81711005c3 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -357,11 +357,14 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate, $unit) foreach ($data['data'] as $timestamp => $values) { $table->data[$i][0] = date($time_format, $timestamp); for ($j = 0; $j < $source_count; $j++) { - if (isset($values[$source_index[$j]])) { - $table->data[$i][($j + 1)] = format_numeric($values[$source_index[$j]]).' '.netflow_format_unit($unit); - } else { - $table->data[$i][($j + 1)] = (0).' '.netflow_format_unit($unit); - } + $table->data[$i][($j + 1)] = format_for_graph( + (isset($values[$source_index[$j]])) ? $values[$source_index[$j]] : 0, + 2, + '.', + ',', + 1024, + 'B' + ); } $i++; @@ -453,11 +456,13 @@ function netflow_is_net($address) * @param string filter Netflow filter. * @param string aggregate Aggregate field. * @param int max Maximum number of aggregates. - * @param string unit Unit to show. + * @param int max Maximum number of aggregates. + * @param boolean absolute True to give the absolute data and false to get + * troughput. * * @return An array with netflow stats. */ -function netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max, $unit, $connection_name='', $address_resolution=false) +function netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max, $absolute, $connection_name='', $address_resolution=false) { global $nfdump_date_format; global $config; @@ -669,17 +674,18 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag * @param string filter Netflow filter. * @param string aggregate Aggregate field. * @param int max Maximum number of aggregates. - * @param string unit Unit to show. + * @param boolean absolute True to give the absolute data and false to get + * troughput. * * @return An array with netflow stats. */ -function netflow_get_stats($start_date, $end_date, $filter, $aggregate, $max, $unit, $connection_name='', $address_resolution=false) +function netflow_get_stats($start_date, $end_date, $filter, $aggregate, $max, $absolute=true, $connection_name='', $address_resolution=false) { global $config, $nfdump_date_format; // Requesting remote data if (defined('METACONSOLE') && $connection_name != '') { - $data = metaconsole_call_remote_api($connection_name, 'netflow_get_stats', "$start_date|$end_date|".base64_encode(json_encode($filter))."|$aggregate|$max|$unit|".(int) $address_resolution); + $data = metaconsole_call_remote_api($connection_name, 'netflow_get_stats', "$start_date|$end_date|".base64_encode(json_encode($filter))."|$aggregate|$max|$absolute|".(int) $address_resolution); return json_decode($data, true); } @@ -740,30 +746,9 @@ function netflow_get_stats($start_date, $end_date, $filter, $aggregate, $max, $u return []; } - switch ($unit) { - case 'megabytes': - $values[$i]['data'] = ($val[9] / 1048576); - break; - - case 'megabytespersecond': - $values[$i]['data'] = ($val[9] / 1048576 / $interval_length); - break; - - case 'kilobytes': - $values[$i]['data'] = ($val[9] / 1024); - break; - - case 'kilobytespersecond': - $values[$i]['data'] = ($val[9] / 1024 / $interval_length); - break; - - default: - case 'bytes': - $values[$i]['data'] = $val[9]; - break; - case 'bytespersecond': - $values[$i]['data'] = ($val[9] / $interval_length); - break; + $values[$i]['data'] = $val[9]; + if (!$absolute) { + $values[$i]['data'] = ($values[$i]['data'] / $interval_length); } $i++; @@ -1168,29 +1153,20 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil switch ($type) { case '0': case 'netflow_area': - $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, $unit, $connection_name, $address_resolution); + $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, true, $connection_name, $address_resolution); if (empty($data)) { break; } - if ($output == 'HTML') { + if ($output == 'HTML' || $output == 'PDF') { $html = ''.__('Unit').': '.netflow_format_unit($unit); $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); if ($interval_length != 0) { - $html .= ' '._('Resolution').": $interval_length ".__('seconds'); + $html .= ' '._('Resolution').': '.netflow_get_resolution_name($interval_length); } $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 1, false, $end_date); return $html; - } else if ($output == 'PDF') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); - $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); - if ($interval_length != 0) { - $html .= ' '._('Resolution').": $interval_length ".__('seconds'); - } - - $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 2, true, $end_date); - return $html; } else if ($output == 'XML') { $xml = "$unit\n"; $xml .= "$aggregate\n"; @@ -1202,7 +1178,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil case '2': case 'netflow_data': - $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, $unit, $connection_name, $address_resolution); + $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, false, $connection_name, $address_resolution); if (empty($data)) { break; @@ -1212,7 +1188,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $html = ''.__('Unit').': '.netflow_format_unit($unit); $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); if ($interval_length != 0) { - $html .= ' '._('Resolution').": $interval_length ".__('seconds'); + $html .= ' '._('Resolution').': '.netflow_get_resolution_name($interval_length); } $html .= "
"; @@ -1969,3 +1945,17 @@ function netflow_resolution_select_params() NETFLOW_RES_DAILY => __('Daily'), ]; } + + +/** + * Get the resolution name. + * + * @param mixed $value Type. + * + * @return string Translated name. Unknown for unrecognized resolution names. + */ +function netflow_get_resolution_name($value) +{ + $resolutions = netflow_resolution_select_params(); + return (isset($resolutions[$value])) ? $resolutions[$value] : __('Unknown'); +} From 834c18e49ee280eed0c90752e1fab044d40030d1 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 14 Mar 2019 09:07:17 +0100 Subject: [PATCH 57/94] [Netflow live] Remove unit from statistics table Former-commit-id: 2b0289fef0b663b558794b2ac1b16d0128c68bc9 --- pandora_console/include/functions_netflow.php | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 81711005c3..f197b43063 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -236,11 +236,10 @@ function sort_netflow_data(&$netflow_data) * @param string start_date Start date. * @param string end_date End date. * @param string aggregate Aggregate field. - * @param string unit Unit to show. * * @return The statistics table. */ -function netflow_stat_table($data, $start_date, $end_date, $aggregate, $unit) +function netflow_stat_table($data, $start_date, $end_date, $aggregate) { global $nfdump_date_format; @@ -256,7 +255,7 @@ function netflow_stat_table($data, $start_date, $end_date, $aggregate, $unit) $table->head = []; $table->head[0] = ''.netflow_format_aggregate($aggregate).''; - $table->head[1] = ''.netflow_format_unit($unit).''; + $table->head[1] = ''.__('Value').''; $table->style[0] = 'padding: 6px;'; $table->style[1] = 'padding: 6px;'; @@ -264,14 +263,20 @@ function netflow_stat_table($data, $start_date, $end_date, $aggregate, $unit) $agg = $data[$j]['agg']; if (!isset($values[$agg])) { $values[$agg] = $data[$j]['data']; - $table->data[$x][0] = $agg; - $table->data[$x][1] = format_numeric($data[$j]['data']).' '.netflow_format_unit($unit); } else { $values[$agg] += $data[$j]['data']; - $table->data[$x][0] = $agg; - $table->data[$x][1] = format_numeric($data[$j]['data']).' '.netflow_format_unit($unit); } + $table->data[$x][0] = $agg; + $table->data[$x][1] = format_for_graph( + $data[$j]['data'], + 2, + '.', + ',', + 1024, + 'B' + ); + $j++; $x++; } @@ -1214,7 +1219,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $filter, $aggregate, $max_aggregates, - $unit, + true, $connection_name, $address_resolution ); @@ -1223,7 +1228,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil } if ($output == 'HTML' || $output == 'PDF') { - $html = netflow_stat_table($data, $start_date, $end_date, $aggregate, $unit); + $html = netflow_stat_table($data, $start_date, $end_date, $aggregate); return $html; } else if ($output == 'XML') { return netflow_stat_xml($data); From e16d48804e7ac6c0c76ec94bfceded219767d53a Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 14 Mar 2019 09:25:50 +0100 Subject: [PATCH 58/94] [Netflow live] Added removed unit from pie graph and summary table and refactorized bytes format Former-commit-id: 35b9fd71ad97869e23119bd0d2031ec12400d745 --- pandora_console/include/functions_netflow.php | 32 ++++++------------- pandora_console/include/functions_network.php | 26 +++++++++++++++ .../operation/network/network_report.php | 9 +----- 3 files changed, 37 insertions(+), 30 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index f197b43063..af4ca422b2 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -14,6 +14,7 @@ require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_io.php'; require_once $config['homedir'].'/include/functions_io.php'; +require_once $config['homedir'].'/include/functions_network.php'; enterprise_include_once($config['homedir'].'/enterprise/include/pdf_translator.php'); enterprise_include_once($config['homedir'].'/enterprise/include/functions_metaconsole.php'); @@ -268,14 +269,7 @@ function netflow_stat_table($data, $start_date, $end_date, $aggregate) } $table->data[$x][0] = $agg; - $table->data[$x][1] = format_for_graph( - $data[$j]['data'], - 2, - '.', - ',', - 1024, - 'B' - ); + $table->data[$x][1] = network_format_bytes($data[$j]['data']); $j++; $x++; @@ -362,13 +356,8 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate, $unit) foreach ($data['data'] as $timestamp => $values) { $table->data[$i][0] = date($time_format, $timestamp); for ($j = 0; $j < $source_count; $j++) { - $table->data[$i][($j + 1)] = format_for_graph( - (isset($values[$source_index[$j]])) ? $values[$source_index[$j]] : 0, - 2, - '.', - ',', - 1024, - 'B' + $table->data[$i][($j + 1)] = network_format_bytes( + $values[$source_index[$j]] ); } @@ -402,32 +391,32 @@ function netflow_summary_table($data) $row = []; $row[] = __('Total flows'); - $row[] = format_numeric($data['totalflows']); + $row[] = format_for_graph($data['totalflows'], 2); $table->data[] = $row; $row = []; $row[] = __('Total bytes'); - $row[] = format_numeric($data['totalbytes']); + $row[] = network_format_bytes($data['totalbytes']); $table->data[] = $row; $row = []; $row[] = __('Total packets'); - $row[] = format_numeric($data['totalpackets']); + $row[] = format_for_graph($data['totalpackets'], 2); $table->data[] = $row; $row = []; $row[] = __('Average bits per second'); - $row[] = format_numeric($data['avgbps']); + $row[] = network_format_bytes($data['avgbps']); $table->data[] = $row; $row = []; $row[] = __('Average packets per second'); - $row[] = format_numeric($data['avgpps']); + $row[] = format_for_graph($data['avgpps'], 2); $table->data[] = $row; $row = []; $row[] = __('Average bytes per packet'); - $row[] = format_numeric($data['avgbpp']); + $row[] = format_for_graph($data['avgbpp'], 2); $table->data[] = $row; $html = html_print_table($table, true); @@ -1319,7 +1308,6 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $html .= ''; $html .= ''; $html .= netflow_summary_table($data_summary); - $html .= ''.__('Unit').': '.netflow_format_unit($unit); $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); $html .= ''; $html .= ''; diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index 186f751426..802fc4bb5c 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -128,3 +128,29 @@ function network_print_explorer_header( return $cell; } + + +/** + * Alias for format_for_graph to print bytes. + * + * @param integer $value Value to parse like bytes. + * + * @return string Number parsed. + */ +function network_format_bytes($value) +{ + if (!isset($value)) { + $value = 0; + } + + $value = (int) $value; + + return format_for_graph( + $value, + 2, + '.', + ',', + 1024, + 'B' + ); +} diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index ba6ddf2dc4..7ca13a8e79 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -299,14 +299,7 @@ foreach ($data as $item) { $row['pkts'] .= ' ('.$item['pct_pkts'].'%)'; } - $row['bytes'] = format_for_graph( - $item['sum_bytes'], - 2, - '.', - ',', - 1024, - 'B' - ); + $row['bytes'] = network_format_bytes($item['sum_bytes']); if (!$is_network) { $row['bytes'] .= ' ('.$item['pct_bytes'].'%)'; } From cf8915af36edb6b01b8e3d3c6ee33d069c7e8f76 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 14 Mar 2019 10:05:21 +0100 Subject: [PATCH 59/94] [Netflow live] Removed unit from circular mesh Former-commit-id: 4f6fceadcf504ccf5006722b26a5b2259adc2970 --- pandora_console/include/functions_graph.php | 4 +- pandora_console/include/functions_netflow.php | 38 +++---------------- .../include/graphs/functions_d3.php | 4 +- pandora_console/include/graphs/pandora.d3.js | 32 +++++++++------- 4 files changed, 29 insertions(+), 49 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 4d9ae9eca6..6843dab8da 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4289,7 +4289,7 @@ function graph_netflow_aggregate_pie($data, $aggregate, $ttl=1, $only_image=fals /** * Print a circular graph with the data transmitted between IPs */ -function graph_netflow_circular_mesh($data, $unit, $radius=700) +function graph_netflow_circular_mesh($data, $radius=700) { global $config; @@ -4299,7 +4299,7 @@ function graph_netflow_circular_mesh($data, $unit, $radius=700) include_once $config['homedir'].'/include/graphs/functions_d3.php'; - return d3_relationship_graph($data['elements'], $data['matrix'], $unit, $radius, true); + return d3_relationship_graph($data['elements'], $data['matrix'], $radius, true); } diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index af4ca422b2..18a604dfb3 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -809,11 +809,10 @@ function netflow_get_summary($start_date, $end_date, $filter, $connection_name=' * @param string end_date Period end date. * @param string filter Netflow filter. * @param int max Maximum number of elements. - * @param string unit to show. * * @return An array with netflow stats. */ -function netflow_get_record($start_date, $end_date, $filter, $max, $unit, $address_resolution=false) +function netflow_get_record($start_date, $end_date, $filter, $max, $address_resolution=false) { global $nfdump_date_format; global $config; @@ -852,32 +851,7 @@ function netflow_get_record($start_date, $end_date, $filter, $max, $unit, $addre $data['source_port'] = $items[5]; $data['destination_port'] = $items[6]; $data['protocol'] = $items[7]; - - switch ($unit) { - case 'megabytes': - $data['data'] = ($items[12] / 1048576); - break; - - case 'megabytespersecond': - $data['data'] = ($items[12] / 1048576 / $data['duration']); - break; - - case 'kilobytes': - $data['data'] = ($items[12] / 1024); - break; - - case 'kilobytespersecond': - $data['data'] = ($items[12] / 1024 / $data['duration']); - break; - - default: - case 'bytes': - $data['data'] = $items[12]; - break; - case 'bytespersecond': - $data['data'] = ($items[12] / $data['duration']); - break; - } + $data['data'] = $items[12]; $values[] = $data; } @@ -1329,7 +1303,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil break; case 'netflow_mesh': - $netflow_data = netflow_get_record($start_date, $end_date, $filter, $max_aggregates, $unit, $address_resolution); + $netflow_data = netflow_get_record($start_date, $end_date, $filter, $max_aggregates, $address_resolution); switch ($aggregate) { case 'srcport': @@ -1374,14 +1348,14 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil } $html = '
'; - $html .= graph_netflow_circular_mesh($data, netflow_format_unit($unit), 700); + $html .= graph_netflow_circular_mesh($data, 700); $html .= '
'; return $html; break; case 'netflow_host_treemap': - $netflow_data = netflow_get_record($start_date, $end_date, $filter, $max_aggregates, $unit, $address_resolution); + $netflow_data = netflow_get_record($start_date, $end_date, $filter, $max_aggregates, $address_resolution); switch ($aggregate) { case 'srcip': @@ -1434,7 +1408,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $children_data['id'] = $id++; $children_data['name'] = $port; $children_data['value'] = $value; - $children_data['tooltip_content'] = "$port: ".format_numeric($value).' '.netflow_format_unit($unit).''; + $children_data['tooltip_content'] = $port.': '.network_format_bytes($value).''; $children['children'][] = $children_data; } diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php index 3bd3224445..70cafb221f 100644 --- a/pandora_console/include/graphs/functions_d3.php +++ b/pandora_console/include/graphs/functions_d3.php @@ -38,7 +38,7 @@ function include_javascript_d3($return=false) } -function d3_relationship_graph($elements, $matrix, $unit, $width=700, $return=false) +function d3_relationship_graph($elements, $matrix, $width=700, $return=false) { global $config; @@ -53,7 +53,7 @@ function d3_relationship_graph($elements, $matrix, $unit, $width=700, $return=fa $output = '
'; $output .= include_javascript_d3(true); $output .= ""; if (!$return) { diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index 40dcd34ac1..fdca6d10fd 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -20,7 +20,7 @@ // matrix = [[0, 0, 2], // a[a => a, a => b, a => c] // [5, 0, 1], // b[b => a, b => b, b => c] // [2, 3, 0]]; // c[c => a, c => b, c => c] -function chordDiagram(recipient, elements, matrix, unit, width) { +function chordDiagram(recipient, elements, matrix, width) { d3.chart = d3.chart || {}; d3.chart.chordWheel = function(options) { // Default values @@ -206,18 +206,14 @@ function chordDiagram(recipient, elements, matrix, unit, width) { " → " + elements[d.target.index] + ": " + - d.source.value.toFixed(2) + - " " + - unit + + valueToBytes(d.source.value) + "" + "
" + elements[d.target.index] + " → " + elements[d.source.index] + ": " + - d.target.value.toFixed(2) + - " " + - unit + + valueToBytes(d.target.value) + "" ) ); @@ -227,18 +223,14 @@ function chordDiagram(recipient, elements, matrix, unit, width) { " → " + elements[d.target.index] + ": " + - d.source.value.toFixed(2) + - " " + - unit + + valueToBytes(d.source.value) + "" + "
" + elements[d.target.index] + " → " + elements[d.source.index] + ": " + - d.target.value.toFixed(2) + - " " + - unit + + valueToBytes(d.target.value) + "" ); } @@ -2744,3 +2736,17 @@ function printClockDigital1( setTimeout(tick, 1000 - (now % 1000)); })(); } + +function valueToBytes(value) { + var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"]; + var pos = 0; + while (value >= 1024) { + // As long as the number can be divided by divider. + pos++; + // Position in array starting with 0. + value = value / 1024; + } + + // This will actually do the rounding and the decimals. + return value.toFixed(2) + shorts[pos] + "B"; +} From da08acce4f171279d89ff25059c59c10d672b8b2 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 14 Mar 2019 10:36:15 +0100 Subject: [PATCH 60/94] [Netflow live] Removed units Former-commit-id: 37d9182a46a85b44a400a50eae48cd7778a3dc84 --- pandora_console/include/functions_graph.php | 6 +- pandora_console/include/functions_netflow.php | 63 ++++--------------- .../operation/netflow/nf_live_view.php | 15 ----- 3 files changed, 14 insertions(+), 70 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 6843dab8da..6e881a06b9 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4109,7 +4109,7 @@ function fullscale_data( /** * Print an area graph with netflow aggregated */ -function graph_netflow_aggregate_area($data, $period, $width, $height, $unit='', $ttl=1, $only_image=false, $date=null) +function graph_netflow_aggregate_area($data, $period, $width, $height, $ttl=1, $only_image=false, $date=null) { global $config; global $graphic_type; @@ -4155,7 +4155,7 @@ function graph_netflow_aggregate_area($data, $period, $width, $height, $unit='', 'period' => $period, 'width' => '90%', 'height' => 450, - 'unit' => $unit, + 'unit' => 'bytes', 'only_image' => $only_image, 'homeurl' => $homeurl, 'menu' => true, @@ -4306,7 +4306,7 @@ function graph_netflow_circular_mesh($data, $radius=700) /** * Print a rectangular graph with the traffic of the ports for each IP */ -function graph_netflow_host_traffic($data, $unit, $width=700, $height=700) +function graph_netflow_host_traffic($data, $width=700, $height=700) { global $config; diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 18a604dfb3..76b75f44ae 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -289,7 +289,7 @@ function netflow_stat_table($data, $start_date, $end_date, $aggregate) * * @return The statistics table. */ -function netflow_data_table($data, $start_date, $end_date, $aggregate, $unit) +function netflow_data_table($data, $start_date, $end_date, $aggregate) { global $nfdump_date_format; @@ -346,7 +346,7 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate, $unit) foreach ($data as $timestamp => $value) { $table->data[$i][0] = date($time_format, $timestamp); - $table->data[$i][1] = format_numeric($value['data']).' '.netflow_format_unit($unit); + $table->data[$i][1] = network_format_bytes($value['data']); $i++; } } @@ -463,7 +463,7 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag // Requesting remote data if (defined('METACONSOLE') && $connection_name != '') { - $data = metaconsole_call_remote_api($connection_name, 'netflow_get_data', "$start_date|$end_date|$interval_length|".base64_encode(json_encode($filter))."|$aggregate|$max|$unit".(int) $address_resolution); + $data = metaconsole_call_remote_api($connection_name, 'netflow_get_data', "$start_date|$end_date|$interval_length|".base64_encode(json_encode($filter))."|$aggregate|$max|1".(int) $address_resolution); return json_decode($data, true); } @@ -611,7 +611,7 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag $filter, $aggregate, $max, - $unit, + $absolute, $connection_name ); @@ -1107,7 +1107,6 @@ function netflow_get_valid_intervals() function netflow_draw_item($start_date, $end_date, $interval_length, $type, $filter, $max_aggregates, $connection_name='', $output='HTML', $address_resolution=false) { $aggregate = $filter['aggregate']; - $unit = $filter['output']; $interval = ($end_date - $start_date); if (defined('METACONSOLE')) { $width = 950; @@ -1121,22 +1120,20 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil switch ($type) { case '0': case 'netflow_area': - $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, true, $connection_name, $address_resolution); + $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, false, $connection_name, $address_resolution); if (empty($data)) { break; } if ($output == 'HTML' || $output == 'PDF') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); if ($interval_length != 0) { $html .= ' '._('Resolution').': '.netflow_get_resolution_name($interval_length); } - $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 1, false, $end_date); + $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, 1, false, $end_date); return $html; } else if ($output == 'XML') { - $xml = "$unit\n"; $xml .= "$aggregate\n"; $xml .= "$interval_length\n"; $xml .= netflow_aggregate_area_xml($data); @@ -1146,26 +1143,24 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil case '2': case 'netflow_data': - $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, false, $connection_name, $address_resolution); + $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, true, $connection_name, $address_resolution); if (empty($data)) { break; } if ($output == 'HTML' || $output == 'PDF') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); if ($interval_length != 0) { $html .= ' '._('Resolution').': '.netflow_get_resolution_name($interval_length); } $html .= "
"; - $html .= netflow_data_table($data, $start_date, $end_date, $aggregate, $unit); + $html .= netflow_data_table($data, $start_date, $end_date, $aggregate); $html .= '
'; return $html; } else if ($output == 'XML') { - $xml = "$unit\n"; $xml .= "$aggregate\n"; $xml .= "$interval_length\n"; // Same as netflow_aggregate_area_xml @@ -1225,7 +1220,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $filter, $aggregate, $max_aggregates, - $unit, + true, $connection_name, $address_resolution ); @@ -1234,17 +1229,14 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil } if ($output == 'HTML') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); $html .= graph_netflow_aggregate_pie($data_pie, netflow_format_aggregate($aggregate)); return $html; } else if ($output == 'PDF') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); $html .= ' '.__('Aggregate').": $aggregate"; $html .= graph_netflow_aggregate_pie($data_pie, netflow_format_aggregate($aggregate), 2, true); return $html; } else if ($output == 'XML') { - $xml = "$unit\n"; $xml .= "$aggregate\n"; $xml .= netflow_aggregate_pie_xml($data_pie); return $xml; @@ -1268,7 +1260,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $filter, $aggregate, $max_aggregates, - $unit, + true, $connection_name, $address_resolution ); @@ -1415,7 +1407,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $data['children'][] = $children; } } - return graph_netflow_host_traffic($data, netflow_format_unit($unit), 'auto', 400); + return graph_netflow_host_traffic($data, 'auto', 400); break; default: @@ -1493,7 +1485,6 @@ function netflow_xml_report($id, $start_date, $end_date, $interval_length=0) echo ' '.io_safe_output($filter['src_port'])."\n"; echo ' '.io_safe_output($filter['advanced_filter'])."\n"; echo ' '.io_safe_output($filter['aggregate'])."\n"; - echo ' '.io_safe_output($filter['output'])."\n"; echo " \n"; echo netflow_draw_item($start_date, $end_date, $interval_length, $content['show_graph'], $filter, $content['max'], $report['server_name'], 'XML'); @@ -1642,38 +1633,6 @@ function netflow_summary_xml($data) } -/** - * Return a string describing the given unit. - * - * @param string Netflow unit. - */ -function netflow_format_unit($unit) -{ - switch ($unit) { - case 'megabytes': - return __('MB'); - - case 'megabytespersecond': - return __('MB/s'); - - case 'kilobytes': - return __('kB'); - - case 'kilobytespersecond': - return __('kB/s'); - - case 'bytes': - return __('Bytes'); - - case 'bytespersecond': - return __('B/s'); - - default: - return ''; - } -} - - /** * Return a string describing the given aggregate. * diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 4724371b0f..65a7f31f12 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -80,7 +80,6 @@ $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', ''); @@ -453,17 +452,6 @@ if (is_metaconsole()) { 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 ''; echo ''; @@ -625,7 +613,6 @@ if (is_metaconsole()) { $("#text-router_ip").val(''); $("#textarea_advanced_filter").val(''); $("#aggregate").val(''); - $("#output").val(''); // Hide update filter button $("#submit-update_button").hide(); @@ -694,8 +681,6 @@ if (is_metaconsole()) { $("#textarea_advanced_filter").val(val); if (i == 'aggregate') $("#aggregate").val(val); - if (i == 'output') - $("#output").val(val); }); }, "json"); From d174af9a57f99b5a6715b55ddcee079b69239107 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 14 Mar 2019 10:43:59 +0100 Subject: [PATCH 61/94] [Netflow live] Fixed filter styles Former-commit-id: 8990361112fb96fbe2589ac2e31a105167754a8d --- pandora_console/operation/netflow/nf_live_view.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 65a7f31f12..b9913f6b76 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -361,7 +361,7 @@ if (is_metaconsole()) { 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 ''.__('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).''; } @@ -384,7 +384,7 @@ if (is_metaconsole()) { 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).''; + echo ''.html_print_input_text('ip_dst', $filter['ip_dst'], false, 40, 80, true).''; } if ($netflow_disable_custom_lvfilters) { @@ -392,7 +392,7 @@ if (is_metaconsole()) { 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 ''.html_print_input_text('ip_src', $filter['ip_src'], false, 40, 80, true).''; } echo ''; @@ -403,7 +403,7 @@ if (is_metaconsole()) { 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).''; + echo ''.html_print_input_text('dst_port', $filter['dst_port'], false, 40, 80, true).''; } if ($netflow_disable_custom_lvfilters) { @@ -411,7 +411,7 @@ if (is_metaconsole()) { 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 ''.html_print_input_text('src_port', $filter['src_port'], false, 40, 80, true).''; } echo ''; @@ -447,10 +447,10 @@ if (is_metaconsole()) { true ); echo ''.__('IP address resolution').''.ui_print_help_tip(__('Resolve the IP addresses to get their hostnames.'), true).''; - echo ''.$radio_buttons.''; + echo ''.$radio_buttons.''; echo ''.__('Router ip').''; - echo ''.html_print_input_text('router_ip', $filter['router_ip'], false, 30, 80, true).''; + echo ''.html_print_input_text('router_ip', $filter['router_ip'], false, 40, 80, true).''; echo ''; From 6299d2352860d15db9097e32fe16603c9b344764 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 14 Mar 2019 17:49:44 +0100 Subject: [PATCH 62/94] [Netflow live] Minor fixes Former-commit-id: 9778bf449513e3fad89f59f56f327e7afd154d96 --- pandora_console/include/functions_graph.php | 2 ++ pandora_console/include/functions_netflow.php | 10 +++++++++- pandora_console/operation/netflow/nf_live_view.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 6e881a06b9..19e04e39f8 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4166,6 +4166,8 @@ function graph_netflow_aggregate_area($data, $period, $width, $height, $ttl=1, $ 'array_data_create' => $chart, 'stacked' => 1, 'date' => $date, + 'show_export_csv' => false, + 'show_overview' => false, ]; return grafico_modulo_sparse($params); diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 76b75f44ae..c89366b1c4 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1131,7 +1131,15 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $html .= ' '._('Resolution').': '.netflow_get_resolution_name($interval_length); } - $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, 1, false, $end_date); + $html .= graph_netflow_aggregate_area( + $data, + $interval, + $width, + $height, + ($output === 'HTML') ? 1 : 2, + ($output === 'HTML'), + $end_date + ); return $html; } else if ($output == 'XML') { $xml .= "$aggregate\n"; diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index b9913f6b76..662403c370 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -449,7 +449,7 @@ if (is_metaconsole()) { echo ''.__('IP address resolution').''.ui_print_help_tip(__('Resolve the IP addresses to get their hostnames.'), true).''; echo ''.$radio_buttons.''; - echo ''.__('Router ip').''; + echo ''.__('Source ip').''; echo ''.html_print_input_text('router_ip', $filter['router_ip'], false, 40, 80, true).''; echo ''; From 33fd100d91685132e4fc9694c7f18d0c340b07f6 Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 15 Mar 2019 10:46:18 +0100 Subject: [PATCH 63/94] [Netflow view] Added start date Former-commit-id: 98134de0f1e8c40458b36b0a14ad0b8c87bff0f2 --- .../operation/netflow/nf_live_view.php | 68 +++++++++++++++---- 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 662403c370..a264d3f7c2 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -90,25 +90,33 @@ $filter['router_ip'] = get_parameter('router_ip'); // Read chart configuration. $chart_type = get_parameter('chart_type', 'netflow_area'); $max_aggregates = (int) get_parameter('max_aggregates', 10); -$period = (int) get_parameter('period', SECONDS_1DAY); $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 = 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 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. ui_print_page_header( @@ -248,15 +256,40 @@ if (is_metaconsole()) { echo ''; - echo ''.__('Date').''; + 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).''; - echo ''.__('Interval').''; - echo ''.html_print_select(netflow_get_valid_intervals(), 'period', $period, '', '', 0, true, false, false).''; + $class_not_period = ($is_period) ? 'nf_hidden' : 'nf_display'; + $class_period = ($is_period) ? 'nf_display' : 'nf_hidden'; + echo ''; + echo ''.__('Interval').''; + echo ''.__('Start date').''; + 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 ''; + 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 ''; echo ''.__('Resolution').ui_print_help_tip(__('The interval will be divided in chunks the length of the resolution.'), true).''; echo ''.html_print_select( @@ -341,7 +374,7 @@ if (is_metaconsole()) { echo ''; echo ''; - echo ''; + echo ''; html_print_image( 'images/darrowdown.png', false, @@ -714,7 +747,7 @@ if (is_metaconsole()) { }); }); - $("#text-time").timepicker({ + $("#text-time, #text-time_lower").timepicker({ showSecond: true, timeFormat: '', timeOnlyTitle: '', @@ -725,12 +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 From bf5dfd8bdb7d11561159e8b861fded2b69ea85b9 Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 15 Mar 2019 10:52:46 +0100 Subject: [PATCH 64/94] Extend class to pencil image in html interval component Former-commit-id: baf46a4b64f58e300b092a8ee71c438931e2d840 --- pandora_console/include/functions_html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index e38e7160ec..d244351c6c 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1060,7 +1060,7 @@ function html_print_extended_select_for_time( 'images/pencil.png', true, [ - 'class' => $uniq_name.'_toggler', + 'class' => $uniq_name.'_toggler '.$class, 'alt' => __('Custom'), 'title' => __('Custom'), 'style' => 'width: 18px;'.$style_icon, From c123d9d9fd702426549e8d1828e0a89c4cc98249 Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 15 Mar 2019 11:36:13 +0100 Subject: [PATCH 65/94] [Netflow live] Recalculate multiplier time if resolution is too high Former-commit-id: 60861c9e220a9d69841939dd485265e52542b1ae --- pandora_console/include/functions_netflow.php | 41 ++++--------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index c89366b1c4..2cef9b3263 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -494,6 +494,15 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag break; } + // Recalculate to not pass of netflow_max_resolution. + if ($config['netflow_max_resolution'] > 0 + && (($end_date - $start_date) / $multiplier_time) > 50 + ) { + $multiplier_time = ceil( + (($end_date - $start_date) / $config['netflow_max_resolution']) + ); + } + // Put all points into an array. $intervals = [($start_date - $multiplier_time)]; while ((end($intervals) < $end_date) === true) { @@ -1059,38 +1068,6 @@ function netflow_get_chart_types() } -/** - * Gets valid intervals for a netflow chart in the format: - * - * interval_length => interval_description - * - * @return array of valid intervals. - */ -function netflow_get_valid_intervals() -{ - return [ - (string) SECONDS_10MINUTES => __('10 mins'), - (string) SECONDS_15MINUTES => __('15 mins'), - (string) SECONDS_30MINUTES => __('30 mins'), - (string) SECONDS_1HOUR => __('1 hour'), - (string) SECONDS_2HOUR => __('2 hours'), - (string) SECONDS_5HOUR => __('5 hours'), - (string) SECONDS_12HOURS => __('12 hours'), - (string) SECONDS_1DAY => __('1 day'), - (string) SECONDS_2DAY => __('2 days'), - (string) SECONDS_5DAY => __('5 days'), - (string) SECONDS_15DAYS => __('15 days'), - (string) SECONDS_1WEEK => __('Last week'), - (string) SECONDS_1MONTH => __('Last month'), - (string) SECONDS_2MONTHS => __('2 months'), - (string) SECONDS_3MONTHS => __('3 months'), - (string) SECONDS_6MONTHS => __('6 months'), - (string) SECONDS_1YEAR => __('Last year'), - (string) SECONDS_2YEARS => __('2 years'), - ]; -} - - /** * Draw a netflow report item. * From fbce6d8abaf26f6ee245551c0f531d9961ab193f Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 15 Mar 2019 14:24:49 +0100 Subject: [PATCH 66/94] Fixed code style Former-commit-id: 0292582ee1d12de325929e77053f1f15985791fb --- pandora_console/include/functions_netflow.php | 595 ++++++++---------- 1 file changed, 257 insertions(+), 338 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 2cef9b3263..4686e5588f 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1,22 +1,34 @@ id_name)) or filters filtered * - * @param mixed Array with filter conditions to retrieve filters or false. + * @param mixed $filter Array with filter conditions to retrieve filters or + * false. * - * @return array List of all filters + * @return array List of all filters. */ function netflow_get_filters($filter=false) { @@ -64,9 +77,10 @@ function netflow_get_filters($filter=false) /** * Selects all netflow reports (array (id_name => id_name)) or filters filtered * - * @param mixed Array with filter conditions to retrieve filters or false. + * @param mixed $filter Array with filter conditions to retrieve filters or + * false. * - * @return array List of all filters + * @return array List of all filters. */ function netflow_get_reports($filter=false) { @@ -89,14 +103,20 @@ function netflow_get_reports($filter=false) } -// permite validar si un filtro pertenece a un grupo permitido para el usuario +/** + * Check if a filter owns to a certain group. + * + * @param integer $id_sg Id group to check. + * + * @return boolean True if user manages that group. + */ function netflow_check_filter_group($id_sg) { global $config; $id_group = db_get_value('id_group', 'tnetflow_filter', 'id_sg', $id_sg); $own_info = get_user_info($config['id_user']); - // Get group list that user has access + // Get group list that user has access. $groups_user = users_get_groups($config['id_user'], 'IW', $own_info['is_admin'], true); $groups_id = []; $has_permission = false; @@ -111,44 +131,12 @@ function netflow_check_filter_group($id_sg) } -/* - Permite validar si un informe pertenece a un grupo permitido para el usuario. - * Si mode = false entonces es modo godmode y solo puede ver el grupo All el admin - * Si es modo operation (mode = true) entonces todos pueden ver el grupo All - */ - -function netflow_check_report_group($id_report, $mode=false) -{ - global $config; - - if (!$mode) { - $own_info = get_user_info($config['id_user']); - $mode = $own_info['is_admin']; - } - - $id_group = db_get_value('id_group', 'tnetflow_report', 'id_report', $id_report); - - // Get group list that user has access - $groups_user = users_get_groups($config['id_user'], 'IW', $mode, true); - $groups_id = []; - $has_permission = false; - - foreach ($groups_user as $key => $groups) { - if ($groups['id_grupo'] == $id_group) { - return true; - } - } - - return false; -} - - /** * Get a filter. * - * @param int filter id to be fetched. - * @param array Extra filter. - * @param array Fields to be fetched. + * @param integer $id_sg Filter id to be fetched. + * @param mixed $filter Extra filter. + * @param mixed $fields Fields to be fetched. * * @return array A netflow filter matching id and filter. */ @@ -164,52 +152,11 @@ function netflow_filter_get_filter($id_sg, $filter=false, $fields=false) } -/** - * Get options. - * - * @param int filter id to be fetched. - * @param array Extra filter. - * @param array Fields to be fetched. - * - * @return array A netflow filter matching id and filter. - */ -function netflow_reports_get_reports($id_report, $filter=false, $fields=false) -{ - if (empty($id_report)) { - return false; - } - - if (! is_array($filter)) { - $filter = []; - } - - $filter['id_report'] = (int) $id_report; - - return db_get_row_filter('tnetflow_report', $filter, $fields); -} - - -function netflow_reports_get_content($id_rc, $filter=false, $fields=false) -{ - if (empty($id_rc)) { - return false; - } - - if (! is_array($filter)) { - $filter = []; - } - - $filter['id_rc'] = (int) $id_rc; - - return db_get_row_filter('tnetflow_report_content', $filter, $fields); -} - - /** * Compare two flows according to the 'data' column. * - * @param array a First flow. - * @param array b Second flow. + * @param array $a First flow. + * @param array $b Second flow. * * @return Result of the comparison. */ @@ -222,7 +169,9 @@ function compare_flows($a, $b) /** * Sort netflow data according to the 'data' column. * - * @param array netflow_data Netflow data array. + * @param array $netflow_data Netflow data array. + * + * @return void (Array passed by reference) */ function sort_netflow_data(&$netflow_data) { @@ -233,12 +182,12 @@ function sort_netflow_data(&$netflow_data) /** * Show a table with netflow statistics. * - * @param array data Statistic data. - * @param string start_date Start date. - * @param string end_date End date. - * @param string aggregate Aggregate field. + * @param array $data Statistic data. + * @param string $start_date Start date. + * @param string $end_date End date. + * @param string $aggregate Aggregate field. * - * @return The statistics table. + * @return string HTML statistics table. */ function netflow_stat_table($data, $start_date, $end_date, $aggregate) { @@ -282,12 +231,12 @@ function netflow_stat_table($data, $start_date, $end_date, $aggregate) /** * Show a table with netflow data. * - * @param array data Netflow data. - * @param string start_date Start date. - * @param string end_date End date. - * @param string aggregate Aggregate field. + * @param array $data Netflow data. + * @param string $start_date Start date. + * @param string $end_date End date. + * @param string $aggregate Aggregate field. * - * @return The statistics table. + * @return string HTML data table. */ function netflow_data_table($data, $start_date, $end_date, $aggregate) { @@ -297,7 +246,7 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate) $start_date = date($nfdump_date_format, $start_date); $end_date = date($nfdump_date_format, $end_date); - // Set the format + // Set the format. if ($period <= SECONDS_6HOURS) { $time_format = 'H:i:s'; } else if ($period < SECONDS_1DAY) { @@ -338,7 +287,7 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate) $table->style[1] = 'padding: 4px;'; } - // No aggregates + // No aggregates. if ($source_count == 0) { $table->head[1] = __('Data'); $table->align[1] = 'right'; @@ -350,7 +299,8 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate) $i++; } } - // Aggregates + + // Aggregates. else { $i = 0; foreach ($data['data'] as $timestamp => $values) { @@ -372,9 +322,9 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate) /** * Show a table with a traffic summary. * - * @param array data Summary data. + * @param array $data Summary data. * - * @return The statistics table. + * @return string HTML summary table. */ function netflow_summary_table($data) { @@ -428,7 +378,7 @@ function netflow_summary_table($data) /** * Returns 1 if the given address is a network address. * - * @param string address Host or network address. + * @param string $address Host or network address. * * @return 1 if the address is a network address, 0 otherwise. */ @@ -445,25 +395,40 @@ function netflow_is_net($address) /** * Returns netflow data for the given period in an array. * - * @param string start_date Period start date. - * @param string end_date Period end date. - * @param string filter Netflow filter. - * @param string aggregate Aggregate field. - * @param int max Maximum number of aggregates. - * @param int max Maximum number of aggregates. - * @param boolean absolute True to give the absolute data and false to get - * troughput. + * @param string $start_date Period start date. + * @param string $end_date Period end date. + * @param mixed $interval_length Resolution points or hourly or daily. + * @param string $filter Netflow filter. + * @param string $aggregate Aggregate field. + * @param integer $max Maximum number of aggregates. + * @param boolean $absolute True to give the absolute data and false + * to get troughput. + * @param string $connection_name Node name when data is get in meta. + * @param boolean $address_resolution True to resolve ips to hostnames. * - * @return An array with netflow stats. + * @return array An array with netflow stats. */ -function netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max, $absolute, $connection_name='', $address_resolution=false) -{ +function netflow_get_data( + $start_date, + $end_date, + $interval_length, + $filter, + $aggregate, + $max, + $absolute, + $connection_name='', + $address_resolution=false +) { global $nfdump_date_format; global $config; - // Requesting remote data + // Requesting remote data. if (defined('METACONSOLE') && $connection_name != '') { - $data = metaconsole_call_remote_api($connection_name, 'netflow_get_data', "$start_date|$end_date|$interval_length|".base64_encode(json_encode($filter))."|$aggregate|$max|1".(int) $address_resolution); + $data = metaconsole_call_remote_api( + $connection_name, + 'netflow_get_data', + "$start_date|$end_date|$interval_length|".base64_encode(json_encode($filter))."|$aggregate|$max|1".(int) $address_resolution + ); return json_decode($data, true); } @@ -513,24 +478,25 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag $intervals[] = $end_date; } - // If there is aggregation calculate the top n + // If there is aggregation calculate the top n. $values['data'] = []; $values['sources'] = []; - // Get the command to call nfdump + // Get the command to call nfdump. $command = netflow_get_command($filter); - // Suppress the header line and the statistics at the bottom and configure piped output + // Suppress the header line and the statistics at the bottom and configure + // piped output. $command .= ' -q -o csv'; - // Call nfdump + // Call nfdump. $agg_command = $command." -n $max -s $aggregate/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($agg_command, $string); - // Remove the first line + // Remove the first line. $string[0] = ''; - // Parse aggregates + // Parse aggregates. foreach ($string as $line) { if ($line == '') { continue; @@ -544,7 +510,7 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag } } - // Update the filter + // Update the filter. switch ($aggregate) { case 'proto': $extra_filter = 'proto'; @@ -576,7 +542,7 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag array_keys($values['sources']) ); - // Address resolution start + // Address resolution start. $get_hostnames = false; if ($address_resolution && ($aggregate == 'srcip' || $aggregate == 'dstip')) { $get_hostnames = true; @@ -609,7 +575,7 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag $interval_end = $intervals[($k + 1)]; - // Set default values + // Set default values. foreach ($values['sources'] as $source => $discard) { $values['data'][$interval_end][$source] = 0; } @@ -625,11 +591,11 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag ); foreach ($data as $line) { - // Address resolution start + // Address resolution start. if ($get_hostnames) { if (!isset($hostnames[$line['agg']])) { $hostname = false; - // Trying to get something like an IP from the description + // Trying to get something like an IP from the description. if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $line['agg'], $matches) || preg_match( "/(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:?)|\2))(?4){5}((?4){2}|(25[0-5]| @@ -652,7 +618,7 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag } } - // Address resolution end + // Address resolution end. if (! isset($values['sources'][$line['agg']])) { continue; } @@ -672,30 +638,40 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag /** * Returns netflow stats for the given period in an array. * - * @param string start_date Period start date. - * @param string end_date Period end date. - * @param string filter Netflow filter. - * @param string aggregate Aggregate field. - * @param int max Maximum number of aggregates. - * @param boolean absolute True to give the absolute data and false to get - * troughput. + * @param string $start_date Period start date. + * @param string $end_date Period end date. + * @param string $filter Netflow filter. + * @param string $aggregate Aggregate field. + * @param integer $max Maximum number of aggregates. + * @param boolean $absolute True to give the absolute data and false to get + * troughput. + * @param string $connection_name Node name when data is get in meta. + * @param boolean $address_resolution True to resolve ips to hostnames. * - * @return An array with netflow stats. + * @return array With netflow stats. */ -function netflow_get_stats($start_date, $end_date, $filter, $aggregate, $max, $absolute=true, $connection_name='', $address_resolution=false) -{ +function netflow_get_stats( + $start_date, + $end_date, + $filter, + $aggregate, + $max, + $absolute=true, + $connection_name='', + $address_resolution=false +) { global $config, $nfdump_date_format; - // Requesting remote data + // Requesting remote data. if (defined('METACONSOLE') && $connection_name != '') { $data = metaconsole_call_remote_api($connection_name, 'netflow_get_stats', "$start_date|$end_date|".base64_encode(json_encode($filter))."|$aggregate|$max|$absolute|".(int) $address_resolution); return json_decode($data, true); } - // Get the command to call nfdump + // Get the command to call nfdump. $command = netflow_get_command($filter); - // Execute nfdump + // Execute nfdump. $command .= " -o csv -q -n $max -s $aggregate/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($command, $string); @@ -703,7 +679,7 @@ function netflow_get_stats($start_date, $end_date, $filter, $aggregate, $max, $a return []; } - // Remove the first line + // Remove the first line. $string[0] = ''; $i = 0; @@ -719,14 +695,14 @@ function netflow_get_stats($start_date, $end_date, $filter, $aggregate, $max, $a $values[$i]['date'] = $val[0]; $values[$i]['time'] = $val[1]; - // create field to sort array + // Create field to sort array. $datetime = $val[0]; $end_date = strtotime($datetime); $values[$i]['datetime'] = $end_date; if ($aggregate == 'proto') { $values[$i]['agg'] = $val[3]; } else { - // Address resolution start + // Address resolution start. if ($address_resolution && ($aggregate == 'srcip' || $aggregate == 'dstip')) { global $hostnames; @@ -741,7 +717,7 @@ function netflow_get_stats($start_date, $end_date, $filter, $aggregate, $max, $a } } - // Address resolution end + // Address resolution end. $values[$i]['agg'] = $val[4]; } @@ -766,27 +742,28 @@ function netflow_get_stats($start_date, $end_date, $filter, $aggregate, $max, $a /** * Returns a traffic summary for the given period in an array. * - * @param string start_date Period start date. - * @param string end_date Period end date. - * @param string filter Netflow filter. + * @param string $start_date Period start date. + * @param string $end_date Period end date. + * @param string $filter Netflow filter. + * @param string $connection_name Node name when data is get in meta. * - * @return An array with netflow stats. + * @return array With netflow summary data. */ function netflow_get_summary($start_date, $end_date, $filter, $connection_name='') { global $nfdump_date_format; global $config; - // Requesting remote data + // Requesting remote data. if (defined('METACONSOLE') && $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); } - // Get the command to call nfdump + // Get the command to call nfdump. $command = netflow_get_command($filter); - // Execute nfdump + // Execute nfdump. $command .= ' -o csv -n 1 -s srcip/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($command, $string); @@ -794,7 +771,7 @@ function netflow_get_summary($start_date, $end_date, $filter, $connection_name=' return []; } - // Read the summary + // Read the summary. $summary = explode(',', $string[5]); if (! isset($summary[5])) { return []; @@ -814,31 +791,28 @@ function netflow_get_summary($start_date, $end_date, $filter, $connection_name=' /** * Returns a traffic record for the given period in an array. * - * @param string start_date Period start date. - * @param string end_date Period end date. - * @param string filter Netflow filter. - * @param int max Maximum number of elements. + * @param string $start_date Period start date. + * @param string $end_date Period end date. + * @param string $filter Netflow filter. + * @param integer $max Maximum number of elements. + * @param boolean $address_resolution True to resolve ips to hostnames. * - * @return An array with netflow stats. + * @return array With netflow record data. */ -function netflow_get_record($start_date, $end_date, $filter, $max, $address_resolution=false) -{ +function netflow_get_record( + $start_date, + $end_date, + $filter, + $max, + $address_resolution=false +) { global $nfdump_date_format; global $config; - // TIME_START = 0; - // TIME_END = 1; - // DURATION = 2; - // SOURCE_ADDRESS = 3; - // DESTINATION_ADDRESS = 4; - // SOURCE_PORT = 5; - // DESTINATION_PORT = 6; - // PROTOCOL = 7; - // INPUT_BYTES = 12; - // Get the command to call nfdump + // Get the command to call nfdump. $command = netflow_get_command($filter); - // Execute nfdump + // Execute nfdump. $command .= " -q -o csv -n $max -s record/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($command, $result); @@ -865,7 +839,7 @@ function netflow_get_record($start_date, $end_date, $filter, $max, $address_reso $values[] = $data; } - // Address resolution start + // Address resolution start. if ($address_resolution) { global $hostnames; @@ -892,7 +866,7 @@ function netflow_get_record($start_date, $end_date, $filter, $max, $address_reso } } - // Address resolution end + // Address resolution end. return $values; } @@ -900,23 +874,23 @@ function netflow_get_record($start_date, $end_date, $filter, $max, $address_reso /** * Returns the command needed to run nfdump for the given filter. * - * @param array filter Netflow filter. + * @param array $filter Netflow filter. * - * @return Command to run. + * @return string Command to run. */ function netflow_get_command($filter) { global $config; - // Build command + // Build command. $command = io_safe_output($config['netflow_nfdump']).' -N'; - // Netflow data path + // Netflow data path. if (isset($config['netflow_path']) && $config['netflow_path'] != '') { $command .= ' -R. -M '.$config['netflow_path']; } - // Filter options + // Filter options. $command .= netflow_get_filter_arguments($filter); return $command; @@ -926,13 +900,13 @@ function netflow_get_command($filter) /** * Returns the nfdump command line arguments that match the given filter. * - * @param array filter Netflow filter. + * @param array $filter Netflow filter. * - * @return Command line argument string. + * @return string Command line argument string. */ function netflow_get_filter_arguments($filter) { - // Advanced filter + // Advanced filter. $filter_args = ''; if ($filter['advanced_filter'] != '') { $filter_args = preg_replace('/["\r\n]/', '', io_safe_output($filter['advanced_filter'])); @@ -943,7 +917,7 @@ function netflow_get_filter_arguments($filter) $filter_args .= ' "(router ip '.$filter['router_ip'].')'; } - // Normal filter + // Normal filter. if ($filter['ip_dst'] != '') { $filter_args .= ' "('; $val_ipdst = explode(',', io_safe_output($filter['ip_dst'])); @@ -1071,18 +1045,30 @@ function netflow_get_chart_types() /** * Draw a netflow report item. * - * @param string start_date Period start date. - * @param string end_date Period end date. - * @param string interval_length Interval length in seconds (num_intervals * interval_length = start_date - end_date). - * @param string type Chart type. - * @param array filter Netflow filter. - * @param int max_aggregates Maximum number of aggregates. - * @param string output Output format. Only HTML and XML are supported. + * @param string $start_date Period start date. + * @param string $end_date Period end date. + * @param mixed $interval_length Resolution points or hourly or daily. + * @param string $type Chart type. + * @param array $filter Netflow filter. + * @param integer $max_aggregates Maximum number of aggregates. + * @param string $connection_name Node name when data is get in meta. + * @param string $output Output format. Only HTML, PDF and XML + * are supported. + * @param boolean $address_resolution True to resolve ips to hostnames. * - * @return The netflow report in the appropriate format. + * @return string The netflow report in the appropriate format. */ -function netflow_draw_item($start_date, $end_date, $interval_length, $type, $filter, $max_aggregates, $connection_name='', $output='HTML', $address_resolution=false) -{ +function netflow_draw_item( + $start_date, + $end_date, + $interval_length, + $type, + $filter, + $max_aggregates, + $connection_name='', + $output='HTML', + $address_resolution=false +) { $aggregate = $filter['aggregate']; $interval = ($end_date - $start_date); if (defined('METACONSOLE')) { @@ -1093,11 +1079,21 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $height = 320; - // Process item + // Process item. switch ($type) { case '0': case 'netflow_area': - $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, false, $connection_name, $address_resolution); + $data = netflow_get_data( + $start_date, + $end_date, + $interval_length, + $filter, + $aggregate, + $max_aggregates, + false, + $connection_name, + $address_resolution + ); if (empty($data)) { break; } @@ -1119,8 +1115,8 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil ); return $html; } else if ($output == 'XML') { - $xml .= "$aggregate\n"; - $xml .= "$interval_length\n"; + $xml .= ''.$aggregate."\n"; + $xml .= ''.$interval_length."\n"; $xml .= netflow_aggregate_area_xml($data); return $xml; } @@ -1128,8 +1124,17 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil case '2': case 'netflow_data': - $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, true, $connection_name, $address_resolution); - + $data = netflow_get_data( + $start_date, + $end_date, + $interval_length, + $filter, + $aggregate, + $max_aggregates, + true, + $connection_name, + $address_resolution + ); if (empty($data)) { break; } @@ -1146,9 +1151,9 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil return $html; } else if ($output == 'XML') { - $xml .= "$aggregate\n"; - $xml .= "$interval_length\n"; - // Same as netflow_aggregate_area_xml + $xml .= ''.$aggregate."\n"; + $xml .= ''.$interval_length."\n"; + // Same as netflow_aggregate_area_xml. $xml .= netflow_aggregate_area_xml($data); return $xml; } @@ -1218,11 +1223,11 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $html .= graph_netflow_aggregate_pie($data_pie, netflow_format_aggregate($aggregate)); return $html; } else if ($output == 'PDF') { - $html .= ' '.__('Aggregate').": $aggregate"; + $html .= ' '.__('Aggregate').': '.$aggregate; $html .= graph_netflow_aggregate_pie($data_pie, netflow_format_aggregate($aggregate), 2, true); return $html; } else if ($output == 'XML') { - $xml .= "$aggregate\n"; + $xml .= ''.$aggregate."\n"; $xml .= netflow_aggregate_pie_xml($data_pie); return $xml; } @@ -1268,19 +1273,23 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $html .= ''; return $html; - break; - case 'PDF': - break; - case 'XML': return netflow_summary_xml($data_summary); - break; + default: + // Nothing to do. + break; } break; case 'netflow_mesh': - $netflow_data = netflow_get_record($start_date, $end_date, $filter, $max_aggregates, $address_resolution); + $netflow_data = netflow_get_record( + $start_date, + $end_date, + $filter, + $max_aggregates, + $address_resolution + ); switch ($aggregate) { case 'srcport': @@ -1327,10 +1336,8 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $html = '
'; $html .= graph_netflow_circular_mesh($data, 700); $html .= '
'; - return $html; - break; case 'netflow_host_treemap': $netflow_data = netflow_get_record($start_date, $end_date, $filter, $max_aggregates, $address_resolution); @@ -1394,8 +1401,8 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil } return graph_netflow_host_traffic($data, 'auto', 400); - break; default: + // Nothing to do. break; } @@ -1405,99 +1412,25 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil } -/** - * Render a netflow report as an XML. - * - * @param int ID of the netflow report. - * @param string end_date Period start date. - * @param string end_date Period end date. - * @param string interval_length Interval length in seconds (num_intervals * interval_length = start_date - end_date). - */ -function netflow_xml_report($id, $start_date, $end_date, $interval_length=0) -{ - // Get report data - $report = db_get_row_sql('SELECT * FROM tnetflow_report WHERE id_report ='.(int) $id); - if ($report === false) { - echo ''.__('Error generating report')."\n"; - return; - } - - // Print report header - $time = get_system_time(); - echo ''; - echo "\n"; - echo " \n"; - echo ' '.$time."\n"; - echo ' '.date('r', $time)."\n"; - echo " \n"; - echo ' '.io_safe_output($report['id_name'])."\n"; - echo ' '.io_safe_output($report['description'])."\n"; - echo ' '.date('r', $start_date)."\n"; - echo ' '.date('r', $end_date)."\n"; - - // Get netflow item types - $item_types = netflow_get_chart_types(); - - // Print report items - $report_contents = db_get_all_rows_sql( - "SELECT * - FROM tnetflow_report_content - WHERE id_report='".$report['id_report']."' - ORDER BY `order`" - ); - foreach ($report_contents as $content) { - // Get item filters - $filter = db_get_row_sql( - "SELECT * - FROM tnetflow_filter - WHERE id_sg = '".io_safe_input($content['id_filter'])."'", - false, - true - ); - if ($filter === false) { - continue; - } - - echo " \n"; - echo ' '.io_safe_output($content['description'])."\n"; - echo ' '.io_safe_output($item_types[$content['show_graph']])."\n"; - echo ' '.$content['max']."\n"; - echo " \n"; - echo ' '.io_safe_output($filter['id_name'])."\n"; - echo ' '.io_safe_output($filter['ip_src'])."\n"; - echo ' '.io_safe_output($filter['ip_dst'])."\n"; - echo ' '.io_safe_output($filter['src_port'])."\n"; - echo ' '.io_safe_output($filter['src_port'])."\n"; - echo ' '.io_safe_output($filter['advanced_filter'])."\n"; - echo ' '.io_safe_output($filter['aggregate'])."\n"; - echo " \n"; - - echo netflow_draw_item($start_date, $end_date, $interval_length, $content['show_graph'], $filter, $content['max'], $report['server_name'], 'XML'); - - echo " \n"; - } - - echo "\n"; -} - - /** * Render an aggregated area chart as an XML. * - * @param array Netflow data. + * @param array $data Netflow data. + * + * @return void XML is echoed. */ function netflow_aggregate_area_xml($data) { - // Print source information + // Print source information. if (isset($data['sources'])) { echo "\n"; foreach ($data['sources'] as $source => $discard) { - echo "$source\n"; + echo ''.$source."\n"; } echo "\n"; - // Print flow information + // Print flow information. echo "\n"; foreach ($data['data'] as $timestamp => $flow) { echo "\n"; @@ -1527,36 +1460,16 @@ function netflow_aggregate_area_xml($data) } -/** - * Render an area chart as an XML. - * - * @param array Netflow data. - */ -function netflow_total_area_xml($data) -{ - // Print flow information - $xml = "\n"; - foreach ($data as $timestamp => $flow) { - $xml .= "\n"; - $xml .= ' '.$timestamp."\n"; - $xml .= ' '.$flow['data']."\n"; - $xml .= "\n"; - } - - $xml .= "\n"; - - return $xml; -} - - /** * Render a pie chart as an XML. * - * @param array Netflow data. + * @param array $data Netflow data. + * + * @return void XML is echoed. */ function netflow_aggregate_pie_xml($data) { - // Calculate total + // Calculate total. $total = 0; foreach ($data as $flow) { $total += $flow['data']; @@ -1566,7 +1479,7 @@ function netflow_aggregate_pie_xml($data) return; } - // Print percentages + // Print percentages. echo "\n"; foreach ($data as $flow) { echo ''.$flow['agg']."\n"; @@ -1580,11 +1493,13 @@ function netflow_aggregate_pie_xml($data) /** * Render a stats table as an XML. * - * @param array Netflow data. + * @param array $data Netflow data. + * + * @return string Wiht XML data. */ function netflow_stat_xml($data) { - // Print stats + // Print stats. $xml .= "\n"; foreach ($data as $flow) { $xml .= ''.$flow['agg']."\n"; @@ -1600,7 +1515,9 @@ function netflow_stat_xml($data) /** * Render a summary table as an XML. * - * @param array Netflow data. + * @param array $data Netflow data. + * + * @return string Wiht XML data. */ function netflow_summary_xml($data) { @@ -1621,7 +1538,9 @@ function netflow_summary_xml($data) /** * Return a string describing the given aggregate. * - * @param string Netflow aggregate. + * @param string $aggregate Netflow aggregate. + * + * @return string With formatted aggregate. */ function netflow_format_aggregate($aggregate) { @@ -1650,20 +1569,20 @@ function netflow_format_aggregate($aggregate) /** * Check the nfdump binary for compatibility. * - * @param string nfdump binary full path. + * @param string $nfdump_binary Nfdump binary full path. * - * @return 1 if the binary does not exist or is not executable, 2 if a + * @return integer 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 + // Check that the binary exists and is executable. if (! is_executable($nfdump_binary)) { return 1; } - // Check at least version 1.6.8 + // Check at least version 1.6.8. $output = ''; $rc = -1; exec($nfdump_binary.' -V', $output, $rc); From 60870efad6349402933e375d18268045c547ce64 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 18 Mar 2019 10:54:37 +0100 Subject: [PATCH 67/94] [Netflow live] Removed aggregate and resolution from report content and move to header subtitle Former-commit-id: 205e5f8ff7633016fe83667b2fc237bc1bdae03f --- pandora_console/include/functions_netflow.php | 46 ++++++++++++------- .../include/functions_reporting.php | 34 +++++++++++++- 2 files changed, 61 insertions(+), 19 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 4686e5588f..fb91f3584a 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1099,11 +1099,6 @@ function netflow_draw_item( } if ($output == 'HTML' || $output == 'PDF') { - $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); - if ($interval_length != 0) { - $html .= ' '._('Resolution').': '.netflow_get_resolution_name($interval_length); - } - $html .= graph_netflow_aggregate_area( $data, $interval, @@ -1140,11 +1135,6 @@ function netflow_draw_item( } if ($output == 'HTML' || $output == 'PDF') { - $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); - if ($interval_length != 0) { - $html .= ' '._('Resolution').': '.netflow_get_resolution_name($interval_length); - } - $html .= "
"; $html .= netflow_data_table($data, $start_date, $end_date, $aggregate); $html .= '
'; @@ -1219,16 +1209,10 @@ function netflow_draw_item( } if ($output == 'HTML') { - $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); - $html .= graph_netflow_aggregate_pie($data_pie, netflow_format_aggregate($aggregate)); return $html; } else if ($output == 'PDF') { - $html .= ' '.__('Aggregate').': '.$aggregate; - $html .= graph_netflow_aggregate_pie($data_pie, netflow_format_aggregate($aggregate), 2, true); return $html; } else if ($output == 'XML') { - $xml .= ''.$aggregate."\n"; - $xml .= netflow_aggregate_pie_xml($data_pie); return $xml; } break; @@ -1264,7 +1248,6 @@ function netflow_draw_item( $html .= ''; $html .= ''; $html .= netflow_summary_table($data_summary); - $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); $html .= ''; $html .= ''; $html .= graph_netflow_aggregate_pie($data_pie, netflow_format_aggregate($aggregate)); @@ -1789,3 +1772,32 @@ function netflow_get_resolution_name($value) $resolutions = netflow_resolution_select_params(); return (isset($resolutions[$value])) ? $resolutions[$value] : __('Unknown'); } + + +/** + * Report formatted subtitle. + * + * @param string $aggreagate Aggregate by param. + * @param string $resolution Netfow live view resolution. + * @param string $type Type of view. + * + * @return string HTML with formatted subtitle. + */ +function netflow_generate_subtitle_report($aggregate, $resolution, $type) +{ + $subt = __( + 'Agregate by %s', + netflow_format_aggregate($aggregate) + ); + + // Display the resolution only in required reports. + if (in_array($type, ['netflow_area', 'netflow_data']) === true) { + $subt .= ' - '; + $subt .= __( + 'Resolution %s', + netflow_get_resolution_name($resolution) + ); + } + + return $subt; +} diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 6ab9fefabe..e42a076015 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -3964,6 +3964,20 @@ function reporting_monitor_report($report, $content) } +/** + * Generates the data structure to build a netflow report. + * + * @param array $report Global report info. + * @param array $content Report item info. + * @param string $type Report type (static, dynamic, data). + * @param integer $force_width_chart Fixed width chart. + * @param integer $force_height_chart Fixed height chart. + * @param string $type_netflow One of netflow_area, netflow_pie, + * netflow_data, netflow_statistics, netflow_summary. + * @param boolean $pdf True if a pdf report is generating. + * + * @return array Report item structure. + */ function reporting_netflow( $report, $content, @@ -3995,6 +4009,10 @@ function reporting_netflow( case 'netflow_summary': $return['type'] = 'netflow_summary'; break; + + default: + $return['type'] = 'unknown'; + break; } if (empty($content['name'])) { @@ -4018,6 +4036,10 @@ function reporting_netflow( case 'netflow_summary': $content['name'] = __('Netflow Summary'); break; + + default: + $content['name'] = __('Unknown report'); + break; } } @@ -4025,7 +4047,7 @@ function reporting_netflow( $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); - // Get chart + // Get chart. reporting_set_conf_charts( $width, $height, @@ -4043,7 +4065,7 @@ function reporting_netflow( $height = $force_height_chart; } - // Get item filters + // Get item filters. $filter = db_get_row_sql( "SELECT * FROM tnetflow_filter @@ -4068,9 +4090,17 @@ function reporting_netflow( break; case 'data': + default: + // Nothing to do. break; } + $return['subtitle'] = netflow_generate_subtitle_report( + $filter['aggregate'], + $content['top_n'], + $type_netflow + ); + return reporting_check_structure_content($return); } From 4f8c7daada74dbb9e39407a56b9cc52845e565ae Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 18 Mar 2019 15:33:48 +0100 Subject: [PATCH 68/94] [Netflow live] Change start date and end date Former-commit-id: 14a24767a1426aa8151ba99495a17ddb71047cbb --- .../operation/netflow/nf_live_view.php | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index a264d3f7c2..671909ce31 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -256,27 +256,11 @@ if (is_metaconsole()) { 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).''; - $class_not_period = ($is_period) ? 'nf_hidden' : 'nf_display'; $class_period = ($is_period) ? 'nf_display' : 'nf_hidden'; echo ''; echo ''.__('Interval').''; echo ''.__('Start date').''; - 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 ''; echo html_print_extended_select_for_time('period', $period, '', '', 0, false, true, false, true, $class_period); @@ -289,6 +273,23 @@ if (is_metaconsole()) { '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); echo ''; echo ''.__('Resolution').ui_print_help_tip(__('The interval will be divided in chunks the length of the resolution.'), true).''; From 80c79b532b859a802f7740715795c6be30b19ad9 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 18 Mar 2019 15:44:23 +0100 Subject: [PATCH 69/94] [Netflow live] Removed aggregate by protocol Former-commit-id: 2f02a384966bc4200f8b9b294e02fbd90ab440ef --- pandora_console/include/functions_netflow.php | 43 ++++++------------- .../operation/netflow/nf_live_view.php | 1 - 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index fb91f3584a..cd345be07b 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -503,19 +503,11 @@ function netflow_get_data( } $val = explode(',', $line); - if ($aggregate == 'proto') { - $values['sources'][$val[3]] = 1; - } else { - $values['sources'][$val[4]] = 1; - } + $values['sources'][$val[4]] = 1; } // Update the filter. switch ($aggregate) { - case 'proto': - $extra_filter = 'proto'; - break; - default: case 'srcip': $extra_filter = 'ip_src'; @@ -699,28 +691,24 @@ function netflow_get_stats( $datetime = $val[0]; $end_date = strtotime($datetime); $values[$i]['datetime'] = $end_date; - if ($aggregate == 'proto') { - $values[$i]['agg'] = $val[3]; - } else { - // Address resolution start. - if ($address_resolution && ($aggregate == 'srcip' || $aggregate == 'dstip')) { - global $hostnames; + // Address resolution start. + if ($address_resolution && ($aggregate == 'srcip' || $aggregate == 'dstip')) { + global $hostnames; - if (!isset($hostnames[$val[4]])) { - $hostname = gethostbyaddr($val[4]); - if ($hostname !== false) { - $hostnames[$val[4]] = $hostname; - $val[4] = $hostname; - } - } else { - $val[4] = $hostnames[$val[4]]; + if (!isset($hostnames[$val[4]])) { + $hostname = gethostbyaddr($val[4]); + if ($hostname !== false) { + $hostnames[$val[4]] = $hostname; + $val[4] = $hostname; } + } else { + $val[4] = $hostnames[$val[4]]; } - - // Address resolution end. - $values[$i]['agg'] = $val[4]; } + // Address resolution end. + $values[$i]['agg'] = $val[4]; + if (! isset($val[9])) { return []; } @@ -1534,9 +1522,6 @@ function netflow_format_aggregate($aggregate) case 'dstip': return __('Dst IP'); - case 'proto': - return __('Protocol'); - case 'srcip': return __('Src IP'); diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 671909ce31..a9f742d779 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -336,7 +336,6 @@ if (is_metaconsole()) { echo ''.__('Aggregate by').''.ui_print_help_icon('aggregate_by', true).''; $aggregate_list = []; $aggregate_list = [ - 'proto' => __('Protocol'), 'srcip' => __('Src Ip Address'), 'dstip' => __('Dst Ip Address'), 'srcport' => __('Src Port'), From bf633e891cfa0e2bdeeb36ca7d3706a961f4e25d Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 18 Mar 2019 16:44:16 +0100 Subject: [PATCH 70/94] [Netflow live] Merged summatory pie and statistic into a single view called Summary Former-commit-id: 367adc7ff96bdd6b16c4d4acf9fff2fb02cd4a75 --- pandora_console/include/functions_netflow.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index cd345be07b..49a3a1dd44 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -196,7 +196,7 @@ function netflow_stat_table($data, $start_date, $end_date, $aggregate) $start_date = date($nfdump_date_format, $start_date); $end_date = date($nfdump_date_format, $end_date); $values = []; - $table->width = '40%'; + $table->width = '100%'; $table->cellspacing = 0; $table->class = 'databox'; $table->data = []; @@ -1021,8 +1021,7 @@ function netflow_get_chart_types() { return [ 'netflow_area' => __('Area graph'), - 'netflow_pie_summatory' => __('Pie graph and Summary table'), - 'netflow_statistics' => __('Statistics table'), + 'netflow_pie_summatory' => __('Summary'), 'netflow_data' => __('Data table'), 'netflow_mesh' => __('Circular mesh'), 'netflow_host_treemap' => __('Host detailed traffic'), @@ -1242,6 +1241,8 @@ function netflow_draw_item( $html .= ''; $html .= ''; $html .= ''; + $html .= '
'; + $html .= netflow_stat_table($data_pie, $start_date, $end_date, $aggregate); return $html; case 'XML': From bc9192b98a312c11ac6a9d0ee6e7343aff96aeaf Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 19 Mar 2019 17:33:39 +0100 Subject: [PATCH 71/94] [Netflow] Merge three reports in one Former-commit-id: 1a7fb1aaacda5009ba2ab911dc69594133517f91 --- pandora_console/extras/mr/26.sql | 2 + .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 + .../reporting_builder.item_editor.php | 27 +-- .../godmode/reporting/reporting_builder.php | 4 - pandora_console/include/functions_netflow.php | 215 +++++------------- .../include/functions_reporting.php | 46 +--- .../include/functions_reporting_html.php | 14 -- pandora_console/include/functions_reports.php | 8 - pandora_server/util/pandora_db.pl | 2 +- 9 files changed, 67 insertions(+), 252 deletions(-) diff --git a/pandora_console/extras/mr/26.sql b/pandora_console/extras/mr/26.sql index 4361da07d4..0191b46c6e 100644 --- a/pandora_console/extras/mr/26.sql +++ b/pandora_console/extras/mr/26.sql @@ -11,6 +11,8 @@ CREATE TABLE IF NOT EXISTS `tnetwork_matrix` ( UNIQUE (`source`, `destination`, `utimestamp`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; +UPDATE `treport_content` SET type="netflow_summary" WHERE type="netflow_pie" OR type="netflow_statistics"; + -- ---------------------------------------------------------------------- -- Add column in table `tagent_custom_fields` -- ---------------------------------------------------------------------- diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index fcac6fb9b8..0ac1071058 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1376,6 +1376,7 @@ ALTER TABLE treport_content ADD COLUMN `lapse` int(11) default '300'; ALTER TABLE treport_content ADD COLUMN `visual_format` tinyint(1) default '0'; ALTER TABLE treport_content ADD COLUMN `hide_no_data` tinyint(1) default '0'; ALTER TABLE treport_content ADD COLUMN `recursion` tinyint(1) default NULL; +UPDATE `treport_content` SET type="netflow_summary" WHERE type="netflow_pie" OR type="netflow_statistics"; -- --------------------------------------------------------------------- -- Table `tmodule_relationship` diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 174103f0bb..b5d189c56d 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -597,18 +597,16 @@ switch ($action) { break; case 'netflow_area': - case 'netflow_pie': case 'netflow_data': - case 'netflow_statistics': case 'netflow_summary': $netflow_filter = $item['text']; - // Filter + // Filter. $period = $item['period']; $description = $item['description']; $resolution = $item['top_n']; - // Interval resolution + // Interval resolution. $max_values = $item['top_n_value']; - // Max values + // Max values. break; case 'nt_top_n': @@ -3667,16 +3665,6 @@ function chooseType() { $("#row_historical_db_check").hide(); break; - case 'netflow_pie': - $("#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 'netflow_data': $("#row_netflow_filter").show(); $("#row_description").show(); @@ -3688,15 +3676,6 @@ function chooseType() { break; case 'netflow_summary': - $("#row_netflow_filter").show(); - $("#row_description").show(); - $("#row_period").show(); - $("#row_resolution").show(); - $("#row_servers").show(); - $("#row_historical_db_check").hide(); - break; - - case 'netflow_statistics': $("#row_netflow_filter").show(); $("#row_description").show(); $("#row_period").show(); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index fc2de3d302..4708089693 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1209,9 +1209,7 @@ switch ($action) { break; case 'netflow_area': - case 'netflow_pie': case 'netflow_data': - case 'netflow_statistics': case 'netflow_summary': $values['text'] = get_parameter('netflow_filter'); $values['description'] = get_parameter('description'); @@ -1583,9 +1581,7 @@ switch ($action) { break; case 'netflow_area': - case 'netflow_pie': case 'netflow_data': - case 'netflow_statistics': case 'netflow_summary': $values['text'] = get_parameter('netflow_filter'); $values['description'] = get_parameter('description'); diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 49a3a1dd44..4ff9420aba 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -196,6 +196,7 @@ function netflow_stat_table($data, $start_date, $end_date, $aggregate) $start_date = date($nfdump_date_format, $start_date); $end_date = date($nfdump_date_format, $end_date); $values = []; + $table = new stdClass(); $table->width = '100%'; $table->cellspacing = 0; $table->class = 'databox'; @@ -331,9 +332,10 @@ function netflow_summary_table($data) global $nfdump_date_format; $values = []; - $table->size = ['50%']; + $table = new stdClass(); $table->cellspacing = 0; $table->class = 'databox'; + $table->styleTable = 'width: 100%'; $table->data = []; $table->style[0] = 'font-weight: bold; padding: 6px'; @@ -1020,11 +1022,11 @@ function netflow_get_filter_arguments($filter) function netflow_get_chart_types() { return [ - 'netflow_area' => __('Area graph'), - 'netflow_pie_summatory' => __('Summary'), - 'netflow_data' => __('Data table'), - 'netflow_mesh' => __('Circular mesh'), - 'netflow_host_treemap' => __('Host detailed traffic'), + 'netflow_area' => __('Area graph'), + 'netflow_summary' => __('Summary'), + 'netflow_data' => __('Data table'), + 'netflow_mesh' => __('Circular mesh'), + 'netflow_host_treemap' => __('Host detailed traffic'), ]; } @@ -1068,7 +1070,6 @@ function netflow_draw_item( // Process item. switch ($type) { - case '0': case 'netflow_area': $data = netflow_get_data( $start_date, @@ -1104,7 +1105,6 @@ function netflow_draw_item( } break; - case '2': case 'netflow_data': $data = netflow_get_data( $start_date, @@ -1136,31 +1136,6 @@ function netflow_draw_item( } break; - case '3': - case 'netflow_statistics': - $data = netflow_get_stats( - $start_date, - $end_date, - $filter, - $aggregate, - $max_aggregates, - true, - $connection_name, - $address_resolution - ); - if (empty($data)) { - break; - } - - if ($output == 'HTML' || $output == 'PDF') { - $html = netflow_stat_table($data, $start_date, $end_date, $aggregate); - return $html; - } else if ($output == 'XML') { - return netflow_stat_xml($data); - } - break; - - case '4': case 'netflow_summary': $data_summary = netflow_get_summary( $start_date, @@ -1172,15 +1147,6 @@ function netflow_draw_item( break; } - if ($output == 'HTML' || $output == 'PDF') { - return netflow_summary_table($data_summary); - } else if ($output == 'XML') { - return netflow_summary_xml($data_summary); - } - break; - - case '1': - case 'netflow_pie': $data_pie = netflow_get_stats( $start_date, $end_date, @@ -1195,62 +1161,31 @@ function netflow_draw_item( break; } - if ($output == 'HTML') { + if ($output === 'HTML' || $output === 'PDF') { + $html = ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= '
'; + $html .= netflow_summary_table($data_summary); + $html .= ''; + $html .= graph_netflow_aggregate_pie( + $data_pie, + netflow_format_aggregate($aggregate), + ($output === 'HTML') ? 1 : 2, + ($output === 'HTML') + ); + $html .= '
'; + $html .= netflow_stat_table( + $data_pie, + $start_date, + $end_date, + $aggregate + ); return $html; - } else if ($output == 'PDF') { - return $html; - } else if ($output == 'XML') { - return $xml; - } - break; - - case 'netflow_pie_summatory': - $data_summary = netflow_get_summary( - $start_date, - $end_date, - $filter, - $connection_name - ); - if (empty($data_summary)) { - break; - } - - $data_pie = netflow_get_stats( - $start_date, - $end_date, - $filter, - $aggregate, - $max_aggregates, - true, - $connection_name, - $address_resolution - ); - if (empty($data_pie)) { - break; - } - - switch ($output) { - case 'HTML': - $html = ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= '
'; - $html .= netflow_summary_table($data_summary); - $html .= ''; - $html .= graph_netflow_aggregate_pie($data_pie, netflow_format_aggregate($aggregate)); - $html .= '
'; - $html .= '
'; - $html .= netflow_stat_table($data_pie, $start_date, $end_date, $aggregate); - return $html; - - case 'XML': - return netflow_summary_xml($data_summary); - - default: - // Nothing to do. - break; + } else if ($output === 'XML') { + return netflow_summary_xml($data_summary, $data_pie); } break; @@ -1409,7 +1344,7 @@ function netflow_aggregate_area_xml($data) echo ' '.$timestamp."\n"; echo " \n"; foreach ($flow as $source => $data) { - echo " $source\n"; + echo ' '.$source."\n"; echo ' '.$data."\n"; } @@ -1432,75 +1367,37 @@ function netflow_aggregate_area_xml($data) } -/** - * Render a pie chart as an XML. - * - * @param array $data Netflow data. - * - * @return void XML is echoed. - */ -function netflow_aggregate_pie_xml($data) -{ - // Calculate total. - $total = 0; - foreach ($data as $flow) { - $total += $flow['data']; - } - - if ($total == 0) { - return; - } - - // Print percentages. - echo "\n"; - foreach ($data as $flow) { - echo ''.$flow['agg']."\n"; - echo ''.format_numeric((100 * $flow['data'] / $total), 2)."%\n"; - } - - echo "\n"; -} - - -/** - * Render a stats table as an XML. - * - * @param array $data Netflow data. - * - * @return string Wiht XML data. - */ -function netflow_stat_xml($data) -{ - // Print stats. - $xml .= "\n"; - foreach ($data as $flow) { - $xml .= ''.$flow['agg']."\n"; - $xml .= ''.$flow['data']."\n"; - } - - $xml .= "\n"; - - return $xml; -} - - /** * Render a summary table as an XML. * - * @param array $data Netflow data. + * @param array $data Netflow data. + * @param array $rows_data Table info (top N hosts). * * @return string Wiht XML data. */ -function netflow_summary_xml($data) +function netflow_summary_xml($data, $rows_data) { - // Print summary + // Print summary. $xml = "\n"; - $xml .= ' '.$data['totalflows']."\n"; - $xml .= ' '.$data['totalbytes']."\n"; - $xml .= ' '.$data['totalbytes']."\n"; - $xml .= ' '.$data['avgbps']."\n"; - $xml .= ' '.$data['avgpps']."\n"; - $xml .= ' '.$data['avgpps']."\n"; + $xml = " \n"; + $xml .= ' '.$data['totalflows']."\n"; + $xml .= ' '.$data['totalbytes']."\n"; + $xml .= ' '.$data['totalbytes']."\n"; + $xml .= ' '.$data['avgbps']."\n"; + $xml .= ' '.$data['avgpps']."\n"; + $xml .= ' '.$data['avgpps']."\n"; + $xml .= " \n"; + + // Add the data table. + $xml .= " \n"; + foreach ($rows_data as $d) { + $xml .= "\n"; + $xml .= ''.$d['agg']."\n"; + $xml .= ''.$d['data']."\n"; + $xml .= "\n"; + } + + $xml .= " \n"; $xml .= "\n"; return $xml; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index e42a076015..3cc3df6dae 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -517,16 +517,6 @@ function reporting_make_reporting_data( ); break; - case 'netflow_pie': - $report['contents'][] = reporting_netflow( - $report, - $content, - $type, - $force_width_chart, - $force_height_chart, - 'netflow_pie', - $pdf - ); break; case 'netflow_data': @@ -541,18 +531,6 @@ function reporting_make_reporting_data( ); break; - case 'netflow_statistics': - $report['contents'][] = reporting_netflow( - $report, - $content, - $type, - $force_width_chart, - $force_height_chart, - 'netflow_statistics', - $pdf - ); - break; - case 'netflow_summary': $report['contents'][] = reporting_netflow( $report, @@ -3972,8 +3950,8 @@ function reporting_monitor_report($report, $content) * @param string $type Report type (static, dynamic, data). * @param integer $force_width_chart Fixed width chart. * @param integer $force_height_chart Fixed height chart. - * @param string $type_netflow One of netflow_area, netflow_pie, - * netflow_data, netflow_statistics, netflow_summary. + * @param string $type_netflow One of netflow_area, netflow_data, + * netflow_summary. * @param boolean $pdf True if a pdf report is generating. * * @return array Report item structure. @@ -3994,18 +3972,10 @@ function reporting_netflow( $return['type'] = 'netflow_area'; break; - case 'netflow_pie': - $return['type'] = 'netflow_pie'; - break; - case 'netflow_data': $return['type'] = 'netflow_data'; break; - case 'netflow_statistics': - $return['type'] = 'netflow_statistics'; - break; - case 'netflow_summary': $return['type'] = 'netflow_summary'; break; @@ -4021,22 +3991,14 @@ function reporting_netflow( $content['name'] = __('Netflow Area'); break; - case 'netflow_pie': - $content['name'] = __('Netflow Pie'); + case 'netflow_summary': + $content['name'] = __('Netflow Summary'); break; case 'netflow_data': $content['name'] = __('Netflow Data'); break; - case 'netflow_statistics': - $content['name'] = __('Netflow Statistics'); - break; - - case 'netflow_summary': - $content['name'] = __('Netflow Summary'); - break; - default: $content['name'] = __('Unknown report'); break; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 83a786052e..717ed003c4 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -271,21 +271,7 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) break; case 'netflow_area': - reporting_html_graph($table, $item); - break; - - case 'netflow_pie': - reporting_html_graph($table, $item); - break; - case 'netflow_data': - reporting_html_graph($table, $item); - break; - - case 'netflow_statistics': - reporting_html_graph($table, $item); - break; - case 'netflow_summary': reporting_html_graph($table, $item); break; diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 9c2b05339b..0bf1f8fe70 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -867,18 +867,10 @@ function reports_get_report_types($template=false, $not_editor=false) 'optgroup' => __('Netflow'), 'name' => __('Netflow area chart'), ]; - $types['netflow_pie'] = [ - 'optgroup' => __('Netflow'), - 'name' => __('Netflow pie chart'), - ]; $types['netflow_data'] = [ 'optgroup' => __('Netflow'), 'name' => __('Netflow data table'), ]; - $types['netflow_statistics'] = [ - 'optgroup' => __('Netflow'), - 'name' => __('Netflow statistics table'), - ]; $types['netflow_summary'] = [ 'optgroup' => __('Netflow'), 'name' => __('Netflow summary table'), diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index c8905ea076..192d470dfa 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -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 From f32e022b1b85d0d9e15b3b7e4eff560e81c6c06b Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 20 Mar 2019 10:26:44 +0100 Subject: [PATCH 72/94] Fixed detailed host traffic chart Former-commit-id: abdf6f9d171facf53260d90f28204d1e81bbeaf4 --- pandora_console/include/functions_netflow.php | 69 ++++++++----------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 4ff9420aba..d42f5121f2 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1246,8 +1246,16 @@ function netflow_draw_item( return $html; case 'netflow_host_treemap': - $netflow_data = netflow_get_record($start_date, $end_date, $filter, $max_aggregates, $address_resolution); - + $data_stats = netflow_get_stats( + $start_date, + $end_date, + $filter, + $aggregate, + $max_aggregates, + true, + $connection_name, + $address_resolution + ); switch ($aggregate) { case 'srcip': case 'srcport': @@ -1265,48 +1273,27 @@ function netflow_draw_item( break; } - $data_aux = []; - foreach ($netflow_data as $record) { - $address = $record[$address_type]; - $port = $record[$port_type]; - - if (!isset($data_aux[$address])) { - $data_aux[$address] = []; - } - - if (!isset($data_aux[$address][$port])) { - $data_aux[$address][$port] = 0; - } - - $data_aux[$address][$port] += $record['data']; - } - + $data_graph = [ + 'name' => __('Host detailed traffic').': '.$type, + 'children' => [], + ]; $id = -1; - $data = []; - - if (! empty($netflow_data)) { - $data['name'] = __('Host detailed traffic').': '.$type; - $data['children'] = []; - - foreach ($data_aux as $address => $ports) { - $children = []; - $children['id'] = $id++; - $children['name'] = $address; - $children['children'] = []; - foreach ($ports as $port => $value) { - $children_data = []; - $children_data['id'] = $id++; - $children_data['name'] = $port; - $children_data['value'] = $value; - $children_data['tooltip_content'] = $port.': '.network_format_bytes($value).''; - $children['children'][] = $children_data; - } - - $data['children'][] = $children; - } + foreach ($data_stats as $sdata) { + $data_graph['children'][] = [ + 'id' => $i++, + 'name' => $sdata['agg'], + 'children' => [ + [ + 'id' => $i++, + 'name' => $sdata['agg'], + 'value' => $sdata['data'], + 'tooltip_content' => network_format_bytes($sdata['data']), + ], + ], + ]; } - return graph_netflow_host_traffic($data, 'auto', 400); + return graph_netflow_host_traffic($data_graph, 'auto', 400); default: // Nothing to do. From 9b345ea947bd744370913c8361308f8f5f1c78f1 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 20 Mar 2019 12:16:30 +0100 Subject: [PATCH 73/94] [Netflow live] Hide netflow circular mesh Former-commit-id: d00293853fc8b498ddee9798b1d1feaea3c13fbf --- pandora_console/include/functions_netflow.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index d42f5121f2..cccc69e341 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1025,7 +1025,7 @@ function netflow_get_chart_types() 'netflow_area' => __('Area graph'), 'netflow_summary' => __('Summary'), 'netflow_data' => __('Data table'), - 'netflow_mesh' => __('Circular mesh'), + // 'netflow_mesh' => __('Circular mesh'), Provisionally comented 'netflow_host_treemap' => __('Host detailed traffic'), ]; } From a0f4163c1d372f1baeedc1c83918d20b02855e6b Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 20 Mar 2019 17:19:56 +0100 Subject: [PATCH 74/94] Fix netflow filters on database Former-commit-id: ae1326117f0a78f2234485f1a260df2923e6ce6b --- pandora_console/extras/mr/26.sql | 2 ++ pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/pandora_console/extras/mr/26.sql b/pandora_console/extras/mr/26.sql index 0191b46c6e..0b655ceb4a 100644 --- a/pandora_console/extras/mr/26.sql +++ b/pandora_console/extras/mr/26.sql @@ -13,6 +13,8 @@ CREATE TABLE IF NOT EXISTS `tnetwork_matrix` ( UPDATE `treport_content` SET type="netflow_summary" WHERE type="netflow_pie" OR type="netflow_statistics"; +UPDATE `tnetflow_filter` SET aggregate="dstip" WHERE aggregate NOT IN ("dstip", "srcip", "dstport", "srcport"); + -- ---------------------------------------------------------------------- -- Add column in table `tagent_custom_fields` -- ---------------------------------------------------------------------- diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 0ac1071058..fd478d61fb 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1355,6 +1355,7 @@ ALTER TABLE tgraph ADD COLUMN `fullscale` tinyint(1) UNSIGNED NOT NULL default ' -- Table `tnetflow_filter` -- --------------------------------------------------------------------- ALTER TABLE tnetflow_filter ADD COLUMN `router_ip` TEXT NOT NULL DEFAULT ""; +UPDATE `tnetflow_filter` SET aggregate="dstip" WHERE aggregate NOT IN ("dstip", "srcip", "dstport", "srcport"); -- --------------------------------------------------------------------- -- Table `treport_custom_sql` From 1da6d3710b5c65b7166d7a33c0a114dbac327537 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 20 Mar 2019 18:26:27 +0100 Subject: [PATCH 75/94] Minor style fix Former-commit-id: f730c6b8d4517b750a50ce73d1f940e0110a5f76 --- pandora_console/include/functions_netflow.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index cccc69e341..aa696054e8 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -299,10 +299,7 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate) $table->data[$i][1] = network_format_bytes($value['data']); $i++; } - } - - // Aggregates. - else { + } else { $i = 0; foreach ($data['data'] as $timestamp => $values) { $table->data[$i][0] = date($time_format, $timestamp); @@ -1647,7 +1644,7 @@ function netflow_get_resolution_name($value) /** * Report formatted subtitle. * - * @param string $aggreagate Aggregate by param. + * @param string $aggregate Aggregate by param. * @param string $resolution Netfow live view resolution. * @param string $type Type of view. * From 030bcc69c452b97f3f278952dd4f8d9cfeff36b4 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 21 Mar 2019 12:37:03 +0100 Subject: [PATCH 76/94] [Netflow live] Readded circular mesh and some refactorizations Former-commit-id: a3b2d9cf622a6e539baff9de3c36f1b7a7072e4b --- pandora_console/include/functions_graph.php | 13 +- pandora_console/include/functions_netflow.php | 399 +++++++++++------- 2 files changed, 246 insertions(+), 166 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 19e04e39f8..de0a1bdd6f 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4289,9 +4289,16 @@ function graph_netflow_aggregate_pie($data, $aggregate, $ttl=1, $only_image=fals /** - * Print a circular graph with the data transmitted between IPs + * Print a circular mesh array. + * + * @param array $data Array with properly data structure. Array with two + * elements required: + * 'elements': Non-associative array with all the relationships. + * 'matrix': Array of arrays with value of the relationship. + * + * @return string HTML data. */ -function graph_netflow_circular_mesh($data, $radius=700) +function graph_netflow_circular_mesh($data) { global $config; @@ -4301,7 +4308,7 @@ function graph_netflow_circular_mesh($data, $radius=700) include_once $config['homedir'].'/include/graphs/functions_d3.php'; - return d3_relationship_graph($data['elements'], $data['matrix'], $radius, true); + return d3_relationship_graph($data['elements'], $data['matrix'], 700, true); } diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index aa696054e8..e0914a92cd 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -37,6 +37,8 @@ define('NETFLOW_RES_ULTRAD', 30); define('NETFLOW_RES_HOURLY', 'hourly'); define('NETFLOW_RES_DAILY', 'daily'); +define('NETFLOW_MAX_DATA_CIRCULAR_MESH', 10000); + // Date format for nfdump. global $nfdump_date_format; $nfdump_date_format = 'Y/m/d.H:i:s'; @@ -477,87 +479,29 @@ function netflow_get_data( $intervals[] = $end_date; } - // If there is aggregation calculate the top n. - $values['data'] = []; - $values['sources'] = []; + // Calculate the top values. + $values = netflow_get_top_data( + $start_date, + $end_date, + $filter, + $aggregate, + $max + ); - // Get the command to call nfdump. - $command = netflow_get_command($filter); - - // Suppress the header line and the statistics at the bottom and configure - // piped output. - $command .= ' -q -o csv'; - - // Call nfdump. - $agg_command = $command." -n $max -s $aggregate/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); - exec($agg_command, $string); - - // Remove the first line. - $string[0] = ''; - - // Parse aggregates. - foreach ($string as $line) { - if ($line == '') { - continue; - } - - $val = explode(',', $line); - $values['sources'][$val[4]] = 1; - } - - // Update the filter. - switch ($aggregate) { - default: - case 'srcip': - $extra_filter = 'ip_src'; - break; - case 'srcport': - $extra_filter = 'src_port'; - break; - - case 'dstip': - $extra_filter = 'ip_dst'; - break; - - case 'dstport': - $extra_filter = 'dst_port'; - break; - } - - if (isset($filter[$extra_filter]) && $filter[$extra_filter] != '') { - $filter[$extra_filter] .= ','; - } - - $filter[$extra_filter] = implode( - ',', + // Update the filter to get properly next data. + netflow_update_second_level_filter( + $filter, + $aggregate, array_keys($values['sources']) ); - // Address resolution start. + // Resolve addresses if required. $get_hostnames = false; - if ($address_resolution && ($aggregate == 'srcip' || $aggregate == 'dstip')) { - $get_hostnames = true; + if ($address_resolution === true) { global $hostnames; - - $sources = []; - foreach ($values['sources'] as $source => $value) { - if (!isset($hostnames[$source])) { - $hostname = gethostbyaddr($source); - if ($hostname !== false) { - $hostnames[$source] = $hostname; - $source = $hostname; - } - } else { - $source = $hostnames[$source]; - } - - $sources[$source] = $value; - } - - $values['sources'] = $sources; + netflow_address_resolution($values, $get_hostnames, $aggregate); } - // Address resolution end. foreach ($intervals as $k => $time) { $interval_start = $time; if (!isset($intervals[($k + 1)])) { @@ -634,8 +578,8 @@ function netflow_get_data( * @param string $filter Netflow filter. * @param string $aggregate Aggregate field. * @param integer $max Maximum number of aggregates. - * @param boolean $absolute True to give the absolute data and false to get - * troughput. + * @param boolean $absolute True to give the absolute data and false + * to get troughput. * @param string $connection_name Node name when data is get in meta. * @param boolean $address_resolution True to resolve ips to hostnames. * @@ -782,79 +726,119 @@ function netflow_get_summary($start_date, $end_date, $filter, $connection_name=' * @param string $end_date Period end date. * @param string $filter Netflow filter. * @param integer $max Maximum number of elements. + * @param string $aggregate One of srcip, srcport, dstip, dstport. * @param boolean $address_resolution True to resolve ips to hostnames. * * @return array With netflow record data. */ -function netflow_get_record( +function netflow_get_circular_mesh_data( $start_date, $end_date, $filter, $max, + $aggregate, $address_resolution=false ) { global $nfdump_date_format; global $config; + $max_data = netflow_get_top_data( + $start_date, + $end_date, + $filter, + $aggregate, + $max + ); + + // Update src and dst filter (both). + $sources_array = array_keys($max_data['sources']); + $is_ip = (in_array($aggregate, ['dstip', 'srcip'])); + netflow_update_second_level_filter( + $filter, + ($is_ip === true) ? 'dstip' : 'dstport', + $sources_array + ); + netflow_update_second_level_filter( + $filter, + ($is_ip === true) ? 'srcip' : 'srcport', + $sources_array + ); + + // Get the command to call nfdump. + $command = sprintf( + '%s -q -o csv -n %s -s %s/bytes -t %s-%s', + netflow_get_command($filter), + NETFLOW_MAX_DATA_CIRCULAR_MESH, + 'record', + date($nfdump_date_format, $start_date), + date($nfdump_date_format, $end_date) + ); + // Get the command to call nfdump. $command = netflow_get_command($filter); // Execute nfdump. - $command .= " -q -o csv -n $max -s record/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); + $command .= ' -q -o csv -n 10000 -s record/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($command, $result); if (! is_array($result)) { return []; } - $values = []; - foreach ($result as $key => $line) { - $data = []; + // Initialize some data structures. + $data = [ + 'elements' => [], + 'matrix' => [], + ]; + $initial_data = []; + // This array has the ips or port like keys and the array position as value. + $inverse_sources_array = array_flip($sources_array); + foreach ($sources_array as $sdata) { + $data['elements'][$inverse_sources_array[$sdata]] = $sdata; + $initial_data[$inverse_sources_array[$sdata]] = 0; + } + foreach ($sources_array as $sdata) { + $data['matrix'][$inverse_sources_array[$sdata]] = $initial_data; + } + + // Port are situated in a different places from addreses. + $src_key = ($is_ip === true) ? 3 : 5; + $dst_key = ($is_ip === true) ? 4 : 6; + // Store a footprint of initial data to be compared at the end. + $freeze_data = md5(serialize($data)); + foreach ($result as $line) { + if (empty($line) === true) { + continue; + } + + // Parse the line. $items = explode(',', $line); - $data['time_start'] = $items[0]; - $data['time_end'] = $items[1]; - $data['duration'] = ($items[2] / 1000); - $data['source_address'] = $items[3]; - $data['destination_address'] = $items[4]; - $data['source_port'] = $items[5]; - $data['destination_port'] = $items[6]; - $data['protocol'] = $items[7]; - $data['data'] = $items[12]; + // Get the required data. + $src_item = $inverse_sources_array[$items[$src_key]]; + $dst_item = $inverse_sources_array[$items[$dst_key]]; + $value = $items[12]; - $values[] = $data; - } - - // Address resolution start. - if ($address_resolution) { - global $hostnames; - - for ($i = 0; $i < count($values); $i++) { - if (!isset($hostnames[$values[$i]['source_address']])) { - $hostname = gethostbyaddr($values[$i]['source_address']); - if ($hostname !== false) { - $hostnames[$values[$i]['source_address']] = $hostname; - $values[$i]['source_address'] = $hostname; - } - } else { - $values[$i]['source_address'] = $hostnames[$values[$i]['source_address']]; - } - - if (!isset($hostnames[$values[$i]['destination_address']])) { - $hostname = gethostbyaddr($values[$i]['destination_address']); - if ($hostname !== false) { - $hostnames[$values[$i]['destination_address']] = $hostname; - $values[$i]['destination_address'] = $hostname; - } - } else { - $values[$i]['destination_address'] = $hostnames[$values[$i]['destination_address']]; - } + // Check if valid data. + if (!isset($value) + || !isset($data['matrix'][$dst_item][$src_item]) + || !isset($data['matrix'][$src_item][$dst_item]) + ) { + continue; } + + // Update the value. + $data['matrix'][$src_item][$dst_item] += (int) $value; } - // Address resolution end. - return $values; + // Comparte footprints. + if ($freeze_data === md5(serialize($data))) { + // Taht means that all relationships are 0. + return []; + } + + return $data; } @@ -1022,7 +1006,7 @@ function netflow_get_chart_types() 'netflow_area' => __('Area graph'), 'netflow_summary' => __('Summary'), 'netflow_data' => __('Data table'), - // 'netflow_mesh' => __('Circular mesh'), Provisionally comented + 'netflow_mesh' => __('Circular mesh'), 'netflow_host_treemap' => __('Host detailed traffic'), ]; } @@ -1187,58 +1171,17 @@ function netflow_draw_item( break; case 'netflow_mesh': - $netflow_data = netflow_get_record( + $data = netflow_get_circular_mesh_data( $start_date, $end_date, $filter, $max_aggregates, + $aggregate, $address_resolution ); - switch ($aggregate) { - case 'srcport': - case 'dstport': - $source_type = 'source_port'; - $destination_type = 'destination_port'; - break; - - default: - case 'dstip': - case 'srcip': - $source_type = 'source_address'; - $destination_type = 'destination_address'; - break; - } - - $data = []; - $data['elements'] = []; - $data['matrix'] = []; - foreach ($netflow_data as $record) { - if (!in_array($record[$source_type], $data['elements'])) { - $data['elements'][] = $record[$source_type]; - $data['matrix'][] = []; - } - - if (!in_array($record[$destination_type], $data['elements'])) { - $data['elements'][] = $record[$destination_type]; - $data['matrix'][] = []; - } - } - - for ($i = 0; $i < count($data['matrix']); $i++) { - $data['matrix'][$i] = array_fill(0, count($data['matrix']), 0); - } - - foreach ($netflow_data as $record) { - $source_key = array_search($record[$source_type], $data['elements']); - $destination_key = array_search($record[$destination_type], $data['elements']); - if ($source_key !== false && $destination_key !== false) { - $data['matrix'][$source_key][$destination_key] += $record['data']; - } - } - $html = '
'; - $html .= graph_netflow_circular_mesh($data, 700); + $html .= graph_netflow_circular_mesh($data); $html .= '
'; return $html; @@ -1668,3 +1611,133 @@ function netflow_generate_subtitle_report($aggregate, $resolution, $type) return $subt; } + + +/** + * Returns netflow stats for the given period in an array. + * + * @param string $start_date Period start date. + * @param string $end_date Period end date. + * @param string $filter Netflow filter. + * @param string $aggregate Aggregate field. + * @param integer $max Maximum number of aggregates. + * + * @return array With netflow stats. + */ +function netflow_get_top_data( + $start_date, + $end_date, + $filter, + $aggregate, + $max +) { + global $nfdump_date_format; + + $values = [ + 'data' => [], + 'sources' => [], + ]; + + // Get the command to call nfdump. + $agg_command = sprintf( + '%s -q -o csv -n %s -s %s/bytes -t %s-%s', + netflow_get_command($filter), + $max, + $aggregate, + date($nfdump_date_format, $start_date), + date($nfdump_date_format, $end_date) + ); + + // Call nfdump. + exec($agg_command, $string); + + // Remove the first line. + $string[0] = ''; + + // Parse aggregates. + foreach ($string as $line) { + if (empty($line) === true) { + continue; + } + + $val = explode(',', $line); + $values['sources'][$val[4]] = 1; + } + + return $values; +} + + +/** + * Returns netflow stats for the given period in an array. + * + * @param string $filter Netflow filter (passed by reference). + * @param string $aggregate Aggregate field. + * @param array $sources Sources to aggregate to filter. + * + * @return void $filter is passed by reference. + */ +function netflow_update_second_level_filter(&$filter, $aggregate, $sources) +{ + // Update the filter. + switch ($aggregate) { + default: + case 'srcip': + $extra_filter = 'ip_src'; + break; + case 'srcport': + $extra_filter = 'src_port'; + break; + + case 'dstip': + $extra_filter = 'ip_dst'; + break; + + case 'dstport': + $extra_filter = 'dst_port'; + break; + } + + if (isset($filter[$extra_filter]) && $filter[$extra_filter] != '') { + $filter[$extra_filter] .= ','; + } + + $filter[$extra_filter] = implode(',', $sources); +} + + +/** + * Change some values on address resolve. + * + * @param array $values Where data will be overwritten (ref). + * @param boolean $get_hostnames Change it if address resolution es done (ref). + * @param string $aggregate One of srcip, srcport, dstip, dstport. + * + * @return void Referenced passed params will be changed. + */ +function netflow_address_resolution(&$values, &$get_hostnames, $aggregate) +{ + if ($aggregate !== 'srcip' && $aggregate !== 'dstip') { + return; + } + + $get_hostnames = true; + global $hostnames; + + $sources = []; + foreach ($values['sources'] as $source => $value) { + if (!isset($hostnames[$source])) { + $hostname = gethostbyaddr($source); + if ($hostname !== false) { + $hostnames[$source] = $hostname; + $source = $hostname; + } + } else { + $source = $hostnames[$source]; + } + + $sources[$source] = $value; + } + + $values['sources'] = $sources; +} From 94cf43d6abaf5d3a74eeedf71ff2bf55b54fb52e Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 21 Mar 2019 13:09:48 +0100 Subject: [PATCH 77/94] [Netflow live] Separate relationships data from circular mesh parsing Former-commit-id: 68485217517ab70bcabed8855fdc9127b83547a6 --- pandora_console/include/functions_netflow.php | 65 +++++++++++++++---- 1 file changed, 51 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index e0914a92cd..20176ac074 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -720,24 +720,22 @@ function netflow_get_summary($start_date, $end_date, $filter, $connection_name=' /** - * Returns a traffic record for the given period in an array. + * Returns a relationships data for the given period in an array. * - * @param string $start_date Period start date. - * @param string $end_date Period end date. - * @param string $filter Netflow filter. - * @param integer $max Maximum number of elements. - * @param string $aggregate One of srcip, srcport, dstip, dstport. - * @param boolean $address_resolution True to resolve ips to hostnames. + * @param string $start_date Period start date. + * @param string $end_date Period end date. + * @param string $filter Netflow filter. + * @param integer $max Maximum number of elements. + * @param string $aggregate One of srcip, srcport, dstip, dstport. * - * @return array With netflow record data. + * @return array With raw relationship data. */ -function netflow_get_circular_mesh_data( +function netflow_get_relationships_raw_data( $start_date, $end_date, $filter, $max, - $aggregate, - $address_resolution=false + $aggregate ) { global $nfdump_date_format; global $config; @@ -752,7 +750,7 @@ function netflow_get_circular_mesh_data( // Update src and dst filter (both). $sources_array = array_keys($max_data['sources']); - $is_ip = (in_array($aggregate, ['dstip', 'srcip'])); + $is_ip = netflow_aggregate_is_ip($aggregate); netflow_update_second_level_filter( $filter, ($is_ip === true) ? 'dstip' : 'dstport', @@ -782,6 +780,34 @@ function netflow_get_circular_mesh_data( exec($command, $result); if (! is_array($result)) { + return [ + 'lines' => [], + 'sources' => [], + ]; + } + + return [ + 'lines' => $result, + 'sources' => $sources_array, + ]; +} + + +/** + * Parse the raw relationships data to be painted by circular mesh chart. + * + * @param array $result Lines gotten from nfdump call. + * @param array $sources_array Array with sources involved in the chart. + * @param boolean $is_ip Is ip or port. + * + * @return array With data to be parsed on circular mesh chart. + */ +function netflow_parse_relationships_for_circular_mesh( + $result, + $sources_array, + $is_ip +) { + if (empty($result)) { return []; } @@ -1171,7 +1197,7 @@ function netflow_draw_item( break; case 'netflow_mesh': - $data = netflow_get_circular_mesh_data( + $data = netflow_get_relationships_raw_data( $start_date, $end_date, $filter, @@ -1179,9 +1205,14 @@ function netflow_draw_item( $aggregate, $address_resolution ); + $data_circular = netflow_parse_relationships_for_circular_mesh( + $data['lines'], + $data['sources'], + netflow_aggregate_is_ip($aggregate) + ); $html = '
'; - $html .= graph_netflow_circular_mesh($data); + $html .= graph_netflow_circular_mesh($data_circular); $html .= '
'; return $html; @@ -1741,3 +1772,9 @@ function netflow_address_resolution(&$values, &$get_hostnames, $aggregate) $values['sources'] = $sources; } + + +function netflow_aggregate_is_ip($aggregate) +{ + return in_array($aggregate, ['dstip', 'srcip']); +} From 6a1bf2fbce5261804344112f100ed6e6ad6deb90 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 25 Mar 2019 11:34:03 +0100 Subject: [PATCH 78/94] Added first version of live map Former-commit-id: c440a0d0785d83c17560438986b7b394223e4779 --- pandora_console/include/functions_netflow.php | 99 +++++++++ .../operation/network/network_usage_map.php | 208 ++++++++++++++++++ 2 files changed, 307 insertions(+) create mode 100644 pandora_console/operation/network/network_usage_map.php diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 20176ac074..65b062068e 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -23,6 +23,7 @@ require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_io.php'; require_once $config['homedir'].'/include/functions_io.php'; require_once $config['homedir'].'/include/functions_network.php'; +require_once $config['homedir'].'/include/class/NetworkMap.class.php'; enterprise_include_once( $config['homedir'].'/enterprise/include/pdf_translator.php' ); @@ -1778,3 +1779,101 @@ function netflow_aggregate_is_ip($aggregate) { return in_array($aggregate, ['dstip', 'srcip']); } + + +/** + * Build netflow data structure to network map. + * + * @param integer $start_date Time in timestamp format. + * @param integer $end_date Time in timestamp format. + * @param integer $top Max data to show. + * + * @return array With map structure. + */ +function netflow_build_map_data($start_date, $end_date, $top) +{ + $data = netflow_get_relationships_raw_data( + $start_date, + $end_date, + [ + 'id_name' => '', + 'id_group' => 0, + 'aggregate' => 'srcip', + 'id_dst' => '', + 'ip_src' => '', + 'dst_port' => '', + 'src_port' => '', + 'advanced_filter' => '', + 'router_ip' => '', + ], + $top, + 'srcip' + ); + + $nodes = array_map( + function ($elem) { + return [ + 'name' => $elem, + 'type' => NODE_GENERIC, + 'width' => 20, + 'height' => 20, + 'status' => '#82B92E', + ]; + }, + $data['sources'] + ); + + $relations = []; + + $inverse_nodes = array_flip($data['sources']); + + // Port are situated in a different places from addreses. + $is_ip = true; + $src_key = ($is_ip === true) ? 3 : 5; + $dst_key = ($is_ip === true) ? 4 : 6; + + foreach ($data['lines'] as $line) { + if (empty($line) === true) { + continue; + } + + // Parse the line. + $items = explode(',', $line); + + // Get the required data. + $src_item = $inverse_nodes[$items[$src_key]]; + $dst_item = $inverse_nodes[$items[$dst_key]]; + $value = $items[12]; + $index_rel = $src_item.'-'.$dst_item; + + // Check if valid data. + if (!isset($value) || !isset($src_item) || !isset($dst_item)) { + continue; + } + + if (isset($relations[$index_rel])) { + $relations[$index_rel]['text_start'] += $value; + } else { + // Update the value. + $relations[$index_rel] = [ + 'id_parent' => $src_item, + 'parent_type' => NODE_GENERIC, + 'child_type' => NODE_GENERIC, + 'id_child' => $dst_item, + 'link_color' => '#82B92E', + 'text_start' => $value, + ]; + } + } + + return [ + 'nodes' => $nodes, + 'relations' => $relations, + 'pure' => 1, + 'no_pandora_node' => 1, + 'map_options' => [ + 'generation_method' => LAYOUT_SPRING1, + 'map_filter' => ['node_radius' => 40], + ], + ]; +} 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..e3cc5f7fca --- /dev/null +++ b/pandora_console/operation/network/network_usage_map.php @@ -0,0 +1,208 @@ + + + +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'] .= '
'; + +$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'] = ''; +$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 '
'; +html_print_input_hidden('order_by', $order_by); + +html_print_table($table); +echo '
'; + +$has_data = true; +if ((bool) get_parameter('update_netflow') === true) { + $map_data = netflow_build_map_data( + $utimestamp_lower, + $utimestamp_greater, + $top + ); + $has_data = !empty($map_data['nodes']); +} else if ((bool) get_parameter('update_nta') === true) { + // TODOS. + $has_data = false; +} else { + return; +} + +if ($has_data === true) { + $map_manager = new NetworkMap($map_data); + $map_manager->printMap(); +} else { + ui_print_info_message(__('No data retrieved')); +} + From ddc01f9a4e40c75ac9a42688e9e5d3141bacb224 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 25 Mar 2019 12:30:51 +0100 Subject: [PATCH 79/94] Added data from NTA to networl_usage_map Former-commit-id: 9f6192faa1698959ce1ba44e13b974b8470a6a3c --- pandora_console/include/functions_network.php | 81 ++++++++++++++++++- .../operation/network/network_usage_map.php | 8 +- 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index 802fc4bb5c..a9f7c4d3a5 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -39,7 +39,8 @@ function network_matrix_get_top( $start, $end, $ip_filter='', - $order_by_bytes=true + $order_by_bytes=true, + $host_filter=[] ) { $field_to_group = ($talker === true) ? 'source' : 'destination'; $field_to_order = ($order_by_bytes === true) ? 'sum_bytes' : 'sum_pkts'; @@ -49,11 +50,21 @@ function network_matrix_get_top( $filter_sql = sprintf('AND %s="%s"', $filter_field, $ip_filter); } + $host_filter_sql = ''; + if (!empty($host_filter)) { + $host_filter_sql = sprintf( + ' AND %s IN ("%s")', + $field_to_group, + implode('","', $host_filter) + ); + } + $sql = sprintf( 'SELECT SUM(bytes) sum_bytes, SUM(pkts) sum_pkts, %s host FROM tnetwork_matrix WHERE utimestamp > %d AND utimestamp < %d %s + %s GROUP BY %s ORDER BY %s DESC LIMIT %d', @@ -61,6 +72,7 @@ function network_matrix_get_top( $start, $end, $filter_sql, + $host_filter_sql, $field_to_group, $field_to_order, $top @@ -154,3 +166,70 @@ function network_format_bytes($value) 'B' ); } + + +function network_build_map_data($start, $end, $top) +{ + $data = network_matrix_get_top($top, true, $start, $end); + + $hosts = array_map( + function ($elem) { + return $elem['host']; + }, + $data + ); + $inverse_hosts = array_flip($hosts); + + $nodes = array_map( + function ($elem) { + return [ + 'name' => $elem, + 'type' => NODE_GENERIC, + 'width' => 20, + 'height' => 20, + 'status' => '#82B92E', + ]; + }, + $hosts + ); + + $relations = []; + foreach ($hosts as $host) { + $host_top = network_matrix_get_top( + $top, + false, + $start, + $end, + $host, + true, + $hosts + ); + foreach ($host_top as $sd) { + $src_index = $inverse_hosts[$host]; + $dst_index = $inverse_hosts[$sd['host']]; + if (isset($src_index) === false || isset($dst_index) === false) { + continue; + } + + $relations[$host.'-'.$sd['host']] = [ + 'id_parent' => $inverse_hosts[$sd['host']], + 'parent_type' => NODE_GENERIC, + 'child_type' => NODE_GENERIC, + 'id_child' => $inverse_hosts[$host], + 'link_color' => '#82B92E', + 'text_start' => $sd['sum_bytes'], + ]; + } + } + + return [ + 'nodes' => $nodes, + 'relations' => $relations, + 'pure' => 1, + 'no_pandora_node' => 1, + 'map_options' => [ + 'generation_method' => LAYOUT_SPRING1, + 'map_filter' => ['node_radius' => 40], + ], + ]; +} diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php index e3cc5f7fca..cd094237c3 100644 --- a/pandora_console/operation/network/network_usage_map.php +++ b/pandora_console/operation/network/network_usage_map.php @@ -193,8 +193,12 @@ if ((bool) get_parameter('update_netflow') === true) { ); $has_data = !empty($map_data['nodes']); } else if ((bool) get_parameter('update_nta') === true) { - // TODOS. - $has_data = false; + $map_data = network_build_map_data( + $utimestamp_lower, + $utimestamp_greater, + $top + ); + $has_data = !empty($map_data['nodes']); } else { return; } From eba858d6c1b0e9d9fe2743b52be9e1047ec5f382 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 25 Mar 2019 12:32:39 +0100 Subject: [PATCH 80/94] [Network usage map] Fixed timepickers Former-commit-id: d5803cea0443eae7a0dca2846dfba199a5e35f3c --- .../operation/network/network_usage_map.php | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php index cd094237c3..ca3e8db6d4 100644 --- a/pandora_console/operation/network/network_usage_map.php +++ b/pandora_console/operation/network/network_usage_map.php @@ -39,37 +39,6 @@ if (! check_acl($config['id_user'], 0, 'AR')) { // Include JS timepicker. ui_include_time_picker(); -?> - - - + + From 1dceb93a7650cf86e1f5cc1d68a4a7691c5bb6d4 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 25 Mar 2019 12:40:49 +0100 Subject: [PATCH 81/94] Added some docs Former-commit-id: 22d2aeda5c16a4fcf4414760affb77a6d5c0c375 --- pandora_console/include/functions_netflow.php | 7 +++++++ pandora_console/include/functions_network.php | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 65b062068e..41f2021cbf 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1775,6 +1775,13 @@ function netflow_address_resolution(&$values, &$get_hostnames, $aggregate) } +/** + * Check if is aggregate by IP or by port + * + * @param string $aggregate Aggregate tag. + * + * @return boolean True if is IP. False for port. + */ function netflow_aggregate_is_ip($aggregate) { return in_array($aggregate, ['dstip', 'srcip']); diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index a9f7c4d3a5..69637c1971 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -30,6 +30,7 @@ * @param integer $end Utimestamp of end time. * @param string $ip_filter Ip to filter. * @param boolean $order_by_bytes True by top by bytes. False by packets. + * @param array $host_filter Host filter array. * * @return array With requested data. */ @@ -168,6 +169,15 @@ function network_format_bytes($value) } +/** + * Build netflow data structure to network map. + * + * @param integer $start Time in timestamp format. + * @param integer $end Time in timestamp format. + * @param integer $top Max data to show. + * + * @return array With map structure. + */ function network_build_map_data($start, $end, $top) { $data = network_matrix_get_top($top, true, $start, $end); @@ -211,7 +221,7 @@ function network_build_map_data($start, $end, $top) continue; } - $relations[$host.'-'.$sd['host']] = [ + $relations[$src_index.'-'.$dst_index] = [ 'id_parent' => $inverse_hosts[$sd['host']], 'parent_type' => NODE_GENERIC, 'child_type' => NODE_GENERIC, From d37acbb159444e5f138ad869fc3cef02f853a8d9 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 25 Mar 2019 13:10:47 +0100 Subject: [PATCH 82/94] [Netflow usage map] Added data to show Former-commit-id: ca4db091b4c0f40061b9f7b8f13c4fe915ce022e --- pandora_console/include/functions_netflow.php | 7 ++++--- pandora_console/include/functions_network.php | 15 ++++++++------- .../operation/network/network_usage_map.php | 19 ++++++++++++++++--- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 41f2021cbf..056254f5f6 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1794,10 +1794,11 @@ function netflow_aggregate_is_ip($aggregate) * @param integer $start_date Time in timestamp format. * @param integer $end_date Time in timestamp format. * @param integer $top Max data to show. + * @param integer $aggregate One of dstip or srcip. * * @return array With map structure. */ -function netflow_build_map_data($start_date, $end_date, $top) +function netflow_build_map_data($start_date, $end_date, $top, $aggregate) { $data = netflow_get_relationships_raw_data( $start_date, @@ -1805,7 +1806,7 @@ function netflow_build_map_data($start_date, $end_date, $top) [ 'id_name' => '', 'id_group' => 0, - 'aggregate' => 'srcip', + 'aggregate' => $aggregate, 'id_dst' => '', 'ip_src' => '', 'dst_port' => '', @@ -1814,7 +1815,7 @@ function netflow_build_map_data($start_date, $end_date, $top) 'router_ip' => '', ], $top, - 'srcip' + $aggregate ); $nodes = array_map( diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index 69637c1971..67bf8f68d1 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -92,7 +92,7 @@ function network_matrix_get_top( * * @return array With the actions to print in a select. */ -function network_get_report_actions($network) +function network_get_report_actions($network=true) { $common_actions = [ 'listeners' => __('Top listeners'), @@ -172,15 +172,16 @@ function network_format_bytes($value) /** * Build netflow data structure to network map. * - * @param integer $start Time in timestamp format. - * @param integer $end Time in timestamp format. - * @param integer $top Max data to show. + * @param integer $start Time in timestamp format. + * @param integer $end Time in timestamp format. + * @param integer $top Max data to show. + * @param boolean $talker True to get top tolkers. False for listeners. * * @return array With map structure. */ -function network_build_map_data($start, $end, $top) +function network_build_map_data($start, $end, $top, $talker) { - $data = network_matrix_get_top($top, true, $start, $end); + $data = network_matrix_get_top($top, $talker, $start, $end); $hosts = array_map( function ($elem) { @@ -207,7 +208,7 @@ function network_build_map_data($start, $end, $top) foreach ($hosts as $host) { $host_top = network_matrix_get_top( $top, - false, + !$talker, $start, $end, $host, diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php index ca3e8db6d4..248cf699f1 100644 --- a/pandora_console/operation/network/network_usage_map.php +++ b/pandora_console/operation/network/network_usage_map.php @@ -40,6 +40,7 @@ if (! check_acl($config['id_user'], 0, 'AR')) { ui_include_time_picker(); // Query params and other initializations. +$action = get_parameter('action', 'talkers'); $time_greater = get_parameter('time_greater', date(TIME_FORMAT)); $date_greater = get_parameter('date_greater', date(DATE_FORMAT)); $utimestamp_greater = strtotime($date_greater.' '.$time_greater); @@ -114,7 +115,17 @@ $table->data['0']['2'] .= html_print_select( true ); -$table->data['1']['0'] = ''; + +$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 = ''; @@ -158,14 +169,16 @@ if ((bool) get_parameter('update_netflow') === true) { $map_data = netflow_build_map_data( $utimestamp_lower, $utimestamp_greater, - $top + $top, + ($action === 'talkers') ? 'srcip' : 'dstip' ); $has_data = !empty($map_data['nodes']); } else if ((bool) get_parameter('update_nta') === true) { $map_data = network_build_map_data( $utimestamp_lower, $utimestamp_greater, - $top + $top, + $action === 'talkers' ); $has_data = !empty($map_data['nodes']); } else { From 74e86768f84c797fb7af0c327ee58e516133ac25 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 25 Mar 2019 14:56:42 +0100 Subject: [PATCH 83/94] Fixed no data message Former-commit-id: 46b0c055d05a4c3309840fdb0eb697d78f1f6acd --- pandora_console/operation/network/network_usage_map.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php index 248cf699f1..cc9dd3e9f7 100644 --- a/pandora_console/operation/network/network_usage_map.php +++ b/pandora_console/operation/network/network_usage_map.php @@ -164,7 +164,8 @@ html_print_input_hidden('order_by', $order_by); html_print_table($table); echo ''; -$has_data = true; +$has_data = false; +$first_load = true; if ((bool) get_parameter('update_netflow') === true) { $map_data = netflow_build_map_data( $utimestamp_lower, @@ -173,6 +174,7 @@ if ((bool) get_parameter('update_netflow') === true) { ($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, @@ -181,14 +183,13 @@ if ((bool) get_parameter('update_netflow') === true) { $action === 'talkers' ); $has_data = !empty($map_data['nodes']); -} else { - return; + $first_load = false; } if ($has_data === true) { $map_manager = new NetworkMap($map_data); $map_manager->printMap(); -} else { +} else if (!$first_load) { ui_print_info_message(__('No data retrieved')); } From f9744ca8c88b1df7fb506ccf248c396de9b2b0f3 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 25 Mar 2019 15:57:04 +0100 Subject: [PATCH 84/94] Added Others node Former-commit-id: 64179fd7b2520e3378d188438f8bc846edb56004 --- pandora_console/include/functions_netflow.php | 41 +++++++++++++++++-- pandora_console/include/functions_network.php | 28 ++++++++++++- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 056254f5f6..1d8d8752f7 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1828,7 +1828,7 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) 'status' => '#82B92E', ]; }, - $data['sources'] + array_merge($data['sources'], [__('Others')]) ); $relations = []; @@ -1839,6 +1839,7 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) $is_ip = true; $src_key = ($is_ip === true) ? 3 : 5; $dst_key = ($is_ip === true) ? 4 : 6; + $retrieved_data = array_fill_keys($inverse_nodes, false); foreach ($data['lines'] as $line) { if (empty($line) === true) { @@ -1855,10 +1856,14 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) $index_rel = $src_item.'-'.$dst_item; // Check if valid data. - if (!isset($value) || !isset($src_item) || !isset($dst_item)) { + if (!isset($value) || (!isset($src_item) && !isset($dst_item))) { continue; } + // Mark as connected source and destination. + $retrieved_data[$src_item] = true; + $retrieved_data[$dst_item] = true; + if (isset($relations[$index_rel])) { $relations[$index_rel]['text_start'] += $value; } else { @@ -1874,9 +1879,39 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) } } + // Format the data in edges. + array_walk( + $relations, + function (&$elem) { + $elem['text_start'] = network_format_bytes($elem['text_start']); + } + ); + + // Search for orphan nodes. + $orphan_hosts = []; + $orphan_index = (end($inverse_nodes) + 1); + foreach ($retrieved_data as $position => $rd) { + if ($rd === true) { + continue; + } + + $orphan_hosts[$position.'-'.$orphan_index] = [ + 'id_parent' => $orphan_index, + 'parent_type' => NODE_GENERIC, + 'child_type' => NODE_GENERIC, + 'id_child' => $position, + 'link_color' => '#82B92E', + ]; + } + + // If there is not any orphan node, delete it. + if (empty($orphan_hosts)) { + array_pop($nodes); + } + return [ 'nodes' => $nodes, - 'relations' => $relations, + 'relations' => array_merge($relations, $orphan_hosts), 'pure' => 1, 'no_pandora_node' => 1, 'map_options' => [ diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index 67bf8f68d1..2bec9dad38 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -205,6 +205,7 @@ function network_build_map_data($start, $end, $top, $talker) ); $relations = []; + $orphan_relations = []; foreach ($hosts as $host) { $host_top = network_matrix_get_top( $top, @@ -228,9 +229,34 @@ function network_build_map_data($start, $end, $top, $talker) 'child_type' => NODE_GENERIC, 'id_child' => $inverse_hosts[$host], 'link_color' => '#82B92E', - 'text_start' => $sd['sum_bytes'], + 'text_start' => network_format_bytes($sd['sum_bytes']), ]; } + + // Put the orphans on Other node. + if (empty($host_top)) { + $other_id = (end($inverse_hosts) + 1); + // TODOS: Add the data. + $orphan_relations[$inverse_hosts[$host].'-'.$other_id] = [ + 'id_parent' => $other_id, + 'parent_type' => NODE_GENERIC, + 'child_type' => NODE_GENERIC, + 'id_child' => $inverse_hosts[$host], + 'link_color' => '#82B92E', + ]; + } + } + + // Put the Others node and their relations. + if (empty($orphan_relations) === false) { + $nodes[] = [ + 'name' => __('Others'), + 'type' => NODE_GENERIC, + 'width' => 20, + 'height' => 20, + 'status' => '#82B92E', + ]; + $relations = array_merge($relations, $orphan_relations); } return [ From 4a201bc74b1f63ad52ed3c34ab8946eec8d02e5f Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 25 Mar 2019 16:00:57 +0100 Subject: [PATCH 85/94] [Network usage map] Fixed menus and added header. Former-commit-id: 1cdfc4f7f388f0705b32a362ce8c5f3ac1fb49b2 --- pandora_console/operation/menu.php | 14 +++++++++----- .../operation/network/network_usage_map.php | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index ffeb95bbd3..301f7f167c 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -97,18 +97,22 @@ if (check_acl($config['id_user'], 0, 'AR')) { $netflow_sub = array_merge( $netflow_sub, [ - 'operation/network/network_explorer' => [ + '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', ], - 'operation/network/network_dashboard' => [ - 'text' => __('Network dashboard'), - 'id' => 'Network dashboard', - ], ] ); } diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php index cc9dd3e9f7..ced351e0f0 100644 --- a/pandora_console/operation/network/network_usage_map.php +++ b/pandora_console/operation/network/network_usage_map.php @@ -26,6 +26,8 @@ global $config; check_login(); +ui_print_page_header(__('Network usage map')); + // ACL Check. if (! check_acl($config['id_user'], 0, 'AR')) { db_pandora_audit( From 85474c6037aa2f7c51c2d9345f79d95d806d6f28 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 25 Mar 2019 16:40:07 +0100 Subject: [PATCH 86/94] [Network usage map] Minor changes Former-commit-id: 0dcbfaa911fad7d6ca6179689695d6829fd3822d --- pandora_console/include/functions_netflow.php | 5 ++++- pandora_console/include/functions_network.php | 5 ++++- pandora_console/operation/network/network_usage_map.php | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 1d8d8752f7..370658e41b 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1916,7 +1916,10 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) 'no_pandora_node' => 1, 'map_options' => [ 'generation_method' => LAYOUT_SPRING1, - 'map_filter' => ['node_radius' => 40], + 'map_filter' => [ + 'node_radius' => 40, + 'node_sep' => 7, + ], ], ]; } diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index 2bec9dad38..8dba68d2d4 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -266,7 +266,10 @@ function network_build_map_data($start, $end, $top, $talker) 'no_pandora_node' => 1, 'map_options' => [ 'generation_method' => LAYOUT_SPRING1, - 'map_filter' => ['node_radius' => 40], + 'map_filter' => [ + 'node_radius' => 40, + 'node_sep' => 7, + ], ], ]; } diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php index ced351e0f0..6f0aee1091 100644 --- a/pandora_console/operation/network/network_usage_map.php +++ b/pandora_console/operation/network/network_usage_map.php @@ -224,4 +224,9 @@ function network_report_click_period(event) { : 'block'; } + From 58e74c1db112a87fbd4683f5cb240b89c5ad053e Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 26 Mar 2019 08:40:22 +0100 Subject: [PATCH 87/94] Fixed minor warning Former-commit-id: 38278d285faa6aea5f61d0933543b7e24926ae79 --- pandora_console/include/functions_netflow.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 370658e41b..b669219459 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -264,6 +264,7 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate) } $values = []; + $table = new stdClass(); $table->size = ['100%']; $table->class = 'databox'; $table->cellspacing = 0; From 189d4864dc485bad88df66d228baab2dc0752c07 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 26 Mar 2019 09:10:28 +0100 Subject: [PATCH 88/94] [Network usage map] Refactorized some code Former-commit-id: 83fe7cedef01b4d4d38045b15c6b37ec936d5fb3 --- pandora_console/include/functions_netflow.php | 44 ++------ pandora_console/include/functions_network.php | 102 +++++++++++++----- 2 files changed, 81 insertions(+), 65 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index b669219459..69aa0a1608 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1801,6 +1801,7 @@ function netflow_aggregate_is_ip($aggregate) */ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) { + // Pass an empty filter data structure. $data = netflow_get_relationships_raw_data( $start_date, $end_date, @@ -1821,19 +1822,12 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) $nodes = array_map( function ($elem) { - return [ - 'name' => $elem, - 'type' => NODE_GENERIC, - 'width' => 20, - 'height' => 20, - 'status' => '#82B92E', - ]; + return network_init_node_map($elem); }, array_merge($data['sources'], [__('Others')]) ); $relations = []; - $inverse_nodes = array_flip($data['sources']); // Port are situated in a different places from addreses. @@ -1869,14 +1863,7 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) $relations[$index_rel]['text_start'] += $value; } else { // Update the value. - $relations[$index_rel] = [ - 'id_parent' => $src_item, - 'parent_type' => NODE_GENERIC, - 'child_type' => NODE_GENERIC, - 'id_child' => $dst_item, - 'link_color' => '#82B92E', - 'text_start' => $value, - ]; + network_init_relation_map($relations, $src_item, $dst_item, $value); } } @@ -1896,13 +1883,7 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) continue; } - $orphan_hosts[$position.'-'.$orphan_index] = [ - 'id_parent' => $orphan_index, - 'parent_type' => NODE_GENERIC, - 'child_type' => NODE_GENERIC, - 'id_child' => $position, - 'link_color' => '#82B92E', - ]; + network_init_relation_map($orphan_hosts, $position, $orphan_index); } // If there is not any orphan node, delete it. @@ -1910,17 +1891,8 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) array_pop($nodes); } - return [ - 'nodes' => $nodes, - 'relations' => array_merge($relations, $orphan_hosts), - 'pure' => 1, - 'no_pandora_node' => 1, - 'map_options' => [ - 'generation_method' => LAYOUT_SPRING1, - 'map_filter' => [ - 'node_radius' => 40, - 'node_sep' => 7, - ], - ], - ]; + return network_general_map_configuration( + $nodes, + array_merge($relations, $orphan_hosts) + ); } diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index 8dba68d2d4..e25c86a23d 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -193,13 +193,7 @@ function network_build_map_data($start, $end, $top, $talker) $nodes = array_map( function ($elem) { - return [ - 'name' => $elem, - 'type' => NODE_GENERIC, - 'width' => 20, - 'height' => 20, - 'status' => '#82B92E', - ]; + return network_init_node_map($elem); }, $hosts ); @@ -223,42 +217,46 @@ function network_build_map_data($start, $end, $top, $talker) continue; } - $relations[$src_index.'-'.$dst_index] = [ - 'id_parent' => $inverse_hosts[$sd['host']], - 'parent_type' => NODE_GENERIC, - 'child_type' => NODE_GENERIC, - 'id_child' => $inverse_hosts[$host], - 'link_color' => '#82B92E', - 'text_start' => network_format_bytes($sd['sum_bytes']), - ]; + network_init_relation_map( + $relations, + $src_index, + $dst_index, + network_format_bytes($sd['sum_bytes']) + ); } // Put the orphans on Other node. if (empty($host_top)) { $other_id = (end($inverse_hosts) + 1); // TODOS: Add the data. - $orphan_relations[$inverse_hosts[$host].'-'.$other_id] = [ - 'id_parent' => $other_id, - 'parent_type' => NODE_GENERIC, - 'child_type' => NODE_GENERIC, - 'id_child' => $inverse_hosts[$host], - 'link_color' => '#82B92E', - ]; + network_init_relation_map( + $orphan_relations, + $other_id, + $inverse_hosts[$host] + ); } } // Put the Others node and their relations. if (empty($orphan_relations) === false) { - $nodes[] = [ - 'name' => __('Others'), - 'type' => NODE_GENERIC, - 'width' => 20, - 'height' => 20, - 'status' => '#82B92E', - ]; + $nodes[] = network_init_node_map(__('Others')); $relations = array_merge($relations, $orphan_relations); } + return network_general_map_configuration($nodes, $relations); +} + + +/** + * Return the array to pass to constructor to NetworkMap. + * + * @param array $nodes Nodes data structure. + * @param array $relations Relations data structure. + * + * @return array To be passed to NetworMap class. + */ +function network_general_map_configuration($nodes, $relations) +{ return [ 'nodes' => $nodes, 'relations' => $relations, @@ -273,3 +271,49 @@ function network_build_map_data($start, $end, $top, $talker) ], ]; } + + +/** + * Added a relation to relations array + * + * @param array $relations Relations array (passed by reference). + * @param integer $parent Parent id (numeric). + * @param integer $child Child id (numeric). + * @param string $text Text to show at the end of edge (optional). + * + * @return void Relations will be modified (passed by reference). + */ +function network_init_relation_map(&$relations, $parent, $child, $text='') +{ + $index = $parent.'-'.$child; + $relations[$index] = [ + 'id_parent' => $parent, + 'parent_type' => NODE_GENERIC, + 'child_type' => NODE_GENERIC, + 'id_child' => $child, + 'link_color' => '#82B92E', + ]; + + if (empty($text) === false) { + $relations[$index]['text_start'] = $text; + } +} + + +/** + * Initialize a node structure to NetworkMap class. + * + * @param string $name Node name. + * + * @return array Node data structure. + */ +function network_init_node_map($name) +{ + return [ + 'name' => $name, + 'type' => NODE_GENERIC, + 'width' => 20, + 'height' => 20, + 'status' => '#82B92E', + ]; +} From a7ff6548268ac1ecad1cd3cce43b1d7cde278a2b Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 26 Mar 2019 11:57:54 +0100 Subject: [PATCH 89/94] Removed output in netflow filter Former-commit-id: 4f2cfac6efe1482c86179601bac88826057e7d5c --- pandora_console/godmode/netflow/nf_edit_form.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/pandora_console/godmode/netflow/nf_edit_form.php b/pandora_console/godmode/netflow/nf_edit_form.php index 643d63f8c0..60cd41f019 100644 --- a/pandora_console/godmode/netflow/nf_edit_form.php +++ b/pandora_console/godmode/netflow/nf_edit_form.php @@ -85,7 +85,6 @@ if ($id) { $dst_port = $filter['dst_port']; $src_port = $filter['src_port']; $aggregate = $filter['aggregate']; - $output = $filter['output']; $advanced_filter = $filter['advanced_filter']; } else { $name = ''; @@ -95,7 +94,6 @@ if ($id) { $dst_port = ''; $src_port = ''; $aggregate = 'dstip'; - $output = 'bytes'; $advanced_filter = ''; } @@ -103,7 +101,6 @@ if ($update) { $name = (string) get_parameter('name'); $assign_group = (int) get_parameter('assign_group'); $aggregate = get_parameter('aggregate', ''); - $output = get_parameter('output', 'bytes'); $ip_dst = get_parameter('ip_dst', ''); $ip_src = get_parameter('ip_src', ''); $dst_port = get_parameter('dst_port', ''); @@ -123,7 +120,6 @@ if ($update) { 'dst_port' => $dst_port, 'src_port' => $src_port, 'advanced_filter' => $advanced_filter, - 'output' => $output, ]; // Save filter args @@ -143,7 +139,6 @@ if ($create) { $name = (string) get_parameter('name'); $assign_group = (int) get_parameter('assign_group'); $aggregate = get_parameter('aggregate', 'dstip'); - $output = get_parameter('output', 'bytes'); $ip_dst = get_parameter('ip_dst', ''); $ip_src = get_parameter('ip_src', ''); $dst_port = get_parameter('dst_port', ''); @@ -159,7 +154,6 @@ if ($create) { 'src_port' => $src_port, 'aggregate' => $aggregate, 'advanced_filter' => $advanced_filter, - 'output' => $output, ]; // Save filter args @@ -241,7 +235,6 @@ $table->data[7][1] = html_print_textarea('advanced_filter', 4, 40, $advanced_fil $table->data[8][0] = ''.__('Aggregate by').''.ui_print_help_icon('aggregate_by', true); $aggregate_list = [ - 'proto' => __('Protocol'), 'srcip' => __('Src Ip Address'), 'dstip' => __('Dst Ip Address'), 'srcport' => __('Src Port'), @@ -250,15 +243,6 @@ $aggregate_list = [ $table->data[8][1] = html_print_select($aggregate_list, 'aggregate', $aggregate, '', '', 0, true, false, true, '', false); -$table->data[9][0] = ''.__('Output format').''; -$show_output = [ - 'kilobytes' => __('Kilobytes'), - 'megabytes' => __('Megabytes'), - 'kilobytespersecond' => __('Kilobytes per second'), - 'megabytespersecond' => __('Megabytes per second'), -]; -$table->data[9][1] = html_print_select($show_output, 'output', $output, '', '', 0, true, false, true, '', false); - echo '
'; html_print_table($table); echo '
'; From f2e710907a33649948f2b3f1415ada58924204e8 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 26 Mar 2019 15:01:56 +0100 Subject: [PATCH 90/94] Normalized network/netflow interval-start ddate switch Former-commit-id: 2cce98339fbcca9e7ef6bf29e7ace2d81c5ff525 --- .../operation/network/network_report.php | 26 ++++++++++++------- .../operation/network/network_usage_map.php | 4 +++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 7ca13a8e79..c9f3edf408 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -95,17 +95,10 @@ $table->data['0']['1'] .= html_print_select( true ); -$table->data['0']['2'] = __('Select period').'  '; -$table->data['0']['2'] .= html_print_checkbox( - 'is_period', - 1, - ($is_period === true) ? 1 : 0, - true, - false, - 'network_report_click_period(event)' -); +$table->data['0']['2'] = ''; -$table->data['1']['0'] = '
'; +$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'] .= '  '; @@ -116,6 +109,19 @@ $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); diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php index 6f0aee1091..046cc1fcc4 100644 --- a/pandora_console/operation/network/network_usage_map.php +++ b/pandora_console/operation/network/network_usage_map.php @@ -90,6 +90,10 @@ $table->data['0']['0'] .= html_print_checkbox( 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').'  '; From f880d9202afe2f825e269ce357f83d05e95e72f3 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 26 Mar 2019 15:27:45 +0100 Subject: [PATCH 91/94] Adde no popup configuration token to avoid to show tooltips Former-commit-id: d5b6260a065b40dfbc498db077a610c35a9e0fb3 --- .../include/class/NetworkMap.class.php | 19 +++++++++++++++++-- pandora_console/include/functions_network.php | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index db8df9e2a1..56ef4ce0f5 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -282,6 +282,13 @@ class NetworkMap */ private $filter; + /** + * Do not show the popup window. + * + * @var integer + */ + private $noPopUp; + /** * Base constructor. @@ -369,6 +376,10 @@ class NetworkMap $this->noPandoraNode = $options['no_pandora_node']; } + if (isset($options['no_popup'])) { + $this->noPopUp = $options['no_popup']; + } + // Use a custom parser. if (isset($options['custom_parser'])) { $this->customParser = $options['custom_parser']; @@ -3390,13 +3401,17 @@ class NetworkMap $output .= $this->loadMapSkel(); $output .= $this->loadMapData(); $output .= $this->loadController(); - $output .= $this->loadAdvancedInterface(); + if (!$this->noPopUp) { + $output .= $this->loadAdvancedInterface(); + } } else { // Simulated, no tmap entries. $output .= $this->loadMapSkel(); $output .= $this->loadMapData(); $output .= $this->loadController(); - $output .= $this->loadSimpleInterface(); + if (!$this->noPopUp) { + $output .= $this->loadSimpleInterface(); + } } $output .= ' diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index e25c86a23d..9c9e1456b4 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -262,6 +262,7 @@ function network_general_map_configuration($nodes, $relations) 'relations' => $relations, 'pure' => 1, 'no_pandora_node' => 1, + 'no_popup' => 1, 'map_options' => [ 'generation_method' => LAYOUT_SPRING1, 'map_filter' => [ From 7b901be5fa9093b4a0a1bc23ad8ada7e67639b66 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 27 Mar 2019 12:42:54 +0100 Subject: [PATCH 92/94] Changed default font size name on NetworkMap class Former-commit-id: b1437a7e03eba758d83386166db0063a5fcaf12f --- pandora_console/include/class/NetworkMap.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index bdcde8660d..fb019bfa6f 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -322,7 +322,7 @@ class NetworkMap $this->mapOptions['width'] = $config['networkmap_max_width']; $this->mapOptions['height'] = $config['networkmap_max_width']; $this->mapOptions['simple'] = 0; - $this->mapOptions['font_size'] = 12; + $this->mapOptions['font_size'] = 20; $this->mapOptions['nooverlap'] = 1; $this->mapOptions['z_dash'] = 0.5; $this->mapOptions['center'] = 0; From 082e5f06d6688440dd523448f9c36b6eca252b6f Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Wed, 27 Mar 2019 16:26:47 +0100 Subject: [PATCH 93/94] fix pandora logo image path Former-commit-id: 92bc151f8e988758af7381ca95b8055ec7a23d5e --- pandora_console/general/main_menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index 072484ee06..877f171090 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -56,7 +56,7 @@ $custom_logo_collapsed = 'images/custom_logo/'.$config['custom_logo_collapsed']; if (!defined('PANDORA_ENTERPRISE')) { $logo_title = get_product_name().' Opensource'; - $custom_logo = 'images/custom_logo/pandora_logo_head_green.png'; + $custom_logo = 'images/custom_logo/pandora_logo_head_3.png'; $custom_logo_collapsed = 'images/custom_logo/pandora_logo_green_collapsed.png'; } else { if (file_exists(ENTERPRISE_DIR.'/'.$custom_logo)) { From 74cb6970dcf56d23c565a871e7a59918dcde6542 Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 27 Mar 2019 16:36:00 +0100 Subject: [PATCH 94/94] Updated version and build strings. Former-commit-id: f5c1433f1fcbc61ab069c275f72673b029b98af4 --- pandora_agents/pc/AIX/pandora_agent.conf | 2 +- pandora_agents/pc/FreeBSD/pandora_agent.conf | 2 +- pandora_agents/pc/HP-UX/pandora_agent.conf | 2 +- pandora_agents/pc/Linux/pandora_agent.conf | 2 +- pandora_agents/pc/NT4/pandora_agent.conf | 2 +- pandora_agents/pc/SunOS/pandora_agent.conf | 2 +- pandora_agents/pc/Win32/pandora_agent.conf | 2 +- pandora_agents/shellscript/aix/pandora_agent.conf | 2 +- pandora_agents/shellscript/bsd-ipso/pandora_agent.conf | 2 +- pandora_agents/shellscript/hp-ux/pandora_agent.conf | 2 +- pandora_agents/shellscript/linux/pandora_agent.conf | 2 +- pandora_agents/shellscript/mac_osx/pandora_agent.conf | 2 +- pandora_agents/shellscript/openWRT/pandora_agent.conf | 2 +- pandora_agents/shellscript/solaris/pandora_agent.conf | 2 +- pandora_agents/unix/AIX/pandora_agent.conf | 2 +- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/Darwin/pandora_agent.conf | 2 +- pandora_agents/unix/FreeBSD/pandora_agent.conf | 2 +- pandora_agents/unix/HP-UX/pandora_agent.conf | 2 +- pandora_agents/unix/Linux/pandora_agent.conf | 2 +- pandora_agents/unix/NT4/pandora_agent.conf | 2 +- pandora_agents/unix/NetBSD/pandora_agent.conf | 2 +- pandora_agents/unix/SunOS/pandora_agent.conf | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 4 ++-- pandora_agents/unix/pandora_agent.spec | 4 ++-- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/bin/pandora_agent.conf | 2 +- pandora_agents/win32/installer/pandora.mpi | 4 ++-- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 4 ++-- pandora_console/pandora_console.spec | 4 ++-- pandora_console/pandora_console_install | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/conf/pandora_server.conf.new | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 4 ++-- pandora_server/pandora_server.spec | 4 ++-- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 49 files changed, 56 insertions(+), 56 deletions(-) diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index 07054ee2e1..c5a79a38b5 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, AIX version +# Version 7.0NG.733, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index 9d8a49bb99..da15c864ea 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, FreeBSD Version +# Version 7.0NG.733, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index c02e4647e1..cb8075b7ac 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, HP-UX Version +# Version 7.0NG.733, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 153113e070..170e9c6ccf 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, GNU/Linux +# Version 7.0NG.733, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index 6ddeba7edc..42257021fa 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, GNU/Linux +# Version 7.0NG.733, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index 502317f893..ebad34a0ab 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, Solaris Version +# Version 7.0NG.733, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 96b20ea7e3..972f6d8aa1 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2010 Artica Soluciones Tecnologicas -# Version 7.0NG.732 +# Version 7.0NG.733 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index 200ff9db97..6a80829c29 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.732, AIX version +# Version 7.0NG.733, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index 2002f4db65..6555df787c 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.732 +# Version 7.0NG.733 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index f9c19dbd06..ba29482633 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.732, HPUX Version +# Version 7.0NG.733, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index dc272a7a71..7bd41ad039 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732 +# Version 7.0NG.733 # Licensed under GPL license v2, # (c) 2003-2010 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index 5a466677d2..525f70c2af 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732 +# Version 7.0NG.733 # Licensed under GPL license v2, # (c) 2003-2009 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index 170188cc6f..d3cf26efa2 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732 +# Version 7.0NG.733 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index aad04ca60d..5a94defce2 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.732, Solaris version +# Version 7.0NG.733, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 3ce7da3c7e..ac43dfdabb 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, AIX version +# Version 7.0NG.733, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index c5593f4d39..00bba31f75 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.732-190327 +Version: 7.0NG.733 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 5325602855..53591139bf 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.732-190327" +pandora_version="7.0NG.733" 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/Darwin/pandora_agent.conf b/pandora_agents/unix/Darwin/pandora_agent.conf index 35202fcbe5..3b87b2bdbf 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, GNU/Linux +# Version 7.0NG.733, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index c505d5f75e..55e5ab3dd0 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, FreeBSD Version +# Version 7.0NG.733, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index 237bffb291..3c9891fdce 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, HP-UX Version +# Version 7.0NG.733, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index 5a65e0e095..0f6cbfc83a 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, GNU/Linux +# Version 7.0NG.733, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf index 1394067390..11e8c8e6c0 100644 --- a/pandora_agents/unix/NT4/pandora_agent.conf +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, GNU/Linux +# Version 7.0NG.733, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index 677615a47c..d0e7f040e2 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, NetBSD Version +# Version 7.0NG.733, NetBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index 89d5b46100..bb270634a5 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.732, Solaris Version +# Version 7.0NG.733, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index db68a4c637..6818cc90b7 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '7.0NG.732'; +use constant AGENT_VERSION => '7.0NG.733'; use constant AGENT_BUILD => '190327'; # Agent log default file size maximum and instances diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 92a3d10086..0cf4bc8449 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.732 -%define release 190327 +%define version 7.0NG.733 +%define release 1 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 4ec527ceb8..171b9b5669 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.732 -%define release 190327 +%define version 7.0NG.733 +%define release 1 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 5145594c3d..991399fb08 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -9,7 +9,7 @@ # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.732" +PI_VERSION="7.0NG.733" PI_BUILD="190327" OS_NAME=`uname -s` diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 3d1e208de8..12ccb4e91b 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2017 Artica Soluciones Tecnologicas -# Version 7.0NG.732 +# Version 7.0NG.733 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index ed3a26bf93..449c6e9ec4 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -3,7 +3,7 @@ AllowLanguageSelection {Yes} AppName -{Pandora FMS Windows Agent v7.0NG.732} +{Pandora FMS Windows Agent v7.0NG.733} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -2387,7 +2387,7 @@ Windows,BuildSeparateArchives {No} Windows,Executable -{<%AppName%>-<%Version%>-Setup<%Ext%>} +{<%AppName%>-Setup<%Ext%>} Windows,FileDescription {<%AppName%> <%Version%> Setup} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 39bc92b3c3..8e6b33dddd 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.732(Build 190327)") +#define PANDORA_VERSION ("7.0NG.733(Build 190327)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index ace464831d..17a14d6942 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.732(Build 190327))" + VALUE "ProductVersion", "(7.0NG.733(Build 190327))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 89a8716f46..d7d20f2bd6 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.732-190327 +Version: 7.0NG.733 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 176e8bacfb..f23b9b5aa5 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.732-190327" +pandora_version="7.0NG.733" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 4e913ba3d4..8bdf4572da 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -21,7 +21,7 @@ * Pandora build version and version */ $build_version = 'PC190327'; -$pandora_version = 'v7.0NG.732'; +$pandora_version = 'v7.0NG.733'; // Do not overwrite default timezone set if defined. $script_tz = @date_default_timezone_get(); diff --git a/pandora_console/install.php b/pandora_console/install.php index 58597ed800..9ce9c8fc8f 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -128,7 +128,7 @@