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
|
|
|
|
$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%';
|
|
|
|
$table->class = 'databox';
|
|
|
|
$table->data = array();
|
|
|
|
$j = 0;
|
2012-01-23 19:20:30 +01:00
|
|
|
$x = 0;
|
|
|
|
|
|
|
|
$table->head = array ();
|
|
|
|
$table->head[0] = '<b>' . __($aggregate) . '</b>';
|
|
|
|
$table->head[1] = '<b>' . __($unit) . '</b>';
|
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-01-13 15:52:52 +01:00
|
|
|
$table->data[$x][1] = format_numeric ($data[$j]['data']);
|
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-01-13 15:52:52 +01:00
|
|
|
$table->data[$x][1] = format_numeric ($data[$j]['data']);
|
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-01-13 15:52:52 +01:00
|
|
|
function netflow_data_table ($data, $start_date, $end_date, $aggregate) {
|
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-01-13 15:52:52 +01:00
|
|
|
$table->size = array ('50%');
|
2011-12-21 16:28:01 +01:00
|
|
|
$table->class = 'databox';
|
|
|
|
$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>';
|
2011-12-21 16:28:01 +01:00
|
|
|
|
2012-01-11 20:16:13 +01:00
|
|
|
$j = 0;
|
|
|
|
$source_index = array ();
|
|
|
|
$source_count = 0;
|
|
|
|
foreach ($data['sources'] as $source => $null) {
|
2012-01-23 19:20:30 +01:00
|
|
|
$table->head[$j+1] = $source;
|
2012-01-11 20:16:13 +01:00
|
|
|
$source_index[$j] = $source;
|
|
|
|
$source_count++;
|
2011-12-21 16:28:01 +01:00
|
|
|
$j++;
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-23 19:20:30 +01:00
|
|
|
$i = 0;
|
2012-01-11 20:16:13 +01:00
|
|
|
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]])) {
|
|
|
|
$table->data[$i][$j+1] = format_numeric ($values[$source_index[$j]]);
|
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
|
|
|
}
|
|
|
|
else {
|
2012-01-11 20:16:13 +01:00
|
|
|
$table->data[$i][$j+1] = 0;
|
2011-12-21 16:28:01 +01:00
|
|
|
}
|
|
|
|
}
|
2012-01-11 20:16:13 +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();
|
|
|
|
$table->size = array ('50%');
|
|
|
|
$table->class = 'databox';
|
|
|
|
$table->data = array();
|
|
|
|
|
|
|
|
$table->data[0][0] = '<b>'.__('Total flows').'</b>';
|
|
|
|
$table->data[0][1] = format_numeric ($data['totalflows']);
|
|
|
|
$table->data[1][0] = '<b>'.__('Total megabytes').'</b>';
|
|
|
|
$table->data[1][1] = format_numeric ((int)($data['totalbytes'] / 1048576));
|
|
|
|
$table->data[2][0] = '<b>'.__('Total packets').'</b>';
|
|
|
|
$table->data[2][1] = format_numeric ($data['totalpackets']);
|
|
|
|
$table->data[3][0] = '<b>'.__('Average bits per second'). '</b>';
|
|
|
|
$table->data[3][1] = format_numeric ($data['avgbps']);
|
|
|
|
$table->data[4][0] = '<b>'.__('Average packets per second').'</b>';
|
|
|
|
$table->data[4][1] = format_numeric ($data['avgpps']);
|
|
|
|
$table->data[5][0] = '<b>'.__('Average bytes per packet').'</b>';
|
|
|
|
$table->data[5][1] = format_numeric ($data['avgbpp']);
|
|
|
|
|
|
|
|
|
2012-10-08 21:19:58 +02:00
|
|
|
return html_print_table ($table, true);
|
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-13 14:14:16 +01:00
|
|
|
* @param string unique_id A unique number that is used to generate a cache file.
|
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-11 17:52:26 +02:00
|
|
|
function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $unique_id, $aggregate, $max, $unit, $connection_name = '') {
|
2012-01-11 17:34:53 +01: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-10-11 17:52:26 +02:00
|
|
|
$data = metaconsole_call_remote_api ($connection_name, 'netflow_get_data', "$start_date|$end_date|$interval_length|" . base64_encode(json_encode($filter)) . "|$unique_id|$aggregate|$max|$unit");
|
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-09-21 15:42:13 +02:00
|
|
|
// Suppress the header line and the statistics at the bottom
|
|
|
|
$command .= ' -q';
|
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
// If there is aggregation calculate the top n
|
|
|
|
if ($aggregate != 'none') {
|
2012-01-13 14:14:16 +01:00
|
|
|
$values['data'] = array ();
|
|
|
|
$values['sources'] = array ();
|
|
|
|
$agg_command = $command . " -s $aggregate/$unit -n $max -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
|
2012-01-11 17:34:53 +01:00
|
|
|
exec($agg_command, $string);
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
foreach($string as $line){
|
|
|
|
if ($line=='') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$line = preg_replace('/\(\s*\S+\)/','',$line);
|
|
|
|
$line = preg_replace('/\s+/',' ',$line);
|
|
|
|
$val = explode(' ',$line);
|
2012-01-13 14:14:16 +01:00
|
|
|
$values['sources'][$val[4]] = 1;
|
2012-01-11 17:34:53 +01:00
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-13 14:14:16 +01:00
|
|
|
$values = array ();
|
2012-01-11 17:34:53 +01:00
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Load cache
|
|
|
|
$cache_file = $config['attachment_store'] . '/netflow_' . $unique_id . '.cache';
|
2012-10-11 17:52:26 +02:00
|
|
|
$last_timestamp = netflow_load_cache ($values, $cache_file, $start_date, $end_date, $interval_length, $aggregate);
|
2012-01-13 14:14:16 +01:00
|
|
|
if ($last_timestamp < $end_date) {
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
$last_timestamp++;
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Execute nfdump and save its output in a temporary file
|
|
|
|
$temp_file = $config['attachment_store'] . '/netflow_' . $unique_id . '.tmp';
|
|
|
|
$command .= ' -t '.date($nfdump_date_format, $last_timestamp).'-'.date($nfdump_date_format, $end_date);
|
|
|
|
exec("$command > $temp_file");
|
2012-09-21 15:42:13 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Parse data file
|
|
|
|
// We must parse from $start_date to avoid creating new intervals!
|
2012-10-11 17:52:26 +02:00
|
|
|
netflow_parse_file ($start_date, $end_date, $interval_length, $temp_file, $values, $aggregate, $unit);
|
2012-09-21 15:42:13 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
unlink ($temp_file);
|
2012-01-11 17:34:53 +01:00
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Save cache
|
|
|
|
if ($aggregate == 'none') {
|
|
|
|
netflow_save_cache ($values, $cache_file);
|
|
|
|
}
|
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
|
|
|
|
2012-01-11 17:34:53 +01:00
|
|
|
return $values;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-09-21 15:42:13 +02:00
|
|
|
$command .= " -q -s $aggregate/$unit -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-07-18 15:25:51 +02: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 ();
|
|
|
|
}
|
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
$values = array();
|
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 == '') {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$line = preg_replace('/\(\s*\S+\)/','',$line);
|
|
|
|
$line = preg_replace('/\s+/',' ',$line);
|
|
|
|
$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
|
|
|
|
$date = $val[0];
|
|
|
|
$time = $val[1];
|
|
|
|
$end_date = strtotime ($date." ".$time);
|
|
|
|
$values[$i]['datetime'] = $end_date;
|
|
|
|
$values[$i]['agg'] = $val[4];
|
|
|
|
|
|
|
|
switch ($unit){
|
2012-01-17 15:01:49 +01:00
|
|
|
case "flows":
|
|
|
|
$values[$i]['data'] = $val[5];
|
|
|
|
break;
|
2012-01-11 17:34:53 +01:00
|
|
|
case "packets":
|
|
|
|
$values[$i]['data'] = $val[6];
|
|
|
|
break;
|
|
|
|
case "bytes":
|
|
|
|
default:
|
|
|
|
$values[$i]['data'] = $val[7];
|
|
|
|
break;
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
2012-01-11 17:34:53 +01:00
|
|
|
$i++;
|
|
|
|
}
|
2012-07-18 15:25:51 +02: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
|
|
|
* @param string unique_id A unique number that is used to generate a cache file.
|
|
|
|
*
|
|
|
|
* @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_summary ($start_date, $end_date, $filter, $unique_id, $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 != '') {
|
|
|
|
$data = metaconsole_call_remote_api ($connection_name, 'netflow_get_summary', "$start_date|$end_date|" . base64_encode(json_encode($filter)) . "|$unique_id");
|
|
|
|
return json_decode ($data, true);
|
|
|
|
}
|
|
|
|
|
2012-10-02 13:11:58 +02:00
|
|
|
// Get the command to call nfdump
|
|
|
|
$command = netflow_get_command ($filter);
|
|
|
|
|
2012-09-21 15:42:13 +02:00
|
|
|
// Execute nfdump and save its output in a temporary file
|
|
|
|
$temp_file = $config['attachment_store'] . '/netflow_' . $unique_id . '.tmp';
|
|
|
|
$command .= " -o \"fmt: \" -t " .date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
|
|
|
|
exec("$command > $temp_file");
|
|
|
|
|
|
|
|
// Parse data file
|
|
|
|
// We must parse from $start_date to avoid creating new intervals!
|
|
|
|
$values = array ();
|
2012-10-11 17:52:26 +02:00
|
|
|
netflow_parse_file ($start_date, $end_date, 0, $temp_file, $values);
|
2012-09-21 15:42:13 +02:00
|
|
|
unlink ($temp_file);
|
|
|
|
|
|
|
|
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-09-21 15:42:13 +02:00
|
|
|
$command = 'nfdump -N -m';
|
2012-01-11 17:34:53 +01:00
|
|
|
|
|
|
|
// Netflow data path
|
|
|
|
if (isset($config['netflow_path']) && $config['netflow_path'] != '') {
|
|
|
|
$command .= ' -R '.$config['netflow_path'];
|
|
|
|
}
|
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 .= ' "(';
|
|
|
|
$val_ipdst = explode(',', $filter['ip_dst']);
|
|
|
|
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 (';
|
|
|
|
}
|
|
|
|
$val_ipsrc = explode(',', $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 .= ')';
|
|
|
|
}
|
|
|
|
if ($filter['dst_port'] != 0) {
|
|
|
|
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 (';
|
|
|
|
}
|
|
|
|
$val_dstport = explode(',', $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 .= ')';
|
|
|
|
}
|
|
|
|
if ($filter['src_port'] != 0) {
|
|
|
|
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 (';
|
|
|
|
}
|
|
|
|
$val_srcport = explode(',', $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 .= ')';
|
|
|
|
}
|
|
|
|
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-13 14:14:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parses netflow data from the given file.
|
|
|
|
*
|
|
|
|
* @param string start_date Period start date.
|
|
|
|
* @param string end_date Period end date.
|
|
|
|
* @param string file File that contains netflow data.
|
|
|
|
* @param array values Array where netflow data will be placed.
|
|
|
|
* @param string aggregate Aggregate field.
|
|
|
|
* @param string unit Unit to show.
|
2012-10-08 21:19:58 +02:00
|
|
|
* @param string interval_length Interval length in seconds (num_intervals * interval_length = start_date - end_date).
|
2012-01-13 14:14:16 +01:00
|
|
|
*
|
|
|
|
* @return Timestamp of the last data read.
|
|
|
|
*
|
|
|
|
*/
|
2012-10-11 17:52:26 +02:00
|
|
|
function netflow_parse_file ($start_date, $end_date, $interval_length, $file, &$values, $aggregate = '', $unit = '') {
|
2012-01-13 14:14:16 +01:00
|
|
|
global $config;
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Last timestamp read
|
|
|
|
$last_timestamp = $start_date;
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Open the data file
|
|
|
|
$fh = @fopen ($file, "r");
|
|
|
|
if ($fh === FALSE) {
|
|
|
|
return $last_timestamp;
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Calculate the number of intervals
|
2012-10-11 17:52:26 +02:00
|
|
|
if ($interval_length <= 0) {
|
2012-10-08 21:19:58 +02:00
|
|
|
$num_intervals = $config['graph_res'] * 50;
|
|
|
|
$period = $end_date - $start_date;
|
|
|
|
$interval_length = (int) ($period / $num_intervals);
|
|
|
|
} else {
|
|
|
|
$period = $end_date - $start_date;
|
|
|
|
$num_intervals = (int) ($period / $interval_length);
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-09-21 15:42:13 +02:00
|
|
|
// Parse the summary and exit
|
|
|
|
if ($aggregate == '' && $unit == '') {
|
|
|
|
while ($line = fgets ($fh)) {
|
|
|
|
$line = preg_replace('/\s+/','',$line);
|
|
|
|
$idx = strpos ($line, 'Summary:');
|
|
|
|
if ($idx === FALSE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse summary items
|
|
|
|
$idx += strlen ('Summary:');
|
|
|
|
$line = substr ($line, $idx);
|
|
|
|
$summary = explode(',', $line);
|
|
|
|
foreach ($summary as $item) {
|
|
|
|
$val = explode (':', $item);
|
|
|
|
if (! isset ($val[1])) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$values[$val[0]] = $val[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose ($fh);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Parse flow data
|
|
|
|
$read_flag = 1;
|
|
|
|
$flow = array ();
|
|
|
|
for ($i = 0; $i < $num_intervals; $i++) {
|
|
|
|
$timestamp = $start_date + ($interval_length * $i);
|
|
|
|
|
|
|
|
if ($aggregate != 'none') {
|
|
|
|
$interval_total = array ();
|
|
|
|
$interval_count = array ();
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-13 14:14:16 +01:00
|
|
|
$interval_total = 0;
|
|
|
|
$interval_count = 0;
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
do {
|
|
|
|
if ($read_flag == 1) {
|
|
|
|
$read_flag = 0;
|
|
|
|
$line = fgets($fh, 4096);
|
|
|
|
if ($line === false) {
|
|
|
|
$read_flag = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$line = preg_replace('/\s+/',' ',$line);
|
|
|
|
$val = explode(' ',$line);
|
|
|
|
if (! isset ($val[6])) {
|
|
|
|
$read_flag = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$flow['date'] = $val[0];
|
|
|
|
$flow['time'] = $val[1];
|
|
|
|
|
2012-07-18 15:25:51 +02:00
|
|
|
switch ($aggregate) {
|
2012-01-13 14:14:16 +01:00
|
|
|
case "proto":
|
|
|
|
$flow['agg'] = $val[3];
|
|
|
|
break;
|
|
|
|
case "srcip":
|
|
|
|
$val2 = explode(':', $val[4]);
|
|
|
|
$flow['agg'] = $val2[0];
|
|
|
|
break;
|
|
|
|
case "srcport":
|
|
|
|
$val2 = explode(':', $val[4]);
|
|
|
|
$flow['agg'] = $val2[1];
|
|
|
|
break;
|
|
|
|
case "dstip":
|
|
|
|
$val2 = explode(':', $val[6]);
|
|
|
|
$flow['agg'] = $val2[0];
|
|
|
|
break;
|
|
|
|
case "dstport":
|
|
|
|
$val2 = explode(':', $val[6]);
|
|
|
|
$flow['agg'] = $val2[1];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($unit) {
|
2012-01-17 15:01:49 +01:00
|
|
|
case "flows":
|
|
|
|
$flow['data'] = $val[6];
|
|
|
|
break;
|
2012-01-13 14:14:16 +01:00
|
|
|
case "packets":
|
|
|
|
$flow['data'] = $val[7];
|
|
|
|
break;
|
|
|
|
case "bytes":
|
|
|
|
$flow['data'] = $val[8];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$flow['timestamp'] = strtotime ($flow['date'] . " " . $flow['time']);
|
|
|
|
$last_timestamp = $flow['timestamp'];
|
|
|
|
}
|
|
|
|
if ($flow['timestamp'] >= $timestamp && $flow['timestamp'] <= $timestamp + $interval_length) {
|
|
|
|
$read_flag = 1;
|
|
|
|
if ($aggregate != 'none') {
|
|
|
|
if (isset ($values['sources'][$flow['agg']])) {
|
|
|
|
if (! isset ($interval_total[$flow['agg']])) {
|
|
|
|
$interval_total[$flow['agg']] = 0;
|
|
|
|
$interval_count[$flow['agg']] = 0;
|
|
|
|
}
|
|
|
|
$interval_total[$flow['agg']] += $flow['data'];
|
|
|
|
$interval_count[$flow['agg']] += 1;
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-13 14:14:16 +01:00
|
|
|
$interval_total += $flow['data'];
|
|
|
|
$interval_count += 1;
|
|
|
|
}
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
while ($read_flag == 1);
|
2012-01-13 14:14:16 +01:00
|
|
|
|
|
|
|
if ($aggregate != 'none') {
|
|
|
|
foreach ($interval_total as $agg => $val) {
|
|
|
|
|
|
|
|
// No data for this interval/aggregate
|
|
|
|
if ($interval_count[$agg] == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Read previous data for this interval
|
|
|
|
if (isset ($values['data'][$timestamp][$agg])) {
|
|
|
|
$previous_value = $values['data'][$timestamp][$agg];
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-13 14:14:16 +01:00
|
|
|
$previous_value = 0;
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Calculate interval data
|
2012-09-21 15:42:13 +02:00
|
|
|
$values['data'][$timestamp][$agg] = (int) $interval_total[$agg];
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-09-21 15:42:13 +02:00
|
|
|
// Add previous data
|
2012-01-13 14:14:16 +01:00
|
|
|
if ($previous_value != 0) {
|
2012-09-21 15:42:13 +02:00
|
|
|
$values['data'][$timestamp][$agg] = (int) ($values['data'][$timestamp][$agg] + $previous_data);
|
2012-01-13 14:14:16 +01:00
|
|
|
}
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// No data for this interval
|
|
|
|
if ($interval_count == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read previous data for this interval
|
|
|
|
if (isset ($values[$timestamp]['data'])) {
|
|
|
|
$previous_value = $values[$timestamp]['data'];
|
2012-07-18 15:25:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-13 14:14:16 +01:00
|
|
|
$previous_value = 0;
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Calculate interval data
|
2012-09-21 15:42:13 +02:00
|
|
|
$values[$timestamp]['data'] = (int) $interval_total;
|
2012-01-13 14:14:16 +01:00
|
|
|
|
2012-09-21 15:42:13 +02:00
|
|
|
// Add previous data
|
2012-01-13 14:14:16 +01:00
|
|
|
if ($previous_value != 0) {
|
2012-09-21 15:42:13 +02:00
|
|
|
$values[$timestamp]['data'] = (int) ($values[$timestamp]['data'] + $previous_value);
|
2012-01-13 14:14:16 +01:00
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
fclose ($fh);
|
|
|
|
return $last_timestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save data to the specified cache file.
|
|
|
|
*
|
|
|
|
* @param array data Data array.
|
|
|
|
* @param string cache_file Cache file name.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function netflow_save_cache ($data, $cache_file) {
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-10-02 13:11:58 +02:00
|
|
|
//@file_put_contents ($cache_file, serialize ($data));
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
return;
|
|
|
|
}
|
2012-07-18 15:25:51 +02:00
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
/**
|
|
|
|
* Load data from the specified cache file.
|
|
|
|
*
|
|
|
|
* @param string data Array were cache data will be stored.
|
|
|
|
* @param string cache_file Cache file name.
|
|
|
|
* @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-13 14:14:16 +01:00
|
|
|
*
|
|
|
|
* @return Timestamp of the last data read from cache.
|
|
|
|
*
|
|
|
|
*/
|
2012-10-11 17:52:26 +02:00
|
|
|
function netflow_load_cache (&$data, $cache_file, $start_date, $end_date, $interval_length, $aggregate) {
|
2012-01-13 14:14:16 +01:00
|
|
|
global $config;
|
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
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Open cache file
|
|
|
|
$cache_data = @file_get_contents ($cache_file);
|
|
|
|
$cache_data = @unserialize ($cache_data);
|
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
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Calculate the number of intervals
|
2012-10-11 17:52:26 +02:00
|
|
|
if ($interval_length <= 0) {
|
|
|
|
$num_intervals = $config['graph_res'] * 50;
|
|
|
|
$period = $end_date - $start_date;
|
|
|
|
$interval_length = (int) ($period / $num_intervals);
|
|
|
|
} else {
|
|
|
|
$period = $end_date - $start_date;
|
|
|
|
$num_intervals = (int) ($period / $interval_length);
|
|
|
|
}
|
2012-01-13 14:14:16 +01:00
|
|
|
$last_timestamp = $start_date;
|
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
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
// Initializa chart data
|
|
|
|
if ($aggregate == 'none') {
|
|
|
|
if ($cache_data === FALSE) {
|
|
|
|
$cache_data = array ();
|
|
|
|
}
|
|
|
|
for ($i = 0; $i < $num_intervals; $i++) {
|
|
|
|
$timestamp = $start_date + ($interval_length * $i);
|
|
|
|
$interval_count = 0;
|
|
|
|
$interval_total = 0;
|
|
|
|
foreach ($cache_data as $cache_timestamp => $cache_value) {
|
|
|
|
if ($cache_timestamp < $timestamp + $interval_length) {
|
|
|
|
if ($cache_timestamp >= $timestamp) {
|
|
|
|
$interval_count++;
|
|
|
|
$interval_total += $cache_value['data'];
|
|
|
|
$last_timestamp = $cache_timestamp;
|
|
|
|
}
|
|
|
|
unset ($cache_data[$cache_timestamp]);
|
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-01-13 14:14:16 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
if ($interval_count > 0) {
|
|
|
|
$data[$timestamp]['data'] = (int) ($interval_total / $interval_count);
|
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-01-13 14:14:16 +01:00
|
|
|
$data[$timestamp]['data'] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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 {
|
|
|
|
for ($i = 0; $i < $num_intervals; $i++) {
|
|
|
|
$timestamp = $start_date + ($interval_length * $i);
|
|
|
|
$interval_count = array ();
|
|
|
|
$interval_total = array ();
|
|
|
|
|
|
|
|
foreach ($data['sources'] as $source => $null) {
|
|
|
|
$data['data'][$timestamp][$source] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-13 14:14:16 +01:00
|
|
|
return $last_timestamp;
|
|
|
|
}
|
|
|
|
|
2012-01-20 14:14:09 +01:00
|
|
|
/**
|
|
|
|
* Get the types of netflow charts.
|
|
|
|
*
|
|
|
|
* @return Array of types.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function netflow_get_chart_types () {
|
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
|
|
|
|
2012-01-20 14:14:09 +01:00
|
|
|
return array(
|
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
|
|
|
__('Area graph'),
|
|
|
|
__('Pie graph'),
|
|
|
|
__('Data table'),
|
2012-09-21 15:42:13 +02:00
|
|
|
__('Statistics table'),
|
|
|
|
__('Summary 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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* @param string unique_id A unique number that is used to generate a cache file.
|
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-10-11 17:52:26 +02:00
|
|
|
function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $filter, $max_aggregates, $unique_id, $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;
|
2012-10-02 13:11:58 +02: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-11 17:52:26 +02:00
|
|
|
$data = netflow_get_data ($start_date, $end_date, $interval_length, $filter, $unique_id, $aggregate, $max_aggregates, $unit, $connection_name);
|
2012-01-20 14:14:09 +01:00
|
|
|
if ($aggregate != 'none') {
|
2012-10-02 13:11:58 +02:00
|
|
|
if ($output == 'HTML') {
|
2012-10-08 21:19:58 +02:00
|
|
|
return graph_netflow_aggregate_area ($data, $interval, 660, 320, $unit);
|
|
|
|
} else if ($output == 'PDF') {
|
|
|
|
return graph_netflow_aggregate_area ($data, $interval, 660, 320, $unit, 2, true);
|
2012-10-02 13:11:58 +02:00
|
|
|
} else if ($output == 'XML') {
|
2012-10-08 21:19:58 +02:00
|
|
|
return netflow_aggregate_area_xml ($data);
|
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-10-08 21:19:58 +02:00
|
|
|
return graph_netflow_total_area ($data, $interval, 660, 320, $unit);
|
|
|
|
} else if ($output == 'PDF') {
|
|
|
|
return graph_netflow_total_area ($data, $interval, 660, 320, $unit, 2, true);
|
2012-10-02 13:11:58 +02:00
|
|
|
} else if ($output == 'XML') {
|
2012-10-08 21:19:58 +02:00
|
|
|
return netflow_total_area_xml ($data);
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
2012-01-20 14:14:09 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '1':
|
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
|
|
|
$data = netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max_aggregates, $unit, $connection_name);
|
2012-10-02 13:11:58 +02:00
|
|
|
if ($output == 'HTML') {
|
2012-10-08 21:19:58 +02:00
|
|
|
return graph_netflow_aggregate_pie ($data, $aggregate);
|
|
|
|
} else if ($output == 'PDF') {
|
|
|
|
return graph_netflow_aggregate_pie ($data, $aggregate, 2, true);
|
2012-10-02 13:11:58 +02:00
|
|
|
} else if ($output == 'XML') {
|
2012-10-08 21:19:58 +02:00
|
|
|
return netflow_aggregate_pie_xml ($data);
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
2012-01-20 14:14:09 +01:00
|
|
|
break;
|
|
|
|
case '2':
|
2012-10-11 17:52:26 +02:00
|
|
|
$data = netflow_get_data ($start_date, $end_date, $interval_length, $filter, $unique_id, $aggregate, $max_aggregates, $unit, $connection_name);
|
2012-10-08 21:19:58 +02:00
|
|
|
if ($output == 'HTML' || $output == 'PDF') {
|
|
|
|
return netflow_data_table ($data, $start_date, $end_date, $aggregate);
|
2012-10-02 13:11:58 +02:00
|
|
|
} else if ($output == 'XML') {
|
|
|
|
// Same as netflow_aggregate_area_xml
|
2012-10-08 21:19:58 +02:00
|
|
|
return netflow_aggregate_area_xml ($data);
|
2012-10-02 13:11:58 +02:00
|
|
|
}
|
2012-01-20 14:14:09 +01:00
|
|
|
break;
|
|
|
|
case '3':
|
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
|
|
|
$data = netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max_aggregates, $unit, $connection_name);
|
2012-10-08 21:19:58 +02:00
|
|
|
if ($output == 'HTML' || $output == 'PDF') {
|
|
|
|
return netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit);
|
2012-10-02 13:11:58 +02: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-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
|
|
|
$data = netflow_get_summary ($start_date, $end_date, $filter, $unique_id, $connection_name);
|
2012-10-08 21:19:58 +02:00
|
|
|
if ($output == 'HTML' || $output == 'PDF') {
|
|
|
|
return netflow_summary_table ($data);
|
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
|
|
|
} else if ($output == 'XML') {
|
2012-10-08 21:19:58 +02:00
|
|
|
return netflow_summary_xml ($data);
|
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:
|
2012-10-08 21:19:58 +02:00
|
|
|
if ($output == 'HTML' || $output == 'PDF') {
|
|
|
|
return fs_error_image();
|
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-01-20 14:14:09 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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";
|
|
|
|
|
|
|
|
// Get netflow item types
|
|
|
|
$item_types = netflow_get_chart_types ();
|
|
|
|
|
|
|
|
// Print report items
|
|
|
|
$report_contents = db_get_all_rows_sql ("SELECT * FROM tnetflow_report_content WHERE id_report='" . $report['id_report'] . "' ORDER BY `order`");
|
|
|
|
foreach ($report_contents as $content) {
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
|
|
|
// Build a unique id for the cache
|
|
|
|
$unique_id = $report['id_report'] . '_' . $content['id_rc'] . '_' . ($end_date - $start_date);
|
|
|
|
|
2012-10-11 17:52:26 +02:00
|
|
|
echo netflow_draw_item ($start_date, $end_date, $interval_length, $content['show_graph'], $filter, $content['max'], $unique_id, $report['server_name'], 'XML');
|
2012-10-02 13:11:58 +02:00
|
|
|
|
|
|
|
echo " </report_item>\n";
|
|
|
|
}
|
|
|
|
echo "</report>\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 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) {
|
|
|
|
|
|
|
|
// Print source information
|
|
|
|
echo "<aggregates>\n";
|
|
|
|
foreach ($data['sources'] as $source => $discard) {
|
|
|
|
echo "<aggregate>$source</aggregate>\n";
|
|
|
|
}
|
|
|
|
echo "</aggregates>\n";
|
|
|
|
|
|
|
|
// 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";
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
?>
|