2011-12-21 Vanessa Gil <vanessa.gil@artica.es>

* include/functions_config.php
	  include/functions_graph.php
	  include/styles/menu.css
	  pandoradb.data.oracle.sql
	  pandoradb.data.postgreSQL.sql
  	  pandoradb.data.sql: Netflow traffic monitoring.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5289 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
vgilc 2011-12-21 13:09:26 +00:00
parent 3c4849b72f
commit d47c53eeda
22 changed files with 2457 additions and 3 deletions

View File

@ -1,3 +1,37 @@
2011-12-21 Vanessa Gil <vanessa.gil@artica.es>
* include/functions_config.php
include/functions_graph.php
include/styles/menu.css
pandoradb.data.oracle.sql
pandoradb.data.postgreSQL.sql
pandoradb.data.sql: Netflow traffic monitoring.
2011-12-21 Vanessa Gil <vanessa.gil@artica.es>
* godmode/menu.php
godmode/setup/setup.php
include/functions_config.php
include/functions_graph.php
include/styles/menu.css
operation/menu.php
pandoradb.data.oracle.sql
pandoradb.data.postgreSQL.sql
pandoradb.data.sql
added files:
operation/netflow/nf_reporting.php
operation/netflow/nf_view.php
godmode/netflow/nf_edit.php
godmode/netflow/nf_edit_form.php
godmode/netflow/nf_report.php
godmode/netflow/nf_report_form.php
godmode/netflow/nf_report_item.php
godmode/netflow/nf_item_list.php
godmode/netflow/nf_manage.php
godmode/netflow/nf_option_form.php
images/networkmap/so_cisco_new.png: Netflow traffic monitoring.
2011-12-21 Junichi Satoh <junichi@rworks.jp>
* operation/agentes/status_monitor.php: Fixed that long module names

View File

@ -0,0 +1,94 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
//include_once("include/functions_graph.php");
include_once("include/functions_ui.php");
//ui_require_javascript_file ('calendar');
check_login ();
if (! check_acl ($config["id_user"], 0, "IR")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
$buttons ['view']= '<a href="index.php?sec=netf&sec2=operation/netflow/nf&id_name='.$name.'">'
. html_print_image ("images/lupa.png", true, array ("title" => __('View')))
. '</a>';
$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">'
. html_print_image ("images/add.png", true, array ("title" => __('Add filter')))
. '</a>';
//Header
ui_print_page_header (__('Netflow Manager'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons);
$update = (bool) get_parameter ("update");
if ($update) {
$config['netflow_path'] = (string)get_parameter('netflow_path');
if (db_get_value('token', 'tconfig', 'token', 'netflow_path') === false) {
config_create_value('netflow_path', $config['netflow_path']);
} else {
db_process_sql_update ('tconfig',
array ('value' => $config['netflow_path']),
array ('token' => 'netflow_path'));
}
}
$table->width = '70%';
$table->border = 0;
$table->cellspacing = 3;
$table->cellpadding = 5;
$table->class = "databox_color";
$table->style[0] = 'vertical-align: top;';
$table->data = array ();
$table->data[0][0] = '<b>'.__('Path').'</b>'. ui_print_help_tip (__("Read input from a sequence of files in the same directory."), true);
$table->data[0][1] = html_print_input_text ('netflow_path', $config['netflow_path'], false, 50, 200, true);
echo '<form id="netflow_setup" method="post">';
html_print_table ($table);
// Update button
echo '<div class="action-buttons" style="width:70%;">';
html_print_input_hidden ('update', 1);
html_print_submit_button (__('Update'), 'upd_button', false, 'class="sub upd"');
echo '</div></form>';
?>
<script type="text/javascript">
$(document).ready (function () {
$("textarea").TextAreaResizer ();
});
</script>

View File

@ -0,0 +1,151 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
include_once("include/functions_ui.php");
include_once("include/functions_db.php");
include_once("include/functions_netflow.php");
check_login ();
if (! check_acl ($config["id_user"], 0, "AW")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
$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 (__('Manage Netflow Filter'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons);
$delete = (bool) get_parameter ('delete');
$multiple_delete = (bool)get_parameter('multiple_delete', 0);
$id = (int) get_parameter ('id');
$name = (string) get_parameter ('name');
if ($delete) {
$result = db_process_sql_delete ('tnetflow_filter',
array ('id_sg' => $id));
if ($result !== false) $result = true;
else $result = false;
ui_print_result_message ($result,
__('Successfully deleted'),
__('Not deleted. Error deleting data'));
}
if ($multiple_delete) {
$ids = (array)get_parameter('delete_multiple', array());
db_process_sql_begin();
foreach ($ids as $id) {
$result = db_process_sql_delete ('tnetflow_filter',
array ('id_sg' => $id));
if ($result === false) {
db_process_sql_rollback();
break;
}
}
if ($result !== false) {
db_process_sql_commit();
}
if ($result !== false) $result = true;
else $result = false;
ui_print_result_message ($result,
__('Successfully deleted'),
__('Not deleted. Error deleting data'));
}
$filter = array ();
$filter['offset'] = (int) get_parameter ('offset');
$filter['limit'] = (int) $config['block_size'];
$filters = db_get_all_rows_filter ('tnetflow_filter', $filter);
if ($filters === false)
$filter = array ();
$table->width = '70%';
$table->head = array ();
$table->head[0] = __('Name');
$table->head[1] = __('Action') .
html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->align = array ();
$table->align[2] = 'center';
$table->size = array ();
$table->size[0] = '90%';
$table->size[1] = '80px';
$table->data = array ();
$total_filters = db_get_all_rows_filter ('tnetflow_filter', false, 'COUNT(*) AS total');
$total_filters = $total_filters[0]['total'];
ui_pagination ($total_filters, $url);
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[1] = "<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'>" .
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);
array_push ($table->data, $data);
}
if(isset($data)) {
echo "<form method='post' action='index.php?sec=netf&sec2=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 . "'>";
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
echo "</div>";
echo "</form>";
}
else {
echo "<div class='nf'>".__('There are no defined filters')."</div>";
}
?>
<script type="text/javascript">
function check_all_checkboxes() {
if ($("input[name=all_delete]").attr('checked')) {
$(".check_delete").attr('checked', true);
}
else {
$(".check_delete").attr('checked', false);
}
}
</script>

View File

@ -0,0 +1,218 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
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");
check_login ();
if (! check_acl ($config["id_user"], 0, "AW")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
$id = (int) get_parameter ('id');
$name = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id);
$update = (string)get_parameter('update', 0);
$create = (string)get_parameter('create', 0);
$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">'
. 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);
if ($id) {
$filter = netflow_filter_get_filter ($id);
$assign_group = $filter['group'];
$name = $filter['id_name'];
$ip_dst = $filter['ip_dst'];
$ip_src = $filter['ip_src'];
$dst_port = $filter['dst_port'];
$src_port = $filter['src_port'];
$aggregate = $filter['aggregate'];
$show_packets = $filter['show_packets'];
$show_bytes = $filter['show_bytes'];
$show_bps = $filter['show_bps'];
$show_bpp = $filter['show_bpp'];
} else {
$name = '';
$assign_group = 'none';
$ip_dst = '';
$ip_src = '';
$dst_port = '';
$src_port = '';
$aggregate = 'none';
$show_packets = '';
$show_bytes = 1;
$show_bps = '';
$show_bpp = '';
}
if ($update) {
$name = (string) get_parameter ('name');
$assign_group = (int) get_parameter ('assign_group');
$aggregate = get_parameter('aggregate','');
$show_packets = (bool)get_parameter('show_packets');
$show_bytes = (bool)get_parameter('show_bytes');
$show_bps = (bool)get_parameter('show_bps');
$show_bpp = (bool)get_parameter('show_bpp');
$ip_dst = get_parameter('ip_dst','');
$ip_src = get_parameter('ip_src','');
$dst_port = get_parameter('dst_port','');
$src_port = get_parameter('src_port','');
if ($name == '') {
ui_print_error_message (__('Not updated. Blank name'));
} else {
$result = db_process_sql_update ('tnetflow_filter',
array ('id_sg' => $id,
'id_name' => $name,
'group' => $assign_group,
'aggregate' => $aggregate,
'ip_dst' => $ip_dst,
'ip_src' => $ip_src,
'dst_port' => $dst_port,
'src_port' => $src_port,
'show_packets' => $show_packets,
'show_bytes' => $show_bytes,
'show_bps' => $show_bps,
'show_bpp' => $show_bpp, ),
array ('id_sg' => $id));
ui_print_result_message ($result,
__('Successfully updated'),
__('Not updated. Error updating data'));
}
}
if ($create){
$name = (string) get_parameter ('name');
$assign_group = (int) get_parameter ('assign_group');
$aggregate = get_parameter('aggregate','none');
$show_packets = (bool)get_parameter('show_packets',0);
$show_bytes = (bool)get_parameter('show_bytes',1);
$show_bps = (bool)get_parameter('show_bps',0);
$show_bpp = (bool)get_parameter('show_bpp',0);
$ip_dst = get_parameter('ip_dst','');
$ip_src = get_parameter('ip_src','');
$dst_port = get_parameter('dst_port','');
$src_port = get_parameter('src_port','');
if($name == db_get_value('id_name', 'tnetflow_filter', 'id_name', $name)){
$result = false;
} else {
$values = array (
'id_name'=>$name,
'group' => $assign_group,
'ip_dst'=>$ip_dst,
'ip_src'=>$ip_src,
'dst_port'=>$dst_port,
'src_port'=>$src_port,
'aggregate'=>$aggregate,
'show_packets'=>$show_packets,
'show_bytes'=>$show_bytes,
'show_bps'=>$show_bps,
'show_bpp'=>$show_bpp
);
$result = db_process_sql_insert('tnetflow_filter', $values);
}
if ($result === false)
echo '<h3 class="error">'.__ ('Error creating filter').'</h3>';
else
echo '<h3 class="suc">'.__ ('filter created successfully').'</h3>';
}
$table->width = '80%';
$table->border = 0;
$table->cellspacing = 3;
$table->cellpadding = 5;
$table->class = "databox_color";
$table->style[0] = 'vertical-align: top;';
$table->data = array ();
$table->data[0][0] = '<b>'.__('Name').'</b>';
$table->data[0][1] = html_print_input_text ('name', $name, false, 20, 80, true);
$own_info = get_user_info ($config['id_user']);
$table->data[1][0] = '<b>'.__('Group').'</b>';
$table->data[1][1] = html_print_select_groups($config['id_user'], "AW",
$own_info['is_admin'], 'assign_group', $assign_group, '', __('None'), -1, true,
false, false);
$table->data[2][0] = '<b>'.__('Filter:').'</b>';
$table->data[3][0] = __('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:<br>25.46.157.214,160.253.135.249"), true);
$table->data[3][1] = html_print_input_text ('ip_dst', $ip_dst, false, 40, 80, true);
$table->data[4][0] = __('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:<br>25.46.157.214,160.253.135.249"), true);
$table->data[4][1] = html_print_input_text ('ip_src', $ip_src, false, 40, 80, true);
$table->data[5][0] = __('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:<br>80,22"), true);
$table->data[5][1] = html_print_input_text ('dst_port', $dst_port, false, 40, 80, true);
$table->data[6][0] = __('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:<br>80,22"), true);
$table->data[6][1] = html_print_input_text ('src_port', $src_port, false, 40, 80, true);
$table->data[7][0] = '<b>'.__('Aggregate by').'</b>'. ui_print_help_icon ('aggregate_by', true);
$aggregate_list = array();
$aggregate_list = array ('none' => __('None'), 'proto' => __('Protocol'), 'srcip' =>__('Src Ip Address'), 'dstip' =>__('Dst Ip Address'), 'srcport' =>__('Src Port'), 'dstport' =>__('Dst Port') );
$table->data[7][1] = html_print_select ($aggregate_list, "aggregate", $aggregate, '', '', 0, true, false, true, '', false);
$table->data[8][0] = '<b>'.__('Output format').'</b>';
$table->data[8][1] .= __('Packets');
$table->data[8][1] .= html_print_checkbox ('show_packets', 1, $show_packets, true);
$table->data[8][1] .= __('Bytes');
$table->data[8][1] .= html_print_checkbox ('show_bytes', 1, $show_bytes, true);
$table->data[8][1] .= __('Bits per second');
$table->data[8][1] .= html_print_checkbox ('show_bps', 1, $show_bps, true);
$table->data[8][1] .= __('Bytes per packet');
$table->data[8][1] .= html_print_checkbox ('show_bpp', 1, $show_bpp, true);
echo '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_edit_form">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {
html_print_input_hidden ('update', 1);
html_print_input_hidden ('id', $id);
html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"');
} else {
html_print_input_hidden ('create', 1);
html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"');
}
echo '</div>';
echo '</form>';
?>

View File

@ -0,0 +1,190 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
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");
check_login ();
if (! check_acl ($config["id_user"], 0, "IW")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
$buttons['list'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report">'
. html_print_image ("images/edit.png", true, array ("title" => __('Report list')))
. '</a>';
//Header
ui_print_page_header (__('Item list'), "images/god6.png", false, "", true, $buttons);
$delete = (bool) get_parameter ('delete');
$multiple_delete = (bool)get_parameter('multiple_delete', 0);
//id report
$id = (int) get_parameter ('id');
//id item
$id_rc = (int) get_parameter ('id_rc');
if ($delete) {
$result = db_process_sql_delete ('tnetflow_report_content',
array ('id_rc' => $id_rc));
if ($result !== false) $result = true;
else $result = false;
ui_print_result_message ($result,
__('Successfully deleted'),
__('Not deleted. Error deleting data'));
}
if ($multiple_delete) {
$ids = (array)get_parameter('delete_multiple', array());
db_process_sql_begin();
foreach ($ids as $id_delete) {
$result = db_process_sql_delete ('tnetflow_report_content',
array ('id_rc' => $id_delete));
if ($result === false) {
db_process_sql_rollback();
break;
}
}
if ($result !== false) {
db_process_sql_commit();
}
if ($result !== false) $result = true;
else $result = false;
ui_print_result_message ($result,
__('Successfully deleted'),
__('Not deleted. Error deleting data'));
}
$filter = array ();
$filter['offset'] = (int) get_parameter ('offset');
$filter['limit'] = (int) $config['block_size'];
$reports_item = db_get_all_rows_filter ('tnetflow_report_content', $filter);
$reports_item = db_get_all_rows_sql('
SELECT *
FROM tnetflow_report_content
WHERE id_report = ' . $id);
if ($reports_item === false)
$filter = array ();
$table->width = '90%';
$table->head = array ();
$table->head[0] = __('Id item');
$table->head[1] = __('Filter');
$table->head[2] = __('Period');
$table->head[3] = __('Max values');
$table->head[4] = __('Graph');
$table->head[5] = __('Action') .
html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->align = array ();
$table->align[2] = 'center';
$table->align[3] = 'center';
$table->align[5] = 'right';
$table->size = array ();
$table->size[0] = '10%';
$table->size[1] = '30%';
$table->size[2] = '20%';
$table->size[3] = '10%';
$table->size[4] = '20%';
$table->size[5] = '20px';
$table->data = array ();
$total_reports_item = db_get_all_rows_filter ('tnetflow_report_content', false, 'COUNT(*) AS total');
$total_reports_item = $total_reports_item[0]['total'];
ui_pagination ($total_reports_item, $url);
foreach ($reports_item as $item) {
$data = array ();
$data[0] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report_item&id='.$item['id_report'].'&id_rc='.$item['id_rc'].'">'.$item['id_rc'].'</a>';
$data[1] = $item['id_filter'];
$data[2] = $item['period'];
$data[3] = $item['max'];
$data[4] = $item['show_graph'];
$data[5] = "<a onclick='if(confirm(\"" . __('Are you sure?') . "\")) return true; else return false;'
href='index.php?sec=netf&sec2=godmode/netflow/nf_item_list&delete=1&id_rc=".$item['id_rc']."&id=".$id."&offset=0'>" .
html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "</a>" .
html_print_checkbox_extended ('delete_multiple[]', $item['id_rc'], false, false, '', 'class="check_delete"', true);
array_push ($table->data, $data);
}
if(isset($data)) {
echo '<form method="post" action="index.php?sec=netf&sec2=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 . "'>";
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
echo "</div>";
echo "</form>";
}else {
echo "<div class='nf'>".__('There are no defined filters')."</div>";
}
echo '<form method="post" action="index.php?sec=netf&sec2=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>";
echo "</form>";
?>
<script type="text/javascript">
$(document).ready (function () {
$("textarea").TextAreaResizer ();
});
function check_all_checkboxes() {
if ($("input[name=all_delete]").attr('checked')) {
$(".check_delete").attr('checked', true);
}
else {
$(".check_delete").attr('checked', false);
}
}
</script>

View File

@ -0,0 +1,179 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
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");
check_login ();
if (! check_acl ($config["id_user"], 0, "IW")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
/*
$buttons ['view']= '<a href="index.php?sec=netf&sec2=operation/netflow/nf&id_name='.$name.'">'
. html_print_image ("images/lupa.png", true, array ("title" => __('View')))
. '</a>';
$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">'
. html_print_image ("images/add.png", true, array ("title" => __('Add filter')))
. '</a>';
*/
//Header
ui_print_page_header (__('Netflow Manager'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons);
$delete = (bool) get_parameter ('delete');
$multiple_delete = (bool)get_parameter('multiple_delete', 0);
$id = (int) get_parameter ('id');
if ($delete) {
$result = db_process_sql_delete ('tnetflow_options',
array ('id_option' => $id));
if ($result !== false) $result = true;
else $result = false;
ui_print_result_message ($result,
__('Successfully deleted'),
__('Not deleted. Error deleting data'));
}
if ($multiple_delete) {
$ids = (array)get_parameter('delete_multiple', array());
db_process_sql_begin();
foreach ($ids as $id) {
$result = db_process_sql_delete ('tnetflow_options',
array ('id_option' => $id));
if ($result === false) {
db_process_sql_rollback();
break;
}
}
if ($result !== false) {
db_process_sql_commit();
}
if ($result !== false) $result = true;
else $result = false;
ui_print_result_message ($result,
__('Successfully deleted'),
__('Not deleted. Error deleting data'));
}
$filter = array ();
$filter['offset'] = (int) get_parameter ('offset');
$filter['limit'] = (int) $config['block_size'];
$options = db_get_all_rows_filter ('tnetflow_options', $filter);
if ($options === false)
$filter = array ();
$table->width = '80%';
$table->head = array ();
$table->head[0] = __('Options name');
$table->head[1] = __('Description');
$table->head[2] = __('Action') .
html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->align = array ();
$table->align[2] = 'center';
$table->size = array ();
$table->size[0] = '50%';
$table->size[1] = '40%';
$table->size[2] = '50px';
$table->data = array ();
$total_options = db_get_all_rows_filter ('tnetflow_options', false, 'COUNT(*) AS total');
$total_options = $total_options[0]['total'];
ui_pagination ($total_options, $url);
foreach ($options as $option) {
$data = array ();
$data[0] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_option_form&id='.$option['id_option'].'">'.$option['id_name'].'</a>';
$data[1] = $option['description'];
$data[2] = "<a onclick='if(confirm(\"" . __('Are you sure?') . "\")) return true; else return false;'
href='index.php?sec=netf&sec2=godmode/netflow/nf_manage&delete=1&id=".$option['id_option']."&offset=0'>" .
html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "</a>" .
html_print_checkbox_extended ('delete_multiple[]', $option['id_option'], false, false, '', 'class="check_delete"', true);
array_push ($table->data, $data);
}
if(isset($data)) {
echo "<form method='post' action='index.php?sec=netf&sec2=godmode/netflow/nf_manage'>";
html_print_input_hidden('multiple_delete', 1);
html_print_table ($table);
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
echo "</div>";
echo "</form>";
}else {
echo "<div class='nf'>".__('There are no defined filters')."</div>";
}
echo '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_option_form">';
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
html_print_submit_button (__('Create option'), 'crt', false, 'class="sub wand"');
echo "</div>";
echo "</form>";
?>
<script type="text/javascript">
$(document).ready (function () {
$("textarea").TextAreaResizer ();
});
function check_all_checkboxes() {
if ($("input[name=all_delete]").attr('checked')) {
$(".check_delete").attr('checked', true);
}
else {
$(".check_delete").attr('checked', false);
}
}
</script>

View File

@ -0,0 +1,143 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
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");
check_login ();
if (! check_acl ($config["id_user"], 0, "AW")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
$id = (int) get_parameter ('id');
//$name = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id);
$update = (string)get_parameter('update', 0);
$create = (string)get_parameter('create', 0);
$buttons['edit'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_manage">'
. html_print_image ("images/edit.png", true, array ("title" => __('Option list')))
. '</a>';
//Header
ui_print_page_header (__('Netflow Options'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons);
if ($id) {
$option = netflow_options_get_options ($id);
$name = $option['id_name'];
$description = $option['description'];
$path = $option['path'];
$port = $option['port'];
} else {
$name = '';
$description = '';
$path = '';
$port = '';
}
if ($update) {
$name = (string) get_parameter ('name');
$description = (int) get_parameter ('description','');
$path = get_parameter('path','');
$port = get_parameter('port','');
if ($name == '') {
ui_print_error_message (__('Not updated. Blank name'));
} else {
$result = db_process_sql_update ('tnetflow_options',
array ('id_option' => $id,
'id_name' => $name,
'description' => $description,
'path' => $path,
'port' => $port
),
array ('id_option' => $id));
ui_print_result_message ($result,
__('Successfully updated'),
__('Not updated. Error updating data'));
}
}
if ($create){
$name = (string) get_parameter ('name');
$description = (string) get_parameter ('description','');
$path = get_parameter('path','');
$port = get_parameter('port','');
if($name == db_get_value('id_name', 'tnetflow_options', 'id_name', $name)){
$result = false;
} else {
$values = array (
'id_name'=>$name,
'description' => $description,
'path'=>$path,
'port'=>$port
);
$result = db_process_sql_insert('tnetflow_options', $values);
}
if ($result === false)
echo '<h3 class="error">'.__ ('Error creating filter').'</h3>';
else
echo '<h3 class="suc">'.__ ('Option created successfully').'</h3>';
}
$table->width = '80%';
$table->border = 0;
$table->cellspacing = 3;
$table->cellpadding = 5;
$table->class = "databox_color";
$table->style[0] = 'vertical-align: top;';
$table->data = array ();
$table->data[0][0] = '<b>'.__('Name').'</b>';
$table->data[0][1] = html_print_input_text ('name', $name, false, 50, 80, true);
$table->data[1][0] = '<b>'.__('Description').'</b>';
$table->data[1][1] = html_print_textarea ('description', 2, 65, $description, '', true);
$table->data[2][0] = '<b>'.__('Path').'</b>';
//$table->data[2][1] = html_print_input_text ('path', $config['netflow_path'], false, 50, 200, true);
$table->data[2][1] = html_print_input_text ('path', $path, false, 50, 200, true);
$table->data[3][0] = '<b>'.__('Port').'</b>';
$table->data[3][1] = html_print_input_text ('port', $port, false, 10, 80, true);
echo '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_option_form">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {
html_print_input_hidden ('update', 1);
html_print_input_hidden ('id', $id);
html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"');
} else {
html_print_input_hidden ('create', 1);
html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"');
}
echo '</div>';
echo '</form>';
?>

View File

@ -0,0 +1,164 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
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");
check_login ();
if (! check_acl ($config["id_user"], 0, "IW")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
//Header
ui_print_page_header (__('Report Manager'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons);
$delete = (bool) get_parameter ('delete');
$multiple_delete = (bool)get_parameter('multiple_delete', 0);
$id = (int) get_parameter ('id');
if ($delete) {
$result = db_process_sql_delete ('tnetflow_report',
array ('id_report' => $id));
if ($result !== false) $result = true;
else $result = false;
ui_print_result_message ($result,
__('Successfully deleted'),
__('Not deleted. Error deleting data'));
}
if ($multiple_delete) {
$ids = (array)get_parameter('delete_multiple', array());
db_process_sql_begin();
foreach ($ids as $id) {
$result = db_process_sql_delete ('tnetflow_report',
array ('id_report' => $id));
if ($result === false) {
db_process_sql_rollback();
break;
}
}
if ($result !== false) {
db_process_sql_commit();
}
if ($result !== false) $result = true;
else $result = false;
ui_print_result_message ($result,
__('Successfully deleted'),
__('Not deleted. Error deleting data'));
}
$filter = array ();
$filter['offset'] = (int) get_parameter ('offset');
$filter['limit'] = (int) $config['block_size'];
$reports = db_get_all_rows_filter ('tnetflow_report', $filter);
if ($options === false)
$filter = array ();
$table->width = '80%';
$table->head = array ();
$table->head[0] = __('Report name');
$table->head[1] = __('Description');
$table->head[2] = __('Action') .
html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->align = array ();
$table->align[2] = 'center';
$table->size = array ();
$table->size[0] = '50%';
$table->size[1] = '40%';
$table->size[2] = '50px';
$table->data = array ();
$total_reports = db_get_all_rows_filter ('tnetflow_report', false, 'COUNT(*) AS total');
$total_reports = $total_reports[0]['total'];
ui_pagination ($total_reports, $url);
foreach ($reports as $report) {
$data = array ();
$data[0] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report_form&id='.$report['id_report'].'">'.$report['id_name'].'</a>';
$data[1] = $report['description'];
$data[2] = "<a onclick='if(confirm(\"" . __('Are you sure?') . "\")) return true; else return false;'
href='index.php?sec=netf&sec2=godmode/netflow/nf_report&delete=1&id=".$report['id_report']."&offset=0'>" .
html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "</a>" .
html_print_checkbox_extended ('delete_multiple[]', $report['id_report'], false, false, '', 'class="check_delete"', true);
array_push ($table->data, $data);
}
if(isset($data)) {
echo "<form method='post' action='index.php?sec=netf&sec2=godmode/netflow/nf_report'>";
html_print_input_hidden('multiple_delete', 1);
html_print_table ($table);
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
echo "</div>";
echo "</form>";
}else {
echo "<div class='nf'>".__('There are no defined reports')."</div>";
}
echo '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_report_form">';
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
html_print_submit_button (__('Create report'), 'crt', false, 'class="sub wand"');
echo "</div>";
echo "</form>";
?>
<script type="text/javascript">
$(document).ready (function () {
$("textarea").TextAreaResizer ();
});
function check_all_checkboxes() {
if ($("input[name=all_delete]").attr('checked')) {
$(".check_delete").attr('checked', true);
}
else {
$(".check_delete").attr('checked', false);
}
}
</script>

View File

@ -0,0 +1,185 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
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");
check_login ();
if (! check_acl ($config["id_user"], 0, "IW")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
$id = (int)get_parameter('id');
$update = (string)get_parameter('update', 0);
$create = (string)get_parameter('create', 0);
if ($id) {
$report = netflow_reports_get_reports ($id);
$name = $report['id_name'];
$description = $report['description'];
$group = $report['group'];
$name_filter = $report['id_filter'];
$max_val = $report['max_values'];
$show_area = $report['show_area'];
$show_pie = $report['show_pie'];
$show_table = $report['show_table'];
$show_period = $report['show_period'];
} else {
$name = '';
$group = 'none';
$description = '';
$name_filter = 'none';
$max_val = '2';
$show_area = '';
$show_pie = '';
$show_table = '';
$show_period = '';
}
if ($update) {
$id = get_parameter('id');
$name = (string) get_parameter ('name');
$description = get_parameter ('description');
$group = get_parameter('group','none');
$name_filter = get_parameter('id_filter','none');
$max_val = get_parameter('max_values','2');
$show_area = get_parameter('show_area','');
$show_pie = get_parameter('show_pie','');
$show_table = get_parameter('show_table','');
$show_period = get_parameter('show_period','');
if ($name == '') {
ui_print_error_message (__('Not updated. Blank name'));
} else {
$result = db_process_sql_update ('tnetflow_report',
array (
'id_name' => $name,
'group' => $group,
'description' => $description,
'id_filter' => $name_filter,
'max_values' => $max_val,
'show_area' => $show_area,
'show_pie' => $show_pie,
'show_table' => $show_table,
'show_period' => $show_period
),
array ('id_report' => $id));
}
}
if ($create){
$name = (string) get_parameter ('name');
$group = (int) get_parameter ('group');
$description = get_parameter('description','');
$name_filter = get_parameter('name_filter','none');
$max_val = get_parameter('max_val','2');
$show_area = (bool)get_parameter('show_area','0');
$show_pie = (bool)get_parameter('show_pie','0');
$show_table = (bool)get_parameter('show_table','0');
$show_period = (bool)get_parameter('show_period','0');
if($name == db_get_value('id_name', 'tnetflow_report', 'id_name', $name)){
$result = false;
} else {
$values = array (
'id_name' => $name,
'group' => $group,
'description' => $description,
'id_filter' => $name_filter,
'max_values' => $max_val,
'show_area' => $show_area,
'show_pie' => $show_pie,
'show_table' => $show_table,
'show_period' => $show_period
);
$result = db_process_sql_insert('tnetflow_report', $values);
}
$id= db_get_value('id_report', 'tnetflow_report', 'id_name', $name);
}
$buttons['view'] = '<a href="index.php?sec=netf&sec2=operation/netflow/nf_view&id='.$id.'">'
. html_print_image ("images/lupa.png", true, array ("title" => __('View data')))
. '</a>';
$buttons['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['list_items'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_item_list&id='.$id.'">'
. html_print_image ("images/god6.png", true, array ("title" => __('Items list')))
. '</a>';
$buttons['item'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report_item&id='.$id.'">'
. html_print_image ("images/config.png", true, array ("title" => __('Item editor')))
. '</a>';
//Header
ui_print_page_header (__('Netflow Report'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons);
if ($create || $update){
ui_print_result_message ($result,
__('Successfully!'),
__('Error!'));
}
$table->width = '80%';
$table->border = 0;
$table->cellspacing = 3;
$table->cellpadding = 5;
$table->class = "databox_color";
$table->style[0] = 'vertical-align: top;';
$table->data = array ();
$table->data[0][0] = '<b>'.__('Name').'</b>';
$table->data[0][1] = html_print_input_text ('name', $name, false, 30, 80, true);
$own_info = get_user_info ($config['id_user']);
$table->data[1][0] = '<b>'.__('Group').'</b>';
$table->data[1][1] = html_print_select_groups($config['id_user'], "IW",
$own_info['is_admin'], 'group', $group, '', __('None'), -1, true,
false, false);
$table->data[2][0] = '<b>'.__('Description').'</b>';
$table->data[2][1] = html_print_textarea ('description', 2, 65, $description, '', true);
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.'">';
if ($id) {
html_print_input_hidden ('update', 1);
html_print_input_hidden ('id', $id);
html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"');
} else {
html_print_input_hidden ('create', 1);
html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"');
}
echo '</div>';
echo '</form>';
?>

View File

@ -0,0 +1,212 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
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");
ui_require_javascript_file ('calendar');
check_login ();
if (! check_acl ($config["id_user"], 0, "IW")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
$id = (int)get_parameter('id');
$id_rc = (int)get_parameter('id_rc');
$update = (string)get_parameter('update', 0);
$create = (string)get_parameter('create', 0);
$buttons['list_items'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_item_list&id='.$id.'">'
. html_print_image ("images/god6.png", true, array ("title" => __('Item list')))
. '</a>';
$buttons['list'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report">'
. html_print_image ("images/edit.png", true, array ("title" => __('Report list')))
. '</a>';
//Header
ui_print_page_header (__('Netflow Report'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons);
if ($id_rc) {
$item = netflow_reports_get_content ($id_rc);
$date = $item['date'];
$period = $item['period'];
$name_filter = $item['id_filter'];
$max_val = $item['max'];
$show_graph = $item['show_graph'];
} else {
$date = '';
$period ='';
$name_filter = '';
$max_val = '';
$show_graph = '';
}
if ($update) {
$date = get_parameter_post ('date');
$time = get_parameter_post ('time');
$period = get_parameter ('period');
$name_filter = get_parameter('id_filter');
$max_val = get_parameter('max','2');
$show_graph = get_parameter('show_graph','');
$date = str_replace('-','/',$date);
$timedate = $date .".".$time;
$date_time = strtotime ($date." ".$time);
$result = db_process_sql_update ('tnetflow_report_content',
array (
'id_report' => $id,
'id_filter' => $name_filter,
'date' => $date_time,
'period' => $period,
'max' => $max_val,
'show_graph' => $show_graph
),
array ('id_rc' => $id_rc));
ui_print_result_message ($result,
__('Successfully updated'),
__('Not updated. Error updating data'));
}
if ($create){
$date = get_parameter_post ('date');
$time = get_parameter_post ('time');
$period = get_parameter ('period');
$name_filter = get_parameter('id_filter');
$max_val = get_parameter('max','2');
$show_graph = get_parameter('show_graph','');
$date = str_replace('-','/',$date);
$timedate = $date .".".$time;
$date_time = strtotime ($date." ".$time);
$sql1 = "select id_filter from tnetflow_report_content where id_report='".$id."'";
$filters_aux = db_get_all_rows_sql($sql1);
$exist = false;
foreach($filters_aux as $filter_aux){
if ($name_filter == $filter_aux['id_filter']){
$exist = true;
echo '<h3 class="error">'.__ ('Error creating item. Filter already exists.').'</h3>';
break;
}
}
if (!$exist){
$values = array (
'id_report' => $id,
'id_filter' => $name_filter,
'date' => $date_time,
'period' => $period,
'max' => $max_val,
'show_graph' => $show_graph
);
$result = db_process_sql_insert('tnetflow_report_content', $values);
if ($result === false)
echo '<h3 class="error">'.__ ('Error creating item').'</h3>';
else
echo '<h3 class="suc">'.__ ('Item created successfully').'</h3>';
}
}
$table->width = '80%';
$table->border = 0;
$table->cellspacing = 3;
$table->cellpadding = 5;
$table->class = "databox_color";
$table->style[0] = 'vertical-align: top;';
$table->data = array ();
$table->data[0][0] = '<b>'.__('Date').'</b>';
$table->data[0][1] = html_print_input_text ('date', date ("Y/m/d", get_system_time () - 86400), false, 10, 10, true);
$table->data[0][1] .= html_print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => "scwShow(scwID('text-date'),this);"));
$table->data[0][1] .= html_print_input_text ('time', date ("H:i:s", get_system_time () - 86400), false, 10, 5, true);
$table->data[1][0] = '<b>'.__('Interval').'</b>';
$values_period = array ('600' => __('10 mins'),
'900' => __('15 mins'),
'1800' => __('30 mins'),
'3600' => __('1 hour'),
'7200' => __('2 hours'),
'18000' => __('5 hours'),
'43200' => __('12 hours'),
'86400' => __('1 day'),
'172800' => __('2 days'),
'432000' => __('5 days'),
'1296000' => __('15 days'),
'604800' => __('Last week'),
'2592000' => __('Last month'),
'5184000' => __('2 months'),
'7776000' => __('3 months'),
'15552000' => __('6 months'),
'31104000' => __('Last year'),
'62208000' => __('2 years')
);
$table->data[1][1] = html_print_select ($values_period, 'period', $period, '', '', 0, true, false, false);
$filters = netflow_get_filters ();
if ($filters === false) {
$filters = array ();
}
$table->data[2][0] = '<b>'.__('Filters').'</b>';
$table->data[2][1] = html_print_select($filters, 'id_filter', $name_filter, '', '', 0, true);
$table->data[3][0] = '<b>'.__('Max values aggregated').'</b>';
$max_values = array ('2' => '2',
'5' => '5',
'10' => '10',
'15' => '15',
'20' => '20',
'25' => '25',
'50' => '50'
);
$table->data[3][1] = html_print_select ($max_values, 'max', $max_val, '', '', 0, true);
$table->data[4][0] = '<b>'.__('Elements').'</b>';
$show_graph_options = Array();
$show_graph_options[0] = __('Area graph');
$show_graph_options[1] = __('Pie graph');
$show_graph_options[2] = __('Table values');
$show_graph_options[3] = __('Total period');
$table->data[4][1] = html_print_select ($show_graph_options, 'show_graph', $show_graph,'','',0,true);
echo '<form method="post" action="index.php?sec=netf&sec2=godmode/netflow/nf_report_item&id='.$id.'">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id_rc) {
html_print_input_hidden ('update', 1);
html_print_input_hidden ('id_rc', $id_rc);
html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"');
} else {
html_print_input_hidden ('create', 1);
html_print_submit_button (__('Create item'), 'crt', false, 'class="sub wand"');
}
echo '</div>';
echo '</form>';
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

View File

@ -74,7 +74,7 @@ $config["admin_can_make_admin"] = true;
*/
function process_user_login ($login, $pass) {
global $config, $mysql_cache;
// Always authenticate admins against the local database
if (strtolower ($config["auth"]) == 'mysql' || is_user_admin ($login)) {
// Connect to Database
@ -399,7 +399,7 @@ function update_user ($id_user, $values) {
*/
function ldap_process_user_login ($login, $password) {
global $config;
if (! function_exists ("ldap_connect")) {
$config["auth_error"] = 'Your installation of PHP does not support LDAP';
return false;
@ -407,6 +407,7 @@ function ldap_process_user_login ($login, $password) {
// Connect to the LDAP server
$ds = @ldap_connect ($config["ldap_server"], $config["ldap_port"]);
if (!$ds) {
$config["auth_error"] = 'Error connecting to LDAP server';
return false;

View File

@ -120,7 +120,7 @@ function mysql_db_get_value ($field, $table, $field_search = 1, $condition = 1,
$field, $table, $field_search, $condition);
}
$result = db_get_all_rows_sql ($sql, $search_history_db);
if ($result === false)
return false;
@ -860,6 +860,7 @@ function mysql_db_process_sql_update($table, $values, $where = false, $where_joi
}
else if (is_array ($where)) {
$query .= db_format_array_where_clause_sql ($where, $where_join, ' WHERE ');
}
}

View File

@ -184,6 +184,7 @@ function config_update_config () {
config_update_value ('history_db_delay', (string) get_parameter ('history_db_delay', $config['history_db_delay']));
config_update_value ('timezone', (string) get_parameter ('timezone', $config['timezone']));
config_update_value ('activate_gis', (bool) get_parameter ('activate_gis', $config['activate_gis']));
config_update_value ('activate_netflow', (bool) get_parameter ('activate_netflow', $config['activate_netflow']));
config_update_value ('stats_interval', get_parameter ('stats_interval', $config['stats_interval']));
config_update_value ('realtimestats', get_parameter ('realtimestats', $config['realtimestats']));
config_update_value ('event_purge', get_parameter ('event_purge', $config['event_purge']));
@ -476,6 +477,10 @@ function config_process_config () {
if (!isset ($config['activate_gis'])) {
config_update_value ( 'activate_gis', 0);
}
if (!isset ($config['activate_netflow'])) {
config_update_value ( 'activate_netflow', 0);
}
if (!isset ($config['auth'])) {
config_update_value ( 'auth', 'mysql');

View File

@ -1961,6 +1961,288 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
$config['fontpath'], $config['font_size'], "");
}
/**
* Print an area graph with netflow aggregated
*/
function grafico_netflow_aggregate_area ($data, $period,$width, $height , $title, $unit_name, $avg_only = 0, $pure=0,$date = 0, $only_image = false, $homeurl = '') {
global $config;
global $graphic_type;
echo"<h4>Gráfica de área</h4>";
include_flash_chart_script($homeurl);
// Set variables
if ($date == 0) $date = get_system_time();
$datelimit = $date - $period;
$resolution = $config['graph_res'] * 50; //Number of points of the graph
$interval = (int) ($period / $resolution);
/////////////////////////////////////////////////////////////////
// Set the title and time format
if ($period <= 3600) {
$title_period = __('Last hour');
$time_format = 'G:i:s';
}
elseif ($period <= 86400) {
$title_period = __('Last day');
$time_format = 'G:i:s';
}
elseif ($period <= 604800) {
$title_period = __('Last week');
$time_format = 'M d H:i:s';
}
elseif ($period <= 2419200) {
$title_period = __('Last month');
$time_format = 'M d H\h';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M d H\h';
}
$timestamp_short = date($time_format, $date);
$long_index[$timestamp_short] = date(
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
$timestamp = $timestamp_short;
/////////////////////////////////////////////////////////////////
///////////////COMBINED
$aggs = array();
// Calculate data for each agg
$j = 0;
for ($i = 0; $i < $resolution; $i++) {
$count = 0;
$timestamp = $datelimit + ($interval * $i);
$timestamp_short = date($time_format, $timestamp);
$long_index[$timestamp_short] = date(
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
if (isset ($data[$i])){
$aggs[$data[$i]['agg']] = $data[$i]['agg'];
}
// Read data that falls in the current interval
while (isset ($data[$j])) {
$ag = $data[$j]['agg'];
$date = $data[$j]['date'];
$time = $data[$j]['time'];
$datetime = strtotime ($date." ".$time);
if ($datetime >= $timestamp && $datetime <= ($timestamp + $interval)){
if ($data[$j]['unit'] == 'G'){
$data[$j]['data'] *= 1024;
}
if(!isset($chart[$timestamp_short][$ag])) {
$chart[$timestamp_short][$ag] = $data[$j]['data'];
$count++;
} else {
$chart[$timestamp_short][$ag] += $data[$j]['data'];
$count++;
}
} else {
break;
}
$j++;
}
// Average
if ($count > 0) {
$chart[$timestamp_short][$ag] = $chart[$timestamp_short][$ag]/$count;
} else {
$chart[$timestamp_short][$ag] = 0;
}
}
foreach($chart as $key => $value) {
foreach($aggs as $agg) {
if(!isset($chart[$key][$agg])) {
$chart[$key][$agg] = 0;
}
}
}
$color = array();
return area_graph($flash_chart, $chart, $width, $height, $color, $aggs,
$long_index, "images/image_problem.opaque.png", "", "", $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size'], "");
}
/**
* Print an area graph with netflow total
*/
function grafico_netflow_total_area ($data, $period,$width, $height , $title, $unit_name, $avg_only = 0, $pure=0,$date = 0, $only_image = false, $homeurl = '') {
global $config;
global $graphic_type;
echo"<h4>Gráfica de área</h4>";
include_flash_chart_script($homeurl);
// Set variables
if ($date == 0) $date = get_system_time();
$datelimit = $date - $period;
$resolution = $config['graph_res'] * 50; //Number of points of the graph
$interval = (int) ($period / $resolution);
/////////////////////////////////////////////////////////////////
// Set the title and time format
if ($period <= 3600) {
$title_period = __('Last hour');
$time_format = 'G:i:s';
}
elseif ($period <= 86400) {
$title_period = __('Last day');
$time_format = 'G:i:s';
}
elseif ($period <= 604800) {
$title_period = __('Last week');
$time_format = 'M d H:i:s';
}
elseif ($period <= 2419200) {
$title_period = __('Last month');
$time_format = 'M d H\h';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M d H\h';
}
$timestamp_short = date($time_format, $date);
$long_index[$timestamp_short] = date(
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
$timestamp = $timestamp_short;
/////////////////////////////////////////////////////////////////
$aggs = array();
// Calculate data for each agg
$j = 0;
for ($i = 0; $i < $resolution; $i++) {
$count = 0;
$timestamp = $datelimit + ($interval * $i);
$timestamp_short = date($time_format, $timestamp);
$long_index[$timestamp_short] = date(
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
// Read data that falls in the current interval
while (isset ($data[$j])) {
$date = $data[$j]['date'];
$time = $data[$j]['time'];
$datetime = strtotime ($date." ".$time);
if ($datetime >= $timestamp && $datetime <= ($timestamp + $interval)){
if ($data[$j]['unit'] == 'G'){
$data[$j]['data'] *= 1024;
}
if(!isset($chart[$timestamp_short][$ip])) {
$chart[$timestamp_short][$ip] = $data[$j]['data'];
$count++;
} else {
$chart[$timestamp_short][$ip] += $data[$j]['data'];
$count++;
}
} else {
break;
}
$j++;
}
// Average
if ($count > 0) {
$chart[$timestamp_short][$ip] = $chart[$timestamp_short][$ip]/$count;
} else {
$chart[$timestamp_short][$ip] = 0;
}
}
foreach($chart as $key => $value) {
foreach($ips as $ip) {
if(!isset($chart[$key][$ip])) {
$chart[$key][$ip] = 0;
}
}
}
//////////FIN COMBINED
$flash_chart = $config['flash_charts'];
if ($only_image) {
$flash_chart = false;
}
$leyend = array();
$color = array();
return area_graph($flash_chart, $chart, $width, $height, $color, $leyend,
$long_index, "images/image_problem.opaque.png", "", "", $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size'], "");
}
/**
* Print a pie graph with netflow aggregated
*/
function grafico_netflow_aggregate_pie ($data) {
global $config;
global $graphic_type;
echo"<h4>Gráfica totalizada</h4>";
$i = 0;
while (isset ($data[$i])) {
$agg = $data[$i]['agg'];
if ($data[$i]['unit'] == 'G') {
$data[$i]['data'] = $data[$i]['data'] * 1024;
}
if (isset($values[$agg])){
$values[$agg] = $data[$i]['data'];
} else {
$values[$agg] += $data[$i]['data'];
}
$i++;
}
return pie3d_graph($config['flash_charts'], $values, 320, 200,
__('Other'), '', $config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size']);
}
/**
* Print a pie graph with netflow total
*/
function grafico_netflow_total_pie ($data) {
global $config;
global $graphic_type;
echo"<h4>Gráfica totalizada</h4>";
$i = 0;
while (isset ($data[$i])) {
$agg = $data[$i]['agg'];
if ($data[$i]['unit'] == 'G') {
$data[$i]['data'] = $data[$i]['data'] * 1024;
}
if (isset($values[$agg])){
$values[$agg] = $data[$i]['data'];
} else {
$values[$agg] += $data[$i]['data'];
}
$i++;
}
return pie3d_graph($config['flash_charts'], $values, 320, 200,
__('Other'), '', $config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size']);
}
/**
* Draw a graph of Module string data of agent
*

View File

@ -132,6 +132,9 @@
#icon_oper-gismaps {
background-image: url(../../images/server_web.png);
}
#icon_oper-netflow {
background-image: url(../../images/networkmap/so_cisco_new.png);
}
#icon_oper-extensions, #icon_god-extensions {
background-image: url(../../images/extensions.png);
}
@ -176,6 +179,9 @@
#icon_god-audit {
background-image: url(../../images/god6.png);
}
#icon_god-netflow {
background-image: url(../../images/networkmap/so_cisco_new.png);
}
#icon_god-setup {
background-image: url(../../images/god7.png);
}

View File

@ -260,6 +260,14 @@ $menu["usuarios"]["id"] = "oper-users";
//End of Users
if (check_acl ($config['id_user'], 0, "IR")) {
if ($config['activate_netflow']) {
$menu["netf"]["text"] = __('Netflow');
$menu["netf"]["sec2"] = "operation/netflow/nf_reporting";
$menu["netf"]["id"] = "oper-netflow";
}
}
// Rest of options, all with AR privilege (or should events be with incidents?)
if (check_acl ($config['id_user'], 0, "AR")) {

View File

@ -0,0 +1,79 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
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");
check_login ();
if (! check_acl ($config["id_user"], 0, "IR")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
//Header
ui_print_page_header (__('Netflow Reporting'), "images/networkmap/so_cisco_new.png", false, "", false, $buttons);
$filter = array ();
$filter['offset'] = (int) get_parameter ('offset');
$filter['limit'] = (int) $config['block_size'];
$reports = db_get_all_rows_filter ('tnetflow_report', $filter);
$table->width = '80%';
$table->head = array ();
$table->head[0] = __('Report name');
$table->head[1] = __('Description');
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->align = array ();
$table->align[2] = 'center';
$table->size = array ();
$table->size[0] = '50%';
$table->size[1] = '40%';
$table->data = array ();
$total_reports = db_get_all_rows_filter ('tnetflow_report', false, 'COUNT(*) AS total');
$total_reports = $total_reports[0]['total'];
ui_pagination ($total_reports, $url);
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[1] = $report['description'];
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 '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button (__('Create report'), 'crt', false, 'class="sub wand"');
echo "</div>";
echo "</form>";
?>

View File

@ -0,0 +1,499 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
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');
check_login ();
if (! check_acl ($config["id_user"], 0, "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
function exec_command ($start_date, $end_date, $command, $show){
$command .= ' -t '.$start_date.'-'.$end_date;
$values = array();
exec($command, $string);
$i = 0;
if(isset($string) && is_array($string)&&($string!=null)){
foreach($string as $line){
$line = preg_replace('/\s+/',' ',$line);
$val = explode(' ',$line);
$values[$i]['date'] = $val[0];
$values[$i]['time'] = $val[1];
$values[$i]['duration'] = $val[2];
$values[$i]['proto'] = $val[3];
$values[$i]['srcip:port'] = $val[4];
$val2 = explode(':', $val[4]);
$values[$i]['srcip'] = $val2[0];
// campo para mostrar grafica de tarta
$values[$i]['agg'] = $val2[0];
$values[$i]['srcport'] = $val2[1];
$values[$i]['dstip:port'] = $val[6];
$val2 = explode(':', $val[6]);
$values[$i]['dstip'] = $val2[0];
$values[$i]['dstport'] = $val2[1];
switch ($show){
case "packets":
$values[$i]['data'] = $val[7];
$values[$i]['unit'] = $val[8];
break;
case "bytes":
$values[$i]['data'] = $val[9];
$values[$i]['unit'] = $val[10];
break;
case "flows":
$values[$i]['data'] = $val[11];
break;
}
$i++;
}
return $values;
}
}
function exec_command_aggregate ($start_date, $end_date, $command, $show){
$command .= ' -t '.$start_date.'-'.$end_date;
$values = array();
exec($command, $string);
$i = 0;
if(isset($string) && is_array($string)&&($string!=null)){
foreach($string as $line){
if ($line=='')
break;
$line = preg_replace('/\s+/',' ',$line);
$val = explode(' ',$line);
$values[$i]['date'] = $val[0];
$values[$i]['time'] = $val[1];
//create field to sort array
$date = $val[0];
$time = $val[1];
$date_time = strtotime ($date." ".$time);
$values[$i]['datetime'] = $date_time;
///
$values[$i]['duration'] = $val[2];
$values[$i]['proto'] = $val[3];
$values[$i]['agg'] = $val[4];
switch ($show){
case "packets":
$val[7]= str_replace('(','',$val[7]);
$values[$i]['data'] = $val[7];
break;
case "bytes":
$val[9]= str_replace('(','',$val[9]);
$values[$i]['data'] = $val[9];
$val[10]= str_replace('(','',$val[10]);
$values[$i]['unit'] = $val[10];
if (($values[$i]['unit']!='M') && ($values[$i]['unit']!='G')) {
$values[$i]['unit'] = '';
}
if ($values[$i]['unit']=='M'){
$values[$i]['data'] = $values[$i]['data'] * 1024;
}
break;
case "bps":
$val[10]= str_replace('(','',$val[10]);
$values[$i]['unit'] = $val[10];
if (($values[$i]['unit']=='M') || ($values[$i]['unit']=='G')) {
$values[$i]['data'] = $val[13];
} else {
$values[$i]['data'] = $val[12];
}
$values[$i]['unit'] = '';
break;
case "bpp":
$val[10]= str_replace('(','',$val[10]);
$values[$i]['unit'] = $val[10];
if (($values[$i]['unit']=='M') || ($values[$i]['unit']=='G')) {
$values[$i]['data'] = $val[14];
} else {
$values[$i]['data'] = $val[13];
}
$values[$i]['unit'] = '';
break;
}
$i++;
}
return $values;
}
}
$id = get_parameter('id');
$period = get_parameter('period');
$report_name = db_get_value('id_name', 'tnetflow_report', 'id_report', $id);
$time_format = 'Y/m/d.H:i:s';
$update_date = get_parameter('update_date',0);
$buttons['report_list'] = '<a href="index.php?sec=netf&sec2=operation/netflow/nf_reporting">'
. html_print_image ("images/edit.png", true, array ("title" => __('Report list')))
. '</a>';
//Header
ui_print_page_header (__('Netflow'), "images/networkmap/so_cisco_new.png", false, "", false, $buttons);
echo"<h4>".__('Filter graph')."</h4>";
echo '<form method="post" action="index.php?sec=netf&sec2=operation/netflow/nf_view&amp;id='.$id.'">';
$table->width = '60%';
$table->border = 0;
$table->cellspacing = 3;
$table->cellpadding = 5;
$table->class = "databox_color";
$table->style[0] = 'vertical-align: top;';
$table->data = array ();
$table->data[0][0] = '<b>'.__('Date').'</b>';
$table->data[0][1] = html_print_input_text ('date', date ("Y/m/d", get_system_time () - 86400), false, 10, 10, true);
$table->data[0][1] .= html_print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => "scwShow(scwID('text-date'),this);"));
$table->data[0][1] .= html_print_input_text ('time', date ("H:i:s", get_system_time () - 86400), false, 10, 5, true);
$table->data[1][0] = '<b>'.__('Interval').'</b>';
$values_period = array ('600' => __('10 mins'),
'900' => __('15 mins'),
'1800' => __('30 mins'),
'3600' => __('1 hour'),
'7200' => __('2 hours'),
'18000' => __('5 hours'),
'43200' => __('12 hours'),
'86400' => __('1 day'),
'172800' => __('2 days'),
'432000' => __('5 days'),
'1296000' => __('15 days'),
'604800' => __('Last week'),
'2592000' => __('Last month'),
'5184000' => __('2 months'),
'7776000' => __('3 months'),
'15552000' => __('6 months'),
'31104000' => __('Last year'),
'62208000' => __('2 years')
);
$table->data[1][1] = html_print_select ($values_period, 'period', $period, '', '', 0, true, false, false);
html_print_table ($table);
echo '<div class="action-buttons" style="width:60%;">';
html_print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"');
html_print_input_hidden ('update_date', 1);
echo '</div>';
echo'</form>';
if ($id!=''){
echo"<h3>$report_name</h3>";
$sql1 = "select id_filter from tnetflow_report_content where id_report='".$id."'";
$all_filters = db_get_all_rows_sql($sql1);
$x = 0;
while(isset($all_filters[$x]['id_filter'])) {
$filter = $all_filters[$x]['id_filter'];
$sql = "SELECT * FROM tnetflow_report_content WHERE id_report='".$id."' and id_filter='".$filter."'";
$content_report = db_get_row_sql($sql);
$name_filter = $content_report['id_filter'];
$interval = $content_report['period'];
$date = $content_report['date'];
$max_val= $content_report['max'];
$element = $content_report['show_graph'];
$date_time = date($time_format, $date+84600);
if($update_date){
$date = get_parameter_post ('date');
$time = get_parameter_post ('time');
$period = get_parameter('period','0');
$date = strtotime ($date." ".$time);
if(($period!='None')&&($period!='0'))
$interval = $period;
}
$limit = $date - $interval;
$date_limit = date ($time_format, $limit);
$sql = "SELECT * FROM tnetflow_filter WHERE id_name = '".$name_filter."'";
$result = db_get_row_sql($sql,false,true);
$assign_group = $result['group'];
$ip_dst = $result['ip_dst'];
$ip_src = $result['ip_src'];
$dst_port = $result['dst_port'];
$src_port = $result['src_port'];
$aggregate = $result['aggregate'];
$show_packets = $result['show_packets'];
$show_bytes = $result['show_bytes'];
$show_bps = $result['show_bps'];
$show_bpp = $result['show_bpp'];
if(isset($ip_dst)){
$val_ipdst = explode(',',$ip_dst);
$count_ipdst = count($val_ipdst);
}
if(isset($ip_src)){
$val_ipsrc = explode(',',$ip_src);
$count_ipsrc = count($val_ipsrc);
}
if(isset($dst_port)&&($dst_port!='0')){
$val_dstport = explode(',',$dst_port);
$count_dstport = count($val_dstport);
}
if(isset($src_port)&&($src_port!='0')){
$val_srcport = explode(',',$src_port);
$count_srcport = count($val_srcport);
}
//// Build command line
$command = 'nfdump -q';
if (isset($config['netflow_path']))
$command .= ' -R '.$config['netflow_path'];
if (isset($aggregate)&&($aggregate!='none')){
$command .= ' -s '.$aggregate;
if (isset($max_val))
$command .= ' -n '.$max_val;
}
//filter options
if (isset($ip_dst)&&($ip_dst!='')){
$command .= ' "';
for($i=0;$i<$count_ipdst;$i++){
if ($i==0)
$command .= 'dst ip '.$val_ipdst[$i];
else
$command .= ' or dst ip '.$val_ipdst[$i];
}
if (isset($ip_src)&&($ip_src!='')){
$command .= ' and (';
for($i=0;$i<$count_ipsrc;$i++){
if ($i==0)
$command .= 'src ip '.$val_ipsrc[$i];
else
$command .= ' or src ip '.$val_ipsrc[$i];
}
$command .= ')';
}
if (isset($dst_port)&&($dst_port!='')&&($dst_port!='0')){
$command .= ' and (';
for($i=0;$i<$count_dstport;$i++){
if ($i==0)
$command .= 'dst port '. $val_dstport[$i];
else
$command .= ' or dst port '.$val_dstport[$i];
}
$command .= ')';
}
if (isset($src_port)&&($src_port!='')&&($src_port!='0')){
$command .= ' and (';
for($i=0;$i<$count_srcport;$i++){
if ($i==0)
$command .= 'src port '. $val_srcport[$i];
else
$command .= ' or src port '.$val_srcport[$i];
}
$command .= ')';
}
$command .= '"';
} else if (isset($ip_src)&&($ip_src!='')){
$command .= ' "';
for($i=0;$i<$count_ipsrc;$i++){
if ($i==0)
$command .= 'src ip '.$val_ipsrc[$i];
else
$command .= ' or src ip '.$val_ipsrc[$i];
}
if (isset($dst_port)&&($dst_port!='')&&($dst_port!='0')){
$command .= ' and (';
for($i=0;$i<$count_dstport;$i++){
if ($i==0)
$command .= 'dst port '. $val_dstport[$i];
else
$command .= ' or dst port '.$val_dstport[$i];
}
$command .= ')';
}
if (isset($src_port)&&($src_port!='')&&($src_port!='0')){
$command .= ' and (';
for($i=0;$i<$count_srcport;$i++){
if ($i==0)
$command .= 'src port '. $val_srcport[$i];
else
$command .= ' or src port '.$val_srcport[$i];
}
$command .= ')';
} else {
$command .= '"';
}
} else if (isset($dst_port)&&($dst_port!='')&&($dst_port!='0')){
$command .= ' "';
for($i=0;$i<$count_dstport;$i++){
if ($i==0)
$command .= 'dst port '.$val_dstport[$i];
else
$command .= ' or dst port '.$val_dstport[$i];
}
if (isset($src_port)&&($src_port!='')&&($src_port!='0')){
$command .= ' and (';
for($i=0;$i<$count_srcport;$i++){
if ($i==0)
$command .= 'src port '. $val_srcport[$i];
else
$command .= ' or src port '.$val_srcport[$i];
}
$command .= ')';
} else {
$command .= '"';
}
} else {
if (isset($src_port)&&($src_port!='')&&($src_port!='0')){
$command .= ' "(';
for($i=0;$i<$count_ipdst;$i++){
if ($i==0)
$command .= 'dst ip '.$val_ipdst[$i];
else
$command .= ' or dst ip '.$val_ipdst[$i];
}
$command .= ' )"';
}
}
if ($show_packets)
$show = 'packets';
if ($show_bytes)
$show = 'bytes';
if ($show_bps)
$show = 'bps';
if ($show_bpp)
$show = 'bpp';
//create interval to divide command execution
if ($interval<43200)
$inter = 1;
else if (($interval>=43200)&&($interval<=86400))
$inter = 25;
else if ($interval > 86400 && $interval < 604800) //1296000)
$inter = 150;
else if ($interval >= 604800 && $interval <= 1296000)
$inter = 600;
else
$inter = 1600;
if ($aggregate!='none')
$inter = 1;
$fecha_limite = date ($time_format, $limit);
$res = $interval/$inter;
// Data iterator
$j = 0;
// Calculate interval date
for ($i = 0; $i < $inter; $i++) {
$timestamp = $limit + ($res * $i);
$timestamp_short = date($time_format, $timestamp);
$end_date = $timestamp + $res;
$end = date ($time_format, $end_date);
if($aggregate!='none'){
$result = exec_command_aggregate($timestamp_short, $end, $command, $show);
$result = orderMultiDimensionalArray($result, 'datetime');
} else {
$result = exec_command($timestamp_short, $end, $command, $show);
}
$total = 0;
$count = 0;
if(!empty($result)){
foreach($result as $data){
$dates = $data['date'];
$times = $data['time'];
$total += $data['data'];
$count++;
}
$values[$j]['date'] = $dates;
$values[$j]['time'] = $times;
if ($count > 0) {
$values[$j]['data'] = $total / $count;
$var = $values[$j]['data'];
} else {
$values[$j]['data'] = 0;
}
$j++;
}
}
if($aggregate!='none'){
switch ($element){
case '0':
echo grafico_netflow_aggregate_area($result, $interval, 880, 540, $id_name, '','','',$date);
break;
case '1':
echo grafico_netflow_aggregate_pie($result);
break;
case '2':
echo netflow_show_table_values($result, $date_limit, $date_time);
break;
case '3':
echo netflow_show_total_period($result, $date_limit, $date_time);
break;
}
}else{
switch ($element){
case '0':
echo grafico_netflow_total_area($values, $interval, 660, 320, $id_name, '','','',$date);
break;
}
}
$x++;
}
}
?>

View File

@ -71,6 +71,7 @@ INSERT INTO tconfig (token, value) VALUES ('timesource', 'system');
INSERT INTO tconfig (token, value) VALUES ('realtimestats', '1');
INSERT INTO tconfig (token, value) VALUES ('stats_interval', '60');
INSERT INTO tconfig (token, value) VALUES ('activate_gis', '0');
INSERT INTO tconfig (token, value) VALUES ('activate_netflow', '0');
INSERT INTO tconfig (token, value) VALUES ('timezone', 'Europe/Berlin');
INSERT INTO tconfig (token, value) VALUES ('string_purge', 7);
INSERT INTO tconfig (token, value) VALUES ('audit_purge', 15);

View File

@ -68,6 +68,7 @@ INSERT INTO "tconfig" ("token", "value") VALUES
('realtimestats', '1'),
('stats_interval', '60'),
('activate_gis', '0'),
('activate_netflow', '0'),
('timezone', 'Europe/Berlin'),
('string_purge', 7),
('audit_purge', 15),

View File

@ -67,6 +67,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('realtimestats', '1'),
('stats_interval', '60'),
('activate_gis', '0'),
('activate_netflow', '0'),
('timezone', 'Europe/Berlin'),
('string_purge', 7),
('audit_purge', 15),