mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-25 19:09:08 +02:00
Added network explorer report filter
Former-commit-id: f50d86b3ba226cc8068b3eae0fb5c72f4d30dd0b
This commit is contained in:
parent
f9b14072d8
commit
8480572e5a
@ -52,3 +52,31 @@ function network_matrix_get_top($top, $talker, $start, $end)
|
|||||||
|
|
||||||
return ($data !== false) ? $data : [];
|
return ($data !== false) ? $data : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the possible actions on networking.
|
||||||
|
*
|
||||||
|
* @param boolean $network True if network. False if netflow.
|
||||||
|
*
|
||||||
|
* @return array With the actions to print in a select.
|
||||||
|
*/
|
||||||
|
function network_get_report_actions($network)
|
||||||
|
{
|
||||||
|
$common_actions = [
|
||||||
|
'listeners' => __('Top listeners'),
|
||||||
|
'talkers' => __('Top talkers'),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($network) {
|
||||||
|
return $common_actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_merge(
|
||||||
|
$common_actions,
|
||||||
|
[
|
||||||
|
'tcp' => __('Top TCP protocols'),
|
||||||
|
'udp' => __('Top UDP protocols'),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -18,4 +18,9 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODOS.
|
global $config;
|
||||||
|
|
||||||
|
$action = get_parameter('action', 'listeners');
|
||||||
|
$is_network = true;
|
||||||
|
|
||||||
|
require $config['homedir'].'/operation/network/network_report.php';
|
||||||
|
158
pandora_console/operation/network/network_report.php
Normal file
158
pandora_console/operation/network/network_report.php
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Network explorer
|
||||||
|
*
|
||||||
|
* @package Operations.
|
||||||
|
* @subpackage Network explorer view.
|
||||||
|
*
|
||||||
|
* Pandora FMS - http://pandorafms.com
|
||||||
|
* ==================================================
|
||||||
|
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||||
|
* Please see http://pandorafms.org for full contribution list
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; version 2
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
check_login();
|
||||||
|
|
||||||
|
// ACL Check.
|
||||||
|
if (! check_acl($config['id_user'], 0, 'AR')) {
|
||||||
|
db_pandora_audit(
|
||||||
|
'ACL Violation',
|
||||||
|
'Trying to access Network report (Grouped)'
|
||||||
|
);
|
||||||
|
include 'general/noaccess.php';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Include JS timepicker.
|
||||||
|
ui_include_time_picker();
|
||||||
|
|
||||||
|
// Query params and other initializations.
|
||||||
|
$time_greater = get_parameter('time_greater', date(TIME_FORMAT));
|
||||||
|
$date_greater = get_parameter('date_greater', date(DATE_FORMAT));
|
||||||
|
$utimestamp_greater = strtotime($date_greater.' '.$time_greater);
|
||||||
|
$is_period = (bool) get_parameter('is_period', false);
|
||||||
|
$period = (int) get_parameter('period', SECONDS_1HOUR);
|
||||||
|
$time_lower = get_parameter('time_lower', date(TIME_FORMAT, ($utimestamp_greater - $period)));
|
||||||
|
$date_lower = get_parameter('date_lower', date(DATE_FORMAT, ($utimestamp_greater - $period)));
|
||||||
|
$utimestamp_lower = ($is_period) ? ($utimestamp_greater - $period) : strtotime($date_lower.' '.$time_lower);
|
||||||
|
if (!$is_period) {
|
||||||
|
$period = ($utimestamp_greater - $utimestamp_lower);
|
||||||
|
}
|
||||||
|
|
||||||
|
$top = get_parameter('top', 10);
|
||||||
|
$style_end = ($is_period) ? 'display: none;' : '';
|
||||||
|
$style_period = ($is_period) ? '' : 'display: none;';
|
||||||
|
|
||||||
|
// Build the table.
|
||||||
|
$table = new stdClass();
|
||||||
|
$table->class = 'databox';
|
||||||
|
$table->styleTable = 'width: 100%';
|
||||||
|
$table->style[0] = 'width: 40%';
|
||||||
|
$table->style[1] = 'width: 40%';
|
||||||
|
$table->style[2] = 'width: 20%';
|
||||||
|
$table->data['0']['0'] = __('Data to show').' ';
|
||||||
|
$table->data['0']['0'] .= html_print_select(
|
||||||
|
network_get_report_actions($is_network),
|
||||||
|
'action',
|
||||||
|
$action,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
0,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$table->data['0']['1'] = __('Number of result to show').' ';
|
||||||
|
$table->data['0']['1'] .= html_print_select(
|
||||||
|
[
|
||||||
|
'5' => 5,
|
||||||
|
'10' => 10,
|
||||||
|
'15' => 15,
|
||||||
|
'20' => 20,
|
||||||
|
'25' => 25,
|
||||||
|
'50' => 50,
|
||||||
|
'100' => 100,
|
||||||
|
'250' => 250,
|
||||||
|
],
|
||||||
|
'top',
|
||||||
|
$top,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
0,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$table->data['0']['2'] = __('Select period').' ';
|
||||||
|
$table->data['0']['2'] .= html_print_checkbox(
|
||||||
|
'is_period',
|
||||||
|
1,
|
||||||
|
($is_period === true) ? 1 : 0,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
'network_report_click_period(event)'
|
||||||
|
);
|
||||||
|
|
||||||
|
$table->data['1']['0'] = __('Start date').' ';
|
||||||
|
$table->data['1']['0'] .= html_print_input_text('date_greater', $date_greater, '', 10, 7, true);
|
||||||
|
$table->data['1']['0'] .= ' ';
|
||||||
|
$table->data['1']['0'] .= html_print_input_text('time_greater', $time_greater, '', 7, 8, true);
|
||||||
|
|
||||||
|
$table->data['1']['1'] = '<div id="end_date_container" style="'.$style_end.'">';
|
||||||
|
$table->data['1']['1'] .= __('End date').' ';
|
||||||
|
$table->data['1']['1'] .= html_print_input_text('date_lower', $date_lower, '', 10, 7, true, $is_period);
|
||||||
|
$table->data['1']['1'] .= ' ';
|
||||||
|
$table->data['1']['1'] .= html_print_input_text('time_lower', $time_lower, '', 7, 8, true, $is_period);
|
||||||
|
$table->data['1']['1'] .= '</div>';
|
||||||
|
|
||||||
|
$table->data['1']['1'] .= '<div id="period_container" style="'.$style_period.'">';
|
||||||
|
$table->data['1']['1'] .= __('Time Period').' ';
|
||||||
|
$table->data['1']['1'] .= html_print_input_text('period', $period, '', 7, 8, true, !$is_period);
|
||||||
|
$table->data['1']['1'] .= '</div>';
|
||||||
|
|
||||||
|
$table->data['1']['2'] = html_print_submit_button(
|
||||||
|
__('Update'),
|
||||||
|
'update',
|
||||||
|
false,
|
||||||
|
'class="sub upd"',
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<form method="post">';
|
||||||
|
html_print_table($table);
|
||||||
|
echo '</form>';
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// Configure jQuery timepickers.
|
||||||
|
$("#text-time_lower, #text-time_greater").timepicker({
|
||||||
|
showSecond: true,
|
||||||
|
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
||||||
|
timeOnlyTitle: '<?php echo __('Choose time'); ?>',
|
||||||
|
timeText: '<?php echo __('Time'); ?>',
|
||||||
|
hourText: '<?php echo __('Hour'); ?>',
|
||||||
|
minuteText: '<?php echo __('Minute'); ?>',
|
||||||
|
secondText: '<?php echo __('Second'); ?>',
|
||||||
|
currentText: '<?php echo __('Now'); ?>',
|
||||||
|
closeText: '<?php echo __('Close'); ?>'
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#text-date_lower, #text-date_greater").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
||||||
|
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
||||||
|
|
||||||
|
function network_report_click_period(event) {
|
||||||
|
var is_period = document.getElementById(event.target.id).checked;
|
||||||
|
|
||||||
|
document.getElementById('period_container').style.display = !is_period ? 'none' : 'block';
|
||||||
|
document.getElementById('end_date_container').style.display = is_period ? 'none' : 'block';
|
||||||
|
|
||||||
|
document.getElementById('text-time_lower').disabled = is_period;
|
||||||
|
document.getElementById('text-date_lower').disabled = is_period;
|
||||||
|
document.getElementById('text-period').disabled = !is_period;
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user