From d47c53eedae64b93a973c5879c93960f5bf3e0ce Mon Sep 17 00:00:00 2001 From: vgilc Date: Wed, 21 Dec 2011 13:09:26 +0000 Subject: [PATCH] 2011-12-21 Vanessa Gil * 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 --- pandora_console/ChangeLog | 34 ++ pandora_console/godmode/netflow/nf.php | 94 ++++ pandora_console/godmode/netflow/nf_edit.php | 151 ++++++ .../godmode/netflow/nf_edit_form.php | 218 ++++++++ .../godmode/netflow/nf_item_list.php | 190 +++++++ pandora_console/godmode/netflow/nf_manage.php | 179 +++++++ .../godmode/netflow/nf_option_form.php | 143 +++++ pandora_console/godmode/netflow/nf_report.php | 164 ++++++ .../godmode/netflow/nf_report_form.php | 185 +++++++ .../godmode/netflow/nf_report_item.php | 212 ++++++++ .../images/networkmap/so_cisco_new.png | Bin 0 -> 864 bytes pandora_console/include/auth/mysql.php | 5 +- pandora_console/include/db/mysql.php | 3 +- pandora_console/include/functions_config.php | 5 + pandora_console/include/functions_graph.php | 282 ++++++++++ pandora_console/include/styles/menu.css | 6 + pandora_console/operation/menu.php | 8 + .../operation/netflow/nf_reporting.php | 79 +++ pandora_console/operation/netflow/nf_view.php | 499 ++++++++++++++++++ pandora_console/pandoradb.data.oracle.sql | 1 + pandora_console/pandoradb.data.postgreSQL.sql | 1 + pandora_console/pandoradb_data.sql | 1 + 22 files changed, 2457 insertions(+), 3 deletions(-) create mode 100644 pandora_console/godmode/netflow/nf.php create mode 100644 pandora_console/godmode/netflow/nf_edit.php create mode 100644 pandora_console/godmode/netflow/nf_edit_form.php create mode 100644 pandora_console/godmode/netflow/nf_item_list.php create mode 100644 pandora_console/godmode/netflow/nf_manage.php create mode 100644 pandora_console/godmode/netflow/nf_option_form.php create mode 100644 pandora_console/godmode/netflow/nf_report.php create mode 100644 pandora_console/godmode/netflow/nf_report_form.php create mode 100644 pandora_console/godmode/netflow/nf_report_item.php create mode 100644 pandora_console/images/networkmap/so_cisco_new.png create mode 100644 pandora_console/operation/netflow/nf_reporting.php create mode 100644 pandora_console/operation/netflow/nf_view.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 06b08d9390..0c941d54ce 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,37 @@ +2011-12-21 Vanessa Gil + + * 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 + + * 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 * operation/agentes/status_monitor.php: Fixed that long module names diff --git a/pandora_console/godmode/netflow/nf.php b/pandora_console/godmode/netflow/nf.php new file mode 100644 index 0000000000..4a46728499 --- /dev/null +++ b/pandora_console/godmode/netflow/nf.php @@ -0,0 +1,94 @@ +' + . html_print_image ("images/lupa.png", true, array ("title" => __('View'))) + . ''; + +$buttons['edit'] = '' + . html_print_image ("images/edit.png", true, array ("title" => __('Filter list'))) + . ''; + +$buttons['add'] = '' + . html_print_image ("images/add.png", true, array ("title" => __('Add filter'))) + . ''; + +//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] = ''.__('Path').''. 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 '
'; + +html_print_table ($table); + +// Update button +echo '
'; + html_print_input_hidden ('update', 1); + html_print_submit_button (__('Update'), 'upd_button', false, 'class="sub upd"'); +echo '
'; + +?> + + diff --git a/pandora_console/godmode/netflow/nf_edit.php b/pandora_console/godmode/netflow/nf_edit.php new file mode 100644 index 0000000000..a0f990f28c --- /dev/null +++ b/pandora_console/godmode/netflow/nf_edit.php @@ -0,0 +1,151 @@ +' + . html_print_image ("images/add.png", true, array ("title" => __('Add filter'))) + . ''; + +//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] = ''.$filter['id_name'].''; + + $data[1] = "" . + html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "" . + html_print_checkbox_extended ('delete_multiple[]', $filter['id_sg'], false, false, '', 'class="check_delete"', true); + + array_push ($table->data, $data); +} + +if(isset($data)) { + echo "
"; + html_print_input_hidden('multiple_delete', 1); + html_print_table ($table); + echo "
"; + html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); + echo "
"; + echo "
"; +} +else { + echo "
".__('There are no defined filters')."
"; +} + +?> + + diff --git a/pandora_console/godmode/netflow/nf_edit_form.php b/pandora_console/godmode/netflow/nf_edit_form.php new file mode 100644 index 0000000000..16200046c2 --- /dev/null +++ b/pandora_console/godmode/netflow/nf_edit_form.php @@ -0,0 +1,218 @@ +' + . html_print_image ("images/edit.png", true, array ("title" => __('Filter list'))) + . ''; + +$buttons['add'] = '' + . html_print_image ("images/add.png", true, array ("title" => __('Add filter'))) + . ''; + +//Header +ui_print_page_header (__('Netflow Filter'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons); + +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 '

'.__ ('Error creating filter').'

'; + else + echo '

'.__ ('filter created successfully').'

'; +} + +$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] = ''.__('Name').''; +$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] = ''.__('Group').''; +$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] = ''.__('Filter:').''; + +$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:
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:
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:
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:
80,22"), true); +$table->data[6][1] = html_print_input_text ('src_port', $src_port, false, 40, 80, true); + + +$table->data[7][0] = ''.__('Aggregate by').''. 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] = ''.__('Output format').''; + +$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 '
'; +html_print_table ($table); +echo '
'; +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 '
'; +echo '
'; +?> + + diff --git a/pandora_console/godmode/netflow/nf_item_list.php b/pandora_console/godmode/netflow/nf_item_list.php new file mode 100644 index 0000000000..6ead5d40e0 --- /dev/null +++ b/pandora_console/godmode/netflow/nf_item_list.php @@ -0,0 +1,190 @@ +' + . html_print_image ("images/edit.png", true, array ("title" => __('Report list'))) + . ''; + +//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] = ''.$item['id_rc'].''; + + $data[1] = $item['id_filter']; + + $data[2] = $item['period']; + + $data[3] = $item['max']; + + $data[4] = $item['show_graph']; + + $data[5] = "" . + html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "" . + html_print_checkbox_extended ('delete_multiple[]', $item['id_rc'], false, false, '', 'class="check_delete"', true); + + array_push ($table->data, $data); +} + +if(isset($data)) { + echo '
'; + html_print_input_hidden('multiple_delete', 1); + html_print_table ($table); + echo "
"; + html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); + echo "
"; + echo "
"; +}else { + echo "
".__('There are no defined filters')."
"; +} + +echo '
'; + echo "
"; + html_print_submit_button (__('Create item'), 'crt', false, 'class="sub wand"'); + echo "
"; + echo "
"; + +?> + + diff --git a/pandora_console/godmode/netflow/nf_manage.php b/pandora_console/godmode/netflow/nf_manage.php new file mode 100644 index 0000000000..5f5f783471 --- /dev/null +++ b/pandora_console/godmode/netflow/nf_manage.php @@ -0,0 +1,179 @@ +' + . html_print_image ("images/lupa.png", true, array ("title" => __('View'))) + . ''; + +$buttons['edit'] = '' + . html_print_image ("images/edit.png", true, array ("title" => __('Filter list'))) + . ''; + +$buttons['add'] = '' + . html_print_image ("images/add.png", true, array ("title" => __('Add filter'))) + . ''; + +*/ +//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] = ''.$option['id_name'].''; + + $data[1] = $option['description']; + + $data[2] = "" . + html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "" . + html_print_checkbox_extended ('delete_multiple[]', $option['id_option'], false, false, '', 'class="check_delete"', true); + + array_push ($table->data, $data); +} + +if(isset($data)) { + echo "
"; + html_print_input_hidden('multiple_delete', 1); + html_print_table ($table); + echo "
"; + html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); + echo "
"; + echo "
"; +}else { + echo "
".__('There are no defined filters')."
"; +} + +echo '
'; + echo "
"; + html_print_submit_button (__('Create option'), 'crt', false, 'class="sub wand"'); + echo "
"; + echo "
"; + +?> + + diff --git a/pandora_console/godmode/netflow/nf_option_form.php b/pandora_console/godmode/netflow/nf_option_form.php new file mode 100644 index 0000000000..5e293fe930 --- /dev/null +++ b/pandora_console/godmode/netflow/nf_option_form.php @@ -0,0 +1,143 @@ +' + . html_print_image ("images/edit.png", true, array ("title" => __('Option list'))) + . ''; + +//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 '

'.__ ('Error creating filter').'

'; + else + echo '

'.__ ('Option created successfully').'

'; +} + +$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] = ''.__('Name').''; +$table->data[0][1] = html_print_input_text ('name', $name, false, 50, 80, true); + +$table->data[1][0] = ''.__('Description').''; +$table->data[1][1] = html_print_textarea ('description', 2, 65, $description, '', true); + +$table->data[2][0] = ''.__('Path').''; +//$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] = ''.__('Port').''; +$table->data[3][1] = html_print_input_text ('port', $port, false, 10, 80, true); + + +echo '
'; +html_print_table ($table); +echo '
'; +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 '
'; +echo '
'; +?> diff --git a/pandora_console/godmode/netflow/nf_report.php b/pandora_console/godmode/netflow/nf_report.php new file mode 100644 index 0000000000..2f51cda508 --- /dev/null +++ b/pandora_console/godmode/netflow/nf_report.php @@ -0,0 +1,164 @@ + $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] = ''.$report['id_name'].''; + + $data[1] = $report['description']; + + $data[2] = "" . + html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "" . + html_print_checkbox_extended ('delete_multiple[]', $report['id_report'], false, false, '', 'class="check_delete"', true); + + array_push ($table->data, $data); +} + +if(isset($data)) { + echo "
"; + html_print_input_hidden('multiple_delete', 1); + html_print_table ($table); + echo "
"; + html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); + echo "
"; + echo "
"; +}else { + echo "
".__('There are no defined reports')."
"; +} + +echo '
'; + echo "
"; + html_print_submit_button (__('Create report'), 'crt', false, 'class="sub wand"'); + echo "
"; + echo "
"; + +?> + + diff --git a/pandora_console/godmode/netflow/nf_report_form.php b/pandora_console/godmode/netflow/nf_report_form.php new file mode 100644 index 0000000000..d0cb32f13e --- /dev/null +++ b/pandora_console/godmode/netflow/nf_report_form.php @@ -0,0 +1,185 @@ + $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'] = '' + . html_print_image ("images/lupa.png", true, array ("title" => __('View data'))) + . ''; + +$buttons['list'] = '' + . html_print_image ("images/edit.png", true, array ("title" => __('Report list'))) + . ''; + +$buttons['list_items'] = '' + . html_print_image ("images/god6.png", true, array ("title" => __('Items list'))) + . ''; + +$buttons['item'] = '' + . html_print_image ("images/config.png", true, array ("title" => __('Item editor'))) + . ''; + +//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] = ''.__('Name').''; +$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] = ''.__('Group').''; +$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] = ''.__('Description').''; +$table->data[2][1] = html_print_textarea ('description', 2, 65, $description, '', true); + + +echo '
'; +html_print_table ($table); +echo '
'; + +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 '
'; +echo '
'; + +?> diff --git a/pandora_console/godmode/netflow/nf_report_item.php b/pandora_console/godmode/netflow/nf_report_item.php new file mode 100644 index 0000000000..d388dfd9c9 --- /dev/null +++ b/pandora_console/godmode/netflow/nf_report_item.php @@ -0,0 +1,212 @@ +' + . html_print_image ("images/god6.png", true, array ("title" => __('Item list'))) + . ''; + +$buttons['list'] = '' + . html_print_image ("images/edit.png", true, array ("title" => __('Report list'))) + . ''; +//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 '

'.__ ('Error creating item. Filter already exists.').'

'; + 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 '

'.__ ('Error creating item').'

'; + else + echo '

'.__ ('Item created successfully').'

'; + } +} +$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] = ''.__('Date').''; + +$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] = ''.__('Interval').''; + $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] = ''.__('Filters').''; +$table->data[2][1] = html_print_select($filters, 'id_filter', $name_filter, '', '', 0, true); + +$table->data[3][0] = ''.__('Max values aggregated').''; + $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] = ''.__('Elements').''; + +$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 '
'; +html_print_table ($table); +echo '
'; + +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 '
'; +echo '
'; + +?> diff --git a/pandora_console/images/networkmap/so_cisco_new.png b/pandora_console/images/networkmap/so_cisco_new.png new file mode 100644 index 0000000000000000000000000000000000000000..ab311e43765bc451cf699a4a030a78a4a5e173e8 GIT binary patch literal 864 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaL-l0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YPV z+ueoX9|*pdxY7g^;VkfoECyPA4TKpdQ&rUPlPLl|O?tv$@Zz~tcR;uvCa z`sn1d-XVz+N9)g9m#6LdyfSju0trFZt4h&d*j)q!outimqeLZM?EBXg_O^@Zx}b{7 z!(F#5RRzEORjkcidd_08@vAd)tKa{&)76@u%VYK7z)hR|M<2=rhHg{dy!L%Piej%jUl~uX1;U{lA>L+!G7_F0d}(o3l1jy4K$6f@SrF^*;*UT)D9K-#aH^hmfhK z%jeJC^*7~TTgANxZUVtCKHRuJ`M8yPxZ26adp7T5VUKYb(rakMhmaU-RjUx9D@3d4fTliqriz7|&MQHtllX`wp&(an7i7aygrrp&<&&Qdpy&lGIXwUMN7`O z!0V5 z?`1LTQYO8Zzx(Nt!&C9+>xCGPW^CJ9v>YfZ^!wYp!`kQfPC06>Z^E@+aem#2FJDX+i|Z{jGe1<*K3`8le>ho{)0yQvr My85}Sb4q9e08GniasU7T literal 0 HcmV?d00001 diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 49837abbbf..fedbeb6019 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -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; diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index a6f74e5fe2..26b4eef4f4 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -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 '); + } } diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index a5cbcdc086..42a28edd20 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -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'); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 26333d4ca0..fccb59d31d 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -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"

Gráfica de área

"; + 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"

Gráfica de área

"; + 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"

Gráfica totalizada

"; + + $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"

Gráfica totalizada

"; + + $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 * diff --git a/pandora_console/include/styles/menu.css b/pandora_console/include/styles/menu.css index 8b94ede331..c898b9ea69 100644 --- a/pandora_console/include/styles/menu.css +++ b/pandora_console/include/styles/menu.css @@ -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); } diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 921527b5e1..6ef2d338d2 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -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")) { diff --git a/pandora_console/operation/netflow/nf_reporting.php b/pandora_console/operation/netflow/nf_reporting.php new file mode 100644 index 0000000000..4d2d8b2def --- /dev/null +++ b/pandora_console/operation/netflow/nf_reporting.php @@ -0,0 +1,79 @@ +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] = ''.$report['id_name'].''; + $data[1] = $report['description']; + + array_push ($table->data, $data); +} + +html_print_table ($table); + +echo '
'; + echo '
'; + html_print_submit_button (__('Create report'), 'crt', false, 'class="sub wand"'); + echo "
"; + echo "
"; + +?> diff --git a/pandora_console/operation/netflow/nf_view.php b/pandora_console/operation/netflow/nf_view.php new file mode 100644 index 0000000000..0b8b8ecd3c --- /dev/null +++ b/pandora_console/operation/netflow/nf_view.php @@ -0,0 +1,499 @@ +' + . html_print_image ("images/edit.png", true, array ("title" => __('Report list'))) + . ''; + +//Header +ui_print_page_header (__('Netflow'), "images/networkmap/so_cisco_new.png", false, "", false, $buttons); + +echo"

".__('Filter graph')."

"; + +echo '
'; + + $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] = ''.__('Date').''; + + $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] = ''.__('Interval').''; + $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 '
'; + html_print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); + html_print_input_hidden ('update_date', 1); + echo '
'; +echo'
'; + + +if ($id!=''){ + echo"

$report_name

"; + $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++; + } +} + +?> + + diff --git a/pandora_console/pandoradb.data.oracle.sql b/pandora_console/pandoradb.data.oracle.sql index c2c39eebfe..88bef43a8f 100644 --- a/pandora_console/pandoradb.data.oracle.sql +++ b/pandora_console/pandoradb.data.oracle.sql @@ -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); diff --git a/pandora_console/pandoradb.data.postgreSQL.sql b/pandora_console/pandoradb.data.postgreSQL.sql index b0a9ac1603..2fb14ba6b9 100644 --- a/pandora_console/pandoradb.data.postgreSQL.sql +++ b/pandora_console/pandoradb.data.postgreSQL.sql @@ -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), diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 76ff3edb55..a2bca35fc6 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -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),