2012-10-04 Ramon Novoa <rnovoa@artica.es>

* 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
This commit is contained in:
ramonn 2012-10-04 10:49:11 +00:00
parent 0d5ebd12d7
commit 24c33577d8
16 changed files with 323 additions and 96 deletions

View File

@ -1,3 +1,23 @@
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* 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 <juanmanuel.ramon@artica.es>
* include/functions_html.php: Fixed path to images in metaconsole.

View File

@ -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;

View File

@ -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;;

View File

@ -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
);
-- -----------------------------------------------------

View File

@ -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] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_edit_form&id='.$filter['id_sg'].'">'.$filter['id_name'].'</a>';
$data[0] = '<a href="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config ['homedir'] . '/godmode/netflow/nf_edit_form&id='.$filter['id_sg'].'">'.$filter['id_name'].'</a>';
$group = db_get_value('nombre','tgrupo', 'id_grupo', $filter['id_group']);
if ($group == '')
$group = 'All';
$data[1] = $group;
$data[2] = "<a onclick='if(confirm(\"" . __('Are you sure?') . "\")) return true; else return false;'
href='index.php?sec=netf&sec2=godmode/netflow/nf_edit&delete=1&id=".$filter['id_sg']."&offset=0'>" .
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'))) . "</a>" .
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 "<form method='post' action='index.php?sec=netf&sec2=godmode/netflow/nf_edit'>";
echo "<form method='post' action='" . $config['homeurl'] . "index.php?sec=netf&sec2=" . $config['homedir'] . "/godmode/netflow/nf_edit'>";
html_print_input_hidden('multiple_delete', 1);
html_print_table ($table);
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
@ -149,7 +155,7 @@ else {
echo "<div class='nf'>".__('There are no defined filters')."</div>";
}
echo '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_edit_form">';
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_edit_form">';
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
html_print_submit_button (__('Create filter'), 'crt', false, 'class="sub wand"');
echo "</div>";

View File

@ -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'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_edit">'
//Header
if (! defined ('METACONSOLE')) {
$buttons['edit'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_edit">'
. html_print_image ("images/edit.png", true, array ("title" => __('Filter list')))
. '</a>';
$buttons['add'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_edit_form">'
$buttons['add'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_edit_form">'
. html_print_image ("images/add.png", true, array ("title" => __('Add filter')))
. '</a>';
//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 '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_edit_form">';
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_edit_form">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {

View File

@ -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'] = '<a href="index.php?sec=netf&sec2=godmode/netf
. '</a>';
//Header
ui_print_page_header (__('Report items'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons);
if (! defined ('METACONSOLE')) {
ui_print_page_header (__('Report items'), "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')));
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 '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_item_list&id='.$id.'">';
if (! defined ('METACONSOLE')) {
echo '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_item_list&id='.$id.'">';
} else {
echo '<form method="post" action="' . ui_get_full_url(false) . 'enterprise/meta/index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_item_list&id='.$id.'">';
}
html_print_input_hidden('multiple_delete', 1);
html_print_table ($table);
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
@ -234,7 +245,7 @@ else {
echo "<div class='nf'>".__('There are no defined items')."</div>";
}
echo '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_report_item&id='.$id.'">';
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report_item&id='.$id.'">';
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
html_print_submit_button (__('Create item'), 'crt', false, 'class="sub wand"');
echo "</div>";

View File

@ -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'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report">'
if (! defined ('METACONSOLE')) {
$buttons['report_list']['active'] = false;
$buttons['report_list'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report">'
. html_print_image ("images/edit.png", true, array ("title" => __('Report list')))
. '</a>';
$buttons['report_items']['active'] = false;
$buttons['report_items']['text'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_item_list&id='.$id.'">'
$buttons['report_items']['active'] = false;
$buttons['report_items']['text'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_item_list&id='.$id.'">'
. html_print_image ("images/god6.png", true, array ("title" => __('Report items')))
. '</a>';
$buttons['edit_report']['active'] = true;
$buttons['edit_report']['text'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report_form&id='.$id.'">'
$buttons['edit_report']['active'] = true;
$buttons['edit_report']['text'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report_form&id='.$id.'">'
. html_print_image ("images/config.png", true, array ("title" => __('Edit report')))
. '</a>';
//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] = '<b>'.__('Description').'</b>';
$table->data[2][1] = html_print_textarea ('description', 2, 65, $description, '', true);
if (defined ('METACONSOLE')) {
$table->data[3][0] = '<b>'.__('Connection').'</b>';
$table->data[3][1] = html_print_select (metaconsole_get_connection_names (), 'connection_name', $connection_name, '', '', 0, true, false, false);
}
if (defined ('METACONSOLE')) {
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report_form">';
}
echo '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_report_form">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
@ -159,4 +183,4 @@ else {
}
echo '</div>';
echo '</form>';
?>
?>

View File

@ -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'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report_form&id='.$id.'">'
. html_print_image ("images/config.png", true, array ("title" => __('Edit report')))
. '</a>';
//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] = '<b>'.__('Chart type').'</b>';
$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 '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_report_item&id='.$id.'">';
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir']. '/godmode/netflow/nf_report_item&id='.$id.'">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';

View File

@ -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 " </report_item>\n";
}
echo "</report>\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 "</flows>\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 "</flows>\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 "</pie>\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 "</stats>\n";
}
/**
* Render a summary table as an XML.
*
* @param array Netflow data.
*
*/
function netflow_summary_xml ($data) {
// Print summary

View File

@ -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 '<form method="post" action="index.php?sec=netf&sec2=operation/netflow/nf_live_view">';
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_live_view">';
// Chart options table
$table->width = '100%';
$table->border = 0;
@ -157,6 +168,11 @@ echo '<form method="post" action="index.php?sec=netf&sec2=operation/netflow/nf_l
);
$table->data[0][6] = '<b>'.__('Max. values').'</b>';
$table->data[0][7] = html_print_select ($max_values, 'max_aggregates', $max_aggregates, '', '', 0, true);
if (defined ('METACONSOLE')) {
$table->data[0][8] = '<b>'.__('Connection').'</b>';
$table->data[0][9] = html_print_select (metaconsole_get_connection_names (), 'connection_name', $connection_name, '', '', 0, true, false, false);
}
html_print_table ($table);
@ -237,7 +253,7 @@ if ($draw != '') {
$unique_id = 'live_view__' . ($end_date - $start_date);
// Draw
netflow_draw_item ($start_date, $end_date, $chart_type, $filter, $command, $filter, $max_aggregates, $unique_id);
netflow_draw_item ($start_date, $end_date, $chart_type, $filter, $max_aggregates, $unique_id, $connection_name);
}
?>
@ -330,7 +346,13 @@ if ($draw != '') {
// Load fields from DB
// Get filter type
jQuery.post ("ajax.php",
<?php
if (! defined ('METACONSOLE')) {
echo 'jQuery.post ("ajax.php",';
} else {
echo 'jQuery.post ("' . $config['homeurl'] . '../../ajax.php",';
}
?>
{"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",
<?php
if (! defined ('METACONSOLE')) {
echo 'jQuery.post ("ajax.php",';
} else {
echo 'jQuery.post ("' . $config['homeurl'] . '../../ajax.php",';
}
?>
{"page" : "operation/netflow/nf_live_view",
"get_filter_values" : 1,
"id" : $("#filter_id").val()

View File

@ -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] = '<span title="Operations">' . __('Op.') . '</span>';
}
$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] = '<a href="index.php?sec=netf&sec2=operation/netflow/nf_view&id='.$report['id_report'].'">'.$report['id_name'].'</a>';
$data[0] = '<a href="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_view&id='.$report['id_report'].'">'.$report['id_name'].'</a>';
$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] = '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report_form&id=' . $report['id_report'] . '" style="display:inline">';
$data[3] .= html_print_input_image ('edit', 'images/config.png', 1, '', true, array ('title' => __('Edit')));
$data[3] .= '</form>';
$data[3] .= '&nbsp;&nbsp;<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_item_list&id=' . $report['id_report'] . '" style="display:inline">';
$data[3] .= html_print_input_image ('edit', 'images/god6.png', 1, '', true, array ('title' => __('Items')));
$data[3] .= '</form>';
$data[3] .= '&nbsp;&nbsp;<form method="post" style="display:inline" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">';
$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] .= '</form>';
}
array_push ($table->data, $data);
}
html_print_table ($table);
echo '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_report_form">';
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report_form">';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button (__('Create report'), 'crt', false, 'class="sub wand"');
echo "</div>";

View File

@ -88,11 +88,16 @@ $buttons['report_list'] = '<a href="index.php?sec=netf&sec2=operation/netflow/nf
. '</a>';
//Header
ui_print_page_header (__('Netflow'), "images/networkmap/so_cisco_new.png", false, "", false, $buttons);
if (! defined ('METACONSOLE')) {
ui_print_page_header (__('Netflow'), "images/networkmap/so_cisco_new.png", false, "", false, $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'] . '/operation/netflow/nf_view', 'text' => __('View netflow report')));
ui_meta_print_page_header($nav_bar);
}
echo"<h4>".__('Filter graph')."</h4>";
echo '<form method="post" action="index.php?sec=netf&sec2=operation/netflow/nf_view&amp;id='.$id.'">';
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_view&amp;id='.$id.'">';
$table->width = '60%';
$table->border = 0;
@ -113,8 +118,11 @@ echo '<form method="post" action="index.php?sec=netf&sec2=operation/netflow/nf_v
$table->data[1][1] = html_print_select (netflow_get_valid_intervals (), 'period', $period, '', '', 0, true, false, false);
$table->data[2][0] = '<b>'.__('Export').'</b>';
$table->data[2][1] = '<a title="XML" href="' . $config['homeurl'] . 'ajax.php?page=' . $config['homedir'] . '/operation/netflow/nf_view&id='.$id."&date=$date&time=$time&period=$period&xml=1\">" . html_print_image("images/database_lightning.png", true) . '</a>';
if (! defined ('METACONSOLE')) {
$table->data[2][1] = '<a title="XML" href="' . $config['homeurl'] . 'ajax.php?page=' . $config['homedir'] . '/operation/netflow/nf_view&id='.$id."&date=$date&time=$time&period=$period&xml=1\">" . html_print_image("images/database_lightning.png", true) . '</a>';
} else {
$table->data[2][1] = '<a title="XML" href="' . $config['homeurl'] . '../../ajax.php?page=' . $config['homedir'] . '/operation/netflow/nf_view&id='.$id."&date=$date&time=$time&period=$period&xml=1\">" . html_print_image("images/database_lightning.png", true) . '</a>';
}
html_print_table ($table);
@ -123,14 +131,14 @@ echo '<form method="post" action="index.php?sec=netf&sec2=operation/netflow/nf_v
echo '</div>';
echo'</form>';
if (empty ($id)){
$report = db_get_row_sql('SELECT * FROM tnetflow_report WHERE id_report =' . (int)$id);
if (empty ($report)){
echo fs_error_image();
return;
}
$report_name = db_get_value('id_name', 'tnetflow_report', 'id_report', $id);
echo"<h3>$report_name</h3>";
$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);
}
?>

View File

@ -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;

View File

@ -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
);
-- -----------------------------------------------------

View File

@ -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;