2012-07-18 Miguel de Dios <miguel.dedios@artica.es>
* general/logon_ok.php, godmode/db/db_event.php, godmode/db/db_purge.php, include/functions_config.php, include/functions_ui.php, include/functions_netflow.php, include/functions.php, include/constants.php, include/functions_graph.php, operation/agentes/estado_ultimopaquete.php: clean source code style and kill some unicorns and magical numbers. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6788 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
8c3d85b507
commit
ed1c79730c
|
@ -1,3 +1,13 @@
|
|||
2012-07-18 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* general/logon_ok.php, godmode/db/db_event.php,
|
||||
godmode/db/db_purge.php, include/functions_config.php,
|
||||
include/functions_ui.php, include/functions_netflow.php,
|
||||
include/functions.php, include/constants.php,
|
||||
include/functions_graph.php,
|
||||
operation/agentes/estado_ultimopaquete.php: clean source code style
|
||||
and kill some unicorns and magical numbers.
|
||||
|
||||
2012-07-18 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/javascript/pandora.js, include/functions_agents.php,
|
||||
|
|
|
@ -180,19 +180,19 @@ switch ($config["dbtype"]) {
|
|||
case "mysql":
|
||||
$sql = sprintf ("SELECT id_usuario,accion,fecha,ip_origen,descripcion
|
||||
FROM tsesion
|
||||
WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - 604800)
|
||||
WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - " . SECONDS_1WEEK . ")
|
||||
AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 10", $config["id_user"]);
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = sprintf ("SELECT \"id_usuario\", accion, fecha, \"ip_origen\", descripcion
|
||||
FROM tsesion
|
||||
WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - 604800)
|
||||
WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - " . SECONDS_1WEEK . ")
|
||||
AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 10", $config["id_user"]);
|
||||
break;
|
||||
case "oracle":
|
||||
$sql = sprintf ("SELECT id_usuario, accion, fecha, ip_origen, descripcion
|
||||
FROM tsesion
|
||||
WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - 604800)
|
||||
WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - " . SECONDS_1WEEK . ")
|
||||
AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", $config["id_user"]);
|
||||
break;
|
||||
}
|
||||
|
@ -230,4 +230,4 @@ echo "<div style='width:100%; overflow-x:auto;'>";
|
|||
html_print_table ($table);
|
||||
echo "</div>";
|
||||
echo "</div>"; // activity
|
||||
?>
|
||||
?>
|
|
@ -71,12 +71,12 @@ echo '<table width="98%" cellpadding="4" cellspacing="4" class="databox">
|
|||
|
||||
$time = get_system_time ();
|
||||
$fields = array ();
|
||||
$fields[$time - 7776000] = __('Purge event data over 90 days');
|
||||
$fields[$time - 2592000] = __('Purge event data over 30 days');
|
||||
$fields[$time - 1209600] = __('Purge event data over 14 days');
|
||||
$fields[$time - 604800] = __('Purge event data over 7 days');
|
||||
$fields[$time - 259200] = __('Purge event data over 3 days');
|
||||
$fields[$time - 86400] = __('Purge event data over 1 day');
|
||||
$fields[$time - SECONDS_3MONTHS] = __('Purge event data over 90 days');
|
||||
$fields[$time - SECONDS_1MONTH] = __('Purge event data over 30 days');
|
||||
$fields[$time - SECONDS_2WEEK] = __('Purge event data over 14 days');
|
||||
$fields[$time - SECONDS_1WEEK] = __('Purge event data over 7 days');
|
||||
$fields[$time - (SECONDS_1WEEK * 3)] = __('Purge event data over 3 days');
|
||||
$fields[$time - SECONDS_1DAY] = __('Purge event data over 1 day');
|
||||
$fields[$time] = __('Purge all event data');
|
||||
|
||||
html_print_select ($fields, "date_purge", '', '', '', '0', false, false, false, "w255");
|
||||
|
|
|
@ -43,25 +43,19 @@ echo '<h4>'.__('Get data from agent').'</h4>';
|
|||
|
||||
// All data (now)
|
||||
$time["all"] = get_system_time ();
|
||||
|
||||
// 1 day ago
|
||||
$time["1day"] = $time["all"]-86400;
|
||||
|
||||
$time["1day"] = $time["all"] - SECONDS_1DAY;
|
||||
// 3 days ago
|
||||
$time["3day"] = $time["all"] - 259200;
|
||||
|
||||
$time["3day"] = $time["all"] - SECONDS_1DAY * 3;
|
||||
// 1 week ago
|
||||
$time["1week"] = $time["all"] - 604800;
|
||||
|
||||
$time["1week"] = $time["all"] - SECONDS_1WEEK;
|
||||
// 2 weeks ago
|
||||
$time["2week"] = $time["all"] - 1209600;
|
||||
|
||||
$time["2week"] = $time["all"] - SECONDS_1WEEK * 2;
|
||||
// 1 month ago
|
||||
$time["1month"] = $time["all"] - 2592000;
|
||||
|
||||
$time["1month"] = $time["all"] - SECONDS_1MONTH;
|
||||
// Three months ago
|
||||
$time["3month"] = $time["all"] - 7776000;
|
||||
|
||||
$time["3month"] = $time["all"] - SECONDS_3MONTHS;
|
||||
|
||||
//Init data
|
||||
$data["1day"] = 0;
|
||||
$data["3day"] = 0;
|
||||
|
@ -102,7 +96,7 @@ if (isset($_POST["purgedb"])) {
|
|||
$errors++;
|
||||
else
|
||||
$affected += $result;
|
||||
|
||||
|
||||
if ($errors == 0) {
|
||||
$result = db_process_sql_delete('tagente_datos_inc', array('id_agente_modulo' => $row["id_agente_modulo"], 'utimestamp' => '< ' . $from_date));
|
||||
|
||||
|
@ -134,10 +128,11 @@ if (isset($_POST["purgedb"])) {
|
|||
}
|
||||
else {
|
||||
db_process_sql_commit ();
|
||||
|
||||
|
||||
echo __('Total records deleted: ') . $affected;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//All agents
|
||||
echo __('Deleting records for all agents');
|
||||
flush ();
|
||||
|
@ -166,7 +161,8 @@ echo '</noscript><br />';
|
|||
|
||||
if ($id_agent > 0) {
|
||||
$title = __('Information on agent %s in the database', agents_get_name ($id_agent));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$title = __('Information on all agents in the database');
|
||||
}
|
||||
|
||||
|
@ -182,13 +178,13 @@ else {
|
|||
$query = "";
|
||||
}
|
||||
|
||||
$data["1day"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE 1=1 %s", $query));
|
||||
$data["1day"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] = db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE 1=1 %s", $query));
|
||||
|
||||
$data["1day"] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] += db_get_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
|
|
|
@ -167,6 +167,12 @@ define('SERVICE_STATUS_UNKNOW', -1);
|
|||
define('SERVICE_STATUS_NORMAL', 0);
|
||||
define('SERVICE_STATUS_CRITICAL', 1);
|
||||
define('SERVICE_STATUS_WARNING', 2);
|
||||
//Default weights
|
||||
define('SERVICE_WEIGHT_CRITICAL', 1);
|
||||
define('SERVICE_WEIGHT_WARNING', 0.5);
|
||||
define('SERVICE_ELEMENT_WEIGHT_CRITICAL', 1);
|
||||
define('SERVICE_ELEMENT_WEIGHT_WARNING', 0.5);
|
||||
define('SERVICE_ELEMENT_WEIGHT_OK', 0);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -405,6 +405,10 @@ function set_user_language() {
|
|||
*/
|
||||
function human_time_description_raw ($seconds, $exactly = false, $units = 'large') {
|
||||
|
||||
//Miguel: I think that I can kill this unicorns and magical numbers
|
||||
// because this function may call without loaded the
|
||||
// constants.php file.
|
||||
|
||||
switch ($units) {
|
||||
case 'large':
|
||||
$secondsString = __('seconds');
|
||||
|
|
|
@ -295,7 +295,7 @@ function config_process_config () {
|
|||
}
|
||||
|
||||
if (!isset ($config["sla_period"]) || empty ($config["sla_period"])) {
|
||||
config_update_value ('sla_period', 604800);
|
||||
config_update_value ('sla_period', SECONDS_1WEEK);
|
||||
}
|
||||
|
||||
if (!isset ($config["prominent_time"])) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,6 +35,7 @@ function netflow_get_filters ($filter = false) {
|
|||
else {
|
||||
$filters = db_get_all_rows_filter ("tnetflow_filter", $filter);
|
||||
}
|
||||
|
||||
$return = array ();
|
||||
if ($filters === false) {
|
||||
return $return;
|
||||
|
@ -60,6 +61,7 @@ function netflow_get_reports ($filter = false) {
|
|||
else {
|
||||
$filters = db_get_all_rows_filter ("tnetflow_report", $filter);
|
||||
}
|
||||
|
||||
$return = array ();
|
||||
if ($filters === false) {
|
||||
return $return;
|
||||
|
@ -126,12 +128,12 @@ function netflow_check_report_group ($id_report, $mode=false) {
|
|||
* @return array A netflow filter matching id and filter.
|
||||
*/
|
||||
function netflow_filter_get_filter ($id_sg, $filter = false, $fields = false) {
|
||||
|
||||
if (! is_array ($filter))
|
||||
$filter = array ();
|
||||
$filter['id_sg'] = (int) $id_sg;
|
||||
if (! is_array ($filter))
|
||||
$filter = array ();
|
||||
|
||||
return db_get_row_filter ('tnetflow_filter', $filter, $fields);
|
||||
$filter['id_sg'] = (int) $id_sg;
|
||||
|
||||
return db_get_row_filter ('tnetflow_filter', $filter, $fields);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,33 +234,33 @@ function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){
|
|||
*/
|
||||
function netflow_data_table ($data, $start_date, $end_date, $aggregate) {
|
||||
global $nfdump_date_format;
|
||||
|
||||
|
||||
$period = $end_date - $start_date;
|
||||
$start_date = date ($nfdump_date_format, $start_date);
|
||||
$end_date = date ($nfdump_date_format, $end_date);
|
||||
|
||||
|
||||
// Set the format
|
||||
if ($period <= 21600) {
|
||||
if ($period <= SECONDS_6HOURS) {
|
||||
$time_format = 'H:i:s';
|
||||
}
|
||||
elseif ($period < 86400) {
|
||||
elseif ($period < SECONDS_1DAY) {
|
||||
$time_format = 'H:i';
|
||||
}
|
||||
elseif ($period < 1296000) {
|
||||
elseif ($period < SECONDS_15DAYS) {
|
||||
$time_format = 'M d H:i';
|
||||
}
|
||||
elseif ($period < 2592000) {
|
||||
elseif ($period < SECONDS_1MONTH) {
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
else {
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
|
||||
|
||||
$values = array();
|
||||
$table->size = array ('50%');
|
||||
$table->class = 'databox';
|
||||
$table->data = array();
|
||||
|
||||
|
||||
$table->head = array();
|
||||
$table->head[0] = '<b>'.__('Timestamp').'</b>';
|
||||
|
||||
|
@ -271,7 +273,7 @@ function netflow_data_table ($data, $start_date, $end_date, $aggregate) {
|
|||
$source_count++;
|
||||
$j++;
|
||||
}
|
||||
|
||||
|
||||
$i = 0;
|
||||
foreach ($data['data'] as $timestamp => $values) {
|
||||
$table->data[$i][0] = date ($time_format, $timestamp);
|
||||
|
@ -284,7 +286,7 @@ function netflow_data_table ($data, $start_date, $end_date, $aggregate) {
|
|||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
html_print_table($table);
|
||||
}
|
||||
|
||||
|
@ -321,14 +323,14 @@ function netflow_is_net ($address) {
|
|||
function netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max, $unit) {
|
||||
global $nfdump_date_format;
|
||||
global $config;
|
||||
|
||||
|
||||
// If there is aggregation calculate the top n
|
||||
if ($aggregate != 'none') {
|
||||
$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);
|
||||
exec($agg_command, $string);
|
||||
|
||||
|
||||
foreach($string as $line){
|
||||
if ($line=='') {
|
||||
continue;
|
||||
|
@ -338,29 +340,30 @@ function netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggreg
|
|||
$val = explode(' ',$line);
|
||||
$values['sources'][$val[4]] = 1;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$values = array ();
|
||||
}
|
||||
|
||||
|
||||
// Load cache
|
||||
$cache_file = $config['attachment_store'] . '/netflow_' . $unique_id . '.cache';
|
||||
$last_timestamp = netflow_load_cache ($values, $cache_file, $start_date, $end_date, $aggregate);
|
||||
if ($last_timestamp < $end_date) {
|
||||
|
||||
|
||||
$last_timestamp++;
|
||||
|
||||
|
||||
// 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");
|
||||
|
||||
|
||||
// Parse data file
|
||||
// We must parse from $start_date to avoid creating new intervals!
|
||||
netflow_parse_file ($start_date, $end_date, $temp_file, $values, $aggregate, $unit);
|
||||
|
||||
unlink ($temp_file);
|
||||
}
|
||||
|
||||
|
||||
// Save cache
|
||||
if ($aggregate == 'none') {
|
||||
netflow_save_cache ($values, $cache_file);
|
||||
|
@ -383,10 +386,10 @@ function netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggreg
|
|||
*/
|
||||
function netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max, $unit){
|
||||
global $nfdump_date_format;
|
||||
|
||||
|
||||
$command .= " -s $aggregate/$unit -n $max -t " .date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
|
||||
exec($command, $string);
|
||||
|
||||
|
||||
if(! is_array($string)){
|
||||
return array ();
|
||||
}
|
||||
|
@ -400,7 +403,7 @@ function netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max,
|
|||
$line = preg_replace('/\(\s*\S+\)/','',$line);
|
||||
$line = preg_replace('/\s+/',' ',$line);
|
||||
$val = explode(' ',$line);
|
||||
|
||||
|
||||
$values[$i]['date'] = $val[0];
|
||||
$values[$i]['time'] = $val[1];
|
||||
|
||||
|
@ -422,11 +425,12 @@ function netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max,
|
|||
default:
|
||||
$values[$i]['data'] = $val[7];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
sort_netflow_data ($values);
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
@ -440,7 +444,7 @@ function netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max,
|
|||
*/
|
||||
function netflow_get_command ($filter) {
|
||||
global $config;
|
||||
|
||||
|
||||
// Build command
|
||||
$command = 'nfdump -q -N -m';
|
||||
|
||||
|
@ -448,10 +452,10 @@ function netflow_get_command ($filter) {
|
|||
if (isset($config['netflow_path']) && $config['netflow_path'] != '') {
|
||||
$command .= ' -R '.$config['netflow_path'];
|
||||
}
|
||||
|
||||
|
||||
// Filter options
|
||||
$command .= netflow_get_filter_arguments ($filter);
|
||||
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
|
@ -464,14 +468,14 @@ function netflow_get_command ($filter) {
|
|||
*
|
||||
*/
|
||||
function netflow_get_filter_arguments ($filter) {
|
||||
|
||||
|
||||
// Advanced filter
|
||||
$filter_args = '';
|
||||
if ($filter['advanced_filter'] != '') {
|
||||
$filter_args = preg_replace('/["\r\n]/','', io_safe_output ($filter['advanced_filter']));
|
||||
return ' "(' . $filter_args . ')"';
|
||||
}
|
||||
|
||||
|
||||
// Normal filter
|
||||
if ($filter['ip_dst'] != ''){
|
||||
$filter_args .= ' "(';
|
||||
|
@ -483,7 +487,8 @@ function netflow_get_filter_arguments ($filter) {
|
|||
|
||||
if (netflow_is_net ($val_ipdst[$i]) == 0) {
|
||||
$filter_args .= 'dst ip '.$val_ipdst[$i];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$filter_args .= 'dst net '.$val_ipdst[$i];
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +497,8 @@ function netflow_get_filter_arguments ($filter) {
|
|||
if ($filter['ip_src'] != ''){
|
||||
if ($filter_args == '') {
|
||||
$filter_args .= ' "(';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$filter_args .= ' and (';
|
||||
}
|
||||
$val_ipsrc = explode(',', $filter['ip_src']);
|
||||
|
@ -503,7 +509,8 @@ function netflow_get_filter_arguments ($filter) {
|
|||
|
||||
if (netflow_is_net ($val_ipsrc[$i]) == 0) {
|
||||
$filter_args .= 'src ip '.$val_ipsrc[$i];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$filter_args .= 'src net '.$val_ipsrc[$i];
|
||||
}
|
||||
}
|
||||
|
@ -512,7 +519,8 @@ function netflow_get_filter_arguments ($filter) {
|
|||
if ($filter['dst_port'] != 0) {
|
||||
if ($filter_args == '') {
|
||||
$filter_args .= ' "(';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$filter_args .= ' and (';
|
||||
}
|
||||
$val_dstport = explode(',', $filter['dst_port']);
|
||||
|
@ -527,7 +535,8 @@ function netflow_get_filter_arguments ($filter) {
|
|||
if ($filter['src_port'] != 0) {
|
||||
if ($filter_args == '') {
|
||||
$filter_args .= ' "(';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$filter_args .= ' and (';
|
||||
}
|
||||
$val_srcport = explode(',', $filter['src_port']);
|
||||
|
@ -542,7 +551,7 @@ function netflow_get_filter_arguments ($filter) {
|
|||
if ($filter_args != '') {
|
||||
$filter_args .= '"';
|
||||
}
|
||||
|
||||
|
||||
return $filter_args;
|
||||
}
|
||||
|
||||
|
@ -562,21 +571,21 @@ function netflow_get_filter_arguments ($filter) {
|
|||
*/
|
||||
function netflow_parse_file ($start_date, $end_date, $file, &$values, $aggregate, $unit) {
|
||||
global $config;
|
||||
|
||||
|
||||
// Last timestamp read
|
||||
$last_timestamp = $start_date;
|
||||
|
||||
|
||||
// Open the data file
|
||||
$fh = @fopen ($file, "r");
|
||||
if ($fh === FALSE) {
|
||||
return $last_timestamp;
|
||||
}
|
||||
|
||||
|
||||
// Calculate the number of intervals
|
||||
$num_intervals = $config['graph_res'] * 50;
|
||||
$period = $end_date - $start_date;
|
||||
$interval_length = (int) ($period / $num_intervals);
|
||||
|
||||
|
||||
// Parse flow data
|
||||
$read_flag = 1;
|
||||
$flow = array ();
|
||||
|
@ -586,11 +595,12 @@ function netflow_parse_file ($start_date, $end_date, $file, &$values, $aggregate
|
|||
if ($aggregate != 'none') {
|
||||
$interval_total = array ();
|
||||
$interval_count = array ();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$interval_total = 0;
|
||||
$interval_count = 0;
|
||||
}
|
||||
|
||||
|
||||
do {
|
||||
if ($read_flag == 1) {
|
||||
$read_flag = 0;
|
||||
|
@ -610,7 +620,7 @@ function netflow_parse_file ($start_date, $end_date, $file, &$values, $aggregate
|
|||
$flow['date'] = $val[0];
|
||||
$flow['time'] = $val[1];
|
||||
|
||||
switch ($aggregate){
|
||||
switch ($aggregate) {
|
||||
case "proto":
|
||||
$flow['agg'] = $val[3];
|
||||
break;
|
||||
|
@ -657,12 +667,14 @@ function netflow_parse_file ($start_date, $end_date, $file, &$values, $aggregate
|
|||
$interval_total[$flow['agg']] += $flow['data'];
|
||||
$interval_count[$flow['agg']] += 1;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$interval_total += $flow['data'];
|
||||
$interval_count += 1;
|
||||
}
|
||||
}
|
||||
} while ($read_flag == 1);
|
||||
}
|
||||
while ($read_flag == 1);
|
||||
|
||||
if ($aggregate != 'none') {
|
||||
foreach ($interval_total as $agg => $val) {
|
||||
|
@ -671,24 +683,26 @@ function netflow_parse_file ($start_date, $end_date, $file, &$values, $aggregate
|
|||
if ($interval_count[$agg] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Read previous data for this interval
|
||||
if (isset ($values['data'][$timestamp][$agg])) {
|
||||
$previous_value = $values['data'][$timestamp][$agg];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$previous_value = 0;
|
||||
}
|
||||
|
||||
|
||||
// Calculate interval data
|
||||
$values['data'][$timestamp][$agg] = (int) ($interval_total[$agg] / $interval_count[$agg]);
|
||||
|
||||
|
||||
// Average with previous data
|
||||
if ($previous_value != 0) {
|
||||
$values['data'][$timestamp][$agg] = (int) (($values['data'][$timestamp][$agg] + $previous_data) / 2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
// No data for this interval
|
||||
if ($interval_count == 0) {
|
||||
continue;
|
||||
|
@ -697,10 +711,11 @@ function netflow_parse_file ($start_date, $end_date, $file, &$values, $aggregate
|
|||
// Read previous data for this interval
|
||||
if (isset ($values[$timestamp]['data'])) {
|
||||
$previous_value = $values[$timestamp]['data'];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$previous_value = 0;
|
||||
}
|
||||
|
||||
|
||||
// Calculate interval data
|
||||
$values[$timestamp]['data'] = (int) ($interval_total / $interval_count);
|
||||
|
||||
|
@ -708,11 +723,11 @@ function netflow_parse_file ($start_date, $end_date, $file, &$values, $aggregate
|
|||
if ($previous_value != 0) {
|
||||
$values[$timestamp]['data'] = (int) (($values[$timestamp]['data'] + $previous_value) / 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fclose ($fh);
|
||||
return $last_timestamp;
|
||||
}
|
||||
|
@ -725,12 +740,12 @@ function netflow_parse_file ($start_date, $end_date, $file, &$values, $aggregate
|
|||
*
|
||||
*/
|
||||
function netflow_save_cache ($data, $cache_file) {
|
||||
|
||||
|
||||
@file_put_contents ($cache_file, serialize ($data));
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load data from the specified cache file.
|
||||
*
|
||||
|
@ -892,5 +907,4 @@ function netflow_draw_item ($start_date, $end_date, $type, $filter, $command, $f
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
|
@ -270,7 +270,8 @@ function ui_print_message ($message, $class = '', $attributes = '', $return = fa
|
|||
|
||||
if ($return)
|
||||
return $output;
|
||||
echo $output;
|
||||
else
|
||||
echo $output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,7 +343,9 @@ function ui_print_result_message ($result, $good = '', $bad = '', $attributes =
|
|||
if (empty ($result)) {
|
||||
return ui_print_error_message ($bad, $attributes, $return, $tag);
|
||||
}
|
||||
return ui_print_success_message ($good, $attributes, $return, $tag);
|
||||
else {
|
||||
return ui_print_success_message ($good, $attributes, $return, $tag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -472,7 +475,7 @@ function ui_print_group_icon ($id_group, $return = false, $path = "groups_small"
|
|||
|
||||
if($style == '')
|
||||
$style = 'width: 16px; height: 16px;';
|
||||
|
||||
|
||||
$output = '';
|
||||
if ($link)
|
||||
$output = '<a href="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$id_group.'">';
|
||||
|
@ -508,7 +511,7 @@ function ui_print_group_icon_path ($id_group, $return = false, $path = "images/g
|
|||
|
||||
if($style == '')
|
||||
$style = 'width: 16px; height: 16px;';
|
||||
|
||||
|
||||
$output = '';
|
||||
if ($link)
|
||||
$output = '<a href="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$id_group.'">';
|
||||
|
@ -823,7 +826,8 @@ function ui_print_string_substr ($string, $cutoff = 16, $return = false, $fontsi
|
|||
$string2 = io_safe_output ($string);
|
||||
if (mb_strlen($string2, "UTF-8") > $cutoff){
|
||||
$string3 = "...";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$string3 = "";
|
||||
}
|
||||
|
||||
|
@ -1298,7 +1302,8 @@ function ui_process_page_head ($string, $bitfield) {
|
|||
$output .= $string;
|
||||
|
||||
if (!empty ($config["compact_header"])) {
|
||||
$output = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $output);
|
||||
$output = str_replace(array("\r\n", "\r", "\n", "\t", ' ',
|
||||
' ', ' '), '', $output);
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
@ -1315,7 +1320,8 @@ function ui_process_page_head ($string, $bitfield) {
|
|||
function ui_process_page_body ($string, $bitfield) {
|
||||
global $config;
|
||||
|
||||
if (isset ($config['ignore_callback']) && $config['ignore_callback'] == true) {
|
||||
if (isset ($config['ignore_callback']) &&
|
||||
$config['ignore_callback'] == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1326,12 +1332,13 @@ function ui_process_page_body ($string, $bitfield) {
|
|||
require_once ($config["homedir"]."/include/htmlawed.php");
|
||||
$htmLawedconfig = array ("valid_xhtml" => 1, "tidy" => -1);
|
||||
$output .= htmLawed ($string, $htmLawedconfig);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$output .= $string;
|
||||
}
|
||||
|
||||
|
||||
$output .= '</body>';
|
||||
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
@ -1433,7 +1440,8 @@ function ui_pagination ($count, $url = false, $offset = 0, $pagination = 0, $ret
|
|||
$output .= '<a class="pagination" href="'.$url.'&'.$offset_name.'='.$inicio_bloque.'">';
|
||||
if ($inicio_bloque == $offset) {
|
||||
$output .= "<b>[ $i ]</b>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$output .= "[ $i ]";
|
||||
}
|
||||
$output .= '</a></span>';
|
||||
|
@ -1512,7 +1520,7 @@ function ui_debug ($var, $backtrace = true) {
|
|||
unset ($traces[0]);
|
||||
foreach ($traces as $trace) {
|
||||
$trace_id++;
|
||||
|
||||
|
||||
/* Many classes are used to allow better customization.
|
||||
Please, do not remove them */
|
||||
echo '<li>';
|
||||
|
@ -1527,7 +1535,8 @@ function ui_debug ($var, $backtrace = true) {
|
|||
echo ' - <span class="filename">';
|
||||
echo str_replace ($config['homedir'].'/', '', $trace['file']);
|
||||
echo ':'.$trace['line'].'</span>';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo ' - <span class="filename"><em>Unknown file</em></span>';
|
||||
}
|
||||
echo '<pre id="args-'.$trace_id.'" class="invisible">';
|
||||
|
@ -1550,6 +1559,7 @@ function ui_debug ($var, $backtrace = true) {
|
|||
echo '<pre class="debug">';
|
||||
print_r ($var);
|
||||
echo '</pre>';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1576,14 +1586,14 @@ function ui_print_moduletype_icon ($id_moduletype, $return = false, $relative =
|
|||
if (! file_exists ($config['homedir'].'/'.$imagepath))
|
||||
$imagepath = ENTERPRISE_DIR.'/'.$imagepath;
|
||||
|
||||
if ($options){
|
||||
if ($options) {
|
||||
return html_print_image ($imagepath, $return,
|
||||
array ("border" => 0,
|
||||
"title" => $type["descripcion"]), false, $relative);
|
||||
}
|
||||
else{
|
||||
return html_print_image ($imagepath, $return,
|
||||
false, false, $relative);
|
||||
else {
|
||||
return html_print_image ($imagepath, $return,
|
||||
false, false, $relative);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1599,15 +1609,15 @@ function ui_print_moduletype_icon ($id_moduletype, $return = false, $relative =
|
|||
*/
|
||||
function ui_print_module_warn_value ($max_warning, $min_warning, $str_warning, $max_critical, $min_critical, $str_critical) {
|
||||
$data = "<span style='font-size: 8px' title='" . __("Warning") . ": " . __("Max") . $max_warning . "/" . __("Min") . $min_warning . " - " . __("Critical") . ": " . __("Max") . $max_critical . "/" . __("Min") . $min_critical . "'>";
|
||||
|
||||
|
||||
if ($max_warning != $min_warning) {
|
||||
$data .= format_for_graph($max_warning) ."/". format_for_graph ($min_warning);
|
||||
} else {
|
||||
$data .= __("N/A");
|
||||
}
|
||||
|
||||
|
||||
$data .= " - ";
|
||||
|
||||
|
||||
if ($max_critical != $min_critical){
|
||||
$data .= format_for_graph($max_critical) ."/". format_for_graph ($min_critical);
|
||||
} else {
|
||||
|
@ -1672,7 +1682,7 @@ function ui_get_status_images_path () {
|
|||
function ui_print_status_image ($type, $title = "", $return = false, $options = false) {
|
||||
list ($imagepath) = ui_get_status_images_path ();
|
||||
|
||||
$imagepath .= "/".$type;
|
||||
$imagepath .= "/" . $type;
|
||||
|
||||
if($options === false) {
|
||||
$options = array();
|
||||
|
@ -1749,7 +1759,7 @@ function ui_print_ui_agents_list ($options = false, $filter = false, $return = f
|
|||
*/
|
||||
function ui_get_include_contents ($filename, $params = false) {
|
||||
global $config;
|
||||
|
||||
|
||||
ob_start ();
|
||||
|
||||
if (is_array ($params)) {
|
||||
|
@ -1760,7 +1770,7 @@ function ui_get_include_contents ($filename, $params = false) {
|
|||
if (strncmp ($config["homedir"], $filename, strlen ($config["homedir"])) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$result = include ($filename);
|
||||
if ($result === false) {
|
||||
ob_end_clean ();
|
||||
|
|
|
@ -479,11 +479,11 @@ foreach ($modules as $module) {
|
|||
|
||||
|
||||
if ($module['history_data'] == 1) {
|
||||
// RAW Table data
|
||||
// RAW Table data
|
||||
echo "<td class=".$tdcolor." width=70>";
|
||||
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente&tab=data_view&period=2592000&id=".$module["id_agente_modulo"]."'>" . html_print_image('images/data_m.png', true, array("border" => '0', "alt" => '')) . "</a> ";
|
||||
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente&tab=data_view&period=604800&id=".$module["id_agente_modulo"]."'>" . html_print_image('images/data_w.png', true, array("border" => '0', "alt" => '')) . "</a> ";
|
||||
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente&tab=data_view&period=86400&id=".$module["id_agente_modulo"]."'>" . html_print_image('images/data_d.png', true, array("border" => '0', "alt" => '')) . "</a>";
|
||||
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente&tab=data_view&period=" . SECONDS_1MONTH . "&id=".$module["id_agente_modulo"]."'>" . html_print_image('images/data_m.png', true, array("border" => '0', "alt" => '')) . "</a> ";
|
||||
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente&tab=data_view&period=" . SECONDS_1WEEK . "&id=".$module["id_agente_modulo"]."'>" . html_print_image('images/data_w.png', true, array("border" => '0', "alt" => '')) . "</a> ";
|
||||
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente&tab=data_view&period=" . SECONDS_1DAY ."&id=".$module["id_agente_modulo"]."'>" . html_print_image('images/data_d.png', true, array("border" => '0', "alt" => '')) . "</a>";
|
||||
}
|
||||
else {
|
||||
echo "<td class=".$tdcolor."></td>";
|
||||
|
@ -494,7 +494,8 @@ foreach ($modules as $module) {
|
|||
$seconds = get_system_time () - $module["utimestamp"];
|
||||
if ($module['id_tipo_modulo'] < 21 && $module["module_interval"] > 0 && $module["utimestamp"] > 0 && $seconds >= ($module["module_interval"] * 2)) {
|
||||
echo '<span class="redb">';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo '<span>';
|
||||
}
|
||||
}
|
||||
|
@ -503,5 +504,4 @@ foreach ($modules as $module) {
|
|||
echo "</td></tr>";
|
||||
}
|
||||
echo '</table>';
|
||||
|
||||
?>
|
Loading…
Reference in New Issue