From 24c33577d82834838d38d4ff67e8d5fbcb0f76f8 Mon Sep 17 00:00:00 2001 From: ramonn Date: Thu, 4 Oct 2012 10:49:11 +0000 Subject: [PATCH] 2012-10-04 Ramon Novoa * include/functions_html.php, include/functions_netflow.php, pandoradb.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql, operation/netflow/nf_live_view.php, operation/netflow/nf_reporting.php, operation/netflow/nf_view.php, extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql, extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, godmode/netflow/nf_edit_form.php, godmode/netflow/nf_item_list.php, godmode/netflow/nf_report_item.php, godmode/netflow/nf_report_form.php, godmode/netflow/nf_edit.php: Added metaconsole integration to netflow reports. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 20 +++++ .../pandoradb_migrate_4.0.x_to_5.0.mysql.sql | 1 + .../pandoradb_migrate_4.0.x_to_5.0.oracle.sql | 3 +- ...doradb_migrate_4.0.x_to_5.0.postgreSQL.sql | 3 +- pandora_console/godmode/netflow/nf_edit.php | 24 ++++-- .../godmode/netflow/nf_edit_form.php | 32 ++++--- .../godmode/netflow/nf_item_list.php | 27 ++++-- .../godmode/netflow/nf_report_form.php | 52 ++++++++---- .../godmode/netflow/nf_report_item.php | 22 +++-- pandora_console/include/functions_netflow.php | 83 ++++++++++++++++--- .../operation/netflow/nf_live_view.php | 52 +++++++++--- .../operation/netflow/nf_reporting.php | 65 +++++++++++++-- pandora_console/operation/netflow/nf_view.php | 30 ++++--- pandora_console/pandoradb.oracle.sql | 1 + pandora_console/pandoradb.postgreSQL.sql | 3 +- pandora_console/pandoradb.sql | 1 + 16 files changed, 323 insertions(+), 96 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 91fcccbc56..d9267bee69 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,23 @@ +2012-10-04 Ramon Novoa + + * include/functions_html.php, + include/functions_netflow.php, + pandoradb.sql, + pandoradb.postgreSQL.sql, + pandoradb.oracle.sql, + operation/netflow/nf_live_view.php, + operation/netflow/nf_reporting.php, + operation/netflow/nf_view.php, + extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, + godmode/netflow/nf_edit_form.php, + godmode/netflow/nf_item_list.php, + godmode/netflow/nf_report_item.php, + godmode/netflow/nf_report_form.php, + godmode/netflow/nf_edit.php: Added metaconsole integration to netflow + reports. + 2012-10-04 Juan Manuel Ramon * include/functions_html.php: Fixed path to images in metaconsole. diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql index 0bda50caba..0fdc3a78dd 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql @@ -24,6 +24,7 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report` ( `id_name` varchar(150) NOT NULL default '', `description` TEXT NOT NULL, `id_group` int(10), + `server_name` TEXT NOT NULL, PRIMARY KEY(`id_report`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql index e9f9b07e9f..cca13730b2 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql @@ -44,7 +44,8 @@ CREATE TABLE tnetflow_report ( id_report NUMBER(10, 0) NOT NULL PRIMARY KEY, id_name VARCHAR2(100) NOT NULL, description CLOB default '', - id_group NUMBER(10, 0) + id_group NUMBER(10, 0), + server_name CLOB default '' ); CREATE SEQUENCE tnetflow_report_s INCREMENT BY 1 START WITH 1; CREATE OR REPLACE TRIGGER tnetflow_report_inc BEFORE INSERT ON tnetflow_report REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnetflow_report_s.nextval INTO :NEW.ID_REPORT FROM dual; END tnetflow_report_inc;; diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql index 4fa7255ceb..3030b3023b 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql @@ -42,7 +42,8 @@ CREATE TABLE "tnetflow_report" ( "id_report" SERIAL NOT NULL PRIMARY KEY, "id_name" varchar(150) NOT NULL default '', "description" TEXT, - "id_group" INTEGER + "id_group" INTEGER, + "server_name" TEXT ); -- ----------------------------------------------------- diff --git a/pandora_console/godmode/netflow/nf_edit.php b/pandora_console/godmode/netflow/nf_edit.php index 708f19120a..9a7ae1bfca 100644 --- a/pandora_console/godmode/netflow/nf_edit.php +++ b/pandora_console/godmode/netflow/nf_edit.php @@ -17,9 +17,9 @@ global $config; -include_once("include/functions_ui.php"); -include_once("include/functions_db.php"); -include_once("include/functions_netflow.php"); +include_once($config['homedir'] . "/include/functions_ui.php"); +include_once($config['homedir'] . "/include/functions_db.php"); +include_once($config['homedir'] . "/include/functions_netflow.php"); check_login (); @@ -31,7 +31,14 @@ if (! check_acl ($config["id_user"], 0, "AW")) { } //Header -ui_print_page_header (__('Manage Netflow Filter'), "images/networkmap/so_cisco_new.png", false, "", true); +if (! defined ('METACONSOLE')) { + ui_print_page_header (__('Manage Netflow Filter'), "images/networkmap/so_cisco_new.png", false, "", true); +} else { + $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_edit', 'text' => __('Netflow filters'))); + + ui_meta_print_page_header($nav_bar); +} $delete = (bool) get_parameter ('delete'); $multiple_delete = (bool)get_parameter('multiple_delete', 0); @@ -122,14 +129,13 @@ $total_filters = $total_filters[0]['total']; foreach ($filters as $filter) { $data = array (); - $data[0] = ''.$filter['id_name'].''; - + $data[0] = ''.$filter['id_name'].''; $group = db_get_value('nombre','tgrupo', 'id_grupo', $filter['id_group']); if ($group == '') $group = 'All'; $data[1] = $group; $data[2] = "" . + href='" . $config['homeurl'] . "index.php?sec=netf&sec2=" . $config['homedir'] . "/godmode/netflow/nf_edit&delete=1&id=".$filter['id_sg']."&offset=0'>" . html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "" . html_print_checkbox_extended ('delete_multiple[]', $filter['id_sg'], false, false, '', 'class="check_delete"', true); @@ -137,7 +143,7 @@ foreach ($filters as $filter) { } if(isset($data)) { - echo "
"; + echo ""; html_print_input_hidden('multiple_delete', 1); html_print_table ($table); echo "
"; @@ -149,7 +155,7 @@ else { echo "
".__('There are no defined filters')."
"; } -echo ''; + echo ''; echo "
"; html_print_submit_button (__('Create filter'), 'crt', false, 'class="sub wand"'); echo "
"; diff --git a/pandora_console/godmode/netflow/nf_edit_form.php b/pandora_console/godmode/netflow/nf_edit_form.php index a7985bc909..f0e846d612 100644 --- a/pandora_console/godmode/netflow/nf_edit_form.php +++ b/pandora_console/godmode/netflow/nf_edit_form.php @@ -17,17 +17,17 @@ global $config; -include_once("include/functions_ui.php"); -include_once("include/functions_netflow.php"); -include_once ("include/functions_users.php"); -include_once ("include/functions_groups.php"); +include_once($config['homedir'] . "/include/functions_ui.php"); +include_once($config['homedir'] . "/include/functions_netflow.php"); +include_once ($config['homedir'] . "/include/functions_users.php"); +include_once ($config['homedir'] . "/include/functions_groups.php"); check_login (); if (! check_acl ($config["id_user"], 0, "IW")) { db_pandora_audit("ACL Violation", "Trying to access event viewer"); - require ("general/noaccess.php"); + require ($config['homedir'] . "/general/noaccess.php"); return; } @@ -39,21 +39,29 @@ $create = (string)get_parameter('create', 0); if ($id){ $permission = netflow_check_filter_group ($id); if (!$permission) { //no tiene permisos para acceder a un filtro - require ("general/noaccess.php"); + require ($config['homedir'] . "/general/noaccess.php"); return; } } -$buttons['edit'] = '' +//Header +if (! defined ('METACONSOLE')) { + $buttons['edit'] = '' . html_print_image ("images/edit.png", true, array ("title" => __('Filter list'))) . ''; -$buttons['add'] = '' + $buttons['add'] = '' . html_print_image ("images/add.png", true, array ("title" => __('Add filter'))) . ''; - -//Header -ui_print_page_header (__('Netflow Filter'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons); + + ui_print_page_header (__('Netflow Filter'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons); +} else { + $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_edit', 'text' => __('Netflow filters')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_edit_form', 'text' => __('Add filter'))); + + ui_meta_print_page_header($nav_bar); +} if ($id) { $filter = netflow_filter_get_filter ($id); @@ -207,7 +215,7 @@ $show_output = array(); $show_output = array ('packets' => __('Packets'), 'bytes' => __('Bytes'), 'flows' =>__('Flows')); $table->data[9][1] = html_print_select ($show_output, 'output', $output, '', '', 0, true, false, true, '', false); -echo ''; +echo ''; html_print_table ($table); echo '
'; if ($id) { diff --git a/pandora_console/godmode/netflow/nf_item_list.php b/pandora_console/godmode/netflow/nf_item_list.php index a6a9ec533a..1f200cc165 100644 --- a/pandora_console/godmode/netflow/nf_item_list.php +++ b/pandora_console/godmode/netflow/nf_item_list.php @@ -17,10 +17,10 @@ global $config; -include_once("include/functions_ui.php"); -include_once("include/functions_db.php"); -include_once("include/functions_netflow.php"); -include_once("include/functions_html.php"); +include_once($config['homedir'] . "/include/functions_ui.php"); +include_once($config['homedir'] . "/include/functions_db.php"); +include_once($config['homedir'] . "/include/functions_netflow.php"); +include_once($config['homedir'] . "/include/functions_html.php"); check_login (); @@ -50,8 +50,15 @@ $buttons['edit_report']['text'] = ' 'index.php?sec=main', 'text' => __('Main')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_reporting', 'text' => __('Netflow reports')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_item_list&id=' . $id, 'text' => __('Item list'))); + ui_meta_print_page_header($nav_bar); +} + $delete = (bool) get_parameter ('delete'); $multiple_delete = (bool)get_parameter('multiple_delete', 0); $order = get_parameter('order'); @@ -222,7 +229,11 @@ foreach ($reports_item as $item) { } if (isset($data)) { - echo ''; + if (! defined ('METACONSOLE')) { + echo ''; + } else { + echo ''; + } html_print_input_hidden('multiple_delete', 1); html_print_table ($table); echo "
"; @@ -234,7 +245,7 @@ else { echo "
".__('There are no defined items')."
"; } -echo ''; + echo ''; echo "
"; html_print_submit_button (__('Create item'), 'crt', false, 'class="sub wand"'); echo "
"; diff --git a/pandora_console/godmode/netflow/nf_report_form.php b/pandora_console/godmode/netflow/nf_report_form.php index 1ea269b00f..b9d1356dc4 100644 --- a/pandora_console/godmode/netflow/nf_report_form.php +++ b/pandora_console/godmode/netflow/nf_report_form.php @@ -16,10 +16,13 @@ global $config; -include_once("include/functions_ui.php"); -include_once("include/functions_html.php"); -include_once("include/functions_db.php"); -include_once("include/functions_netflow.php"); +include_once($config['homedir'] . "/include/functions_ui.php"); +include_once($config['homedir'] . "/include/functions_html.php"); +include_once($config['homedir'] . "/include/functions_db.php"); +include_once($config['homedir'] . "/include/functions_netflow.php"); +if (defined ('METACONSOLE')) { + include_once($config['homedir'] . "/enterprise/include/functions_metaconsole.php"); +} check_login (); @@ -38,11 +41,13 @@ if ($create) { $name = (string) get_parameter ('name'); $group = (int) get_parameter ('id_group'); $description = get_parameter('description',''); + $connection_name = get_parameter('connection_name',''); $values = array ( 'id_name' => $name, 'id_group' => $group, 'description' => $description, + 'server_name' => $connection_name, ); $result_ins = db_process_sql_insert('tnetflow_report', $values); @@ -54,23 +59,30 @@ else { $id = (int)get_parameter('id'); } -$buttons['report_list']['active'] = false; -$buttons['report_list'] = '
' +if (! defined ('METACONSOLE')) { + $buttons['report_list']['active'] = false; + $buttons['report_list'] = '' . html_print_image ("images/edit.png", true, array ("title" => __('Report list'))) . ''; -$buttons['report_items']['active'] = false; -$buttons['report_items']['text'] = '' + $buttons['report_items']['active'] = false; + $buttons['report_items']['text'] = '' . html_print_image ("images/god6.png", true, array ("title" => __('Report items'))) . ''; -$buttons['edit_report']['active'] = true; -$buttons['edit_report']['text'] = '' + $buttons['edit_report']['active'] = true; + $buttons['edit_report']['text'] = '' . html_print_image ("images/config.png", true, array ("title" => __('Edit report'))) . ''; -//Header -ui_print_page_header (__('Netflow Report'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons); + //Header + ui_print_page_header (__('Netflow Report'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons); +} else { + $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_reporting', 'text' => __('Netflow reports')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report_form', 'text' => __('Edit netflow report'))); + ui_meta_print_page_header($nav_bar); +} //Control error creating report if (($result_ins === false) && ($result_ins != -1)) { @@ -93,12 +105,14 @@ if ($id) { $name = $report['id_name']; $description = $report['description']; $group = $report['id_group']; + $connection_name = $report['server_name']; } else { $name = ''; $group = ''; $description = ''; + $connection_name = ''; } if ($update) { @@ -106,6 +120,7 @@ if ($update) { $name = (string) get_parameter ('name'); $description = get_parameter ('description'); $group = get_parameter('id_group'); + $connection_name = get_parameter('connection_name'); if ($name == '') { ui_print_error_message (__('Not updated. Blank name')); @@ -116,6 +131,7 @@ if ($update) { 'id_name' => $name, 'id_group' => $group, 'description' => $description, + 'server_name' => $connection_name, ), array ('id_report' => $id)); ui_print_result_message ($result, __('Report updated successfully'), __('Error updating report')); @@ -143,8 +159,16 @@ $table->data[1][1] = html_print_select_groups($config['id_user'], "IW", $table->data[2][0] = ''.__('Description').''; $table->data[2][1] = html_print_textarea ('description', 2, 65, $description, '', true); +if (defined ('METACONSOLE')) { + $table->data[3][0] = ''.__('Connection').''; + $table->data[3][1] = html_print_select (metaconsole_get_connection_names (), 'connection_name', $connection_name, '', '', 0, true, false, false); +} + + +if (defined ('METACONSOLE')) { + echo ''; +} -echo ''; html_print_table ($table); echo '
'; @@ -159,4 +183,4 @@ else { } echo '
'; echo ''; -?> \ No newline at end of file +?> diff --git a/pandora_console/godmode/netflow/nf_report_item.php b/pandora_console/godmode/netflow/nf_report_item.php index 0e015e0608..c273b855e9 100644 --- a/pandora_console/godmode/netflow/nf_report_item.php +++ b/pandora_console/godmode/netflow/nf_report_item.php @@ -16,10 +16,10 @@ global $config; -include_once("include/functions_ui.php"); -include_once("include/functions_html.php"); -include_once("include/functions_db.php"); -include_once("include/functions_netflow.php"); +include_once($config['homedir'] . "/include/functions_ui.php"); +include_once($config['homedir'] . "/include/functions_html.php"); +include_once($config['homedir'] . "/include/functions_db.php"); +include_once($config['homedir'] . "/include/functions_netflow.php"); ui_require_javascript_file ('calendar'); check_login (); @@ -50,9 +50,17 @@ $buttons['edit_report']['active'] = false; $buttons['edit_report']['text'] = '' . html_print_image ("images/config.png", true, array ("title" => __('Edit report'))) . ''; - + //Header -ui_print_page_header (__('Report item editor'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons); +if (! defined ('METACONSOLE')) { + ui_print_page_header (__('Report item editor'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons); +} else { + $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_reporting', 'text' => __('Netflow reports')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_item_list&id=' . $id, 'text' => __('Item list')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report_item&id=' . $id, 'text' => __('Edit item'))); + ui_meta_print_page_header($nav_bar); +} if ($id_rc) { $item = netflow_reports_get_content ($id_rc); @@ -166,7 +174,7 @@ $table->data[2][0] = ''.__('Chart type').''; $table->data[2][1] = html_print_select (netflow_get_chart_types (), 'show_graph', $show_graph,'','',0,true); $table->data[2][1] = html_print_select (netflow_get_chart_types (), 'show_graph', $show_graph,'','',0,true); -echo '
'; +echo ''; html_print_table ($table); echo '
'; diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 24d6e41dcb..1e77ca97c8 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -364,10 +364,16 @@ function netflow_is_net ($address) { * @return An array with netflow stats. * */ -function netflow_get_data ($start_date, $end_date, $filter, $unique_id, $aggregate, $max, $unit) { +function netflow_get_data ($start_date, $end_date, $filter, $unique_id, $aggregate, $max, $unit, $connection_name = '') { global $nfdump_date_format; global $config; + // Requesting remote data + if (defined ('METACONSOLE') && $connection_name != '') { + $data = metaconsole_call_remote_api ($connection_name, 'netflow_get_data', "$start_date|$end_date|" . base64_encode(json_encode($filter)) . "|$unique_id|$aggregate|$max|$unit"); + return json_decode ($data, true); + } + // Get the command to call nfdump $command = netflow_get_command ($filter); @@ -434,9 +440,15 @@ function netflow_get_data ($start_date, $end_date, $filter, $unique_id, $aggrega * * @return An array with netflow stats. */ -function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $unit) { +function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $unit, $connection_name = '') { global $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"); + return json_decode ($data, true); + } + // Get the command to call nfdump $command = netflow_get_command ($filter); @@ -498,10 +510,16 @@ function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $ * * @return An array with netflow stats. */ -function netflow_get_summary ($start_date, $end_date, $filter, $unique_id) { +function netflow_get_summary ($start_date, $end_date, $filter, $unique_id, $connection_name = '') { global $nfdump_date_format; global $config; + // 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)) . "|$unique_id"); + return json_decode ($data, true); + } + // Get the command to call nfdump $command = netflow_get_command ($filter); @@ -985,8 +1003,7 @@ function netflow_get_valid_intervals () { * @param string output Output format. Only HTML and XML are supported. * */ -function netflow_draw_item ($start_date, $end_date, $type, $filter, $max_aggregates, $unique_id, $output = 'HTML') { - +function netflow_draw_item ($start_date, $end_date, $type, $filter, $max_aggregates, $unique_id, $connection_name = '', $output = 'HTML') { $aggregate = $filter['aggregate']; $unit = $filter['output']; $interval = $end_date - $start_date; @@ -994,7 +1011,7 @@ function netflow_draw_item ($start_date, $end_date, $type, $filter, $max_aggrega // Process item switch ($type) { case '0': - $data = netflow_get_data ($start_date, $end_date, $filter, $unique_id, $aggregate, $max_aggregates, $unit); + $data = netflow_get_data ($start_date, $end_date, $filter, $unique_id, $aggregate, $max_aggregates, $unit, $connection_name); if ($aggregate != 'none') { if ($output == 'HTML') { echo graph_netflow_aggregate_area($data, $interval, 660, 320, 0); @@ -1011,7 +1028,7 @@ function netflow_draw_item ($start_date, $end_date, $type, $filter, $max_aggrega } break; case '1': - $data = netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max_aggregates, $unit); + $data = netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max_aggregates, $unit, $connection_name); if ($output == 'HTML') { echo graph_netflow_aggregate_pie($data, $aggregate); } else if ($output == 'XML') { @@ -1019,7 +1036,7 @@ function netflow_draw_item ($start_date, $end_date, $type, $filter, $max_aggrega } break; case '2': - $data = netflow_get_data ($start_date, $end_date, $filter, $unique_id, $aggregate, $max_aggregates, $unit); + $data = netflow_get_data ($start_date, $end_date, $filter, $unique_id, $aggregate, $max_aggregates, $unit, $connection_name); if ($output == 'HTML') { echo netflow_data_table ($data, $start_date, $end_date, $aggregate); } else if ($output == 'XML') { @@ -1028,7 +1045,7 @@ function netflow_draw_item ($start_date, $end_date, $type, $filter, $max_aggrega } break; case '3': - $data = netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max_aggregates, $unit); + $data = netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max_aggregates, $unit, $connection_name); if ($output == 'HTML') { echo netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit); } else if ($output == 'XML') { @@ -1036,19 +1053,29 @@ function netflow_draw_item ($start_date, $end_date, $type, $filter, $max_aggrega } break; case '4': - $data = netflow_get_summary ($start_date, $end_date, $filter, $unique_id); + $data = netflow_get_summary ($start_date, $end_date, $filter, $unique_id, $connection_name); if ($output == 'HTML') { netflow_summary_table ($data); - } else { + } else if ($output == 'XML') { netflow_summary_xml ($data); } break; default: - echo fs_error_image(); + if ($output == 'HTML') { + echo fs_error_image(); + } break; } } +/** + * 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. + * + */ function netflow_xml_report ($id, $start_date, $end_date) { // Get report data @@ -1101,13 +1128,19 @@ function netflow_xml_report ($id, $start_date, $end_date) { // Build a unique id for the cache $unique_id = $report['id_report'] . '_' . $content['id_rc'] . '_' . ($end_date - $start_date); - netflow_draw_item ($start_date, $end_date, $content['show_graph'], $filter, $content['max'], $unique_id, 'XML'); + netflow_draw_item ($start_date, $end_date, $content['show_graph'], $filter, $content['max'], $unique_id, $report['server_name'], 'XML'); echo " \n"; } echo "\n"; } +/** + * Render an aggregated area chart as an XML. + * + * @param array Netflow data. + * + */ function netflow_aggregate_area_xml ($data) { // Print source information @@ -1134,6 +1167,12 @@ function netflow_aggregate_area_xml ($data) { echo "\n"; } +/** + * Render an area chart as an XML. + * + * @param array Netflow data. + * + */ function netflow_total_area_xml ($data) { // Print flow information @@ -1147,6 +1186,12 @@ function netflow_total_area_xml ($data) { echo "\n"; } +/** + * Render a pie chart as an XML. + * + * @param array Netflow data. + * + */ function netflow_aggregate_pie_xml ($data) { // Calculate total @@ -1167,6 +1212,12 @@ function netflow_aggregate_pie_xml ($data) { echo "\n"; } +/** + * Render a stats table as an XML. + * + * @param array Netflow data. + * + */ function netflow_stat_xml ($data) { // Print stats @@ -1178,6 +1229,12 @@ function netflow_stat_xml ($data) { echo "\n"; } +/** + * Render a summary table as an XML. + * + * @param array Netflow data. + * + */ function netflow_summary_xml ($data) { // Print summary diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 419ebeb3b2..96d0ae0faa 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -16,10 +16,14 @@ global $config; -include_once("include/functions_graph.php"); -include_once("include/functions_ui.php"); -include_once("include/functions_netflow.php"); -ui_require_javascript_file ('calendar'); +include_once($config['homedir'] . "/include/functions_graph.php"); +include_once($config['homedir'] . "/include/functions_ui.php"); +include_once($config['homedir'] . "/include/functions_netflow.php"); +if (defined ('METACONSOLE')) { + ui_require_javascript_file ('calendar', '../../include/javascript/'); +} else { + ui_require_javascript_file ('calendar'); +} // ACL @@ -81,7 +85,7 @@ $period = (int) get_parameter('period', '86400'); $update_date = (int) get_parameter('update_date', 0); $date = get_parameter_post ('date', date ("Y/m/d", get_system_time ())); $time = get_parameter_post ('time', date ("H:i:s", get_system_time ())); - +$connection_name = get_parameter('connection_name', ''); // Read buttons $draw = get_parameter('draw_button', ''); @@ -93,8 +97,15 @@ $update = get_parameter('update_button', ''); $end_date = strtotime ($date . " " . $time); $start_date = $end_date - $period; -//Header -ui_print_page_header (__('Netflow live view'), "images/networkmap/so_cisco_new.png", false, "", false, array ()); +if (! defined ('METACONSOLE')) { + //Header + ui_print_page_header (__('Netflow live view'), "images/networkmap/so_cisco_new.png", false, "", false, array ()); +} else { + $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_live_view', 'text' => __('Netflow live view'))); + + ui_meta_print_page_header($nav_bar); +} // Save user defined filter if ($save != '' && check_acl ($config["id_user"], 0, "AW")) { @@ -129,8 +140,8 @@ else if ($update != '' && check_acl ($config["id_user"], 0, "AW")) { // The filter name will not be needed anymore $filter['id_name'] = ''; -echo ''; - +echo ''; + // Chart options table $table->width = '100%'; $table->border = 0; @@ -157,6 +168,11 @@ echo ' {"page" : "operation/netflow/nf_live_view", "get_filter_type" : 1, "id" : $("#filter_id").val() @@ -362,7 +384,13 @@ if ($draw != '') { $("#submit-update_button").css("visibility", ""); // Get filter values from DB - jQuery.post ("ajax.php", + {"page" : "operation/netflow/nf_live_view", "get_filter_values" : 1, "id" : $("#filter_id").val() diff --git a/pandora_console/operation/netflow/nf_reporting.php b/pandora_console/operation/netflow/nf_reporting.php index 4e5ae55a0f..27b5748847 100644 --- a/pandora_console/operation/netflow/nf_reporting.php +++ b/pandora_console/operation/netflow/nf_reporting.php @@ -29,9 +29,32 @@ if (! check_acl ($config["id_user"], 0, "AR")) { require ("general/noaccess.php"); return; } +$write_permissions = check_acl ($config["id_user"], 0, "AW"); //Header -ui_print_page_header (__('Netflow Reporting'), "images/networkmap/so_cisco_new.png", false, "", false); +if (! defined ('METACONSOLE')) { + ui_print_page_header (__('Netflow Reporting'), "images/networkmap/so_cisco_new.png", false, "", false); +} else { + $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_reporting', 'text' => __('Netflow reports'))); + + ui_meta_print_page_header($nav_bar); +} + +$delete_report = get_parameter ('delete_report', false); +$report_id = (int) get_parameter ('report_id', 0); + +if ($delete_report && $report_id != 0 && $write_permissions) { + $result = db_process_sql_delete ('tnetflow_report', + array ('id_report' => $report_id)); + + if ($result !== false) $result = true; + else $result = false; + + ui_print_result_message ($result, + __('Successfully deleted'), + __('Not deleted. Error deleting data')); +} /* $filter = array (); @@ -60,15 +83,20 @@ $table->head = array (); $table->head[0] = __('Report name'); $table->head[1]= __('Description'); $table->head[2] = __('Group'); +if (defined ('METACONSOLE') && $write_permissions) { + $table->head[3] = '' . __('Op.') . ''; +} $table->style = array (); $table->style[0] = 'font-weight: bold'; $table->align = array (); $table->align[2] = 'center'; $table->size = array (); -$table->size[0] = '40%'; -$table->size[1] = '40%'; -$table->size[2] = '20%'; +$table->size[0] = '30%'; +$table->size[2] = '10px'; +if (defined ('METACONSOLE') && $write_permissions) { + $table->size[3] = '85px'; +} $table->data = array (); $total_reports = db_get_all_rows_filter ('tnetflow_report', false, 'COUNT(*) AS total'); @@ -79,16 +107,39 @@ $total_reports = $total_reports[0]['total']; foreach ($reports as $report) { $data = array (); - $data[0] = ''.$report['id_name'].''; + $data[0] = ''.$report['id_name'].''; $data[1] = $report['description']; - $data[2] = ui_print_group_icon($report['id_group'], true); + + if (! defined ('METACONSOLE')) { + $data[2] = ui_print_group_icon($report['id_group'], true); + } else { + // No link to the group page in the metaconsole + $data[2] = ui_print_group_icon($report['id_group'], true, 'groups_small', '', false); + } + + if (defined ('METACONSOLE') && $write_permissions) { + $data[3] = ''; + $data[3] .= html_print_input_image ('edit', 'images/config.png', 1, '', true, array ('title' => __('Edit'))); + $data[3] .= ''; + + $data[3] .= '  
'; + $data[3] .= html_print_input_image ('edit', 'images/god6.png', 1, '', true, array ('title' => __('Items'))); + $data[3] .= '
'; + + $data[3] .= '  
'; + $data[3] .= html_print_input_hidden ('report_id', $report['id_report'], true); + $data[3] .= html_print_input_hidden ('delete_report', true, true); + $data[3] .= html_print_input_image ('delete', 'images/cross.png', 1, '', + true, array ('title' => __('Delete'))); + $data[3] .= '
'; + } array_push ($table->data, $data); } html_print_table ($table); -echo '
'; +echo ''; echo '
'; html_print_submit_button (__('Create report'), 'crt', false, 'class="sub wand"'); echo "
"; diff --git a/pandora_console/operation/netflow/nf_view.php b/pandora_console/operation/netflow/nf_view.php index 88120d059b..1bf1dd7d38 100644 --- a/pandora_console/operation/netflow/nf_view.php +++ b/pandora_console/operation/netflow/nf_view.php @@ -88,11 +88,16 @@ $buttons['report_list'] = ' 'index.php?sec=main', 'text' => __('Main')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_reporting', 'text' => __('Netflow reports')), + array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_view', 'text' => __('View netflow report'))); + ui_meta_print_page_header($nav_bar); +} -echo"

".__('Filter graph')."

"; - -echo ''; +echo ''; $table->width = '60%'; $table->border = 0; @@ -113,8 +118,11 @@ echo '" . html_print_image("images/database_lightning.png", true) . '
'; - + if (! defined ('METACONSOLE')) { + $table->data[2][1] = '" . html_print_image("images/database_lightning.png", true) . ''; + } else { + $table->data[2][1] = '" . html_print_image("images/database_lightning.png", true) . ''; + } html_print_table ($table); @@ -123,14 +131,14 @@ echo '$report_name"; - +$report_name = $report['id_name']; +$connection_name = $report['server_name']; $report_contents = db_get_all_rows_sql("SELECT * FROM tnetflow_report_content WHERE id_report='$id' ORDER BY `order`"); if (empty ($report_contents)) { echo fs_error_image(); @@ -160,6 +168,6 @@ foreach ($report_contents as $content_report) { $unique_id = $report_id . '_' . $content_id . '_' . ($end_date - $start_date); // Draw - netflow_draw_item ($start_date, $end_date, $type, $filter, $max_aggregates, $unique_id); + netflow_draw_item ($start_date, $end_date, $type, $filter, $max_aggregates, $unique_id, $connection_name); } ?> \ No newline at end of file diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index 16a6173ac3..cc24605bc7 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -1636,6 +1636,7 @@ id_report NUMBER(10, 0) NOT NULL PRIMARY KEY, id_name VARCHAR2(100) NOT NULL, description CLOB default '', id_group NUMBER(10, 0) +server_name CLOB default '', ); CREATE SEQUENCE tnetflow_report_s INCREMENT BY 1 START WITH 1; diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index c6e6c91816..cc0c856006 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -1382,7 +1382,8 @@ CREATE TABLE "tnetflow_report" ( "id_report" SERIAL NOT NULL PRIMARY KEY, "id_name" varchar(150) NOT NULL default '', "description" TEXT, - "id_group" INTEGER + "id_group" INTEGER, + "server_name" TEXT ); -- ----------------------------------------------------- diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index fd7a8c9651..2099295d27 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1555,6 +1555,7 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report` ( `id_name` varchar(150) NOT NULL default '', `description` TEXT NOT NULL, `id_group` int(10), + `server_name` TEXT NOT NULL, PRIMARY KEY(`id_report`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;