2011-12-21 16:28:01 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2010 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 Lesser 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.
|
|
|
|
|
2012-01-11 19:12:33 +01:00
|
|
|
|
2012-10-02 13:11:58 +02:00
|
|
|
include_once($config['homedir'] . "/include/functions_users.php");
|
|
|
|
include_once($config['homedir'] . "/include/functions_io.php");
|
2012-10-11 17:52:26 +02:00
|
|
|
include_once ($config['homedir'] . "/include/functions_io.php");
|
|
|
|
enterprise_include_once ($config['homedir'] . '/enterprise/include/pdf_translator.php');
|
|
|
|
enterprise_include_once ($config['homedir'] . '/enterprise/include/functions_metaconsole.php');
|
2012-01-11 19:12:33 +01:00
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
// Date format for nfdump
|
2012-10-25 20:34:53 +02:00
|
|
|
global $nfdump_date_format;
|
2012-01-11 17:34:53 +01:00
|
|
|
$nfdump_date_format = 'Y/m/d.H:i:s';
|
2011-12-21 16:28:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Selects all netflow filters (array (id_name => id_name)) or filters filtered
|
|
|
|
*
|
|
|
|
* @param mixed Array with filter conditions to retrieve filters or false.
|
|
|
|
*
|
|
|
|
* @return array List of all filters
|
|
|
|
*/
|
|
|
|
function netflow_get_filters ($filter = false) {
|
|
|
|
if ($filter === false) {
|
|
|
|
$filters = db_get_all_rows_in_table ("tnetflow_filter", "id_name");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$filters = db_get_all_rows_filter ("tnetflow_filter", $filter);
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2011-12-21 16:28:01 +01:00
|
|
|
$return = array ();
|
|
|
|
if ($filters === false) {
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
foreach ($filters as $filter) {
|
|
|
|
$return[$filter["id_name"]] = $filter["id_name"];
|
|
|
|
}
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selects all netflow reports (array (id_name => id_name)) or filters filtered
|
|
|
|
*
|
|
|
|
* @param mixed Array with filter conditions to retrieve filters or false.
|
|
|
|
*
|
|
|
|
* @return array List of all filters
|
|
|
|
*/
|
|
|
|
function netflow_get_reports ($filter = false) {
|
|
|
|
if ($filter === false) {
|
|
|
|
$filters = db_get_all_rows_in_table ("tnetflow_report", "id_name");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$filters = db_get_all_rows_filter ("tnetflow_report", $filter);
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2011-12-21 16:28:01 +01:00
|
|
|
$return = array ();
|
|
|
|
if ($filters === false) {
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
foreach ($filters as $filter) {
|
|
|
|
$return[$filter["id_name"]] = $filter["id_name"];
|
|
|
|
}
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
2012-01-11 19:12:33 +01:00
|
|
|
//permite validar si un filtro pertenece a un grupo permitido para el usuario
|
|
|
|
|
|
|
|
function netflow_check_filter_group ($id_sg) {
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
$id_group = db_get_value('id_group', 'tnetflow_filter', 'id_sg', $id_sg);
|
2012-01-12 12:32:49 +01:00
|
|
|
$own_info = get_user_info ($config['id_user']);
|
2012-01-11 19:12:33 +01:00
|
|
|
// Get group list that user has access
|
2012-01-12 12:32:49 +01:00
|
|
|
$groups_user = users_get_groups ($config['id_user'], "IW", $own_info['is_admin'], true);
|
2012-01-11 19:12:33 +01:00
|
|
|
$groups_id = array();
|
|
|
|
$has_permission = false;
|
|
|
|
|
|
|
|
foreach($groups_user as $key => $groups){
|
|
|
|
if ($groups['id_grupo'] == $id_group)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-12 11:52:15 +01:00
|
|
|
/* Permite validar si un informe pertenece a un grupo permitido para el usuario.
|
|
|
|
* Si mode = false entonces es modo godmode y solo puede ver el grupo All el admin
|
|
|
|
* Si es modo operation (mode = true) entonces todos pueden ver el grupo All
|
|
|
|
*/
|
2012-01-11 19:12:33 +01:00
|
|
|
|
2012-01-12 11:52:15 +01:00
|
|
|
function netflow_check_report_group ($id_report, $mode=false) {
|
2012-01-11 19:12:33 +01:00
|
|
|
global $config;
|
|
|
|
|
2012-01-12 11:52:15 +01:00
|
|
|
if (!$mode) {
|
|
|
|
$own_info = get_user_info ($config['id_user']);
|
|
|
|
$mode = $own_info['is_admin'];
|
|
|
|
}
|
|
|
|
$id_group = db_get_value('id_group', 'tnetflow_report', 'id_report', $id_report);
|
|
|
|
|
2012-01-11 19:12:33 +01:00
|
|
|
// Get group list that user has access
|
2012-01-12 11:52:15 +01:00
|
|
|
$groups_user = users_get_groups ($config['id_user'], "IW", $mode, true);
|
2012-01-11 19:12:33 +01:00
|
|
|
$groups_id = array();
|
|
|
|
$has_permission = false;
|
|
|
|
|
|
|
|
foreach($groups_user as $key => $groups){
|
|
|
|
if ($groups['id_grupo'] == $id_group)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-12 11:52:15 +01:00
|
|
|
|
2011-12-21 16:28:01 +01:00
|
|
|
/**
|
|
|
|
* Get a filter.
|
|
|
|
*
|
|
|
|
* @param int filter id to be fetched.
|
|
|
|
* @param array Extra filter.
|
|
|
|
* @param array Fields to be fetched.
|
|
|
|
*
|
|
|
|
* @return array A netflow filter matching id and filter.
|
|
|
|
*/
|
|
|
|
function netflow_filter_get_filter ($id_sg, $filter = false, $fields = false) {
|
2012-07-18 15:25:51 +02:00
|
|
|
if (! is_array ($filter))
|
|
|
|
$filter = array ();
|
|
|
|
|
|
|
|
$filter['id_sg'] = (int) $id_sg;
|
2012-01-11 19:12:33 +01:00
|
|
|
|
2012-07-18 15:25:51 +02:00
|
|
|
return db_get_row_filter ('tnetflow_filter', $filter, $fields);
|
2011-12-21 16:28:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get options.
|
|
|
|
*
|
|
|
|
* @param int filter id to be fetched.
|
|
|
|
* @param array Extra filter.
|
|
|
|
* @param array Fields to be fetched.
|
|
|
|
*
|
|
|
|
* @return array A netflow filter matching id and filter.
|
|
|
|
*/
|
|
|
|
function netflow_reports_get_reports ($id_report, $filter = false, $fields = false) {
|
|
|
|
if (empty ($id_report))
|
|
|
|
return false;
|
|
|
|
if (! is_array ($filter))
|
|
|
|
$filter = array ();
|
|
|
|
$filter['id_report'] = (int) $id_report;
|
|
|
|
|
|
|
|
return db_get_row_filter ('tnetflow_report', $filter, $fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
function netflow_reports_get_content ($id_rc, $filter = false, $fields = false){
|
|
|
|
if (empty ($id_rc))
|
|
|
|
return false;
|
|
|
|
if (! is_array ($filter))
|
|
|
|
$filter = array ();
|
|
|
|
$filter['id_rc'] = (int) $id_rc;
|
|
|
|
|
|
|
|
return db_get_row_filter ('tnetflow_report_content', $filter, $fields);
|
|
|
|
}
|
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
/**
|
|
|
|
* Compare two flows according to the 'data' column.
|
|
|
|
*
|
|
|
|
* @param array a First flow.
|
|
|
|
* @param array b Second flow.
|
|
|
|
*
|
|
|
|
* @return Result of the comparison.
|
|
|
|
*/
|
|
|
|
function compare_flows ($a, $b) {
|
2012-01-13 14:14:16 +01:00
|
|
|
return $a['data'] < $b['data'];
|
2011-12-21 16:28:01 +01:00
|
|
|
}
|
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
/**
|
|
|
|
* Sort netflow data according to the 'data' column.
|
|
|
|
*
|
|
|
|
* @param array netflow_data Netflow data array.
|
|
|
|
*
|
|
|
|
*/
|
2012-01-13 14:14:16 +01:00
|
|
|
function sort_netflow_data (&$netflow_data) {
|
2012-07-10 13:03:00 +02:00
|
|
|
usort($netflow_data, "compare_flows");
|
2012-01-11 17:34:53 +01:00
|
|
|
}
|
|
|
|
|
2012-09-21 15:42:13 +02:00
|
|
|
/**
|
|
|
|
* Show a table with netflow statistics.
|
|
|
|
*
|
|
|
|
* @param array data Statistic data.
|
|
|
|
* @param string start_date Start date.
|
|
|
|
* @param string end_date End date.
|
|
|
|
* @param string aggregate Aggregate field.
|
|
|
|
* @param string unit Unit to show.
|
|
|
|
*
|
|
|
|
* @return The statistics table.
|
|
|
|
*/
|
2012-01-13 15:52:52 +01:00
|
|
|
function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){
|
2012-01-11 17:34:53 +01:00
|
|
|
global $nfdump_date_format;
|
|
|
|
|
|
|
|
$start_date = date ($nfdump_date_format, $start_date);
|
|
|
|
$end_date = date ($nfdump_date_format, $end_date);
|
2011-12-21 16:28:01 +01:00
|
|
|
$values = array();
|
|
|
|
$table->width = '50%';
|
2012-10-25 20:34:53 +02:00
|
|
|
$table->cellspacing = 0;
|
2011-12-21 16:28:01 +01:00
|
|
|
$table->class = 'databox';
|
|
|
|
$table->data = array();
|
|
|
|
$j = 0;
|
2012-01-23 19:20:30 +01:00
|
|
|
$x = 0;
|
|
|
|
|
|
|
|
$table->head = array ();
|
2012-12-07 15:03:00 +01:00
|
|
|
$table->head[0] = '<b>' . netflow_format_aggregate ($aggregate) . '</b>';
|
|
|
|
$table->head[1] = '<b>' . netflow_format_unit ($unit) . '</b>';
|
2014-04-16 14:06:19 +02:00
|
|
|
$table->style[0] = 'padding: 6px';
|
|
|
|
$table->style[1] = 'padding: 6px';
|
2012-12-07 15:03:00 +01:00
|
|
|
|
2011-12-21 16:28:01 +01:00
|
|
|
while (isset ($data[$j])) {
|
|
|
|
$agg = $data[$j]['agg'];
|
|
|
|
if (!isset($values[$agg])){
|
|
|
|
$values[$agg] = $data[$j]['data'];
|
|
|
|
$table->data[$x][0] = $agg;
|
2012-12-07 15:03:00 +01:00
|
|
|
$table->data[$x][1] = format_numeric ($data[$j]['data']) . ' ' . netflow_format_unit ($unit);
|
2012-07-10 13:03:00 +02:00
|
|
|
}
|
|
|
|
else {
|
2011-12-21 16:28:01 +01:00
|
|
|
$values[$agg] += $data[$j]['data'];
|
|
|
|
$table->data[$x][0] = $agg;
|
2012-12-07 15:03:00 +01:00
|
|
|
$table->data[$x][1] = format_numeric ($data[$j]['data']) . ' ' . netflow_format_unit ($unit);
|
2011-12-21 16:28:01 +01:00
|
|
|
}
|
|
|
|
$j++;
|
|
|
|
$x++;
|
|
|
|
}
|
2012-07-10 13:03:00 +02:00
|
|
|
|
2012-10-08 21:19:58 +02:00
|
|
|
return html_print_table ($table, true);
|
2011-12-21 16:28:01 +01:00
|
|
|
}
|
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
/**
|
2012-09-21 15:42:13 +02:00
|
|
|
* Show a table with netflow data.
|
2012-01-11 17:34:53 +01:00
|
|
|
*
|
2012-09-21 15:42:13 +02:00
|
|
|
* @param array data Netflow data.
|
2012-01-11 17:34:53 +01:00
|
|
|
* @param string start_date Start date.
|
|
|
|
* @param string end_date End date.
|
2012-01-13 15:52:52 +01:00
|
|
|
* @param string aggregate Aggregate field.
|
2012-01-11 17:34:53 +01:00
|
|
|
*
|
|
|
|
* @return The statistics table.
|
|
|
|
*/
|
2012-12-07 15:03:00 +01:00
|
|
|
function netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit) {
|
2012-01-11 17:34:53 +01:00
|
|
|
global $nfdump_date_format;
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-11 20:16:13 +01:00
|
|
|
$period = $end_date - $start_date;
|
2012-01-11 17:34:53 +01:00
|
|
|
$start_date = date ($nfdump_date_format, $start_date);
|
|
|
|
$end_date = date ($nfdump_date_format, $end_date);
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-11 20:16:13 +01:00
|
|
|
// Set the format
|
2012-07-18 15:25:51 +02:00
|
|
|
if ($period <= SECONDS_6HOURS) {
|
2012-01-11 20:16:13 +01:00
|
|
|
$time_format = 'H:i:s';
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
elseif ($period < SECONDS_1DAY) {
|
2012-01-11 20:16:13 +01:00
|
|
|
$time_format = 'H:i';
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
elseif ($period < SECONDS_15DAYS) {
|
2012-01-11 20:16:13 +01:00
|
|
|
$time_format = 'M d H:i';
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
elseif ($period < SECONDS_1MONTH) {
|
2012-01-11 20:16:13 +01:00
|
|
|
$time_format = 'M d H\h';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$time_format = 'M d H\h';
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2011-12-21 16:28:01 +01:00
|
|
|
$values = array();
|
2012-12-10 01:05:09 +01:00
|
|
|
$table->size = array ('60%');
|
2014-04-16 14:06:19 +02:00
|
|
|
$table->class = 'databox';
|
2012-10-25 20:34:53 +02:00
|
|
|
$table->cellspacing = 0;
|
2011-12-21 16:28:01 +01:00
|
|
|
$table->data = array();
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-23 19:20:30 +01:00
|
|
|
$table->head = array();
|
|
|
|
$table->head[0] = '<b>'.__('Timestamp').'</b>';
|
2012-12-10 01:05:09 +01:00
|
|
|
$table->style[0] = 'padding: 4px';
|
2012-12-07 15:03:00 +01:00
|
|
|
|
2012-01-11 20:16:13 +01:00
|
|
|
$j = 0;
|
|
|
|
$source_index = array ();
|
|
|
|
$source_count = 0;
|
2012-12-07 15:03:00 +01:00
|
|
|
|
|
|
|
if (isset ($data['sources'])) {
|
|
|
|
foreach ($data['sources'] as $source => $null) {
|
2012-12-10 01:05:09 +01:00
|
|
|
$table->style[$j+1] = 'padding: 4px';
|
2012-12-07 15:03:00 +01:00
|
|
|
$table->align[$j+1] = "right";
|
|
|
|
$table->head[$j+1] = $source;
|
|
|
|
$source_index[$j] = $source;
|
|
|
|
$source_count++;
|
|
|
|
$j++;
|
|
|
|
}
|
2013-02-04 13:19:17 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-12-10 01:05:09 +01:00
|
|
|
$table->style[1] = 'padding: 4px;';
|
2011-12-21 16:28:01 +01:00
|
|
|
}
|
2012-12-07 15:03:00 +01:00
|
|
|
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
// No aggregates
|
|
|
|
if ($source_count == 0) {
|
|
|
|
$table->head[1] = __('Data');
|
|
|
|
$table->align[1] = "right";
|
|
|
|
$i = 0;
|
2013-02-04 13:19:17 +01:00
|
|
|
|
|
|
|
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
foreach ($data as $timestamp => $value) {
|
|
|
|
$table->data[$i][0] = date ($time_format, $timestamp);
|
2012-12-07 15:03:00 +01:00
|
|
|
$table->data[$i][1] = format_numeric ($value['data']) . ' ' . netflow_format_unit ($unit);
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Aggregates
|
|
|
|
else {
|
|
|
|
$i = 0;
|
|
|
|
foreach ($data['data'] as $timestamp => $values) {
|
|
|
|
$table->data[$i][0] = date ($time_format, $timestamp);
|
|
|
|
for ($j = 0; $j < $source_count; $j++) {
|
|
|
|
if (isset ($values[$source_index[$j]])) {
|
2012-12-07 15:03:00 +01:00
|
|
|
$table->data[$i][$j+1] = format_numeric ($values[$source_index[$j]]) . ' ' . netflow_format_unit ($unit);
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-12-07 15:03:00 +01:00
|
|
|
$table->data[$i][$j+1] = 0 . ' ' . netflow_format_unit ($unit);
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
}
|
2011-12-21 16:28:01 +01:00
|
|
|
}
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
$i++;
|
2011-12-21 16:28:01 +01:00
|
|
|
}
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-10-08 21:19:58 +02:00
|
|
|
return html_print_table($table, true);
|
2012-01-11 17:34:53 +01:00
|
|
|
}
|
|
|
|
|
2012-09-21 15:42:13 +02:00
|
|
|
/**
|
|
|
|
* Show a table with a traffic summary.
|
|
|
|
*
|
|
|
|
* @param array data Summary data.
|
|
|
|
*
|
|
|
|
* @return The statistics table.
|
|
|
|
*/
|
|
|
|
function netflow_summary_table ($data) {
|
|
|
|
global $nfdump_date_format;
|
|
|
|
|
|
|
|
$values = array();
|
2014-04-16 14:06:19 +02:00
|
|
|
$table->size = array('50%');
|
2012-10-25 20:34:53 +02:00
|
|
|
$table->cellspacing = 0;
|
2012-09-21 15:42:13 +02:00
|
|
|
$table->class = 'databox';
|
|
|
|
$table->data = array();
|
|
|
|
|
2014-04-16 14:06:19 +02:00
|
|
|
$table->style[0] = 'font-weight: bold; padding: 6px';
|
|
|
|
$table->style[1] = 'padding: 6px';
|
2014-04-16 16:42:28 +02:00
|
|
|
|
2014-04-16 14:06:19 +02:00
|
|
|
$data = array();
|
|
|
|
$data[] = __('Total flows');
|
|
|
|
$data[] = format_numeric ($data['totalflows']);
|
|
|
|
$table->data[] = $data;
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$data[] = __('Total bytes');
|
|
|
|
$data[] = format_numeric ($data['totalbytes']);
|
|
|
|
$table->data[] = $data;
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$data[] = __('Total packets');
|
|
|
|
$data[] = format_numeric ($data['totalpackets']);
|
|
|
|
$table->data[] = $data;
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$data[] = __('Average bits per second');
|
|
|
|
$data[] = format_numeric ($data['avgbps']);
|
|
|
|
$table->data[] = $data;
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$data[] = __('Average packets per second');
|
|
|
|
$data[] = format_numeric ($data['avgpps']);
|
|
|
|
$table->data[] = $data;
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$data[] = __('Average bytes per packet');
|
|
|
|
$data[] = format_numeric ($data['avgbpp']);
|
|
|
|
$table->data[] = $data;
|
2012-09-21 15:42:13 +02:00
|
|
|
|
2013-02-14 14:37:33 +01:00
|
|
|
$html = html_print_table ($table, true);
|
|
|
|
|
|
|
|
return $html;
|
2012-09-21 15:42:13 +02:00
|
|
|
}
|
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
/**
|
|
|
|
* Returns 1 if the given address is a network address.
|
|
|
|
*
|
|
|
|
* @param string address Host or network address.
|
|
|
|
*
|
|
|
|
* @return 1 if the address is a network address, 0 otherwise.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function netflow_is_net ($address) {
|
|
|
|
if (strpos ($address, '/') !== FALSE) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns netflow data for the given period in an array.
|
|
|
|
*
|
|
|
|
* @param string start_date Period start date.
|
|
|
|
* @param string end_date Period end date.
|
2012-10-02 13:11:58 +02:00
|
|
|
* @param string filter Netflow filter.
|
2012-01-11 17:34:53 +01:00
|
|
|
* @param string aggregate Aggregate field.
|
|
|
|
* @param int max Maximum number of aggregates.
|
|
|
|
* @param string unit Unit to show.
|
|
|
|
*
|
|
|
|
* @return An array with netflow stats.
|
|
|
|
*
|
|
|
|
*/
|
2012-12-13 12:04:12 +01:00
|
|
|
function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $aggregate, $max, $unit, $connection_name = '') {
|
2012-01-11 17:34:53 +01:00
|
|
|
global $nfdump_date_format;
|
|
|
|
global $config;
|
2013-02-04 13:19:17 +01:00
|
|
|
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
// Requesting remote data
|
|
|
|
if (defined ('METACONSOLE') && $connection_name != '') {
|
2012-12-13 12:04:12 +01:00
|
|
|
$data = metaconsole_call_remote_api ($connection_name, 'netflow_get_data', "$start_date|$end_date|$interval_length|" . base64_encode(json_encode($filter)) . "|$aggregate|$max|$unit");
|
2012-12-11 17:43:29 +01:00
|
|
|
return json_decode ($data, true);
|
|
|
|
}
|
2013-02-04 13:19:17 +01:00
|
|
|
|
2012-12-11 17:43:29 +01:00
|
|
|
// Calculate the number of intervals
|
|
|
|
if ($interval_length <= 0) {
|
|
|
|
$num_intervals = $config['graph_res'] * 50;
|
|
|
|
$period = $end_date - $start_date;
|
|
|
|
$interval_length = (int) ($period / $num_intervals);
|
2013-02-04 13:19:17 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-12-11 17:43:29 +01:00
|
|
|
$period = $end_date - $start_date;
|
|
|
|
$num_intervals = (int) ($period / $interval_length);
|
|
|
|
}
|
2013-02-04 13:19:17 +01:00
|
|
|
|
2012-12-11 17:43:29 +01:00
|
|
|
// Set a max number of intervals
|
2012-12-12 13:10:16 +01:00
|
|
|
if ($num_intervals > $config['netflow_max_resolution']) {
|
|
|
|
$num_intervals = $config['netflow_max_resolution'];
|
2012-12-11 17:43:29 +01:00
|
|
|
$interval_length = (int) ($period / $num_intervals);
|
|
|
|
}
|
2013-02-04 13:19:17 +01:00
|
|
|
|
2012-12-11 17:43:29 +01:00
|
|
|
// If there is aggregation calculate the top n
|
|
|
|
if ($aggregate != 'none') {
|
|
|
|
$values['data'] = array ();
|
|
|
|
$values['sources'] = array ();
|
|
|
|
|
|
|
|
// Get the command to call nfdump
|
|
|
|
$command = netflow_get_command ($filter);
|
|
|
|
|
|
|
|
// Suppress the header line and the statistics at the bottom and configure piped output
|
|
|
|
$command .= ' -q -o csv';
|
|
|
|
|
|
|
|
// Call nfdump
|
|
|
|
$agg_command = $command . " -s $aggregate/bytes -n $max -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
|
|
|
|
exec($agg_command, $string);
|
2013-02-04 13:19:17 +01:00
|
|
|
|
2012-12-11 17:43:29 +01:00
|
|
|
// Reamove the first line
|
|
|
|
$string[0] = '';
|
2013-02-04 13:19:17 +01:00
|
|
|
|
2012-12-11 17:43:29 +01:00
|
|
|
// Parse aggregates
|
|
|
|
foreach($string as $line){
|
|
|
|
if ($line=='') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$val = explode(',',$line);
|
|
|
|
if ($aggregate == 'proto') {
|
|
|
|
$values['sources'][$val[3]] = 1;
|
2013-02-04 13:19:17 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-12-11 17:43:29 +01:00
|
|
|
$values['sources'][$val[4]] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the filter
|
|
|
|
switch ($aggregate) {
|
|
|
|
case "proto":
|
|
|
|
$extra_filter = 'proto';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case "srcip":
|
|
|
|
$extra_filter = 'ip_src';
|
|
|
|
break;
|
|
|
|
case "srcport":
|
|
|
|
$extra_filter = 'src_port';
|
|
|
|
break;
|
|
|
|
case "dstip":
|
|
|
|
$extra_filter = 'ip_dst';
|
|
|
|
break;
|
|
|
|
case "dstport":
|
|
|
|
$extra_filter = 'dst_port';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (isset ($filter[$extra_filter]) && $filter[$extra_filter] != '') {
|
|
|
|
$filter[$extra_filter] .= ',';
|
|
|
|
}
|
|
|
|
$filter[$extra_filter] = implode (',', array_keys ($values['sources']));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$values = array ();
|
|
|
|
}
|
2013-02-04 13:19:17 +01:00
|
|
|
|
2012-12-13 12:04:12 +01:00
|
|
|
$interval_start = $start_date;
|
2012-12-11 17:43:29 +01:00
|
|
|
for ($i = 0; $i < $num_intervals; $i++, $interval_start+=$interval_length+1) {
|
|
|
|
$interval_end = $interval_start + $interval_length;
|
|
|
|
if ($interval_end > $end_date) {
|
|
|
|
$interval_end = $end_date;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($aggregate == 'none') {
|
2012-12-13 12:04:12 +01:00
|
|
|
$data = netflow_get_summary ($interval_start, $interval_end, $filter, $connection_name);
|
2012-12-11 17:43:29 +01:00
|
|
|
if (! isset ($data['totalbytes'])) {
|
|
|
|
$values[$interval_start]['data'] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($unit) {
|
|
|
|
case 'megabytes':
|
|
|
|
$values[$interval_start]['data'] = $data['totalbytes'] / 1048576;
|
|
|
|
break;
|
|
|
|
case 'megabytespersecond':
|
|
|
|
$values[$interval_start]['data'] = $data['avgbps'] / 1048576 / 8;
|
|
|
|
break;
|
|
|
|
case 'kilobytes':
|
2012-12-13 12:04:12 +01:00
|
|
|
$values[$interval_start]['data'] = $data['totalbytes'] / 1024;
|
2012-12-11 17:43:29 +01:00
|
|
|
break;
|
|
|
|
case 'kilobytespersecond':
|
|
|
|
$values[$interval_start]['data'] = $data['avgbps'] / 1024 / 8;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$values[$interval_start]['data'] = $data['totalbytes'];
|
|
|
|
break;
|
|
|
|
}
|
2013-02-04 13:19:17 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-12-11 17:43:29 +01:00
|
|
|
|
|
|
|
// Set default values
|
|
|
|
foreach ($values['sources'] as $source => $discard) {
|
|
|
|
$values['data'][$interval_start][$source] = 0;
|
|
|
|
}
|
|
|
|
$data = netflow_get_stats ($interval_start, $interval_end, $filter, $aggregate, $max, $unit, $connection_name);
|
|
|
|
foreach ($data as $line) {
|
|
|
|
if (! isset ($values['sources'][$line['agg']])) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-02-04 13:19:17 +01:00
|
|
|
|
2012-12-12 13:10:16 +01:00
|
|
|
$values['data'][$interval_start][$line['agg']] = $line['data'];
|
2012-12-11 17:43:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-04 13:19:17 +01:00
|
|
|
|
|
|
|
if (($aggregate != 'none') && (empty($values['data']))) {
|
|
|
|
return array();
|
|
|
|
}
|
2014-04-16 16:42:28 +02:00
|
|
|
|
2012-12-11 17:43:29 +01:00
|
|
|
return $values;
|
|
|
|
}
|
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
/**
|
|
|
|
* Returns netflow stats for the given period in an array.
|
|
|
|
*
|
|
|
|
* @param string start_date Period start date.
|
|
|
|
* @param string end_date Period end date.
|
2012-10-02 13:11:58 +02:00
|
|
|
* @param string filter Netflow filter.
|
2012-01-11 17:34:53 +01:00
|
|
|
* @param string aggregate Aggregate field.
|
|
|
|
* @param int max Maximum number of aggregates.
|
|
|
|
* @param string unit Unit to show.
|
|
|
|
*
|
|
|
|
* @return An array with netflow stats.
|
|
|
|
*/
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $unit, $connection_name = '') {
|
2012-01-11 17:34:53 +01:00
|
|
|
global $nfdump_date_format;
|
2012-10-02 13:11:58 +02:00
|
|
|
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
// Requesting remote data
|
|
|
|
if (defined ('METACONSOLE') && $connection_name != '') {
|
|
|
|
$data = metaconsole_call_remote_api ($connection_name, 'netflow_get_stats', "$start_date|$end_date|" . base64_encode(json_encode($filter)) . "|$aggregate|$max|$unit");
|
|
|
|
return json_decode ($data, true);
|
|
|
|
}
|
|
|
|
|
2012-10-02 13:11:58 +02:00
|
|
|
// Get the command to call nfdump
|
|
|
|
$command = netflow_get_command ($filter);
|
|
|
|
|
|
|
|
// Execute nfdump
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
$command .= " -o csv -q -s $aggregate/bytes -n $max -t " .date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
|
2012-01-11 17:34:53 +01:00
|
|
|
exec($command, $string);
|
2012-12-13 12:04:12 +01:00
|
|
|
|
2012-08-02 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb_data.sql, pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql, include/functions_config.php: fixed the
"list_ACL_IPs_for_API" update.
* operation/events/events_marquee.php, godmode/setup/setup.php,
godmode/reporting/graph_builder.php,
godmode/reporting/map_builder.php, godmode/reporting/graphs.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.builder.php,
godmode/alerts/configure_alert_special_days.php,
include/functions_api.php, include/functions_ui.php,
include/functions_netflow.php, include/functions_alerts.php,
include/functions_menu.php, include/functions_messages.php: cleaned
source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6846 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-08-03 14:48:09 +02:00
|
|
|
if (! is_array($string)) {
|
2012-01-11 17:34:53 +01:00
|
|
|
return array ();
|
|
|
|
}
|
2012-12-06 19:12:28 +01:00
|
|
|
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
// Remove the first line
|
|
|
|
$string[0] = '';
|
2012-12-06 19:12:28 +01:00
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
$i = 0;
|
|
|
|
$values = array();
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
$interval_length = $end_date - $start_date;
|
2012-08-02 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb_data.sql, pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql, include/functions_config.php: fixed the
"list_ACL_IPs_for_API" update.
* operation/events/events_marquee.php, godmode/setup/setup.php,
godmode/reporting/graph_builder.php,
godmode/reporting/map_builder.php, godmode/reporting/graphs.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.builder.php,
godmode/alerts/configure_alert_special_days.php,
include/functions_api.php, include/functions_ui.php,
include/functions_netflow.php, include/functions_alerts.php,
include/functions_menu.php, include/functions_messages.php: cleaned
source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6846 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-08-03 14:48:09 +02:00
|
|
|
foreach ($string as $line) {
|
2012-01-11 17:34:53 +01:00
|
|
|
if ($line == '') {
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
continue;
|
2012-01-11 17:34:53 +01:00
|
|
|
}
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
|
|
|
|
$val = explode(',',$line);
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
$values[$i]['date'] = $val[0];
|
|
|
|
$values[$i]['time'] = $val[1];
|
|
|
|
|
|
|
|
//create field to sort array
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
$datetime = $val[0];
|
|
|
|
$end_date = strtotime ($datetime);
|
2012-01-11 17:34:53 +01:00
|
|
|
$values[$i]['datetime'] = $end_date;
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
if ($aggregate == 'proto') {
|
|
|
|
$values[$i]['agg'] = $val[3];
|
2013-03-05 12:00:40 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
$values[$i]['agg'] = $val[4];
|
|
|
|
}
|
|
|
|
if (! isset ($val[9])) {
|
2012-11-29 19:16:40 +01:00
|
|
|
return array ();
|
|
|
|
}
|
2012-01-11 17:34:53 +01:00
|
|
|
|
|
|
|
switch ($unit){
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
case "megabytes":
|
|
|
|
$values[$i]['data'] = $val[9] / 1048576;
|
|
|
|
break;
|
|
|
|
case "megabytespersecond":
|
|
|
|
$values[$i]['data'] = $val[9] / 1048576 / $interval_length;
|
2012-01-17 15:01:49 +01:00
|
|
|
break;
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
case "kilobytes":
|
|
|
|
$values[$i]['data'] = $val[9] / 1024;
|
|
|
|
break;
|
|
|
|
case "kilobytespersecond":
|
|
|
|
$values[$i]['data'] = $val[9] / 1024 / $interval_length;
|
2012-01-11 17:34:53 +01:00
|
|
|
break;
|
|
|
|
default:
|
2012-12-12 13:10:16 +01:00
|
|
|
case "bytes":
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
$values[$i]['data'] = $val[9];
|
2012-01-11 17:34:53 +01:00
|
|
|
break;
|
2012-12-12 13:10:16 +01:00
|
|
|
case "bytespersecond":
|
|
|
|
$values[$i]['data'] = $val[9] / $interval_length;
|
|
|
|
break;
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
2012-01-11 17:34:53 +01:00
|
|
|
$i++;
|
|
|
|
}
|
2012-12-06 19:12:28 +01:00
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
sort_netflow_data ($values);
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
return $values;
|
|
|
|
}
|
|
|
|
|
2012-09-21 15:42:13 +02:00
|
|
|
/**
|
|
|
|
* Returns a traffic summary for the given period in an array.
|
|
|
|
*
|
|
|
|
* @param string start_date Period start date.
|
|
|
|
* @param string end_date Period end date.
|
2012-10-02 13:11:58 +02:00
|
|
|
* @param string filter Netflow filter.
|
2012-09-21 15:42:13 +02:00
|
|
|
*
|
|
|
|
* @return An array with netflow stats.
|
|
|
|
*/
|
2012-12-13 12:04:12 +01:00
|
|
|
function netflow_get_summary ($start_date, $end_date, $filter, $connection_name = '') {
|
2012-09-21 15:42:13 +02:00
|
|
|
global $nfdump_date_format;
|
|
|
|
global $config;
|
2012-10-02 13:11:58 +02:00
|
|
|
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
// Requesting remote data
|
|
|
|
if (defined ('METACONSOLE') && $connection_name != '') {
|
2012-12-13 12:04:12 +01:00
|
|
|
$data = metaconsole_call_remote_api ($connection_name, 'netflow_get_summary', "$start_date|$end_date|" . base64_encode(json_encode($filter)));
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
return json_decode ($data, true);
|
|
|
|
}
|
|
|
|
|
2012-10-02 13:11:58 +02:00
|
|
|
// Get the command to call nfdump
|
|
|
|
$command = netflow_get_command ($filter);
|
|
|
|
|
2012-12-13 12:04:12 +01:00
|
|
|
// Execute nfdump
|
|
|
|
$command .= " -o csv -s srcip/bytes -n 1 -t " .date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
|
|
|
|
exec($command, $string);
|
|
|
|
|
|
|
|
if (! is_array($string) || ! isset ($string[5])) {
|
|
|
|
return array ();
|
|
|
|
}
|
2012-12-06 19:12:28 +01:00
|
|
|
|
2012-12-13 12:04:12 +01:00
|
|
|
// Read the summary
|
|
|
|
$summary = explode (',', $string[5]);
|
|
|
|
if (! isset ($summary[5])) {
|
|
|
|
return array ();
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['totalflows'] = $summary[0];
|
|
|
|
$values['totalbytes'] = $summary[1];
|
|
|
|
$values['totalpackets'] = $summary[2];
|
|
|
|
$values['avgbps'] = $summary[3];
|
|
|
|
$values['avgpps'] = $summary[4];
|
|
|
|
$values['avgbpp'] = $summary[5];
|
2012-09-21 15:42:13 +02:00
|
|
|
|
|
|
|
return $values;
|
|
|
|
}
|
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
/**
|
|
|
|
* Returns the command needed to run nfdump for the given filter.
|
|
|
|
*
|
|
|
|
* @param array filter Netflow filter.
|
|
|
|
*
|
|
|
|
* @return Command to run.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function netflow_get_command ($filter) {
|
|
|
|
global $config;
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
// Build command
|
2012-12-11 17:43:29 +01:00
|
|
|
$command = io_safe_output ($config['netflow_nfdump']) . ' -N -Otstart';
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
// Netflow data path
|
|
|
|
if (isset($config['netflow_path']) && $config['netflow_path'] != '') {
|
2013-05-23 18:21:28 +02:00
|
|
|
$command .= ' -R. -M '.$config['netflow_path'];
|
2012-01-11 17:34:53 +01:00
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-24 Ramon Novoa <rnovoa@artica.es>
* include/functions_config.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/configurar_agente.php,
godmode/menu.php,
godmode/netflow/nf_edit_form.php: Added support for enterprise
netflow modules.
* godmode/netflow/nf_manage.php: Moved to
godmode/setup/setup_netflow.php.
* godmode/netflow/nf_option_form.php: Removed from repository. Not used.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5416 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-01-24 18:11:12 +01:00
|
|
|
// Filter options
|
|
|
|
$command .= netflow_get_filter_arguments ($filter);
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-24 Ramon Novoa <rnovoa@artica.es>
* include/functions_config.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/configurar_agente.php,
godmode/menu.php,
godmode/netflow/nf_edit_form.php: Added support for enterprise
netflow modules.
* godmode/netflow/nf_manage.php: Moved to
godmode/setup/setup_netflow.php.
* godmode/netflow/nf_option_form.php: Removed from repository. Not used.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5416 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-01-24 18:11:12 +01:00
|
|
|
return $command;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the nfdump command line arguments that match the given filter.
|
|
|
|
*
|
|
|
|
* @param array filter Netflow filter.
|
|
|
|
*
|
|
|
|
* @return Command line argument string.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function netflow_get_filter_arguments ($filter) {
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-17 15:01:49 +01:00
|
|
|
// Advanced filter
|
2012-01-11 17:34:53 +01:00
|
|
|
$filter_args = '';
|
2012-01-17 15:01:49 +01:00
|
|
|
if ($filter['advanced_filter'] != '') {
|
2012-01-17 16:37:50 +01:00
|
|
|
$filter_args = preg_replace('/["\r\n]/','', io_safe_output ($filter['advanced_filter']));
|
2012-01-24 Ramon Novoa <rnovoa@artica.es>
* include/functions_config.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/configurar_agente.php,
godmode/menu.php,
godmode/netflow/nf_edit_form.php: Added support for enterprise
netflow modules.
* godmode/netflow/nf_manage.php: Moved to
godmode/setup/setup_netflow.php.
* godmode/netflow/nf_option_form.php: Removed from repository. Not used.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5416 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-01-24 18:11:12 +01:00
|
|
|
return ' "(' . $filter_args . ')"';
|
2012-01-17 15:01:49 +01:00
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-17 15:01:49 +01:00
|
|
|
// Normal filter
|
2012-08-02 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb_data.sql, pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql, include/functions_config.php: fixed the
"list_ACL_IPs_for_API" update.
* operation/events/events_marquee.php, godmode/setup/setup.php,
godmode/reporting/graph_builder.php,
godmode/reporting/map_builder.php, godmode/reporting/graphs.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.builder.php,
godmode/alerts/configure_alert_special_days.php,
include/functions_api.php, include/functions_ui.php,
include/functions_netflow.php, include/functions_alerts.php,
include/functions_menu.php, include/functions_messages.php: cleaned
source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6846 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-08-03 14:48:09 +02:00
|
|
|
if ($filter['ip_dst'] != '') {
|
2012-01-11 17:34:53 +01:00
|
|
|
$filter_args .= ' "(';
|
2012-12-11 17:43:29 +01:00
|
|
|
$val_ipdst = explode(',', io_safe_output ($filter['ip_dst']));
|
2012-01-11 17:34:53 +01:00
|
|
|
for($i = 0; $i < count ($val_ipdst); $i++){
|
|
|
|
if ($i > 0) {
|
|
|
|
$filter_args .= ' or ';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (netflow_is_net ($val_ipdst[$i]) == 0) {
|
|
|
|
$filter_args .= 'dst ip '.$val_ipdst[$i];
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-11 17:34:53 +01:00
|
|
|
$filter_args .= 'dst net '.$val_ipdst[$i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$filter_args .= ')';
|
|
|
|
}
|
2012-08-02 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb_data.sql, pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql, include/functions_config.php: fixed the
"list_ACL_IPs_for_API" update.
* operation/events/events_marquee.php, godmode/setup/setup.php,
godmode/reporting/graph_builder.php,
godmode/reporting/map_builder.php, godmode/reporting/graphs.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.builder.php,
godmode/alerts/configure_alert_special_days.php,
include/functions_api.php, include/functions_ui.php,
include/functions_netflow.php, include/functions_alerts.php,
include/functions_menu.php, include/functions_messages.php: cleaned
source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6846 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-08-03 14:48:09 +02:00
|
|
|
if ($filter['ip_src'] != '') {
|
2012-01-11 17:34:53 +01:00
|
|
|
if ($filter_args == '') {
|
|
|
|
$filter_args .= ' "(';
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-11 17:34:53 +01:00
|
|
|
$filter_args .= ' and (';
|
|
|
|
}
|
2012-12-11 17:43:29 +01:00
|
|
|
$val_ipsrc = explode(',', io_safe_output ($filter['ip_src']));
|
2012-08-02 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb_data.sql, pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql, include/functions_config.php: fixed the
"list_ACL_IPs_for_API" update.
* operation/events/events_marquee.php, godmode/setup/setup.php,
godmode/reporting/graph_builder.php,
godmode/reporting/map_builder.php, godmode/reporting/graphs.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.builder.php,
godmode/alerts/configure_alert_special_days.php,
include/functions_api.php, include/functions_ui.php,
include/functions_netflow.php, include/functions_alerts.php,
include/functions_menu.php, include/functions_messages.php: cleaned
source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6846 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-08-03 14:48:09 +02:00
|
|
|
for ($i = 0; $i < count ($val_ipsrc); $i++) {
|
2012-01-11 17:34:53 +01:00
|
|
|
if ($i > 0) {
|
|
|
|
$filter_args .= ' or ';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (netflow_is_net ($val_ipsrc[$i]) == 0) {
|
|
|
|
$filter_args .= 'src ip '.$val_ipsrc[$i];
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-11 17:34:53 +01:00
|
|
|
$filter_args .= 'src net '.$val_ipsrc[$i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$filter_args .= ')';
|
|
|
|
}
|
2012-12-11 17:43:29 +01:00
|
|
|
if ($filter['dst_port'] != '') {
|
2012-01-11 17:34:53 +01:00
|
|
|
if ($filter_args == '') {
|
|
|
|
$filter_args .= ' "(';
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-11 17:34:53 +01:00
|
|
|
$filter_args .= ' and (';
|
|
|
|
}
|
2012-12-11 17:43:29 +01:00
|
|
|
$val_dstport = explode(',', io_safe_output ($filter['dst_port']));
|
2012-08-02 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb_data.sql, pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql, include/functions_config.php: fixed the
"list_ACL_IPs_for_API" update.
* operation/events/events_marquee.php, godmode/setup/setup.php,
godmode/reporting/graph_builder.php,
godmode/reporting/map_builder.php, godmode/reporting/graphs.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.builder.php,
godmode/alerts/configure_alert_special_days.php,
include/functions_api.php, include/functions_ui.php,
include/functions_netflow.php, include/functions_alerts.php,
include/functions_menu.php, include/functions_messages.php: cleaned
source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6846 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-08-03 14:48:09 +02:00
|
|
|
for ($i = 0; $i < count ($val_dstport); $i++) {
|
2012-01-11 17:34:53 +01:00
|
|
|
if ($i > 0) {
|
|
|
|
$filter_args .= ' or ';
|
|
|
|
}
|
|
|
|
$filter_args .= 'dst port '.$val_dstport[$i];
|
|
|
|
}
|
|
|
|
$filter_args .= ')';
|
|
|
|
}
|
2012-12-11 17:43:29 +01:00
|
|
|
if ($filter['src_port'] != '') {
|
2012-01-11 17:34:53 +01:00
|
|
|
if ($filter_args == '') {
|
|
|
|
$filter_args .= ' "(';
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-11 17:34:53 +01:00
|
|
|
$filter_args .= ' and (';
|
|
|
|
}
|
2012-12-11 17:43:29 +01:00
|
|
|
$val_srcport = explode(',', io_safe_output ($filter['src_port']));
|
2012-08-02 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb_data.sql, pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql, include/functions_config.php: fixed the
"list_ACL_IPs_for_API" update.
* operation/events/events_marquee.php, godmode/setup/setup.php,
godmode/reporting/graph_builder.php,
godmode/reporting/map_builder.php, godmode/reporting/graphs.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.builder.php,
godmode/alerts/configure_alert_special_days.php,
include/functions_api.php, include/functions_ui.php,
include/functions_netflow.php, include/functions_alerts.php,
include/functions_menu.php, include/functions_messages.php: cleaned
source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6846 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-08-03 14:48:09 +02:00
|
|
|
for ($i = 0; $i < count ($val_srcport); $i++) {
|
2012-01-11 17:34:53 +01:00
|
|
|
if ($i > 0) {
|
|
|
|
$filter_args .= ' or ';
|
|
|
|
}
|
|
|
|
$filter_args .= 'src port '.$val_srcport[$i];
|
|
|
|
}
|
|
|
|
$filter_args .= ')';
|
|
|
|
}
|
2012-12-11 17:43:29 +01:00
|
|
|
if (isset ($filter['proto']) && $filter['proto'] != '') {
|
|
|
|
if ($filter_args == '') {
|
|
|
|
$filter_args .= ' "(';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$filter_args .= ' and (';
|
|
|
|
}
|
|
|
|
$val_proto = explode(',', io_safe_output ($filter['proto']));
|
|
|
|
for ($i = 0; $i < count ($val_proto); $i++) {
|
|
|
|
if ($i > 0) {
|
|
|
|
$filter_args .= ' or ';
|
|
|
|
}
|
|
|
|
$filter_args .= 'proto '.$val_proto[$i];
|
|
|
|
}
|
|
|
|
$filter_args .= ')';
|
|
|
|
}
|
2012-01-11 17:34:53 +01:00
|
|
|
if ($filter_args != '') {
|
2012-01-24 Ramon Novoa <rnovoa@artica.es>
* include/functions_config.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/configurar_agente.php,
godmode/menu.php,
godmode/netflow/nf_edit_form.php: Added support for enterprise
netflow modules.
* godmode/netflow/nf_manage.php: Moved to
godmode/setup/setup_netflow.php.
* godmode/netflow/nf_option_form.php: Removed from repository. Not used.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5416 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-01-24 18:11:12 +01:00
|
|
|
$filter_args .= '"';
|
2012-01-11 17:34:53 +01:00
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-24 Ramon Novoa <rnovoa@artica.es>
* include/functions_config.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/configurar_agente.php,
godmode/menu.php,
godmode/netflow/nf_edit_form.php: Added support for enterprise
netflow modules.
* godmode/netflow/nf_manage.php: Moved to
godmode/setup/setup_netflow.php.
* godmode/netflow/nf_option_form.php: Removed from repository. Not used.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5416 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-01-24 18:11:12 +01:00
|
|
|
return $filter_args;
|
2011-12-21 16:28:01 +01:00
|
|
|
}
|
|
|
|
|
2012-01-20 14:14:09 +01:00
|
|
|
/**
|
|
|
|
* Get the types of netflow charts.
|
|
|
|
*
|
|
|
|
* @return Array of types.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function netflow_get_chart_types () {
|
|
|
|
return array(
|
2013-02-14 14:37:33 +01:00
|
|
|
'netflow_area' => __('Area graph'),
|
|
|
|
'netflow_pie_summatory' => __('Pie graph and Summary table'),
|
|
|
|
'netflow_statistics' => __('Statistics table'),
|
|
|
|
'netflow_data' => __('Data table'));
|
2012-01-20 14:14:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets valid intervals for a netflow chart in the format:
|
|
|
|
*
|
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* include/constants.php: added more constants into the constants
block of time conversion to seconds.
* godmode/alerts/alert_commands.php, godmode/setup/performance.php,
include/help/en/help_date_format.php, include/functions_netflow.php,
include/functions_tags.php, include/graphs/functions_pchart.php,
include/functions_modules.php, extensions/agents_modules.php,
extensions/update_manager.php, extensions/resource_exportation.php,
extensions/module_groups.php,
extensions/update_manager/lib/libupdate_manager_client.php,
extensions/system_info.php, operation/events/events_rss.php,
operation/events/export_csv.php, mobile/operation/events/events.php,
mobile/include/system.class.php: used the new constants time instead
the magic numbers, and cleaned source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6762 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-10 15:31:34 +02:00
|
|
|
* interval_length => interval_description
|
2012-01-20 14:14:09 +01:00
|
|
|
*
|
|
|
|
* @return Array of valid intervals.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function netflow_get_valid_intervals () {
|
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* include/constants.php: added more constants into the constants
block of time conversion to seconds.
* godmode/alerts/alert_commands.php, godmode/setup/performance.php,
include/help/en/help_date_format.php, include/functions_netflow.php,
include/functions_tags.php, include/graphs/functions_pchart.php,
include/functions_modules.php, extensions/agents_modules.php,
extensions/update_manager.php, extensions/resource_exportation.php,
extensions/module_groups.php,
extensions/update_manager/lib/libupdate_manager_client.php,
extensions/system_info.php, operation/events/events_rss.php,
operation/events/export_csv.php, mobile/operation/events/events.php,
mobile/include/system.class.php: used the new constants time instead
the magic numbers, and cleaned source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6762 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-10 15:31:34 +02:00
|
|
|
return array (
|
|
|
|
(string)SECONDS_10MINUTES => __('10 mins'),
|
|
|
|
(string)SECONDS_15MINUTES => __('15 mins'),
|
|
|
|
(string)SECONDS_30MINUTES => __('30 mins'),
|
|
|
|
(string)SECONDS_1HOUR => __('1 hour'),
|
|
|
|
(string)SECONDS_2HOUR => __('2 hours'),
|
|
|
|
(string)SECONDS_5HOUR => __('5 hours'),
|
|
|
|
(string)SECONDS_12HOURS => __('12 hours'),
|
|
|
|
(string)SECONDS_1DAY => __('1 day'),
|
|
|
|
(string)SECONDS_2DAY => __('2 days'),
|
|
|
|
(string)SECONDS_5DAY => __('5 days'),
|
|
|
|
(string)SECONDS_15DAYS => __('15 days'),
|
|
|
|
(string)SECONDS_1WEEK => __('Last week'),
|
|
|
|
(string)SECONDS_1MONTH => __('Last month'),
|
|
|
|
(string)SECONDS_2MONTHS => __('2 months'),
|
|
|
|
(string)SECONDS_3MONTHS => __('3 months'),
|
|
|
|
(string)SECONDS_6MONTHS => __('6 months'),
|
|
|
|
(string)SECONDS_1YEAR => __('Last year'),
|
|
|
|
(string)SECONDS_2YEARS => __('2 years'));
|
2012-01-20 14:14:09 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php,
godmode/netflow/nf_edit_form.php: Performance improvements. Use csv
output to avoid using regular expressions. Removed byte, flow and
packet unit and added kilobyte, megabyte, kilobytes per second and
megabytes per second.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7232 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 18:29:06 +01:00
|
|
|
/**
|
|
|
|
* Gets valid intervals for a netflow chart in the format:
|
|
|
|
*
|
|
|
|
* interval_length => interval_description
|
|
|
|
*
|
|
|
|
* @return Array of valid intervals.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function netflow_get_valid_subintervals () {
|
|
|
|
return array (
|
|
|
|
(string)SECONDS_1MINUTE => __('1 min'),
|
|
|
|
(string)SECONDS_2MINUTES => __('2 mins'),
|
|
|
|
(string)SECONDS_5MINUTES => __('5 mins'),
|
|
|
|
(string)SECONDS_10MINUTES => __('10 mins'),
|
|
|
|
(string)SECONDS_15MINUTES => __('15 mins'),
|
|
|
|
(string)SECONDS_30MINUTES => __('30 mins'),
|
|
|
|
(string)SECONDS_1HOUR => __('1 hour'),
|
|
|
|
(string)SECONDS_2HOUR => __('2 hours'),
|
|
|
|
(string)SECONDS_5HOUR => __('5 hours'),
|
|
|
|
(string)SECONDS_12HOURS => __('12 hours'),
|
|
|
|
(string)SECONDS_1DAY => __('1 day'),
|
|
|
|
(string)SECONDS_2DAY => __('2 days'),
|
|
|
|
(string)SECONDS_5DAY => __('5 days'),
|
|
|
|
(string)SECONDS_15DAYS => __('15 days'),
|
|
|
|
(string)SECONDS_1WEEK => __('1 week'),
|
|
|
|
(string)SECONDS_1MONTH => __('1 month'));
|
|
|
|
}
|
|
|
|
|
2012-01-20 14:14:09 +01:00
|
|
|
/**
|
|
|
|
* Draw a netflow report item.
|
|
|
|
*
|
|
|
|
* @param string start_date Period start date.
|
|
|
|
* @param string end_date Period end date.
|
2012-10-11 17:52:26 +02:00
|
|
|
* @param string interval_length Interval length in seconds (num_intervals * interval_length = start_date - end_date).
|
2012-01-20 14:14:09 +01:00
|
|
|
* @param string type Chart type.
|
|
|
|
* @param array filter Netflow filter.
|
|
|
|
* @param int max_aggregates Maximum number of aggregates.
|
2012-10-02 13:11:58 +02:00
|
|
|
* @param string output Output format. Only HTML and XML are supported.
|
2012-01-20 14:14:09 +01:00
|
|
|
*
|
2012-10-08 21:19:58 +02:00
|
|
|
* @return The netflow report in the appropriate format.
|
2012-01-20 14:14:09 +01:00
|
|
|
*/
|
2012-12-13 12:04:12 +01:00
|
|
|
function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $filter, $max_aggregates, $connection_name = '', $output = 'HTML', $only_image = false) {
|
2012-01-20 14:14:09 +01:00
|
|
|
$aggregate = $filter['aggregate'];
|
|
|
|
$unit = $filter['output'];
|
|
|
|
$interval = $end_date - $start_date;
|
2013-01-24 16:00:31 +01:00
|
|
|
|
2012-01-20 14:14:09 +01:00
|
|
|
// Process item
|
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* include/constants.php: added more constants into the constants
block of time conversion to seconds.
* godmode/alerts/alert_commands.php, godmode/setup/performance.php,
include/help/en/help_date_format.php, include/functions_netflow.php,
include/functions_tags.php, include/graphs/functions_pchart.php,
include/functions_modules.php, extensions/agents_modules.php,
extensions/update_manager.php, extensions/resource_exportation.php,
extensions/module_groups.php,
extensions/update_manager/lib/libupdate_manager_client.php,
extensions/system_info.php, operation/events/events_rss.php,
operation/events/export_csv.php, mobile/operation/events/events.php,
mobile/include/system.class.php: used the new constants time instead
the magic numbers, and cleaned source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6762 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-10 15:31:34 +02:00
|
|
|
switch ($type) {
|
2012-01-20 14:14:09 +01:00
|
|
|
case '0':
|
2012-10-25 20:34:53 +02:00
|
|
|
case 'netflow_area':
|
2012-12-13 12:04:12 +01:00
|
|
|
$data = netflow_get_data ($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, $unit, $connection_name);
|
2012-11-29 19:01:56 +01:00
|
|
|
if (empty ($data)) {
|
|
|
|
break;
|
|
|
|
}
|
2012-01-20 14:14:09 +01:00
|
|
|
if ($aggregate != 'none') {
|
2012-10-02 13:11:58 +02:00
|
|
|
if ($output == 'HTML') {
|
2012-12-07 15:43:53 +01:00
|
|
|
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
|
|
|
$html .= " <b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
if ($interval_length != 0) {
|
|
|
|
$html .= " <b>" . _('Resolution') . ":</b> $interval_length " . __('seconds');
|
|
|
|
}
|
2012-12-13 19:12:17 +01:00
|
|
|
$html .= graph_netflow_aggregate_area ($data, $interval, 850, 320, netflow_format_unit ($unit));
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
return $html;
|
2013-02-14 14:37:33 +01:00
|
|
|
}
|
|
|
|
else if ($output == 'PDF') {
|
2012-12-07 15:43:53 +01:00
|
|
|
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
|
|
|
$html .= " <b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
if ($interval_length != 0) {
|
|
|
|
$html .= " <b>" . _('Resolution') . ":</b> $interval_length " . __('seconds');
|
|
|
|
}
|
2012-12-13 19:12:17 +01:00
|
|
|
$html .= graph_netflow_aggregate_area ($data, $interval, 850, 320, netflow_format_unit ($unit), 2, true);
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
return $html;
|
2013-02-14 14:37:33 +01:00
|
|
|
}
|
|
|
|
else if ($output == 'XML') {
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
$xml = "<unit>$unit</unit>\n";
|
|
|
|
$xml .= "<aggregate>$aggregate</aggregate>\n";
|
|
|
|
$xml .= "<resolution>$interval_length</resolution>\n";
|
|
|
|
$xml .= netflow_aggregate_area_xml ($data);
|
|
|
|
return $xml;
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* include/constants.php: added more constants into the constants
block of time conversion to seconds.
* godmode/alerts/alert_commands.php, godmode/setup/performance.php,
include/help/en/help_date_format.php, include/functions_netflow.php,
include/functions_tags.php, include/graphs/functions_pchart.php,
include/functions_modules.php, extensions/agents_modules.php,
extensions/update_manager.php, extensions/resource_exportation.php,
extensions/module_groups.php,
extensions/update_manager/lib/libupdate_manager_client.php,
extensions/system_info.php, operation/events/events_rss.php,
operation/events/export_csv.php, mobile/operation/events/events.php,
mobile/include/system.class.php: used the new constants time instead
the magic numbers, and cleaned source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6762 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-10 15:31:34 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-10-02 13:11:58 +02:00
|
|
|
if ($output == 'HTML') {
|
2012-12-07 15:43:53 +01:00
|
|
|
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
if ($interval_length != 0) {
|
|
|
|
$html .= " <b>" . _('Resolution') . ":</b> $interval_length " . __('seconds');
|
|
|
|
}
|
2012-12-07 15:43:53 +01:00
|
|
|
$html .= graph_netflow_total_area ($data, $interval, 660, 320, netflow_format_unit ($unit));
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
return $html;
|
2013-02-14 14:37:33 +01:00
|
|
|
}
|
|
|
|
else if ($output == 'PDF') {
|
2012-12-07 15:43:53 +01:00
|
|
|
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
if ($interval_length != 0) {
|
|
|
|
$html .= " <b>" . _('Resolution') . ":</b> $interval_length " . __('seconds');
|
|
|
|
}
|
2012-12-07 15:43:53 +01:00
|
|
|
$html .= graph_netflow_total_area ($data, $interval, 660, 320, netflow_format_unit ($unit), 2, true);
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
return $html;
|
2013-02-14 14:37:33 +01:00
|
|
|
}
|
|
|
|
else if ($output == 'XML') {
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
$xml = "<unit>$unit</unit>\n";
|
|
|
|
$xml .= "<resolution>$interval_length</resolution>\n";
|
|
|
|
$xml .= netflow_total_area_xml ($data);
|
|
|
|
return $xml;
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
2012-01-20 14:14:09 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '2':
|
2012-10-25 20:34:53 +02:00
|
|
|
case 'netflow_data':
|
2012-12-13 12:04:12 +01:00
|
|
|
$data = netflow_get_data ($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, $unit, $connection_name);
|
2013-01-24 16:00:31 +01:00
|
|
|
|
2012-11-29 19:01:56 +01:00
|
|
|
if (empty ($data)) {
|
|
|
|
break;
|
|
|
|
}
|
2012-10-08 21:19:58 +02:00
|
|
|
if ($output == 'HTML' || $output == 'PDF') {
|
2012-12-07 15:43:53 +01:00
|
|
|
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
|
|
|
$html .= " <b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
if ($interval_length != 0) {
|
|
|
|
$html .= " <b>" . _('Resolution') . ":</b> $interval_length " . __('seconds');
|
|
|
|
}
|
2012-12-07 15:03:00 +01:00
|
|
|
$html .= netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit);
|
2013-02-04 13:19:17 +01:00
|
|
|
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
return $html;
|
2013-02-04 13:19:17 +01:00
|
|
|
}
|
|
|
|
else if ($output == 'XML') {
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
$xml = "<unit>$unit</unit>\n";
|
|
|
|
$xml .= "<aggregate>$aggregate</aggregate>\n";
|
|
|
|
$xml .= "<resolution>$interval_length</resolution>\n";
|
2012-10-02 13:11:58 +02:00
|
|
|
// Same as netflow_aggregate_area_xml
|
2012-10-29 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
include/javascript/pandora_modules.js,
include/functions_network_components.php,
include/functions_api.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extensions/resource_registration.php,
extensions/plugin_registration.php,
operation/menu.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/servers/plugin.php,
godmode/menu.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php: Added support for
custom timeout and retries to remote modules.
* operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf.php: Deleted from repository. Netflow reports are
now integrated into custom reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7103 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-29 11:13:49 +01:00
|
|
|
$xml .= netflow_aggregate_area_xml ($data);
|
|
|
|
return $xml;
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
2012-01-20 14:14:09 +01:00
|
|
|
break;
|
|
|
|
case '3':
|
2012-10-25 20:34:53 +02:00
|
|
|
case 'netflow_statistics':
|
2013-02-14 14:37:33 +01:00
|
|
|
$data = netflow_get_stats ($start_date, $end_date, $filter,
|
|
|
|
$aggregate, $max_aggregates, $unit, $connection_name);
|
2012-11-29 19:01:56 +01:00
|
|
|
if (empty ($data)) {
|
|
|
|
break;
|
|
|
|
}
|
2012-10-08 21:19:58 +02:00
|
|
|
if ($output == 'HTML' || $output == 'PDF') {
|
2012-12-07 15:03:00 +01:00
|
|
|
$html = netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit);
|
|
|
|
return $html;
|
2013-03-05 12:00:40 +01:00
|
|
|
}
|
|
|
|
else if ($output == 'XML') {
|
2012-10-08 21:19:58 +02:00
|
|
|
return netflow_stat_xml ($data);
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
2012-01-20 14:14:09 +01:00
|
|
|
break;
|
2012-09-21 15:42:13 +02:00
|
|
|
case '4':
|
2012-10-25 20:34:53 +02:00
|
|
|
case 'netflow_summary':
|
2013-02-14 14:37:33 +01:00
|
|
|
$data_summary = netflow_get_summary ($start_date, $end_date,
|
|
|
|
$filter, $connection_name);
|
2012-11-29 19:01:56 +01:00
|
|
|
if (empty ($data)) {
|
|
|
|
break;
|
|
|
|
}
|
2012-10-08 21:19:58 +02:00
|
|
|
if ($output == 'HTML' || $output == 'PDF') {
|
2013-02-14 14:37:33 +01:00
|
|
|
return netflow_summary_table ($data_summary);
|
|
|
|
}
|
|
|
|
else if ($output == 'XML') {
|
|
|
|
return netflow_summary_xml ($data_summary);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '1':
|
|
|
|
case 'netflow_pie':
|
|
|
|
$data_pie = netflow_get_stats ($start_date, $end_date,
|
|
|
|
$filter, $aggregate, $max_aggregates, $unit,
|
|
|
|
$connection_name);
|
|
|
|
if (empty ($data_pie)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ($output == 'HTML') {
|
|
|
|
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
|
|
|
$html .= " <b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
|
|
|
|
$html .= graph_netflow_aggregate_pie ($data_pie, netflow_format_aggregate ($aggregate));
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
else if ($output == 'PDF') {
|
|
|
|
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
|
|
|
$html .= " <b>" . __('Aggregate') . ":</b> $aggregate";
|
|
|
|
$html .= graph_netflow_aggregate_pie ($data_pie, netflow_format_aggregate ($aggregate), 2, true);
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
else if ($output == 'XML') {
|
|
|
|
$xml = "<unit>$unit</unit>\n";
|
|
|
|
$xml .= "<aggregate>$aggregate</aggregate>\n";
|
|
|
|
$xml .= netflow_aggregate_pie_xml ($data_pie);
|
|
|
|
return $xml;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'netflow_pie_summatory':
|
|
|
|
$data_summary = netflow_get_summary ($start_date, $end_date,
|
|
|
|
$filter, $connection_name);
|
|
|
|
if (empty ($data_summary)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data_pie = netflow_get_stats ($start_date, $end_date,
|
|
|
|
$filter, $aggregate, $max_aggregates, $unit,
|
|
|
|
$connection_name);
|
|
|
|
if (empty ($data_pie)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($output) {
|
|
|
|
case 'HTML':
|
|
|
|
$html = '<table>';
|
|
|
|
$html .= '<tr>';
|
|
|
|
$html .= '<td>';
|
|
|
|
$html .= netflow_summary_table ($data_summary);
|
|
|
|
$html .= "<b>" . __('Unit') . ":</b> " .
|
|
|
|
netflow_format_unit ($unit);
|
|
|
|
$html .= " <b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
|
|
|
|
$html .= '</td>';
|
|
|
|
$html .= '<td>';
|
|
|
|
$html .= graph_netflow_aggregate_pie ($data_pie, netflow_format_aggregate ($aggregate));
|
|
|
|
$html .= '</td>';
|
|
|
|
$html .= '</tr>';
|
|
|
|
$html .= '</table>';
|
|
|
|
return $html;
|
|
|
|
break;
|
|
|
|
case 'PDF':
|
|
|
|
break;
|
|
|
|
case 'XML':
|
|
|
|
return netflow_summary_xml ($data_summary);
|
|
|
|
break;
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
2012-09-21 15:42:13 +02:00
|
|
|
break;
|
2012-01-20 14:14:09 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-02-14 14:37:33 +01:00
|
|
|
|
2012-11-29 19:01:56 +01:00
|
|
|
if ($output == 'HTML' || $output == 'PDF') {
|
2013-06-10 18:15:36 +02:00
|
|
|
return graph_nodata_image(300, 110, 'data');
|
2012-11-29 19:01:56 +01:00
|
|
|
}
|
2012-01-20 14:14:09 +01:00
|
|
|
}
|
2012-10-02 13:11:58 +02:00
|
|
|
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
/**
|
|
|
|
* Render a netflow report as an XML.
|
|
|
|
*
|
|
|
|
* @param int ID of the netflow report.
|
|
|
|
* @param string end_date Period start date.
|
|
|
|
* @param string end_date Period end date.
|
2012-10-11 17:52:26 +02:00
|
|
|
* @param string interval_length Interval length in seconds (num_intervals * interval_length = start_date - end_date).
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
*
|
|
|
|
*/
|
2012-10-11 17:52:26 +02:00
|
|
|
function netflow_xml_report ($id, $start_date, $end_date, $interval_length = 0) {
|
2012-10-02 13:11:58 +02:00
|
|
|
|
|
|
|
// Get report data
|
|
|
|
$report = db_get_row_sql ('SELECT * FROM tnetflow_report WHERE id_report =' . (int) $id);
|
|
|
|
if ($report === FALSE) {
|
|
|
|
echo "<report>" . __('Error generating report') . "</report>\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print report header
|
|
|
|
$time = get_system_time ();
|
|
|
|
echo '<?xml version="1.0" encoding="UTF-8" ?>';
|
|
|
|
echo "<report>\n";
|
|
|
|
echo " <generated>\n";
|
|
|
|
echo " <unix>" . $time . "</unix>\n";
|
|
|
|
echo " <rfc2822>" . date ("r", $time) . "</rfc2822>\n";
|
|
|
|
echo " </generated>\n";
|
|
|
|
echo " <name>" . io_safe_output ($report['id_name']) . "</name>\n";
|
|
|
|
echo " <description>" . io_safe_output ($report['description']) . "</description>\n";
|
|
|
|
echo " <start_date>" . date ("r", $start_date) . "</start_date>\n";
|
|
|
|
echo " <end_date>" . date ("r", $end_date) . "</end_date>\n";
|
2013-02-14 14:37:33 +01:00
|
|
|
|
2012-10-02 13:11:58 +02:00
|
|
|
// Get netflow item types
|
|
|
|
$item_types = netflow_get_chart_types ();
|
|
|
|
|
|
|
|
// Print report items
|
2013-02-14 14:37:33 +01:00
|
|
|
$report_contents = db_get_all_rows_sql ("SELECT *
|
|
|
|
FROM tnetflow_report_content
|
|
|
|
WHERE id_report='" . $report['id_report'] . "'
|
|
|
|
ORDER BY `order`");
|
2012-10-02 13:11:58 +02:00
|
|
|
foreach ($report_contents as $content) {
|
2013-02-14 14:37:33 +01:00
|
|
|
|
|
|
|
// Get item filters
|
|
|
|
$filter = db_get_row_sql("SELECT *
|
|
|
|
FROM tnetflow_filter
|
|
|
|
WHERE id_sg = '" . io_safe_input ($content['id_filter']) . "'",
|
|
|
|
false, true);
|
|
|
|
if ($filter === FALSE) {
|
2012-10-02 13:11:58 +02:00
|
|
|
continue;
|
|
|
|
}
|
2013-02-14 14:37:33 +01:00
|
|
|
|
2012-10-02 13:11:58 +02:00
|
|
|
echo " <report_item>\n";
|
2012-10-23 Ramon Novoa <rnovoa@artica.es>
* include/functions_cron.php: Added to repository. Cron related
functions.
* include/functions_html.php, pandoradb.sql,
pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php: Added support for remote
cron modules.
* godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
operation/netflow/nf_view.php,
include/functions_netflow.php: Added a description to report items.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7083 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-23 12:45:25 +02:00
|
|
|
echo " <description>" . io_safe_output ($content['description']) . "</description>\n";
|
2012-10-02 13:11:58 +02:00
|
|
|
echo " <type>" . io_safe_output ($item_types[$content['show_graph']]) . "</type>\n";
|
|
|
|
echo " <max_aggregates>" . $content['max'] . "</max_aggregates>\n";
|
|
|
|
echo " <filter>\n";
|
|
|
|
echo " <name>" . io_safe_output ($filter['id_name']) . "</name>\n";
|
|
|
|
echo " <src_ip>" . io_safe_output ($filter['ip_src']) . "</src_ip>\n";
|
|
|
|
echo " <dst_ip>" . io_safe_output ($filter['ip_dst']) . "</dst_ip>\n";
|
|
|
|
echo " <src_port>" . io_safe_output ($filter['src_port']) . "</src_port>\n";
|
|
|
|
echo " <dst_port>" . io_safe_output ($filter['src_port']) . "</dst_port>\n";
|
|
|
|
echo " <advanced>" . io_safe_output ($filter['advanced_filter']) . "</advanced>\n";
|
|
|
|
echo " <aggregate>" . io_safe_output ($filter['aggregate']) . "</aggregate>\n";
|
|
|
|
echo " <unit>" . io_safe_output ($filter['output']) . "</unit>\n";
|
|
|
|
echo " </filter>\n";
|
2013-02-14 14:37:33 +01:00
|
|
|
|
2012-12-13 12:04:12 +01:00
|
|
|
echo netflow_draw_item ($start_date, $end_date, $interval_length, $content['show_graph'], $filter, $content['max'], $report['server_name'], 'XML');
|
2013-02-14 14:37:33 +01:00
|
|
|
|
2012-10-02 13:11:58 +02:00
|
|
|
echo " </report_item>\n";
|
|
|
|
}
|
2013-07-02 11:44:10 +02:00
|
|
|
echo "</report>\n";
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
|
|
|
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
/**
|
|
|
|
* Render an aggregated area chart as an XML.
|
|
|
|
*
|
|
|
|
* @param array Netflow data.
|
|
|
|
*
|
|
|
|
*/
|
2012-10-02 13:11:58 +02:00
|
|
|
function netflow_aggregate_area_xml ($data) {
|
|
|
|
|
2013-01-24 16:00:31 +01:00
|
|
|
// Print source information
|
|
|
|
if (isset($data['sources'])) {
|
|
|
|
echo "<aggregates>\n";
|
|
|
|
foreach ($data['sources'] as $source => $discard) {
|
|
|
|
echo "<aggregate>$source</aggregate>\n";
|
|
|
|
}
|
|
|
|
echo "</aggregates>\n";
|
2012-10-02 13:11:58 +02:00
|
|
|
|
2013-01-24 16:00:31 +01:00
|
|
|
// Print flow information
|
|
|
|
echo "<flows>\n";
|
|
|
|
foreach ($data['data'] as $timestamp => $flow) {
|
|
|
|
|
|
|
|
echo "<flow>\n";
|
|
|
|
echo " <timestamp>" . $timestamp . "</timestamp>\n";
|
|
|
|
echo " <aggregates>\n";
|
|
|
|
foreach ($flow as $source => $data) {
|
|
|
|
echo " <aggregate>$source</aggregate>\n";
|
|
|
|
echo " <data>" . $data . "</data>\n";
|
|
|
|
}
|
|
|
|
echo " </aggregates>\n";
|
|
|
|
echo "</flow>\n";
|
|
|
|
}
|
|
|
|
echo "</flows>\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo "<flows>\n";
|
|
|
|
foreach ($data as $timestamp => $flow) {
|
|
|
|
echo "<flow>\n";
|
|
|
|
echo " <timestamp>" . $timestamp . "</timestamp>\n";
|
|
|
|
echo " <data>" . $flow['data'] . "</data>\n";
|
|
|
|
echo "</flow>\n";
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
2013-01-24 16:00:31 +01:00
|
|
|
echo "</flows>\n";
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
/**
|
|
|
|
* Render an area chart as an XML.
|
|
|
|
*
|
|
|
|
* @param array Netflow data.
|
|
|
|
*
|
|
|
|
*/
|
2012-10-02 13:11:58 +02:00
|
|
|
function netflow_total_area_xml ($data) {
|
|
|
|
|
|
|
|
// Print flow information
|
2012-10-08 21:19:58 +02:00
|
|
|
$xml = "<flows>\n";
|
2012-10-02 13:11:58 +02:00
|
|
|
foreach ($data as $timestamp => $flow) {
|
2012-10-08 21:19:58 +02:00
|
|
|
$xml .= "<flow>\n";
|
|
|
|
$xml .= " <timestamp>" . $timestamp . "</timestamp>\n";
|
|
|
|
$xml .= " <data>" . $flow['data'] . "</data>\n";
|
|
|
|
$xml .= "</flow>\n";
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
2012-10-08 21:19:58 +02:00
|
|
|
$xml .= "</flows>\n";
|
|
|
|
|
|
|
|
return $xml;
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
|
|
|
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
/**
|
|
|
|
* Render a pie chart as an XML.
|
|
|
|
*
|
|
|
|
* @param array Netflow data.
|
|
|
|
*
|
|
|
|
*/
|
2012-10-02 13:11:58 +02:00
|
|
|
function netflow_aggregate_pie_xml ($data) {
|
|
|
|
|
|
|
|
// Calculate total
|
|
|
|
$total = 0;
|
|
|
|
foreach ($data as $flow) {
|
|
|
|
$total += $flow['data'];
|
|
|
|
}
|
|
|
|
if ($total == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print percentages
|
|
|
|
echo "<pie>\n";
|
|
|
|
foreach ($data as $flow) {
|
|
|
|
echo "<aggregate>" . $flow['agg'] . "</aggregate>\n";
|
|
|
|
echo "<data>" . format_numeric (100 * $flow['data'] / $total, 2) . "%</data>\n";
|
|
|
|
}
|
|
|
|
echo "</pie>\n";
|
|
|
|
}
|
|
|
|
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
/**
|
|
|
|
* Render a stats table as an XML.
|
|
|
|
*
|
|
|
|
* @param array Netflow data.
|
|
|
|
*
|
|
|
|
*/
|
2012-10-02 13:11:58 +02:00
|
|
|
function netflow_stat_xml ($data) {
|
|
|
|
|
|
|
|
// Print stats
|
2012-10-08 21:19:58 +02:00
|
|
|
$xml .= "<stats>\n";
|
2012-10-02 13:11:58 +02:00
|
|
|
foreach ($data as $flow) {
|
2012-10-08 21:19:58 +02:00
|
|
|
$xml .= "<aggregate>" . $flow['agg'] . "</aggregate>\n";
|
|
|
|
$xml .= "<data>" . $flow['data'] . "</data>\n";
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
2012-10-08 21:19:58 +02:00
|
|
|
$xml .= "</stats>\n";
|
|
|
|
|
|
|
|
return $xml;
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
|
|
|
|
2012-10-04 Ramon Novoa <rnovoa@artica.es>
* include/functions_html.php,
include/functions_netflow.php,
pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
operation/netflow/nf_live_view.php,
operation/netflow/nf_reporting.php,
operation/netflow/nf_view.php,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/netflow/nf_edit_form.php,
godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit.php: Added metaconsole integration to netflow
reports.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-04 12:49:11 +02:00
|
|
|
/**
|
|
|
|
* Render a summary table as an XML.
|
|
|
|
*
|
|
|
|
* @param array Netflow data.
|
|
|
|
*
|
|
|
|
*/
|
2012-10-02 13:11:58 +02:00
|
|
|
function netflow_summary_xml ($data) {
|
|
|
|
|
|
|
|
// Print summary
|
2012-10-08 21:19:58 +02:00
|
|
|
$xml = "<summary>\n";
|
|
|
|
$xml .= " <total_flows>" . $data['totalflows'] . "</total_flows>\n";
|
|
|
|
$xml .= " <total_bytes>" . $data['totalbytes'] . "</total_bytes>\n";
|
|
|
|
$xml .= " <total_packets>" . $data['totalbytes'] . "</total_packets>\n";
|
|
|
|
$xml .= " <average_bps>" . $data['avgbps'] . "</average_bps>\n";
|
|
|
|
$xml .= " <average_pps>" . $data['avgpps'] . "</average_pps>\n";
|
|
|
|
$xml .= " <average_bpp>" . $data['avgpps'] . "</average_bpp>\n";
|
|
|
|
$xml .= "</summary>\n";
|
|
|
|
|
|
|
|
return $xml;
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
|
|
|
|
2012-12-07 15:03:00 +01:00
|
|
|
/**
|
|
|
|
* Return a string describing the given unit.
|
2013-07-02 11:44:10 +02:00
|
|
|
*
|
2012-12-07 15:03:00 +01:00
|
|
|
* @param string Netflow unit.
|
|
|
|
*/
|
|
|
|
function netflow_format_unit ($unit) {
|
|
|
|
switch ($unit){
|
|
|
|
case 'megabytes':
|
2012-12-07 15:43:53 +01:00
|
|
|
return __('MB');
|
2012-12-07 15:03:00 +01:00
|
|
|
case 'megabytespersecond':
|
2012-12-07 15:43:53 +01:00
|
|
|
return __('MB/s');
|
2012-12-07 15:03:00 +01:00
|
|
|
case 'kilobytes':
|
2012-12-07 15:43:53 +01:00
|
|
|
return __('kB');
|
2012-12-07 15:03:00 +01:00
|
|
|
case 'kilobytespersecond':
|
2012-12-07 15:43:53 +01:00
|
|
|
return __('kB/s');
|
2012-12-12 13:10:16 +01:00
|
|
|
case 'bytes':
|
2012-12-13 12:04:12 +01:00
|
|
|
return __('Bytes');
|
2012-12-12 13:10:16 +01:00
|
|
|
case 'bytespersecond':
|
|
|
|
return __('B/s');
|
2012-12-07 15:03:00 +01:00
|
|
|
default:
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a string describing the given aggregate.
|
2013-07-02 11:44:10 +02:00
|
|
|
*
|
2012-12-07 15:03:00 +01:00
|
|
|
* @param string Netflow aggregate.
|
|
|
|
*/
|
|
|
|
function netflow_format_aggregate ($aggregate) {
|
|
|
|
switch ($aggregate){
|
|
|
|
case 'dstport':
|
|
|
|
return __('Dst port');
|
|
|
|
case 'dstip':
|
|
|
|
return __('Dst IP');
|
|
|
|
case 'proto':
|
|
|
|
return __('Protocol');
|
|
|
|
case 'srcip':
|
|
|
|
return __('Src IP');
|
|
|
|
case 'srcport':
|
|
|
|
return __('Src port');
|
|
|
|
default:
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-27 13:18:04 +02:00
|
|
|
/**
|
|
|
|
* Check the nfdump binary for compatibility.
|
|
|
|
*
|
|
|
|
* @param string nfdump binary full path.
|
|
|
|
*
|
|
|
|
* @return 1 if the binary does not exist or is not executable, 2 if a
|
|
|
|
* version older than 1.6.8 is installed or the version cannot be
|
|
|
|
* determined, 0 otherwise.
|
|
|
|
*/
|
|
|
|
function netflow_check_nfdump_binary ($nfdump_binary) {
|
|
|
|
|
|
|
|
// Check that the binary exists and is executable
|
|
|
|
if (! is_executable ($nfdump_binary)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check at least version 1.6.8
|
|
|
|
$output = '';
|
|
|
|
$rc = -1;
|
|
|
|
exec ($nfdump_binary . ' -V', $output, $rc);
|
|
|
|
if ($rc != 0) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
$matches = array();
|
|
|
|
foreach ($output as $line) {
|
2014-03-13 15:25:01 +01:00
|
|
|
if (preg_match ('/Version:[^\d]+(\d+)\.(\d+)\.(\d+)/', $line, $matches) === 1) {
|
2013-09-27 13:18:04 +02:00
|
|
|
if ($matches[1] < 1) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if ($matches[2] < 6) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if ($matches[3] < 8) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2012-10-02 13:11:58 +02:00
|
|
|
?>
|