added event time filter in tactical view

This commit is contained in:
danielmaya 2018-10-24 16:36:44 +02:00
parent 41d104ae2c
commit 87abf1dc02
4 changed files with 95 additions and 21 deletions

View File

@ -38,6 +38,9 @@ $get_event_name = (bool) get_parameter ('get_event_name');
$meta = get_parameter ('meta', 0);
$history = get_parameter ('history', 0);
$table_events = get_parameter('table_events', 0);
$total_events = (bool)get_parameter('total_events');
$total_event_graph = (bool)get_parameter('total_event_graph');
$graphic_event_group = (bool)get_parameter('graphic_event_group');
if ($get_event_name) {
$event_id = get_parameter ('event_id');
@ -605,4 +608,37 @@ if ($get_list_events_agents) {
echo $returned_list;
return;
}
if ($total_events) {
global $config;
$sql_count_event = 'SELECT SQL_NO_CACHE COUNT(id_evento) FROM tevento ';
if ($config['event_view_hr']) {
$sql_count_event .= 'WHERE utimestamp > (UNIX_TIMESTAMP(NOW()) - ' . $config['event_view_hr'] * SECONDS_1HOUR . ')';
}
$system_events = db_get_value_sql($sql_count_event);
echo $system_events;
return;
}
if ($total_event_graph) {
global $config;
require_once($config["homedir"] . '/include/functions_graph.php');
$prueba = grafico_eventos_total("", 280, 150, false, true);
echo $prueba;
return;
}
if ($graphic_event_group) {
global $config;
require_once($config["homedir"] . '/include/functions_graph.php');
$prueba = grafico_eventos_grupo(280, 150, "", false, true);
echo $prueba;
return;
}
?>

View File

@ -2756,8 +2756,10 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $noWater
// Add tags condition to filter
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND');
if ($time_limit) {
$tags_condition .= " AND utimestamp > (UNIX_TIMESTAMP(NOW()) - " . SECONDS_1DAY . ")";
if ($time_limit && $config['event_view_hr']) {
$tags_condition .= " AND utimestamp > (UNIX_TIMESTAMP(NOW()) - " .
$config['event_view_hr'] * SECONDS_1HOUR . ")";
}
//This will give the distinct id_agente, give the id_grupo that goes
@ -2835,8 +2837,8 @@ function grafico_eventos_total($filter = "", $width = 320, $height = 200, $noWat
// Add tags condition to filter
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND');
$filter .= $tags_condition;
if ($time_limit) {
$filter .= " AND utimestamp > (UNIX_TIMESTAMP(NOW()) - " . SECONDS_1DAY . ")";
if ($time_limit && $config['event_view_hr']) {
$filter .= " AND utimestamp > (UNIX_TIMESTAMP(NOW()) - " . $config['event_view_hr'] * SECONDS_1HOUR . ")";
}
$data = array ();

View File

@ -10182,17 +10182,11 @@ function reporting_get_stats_servers() {
$table_srv->rowclass[] = '';
$table_srv->data[] = $tdata;
$system_events = db_get_value_sql(
'SELECT SQL_NO_CACHE COUNT(id_evento)
FROM tevento
WHERE utimestamp > (UNIX_TIMESTAMP(NOW()) - ' . SECONDS_1DAY . ')'
);
$tdata = array();
$tdata[0] = html_print_image('images/lightning_go.png', true,
array('title' => __('Total events'), 'width' => '25px'));
$tdata[1] = '<span class="big_data">' .
format_numeric($system_events) . '</span>';
$tdata[1] = '<span class="big_data" id="total_events">' .
html_print_image('images/spinner.gif',true) . '</span>';
/* Hello there! :)
We added some of what seems to be "buggy" messages to the openSource version recently. This is not to force open-source users to move to the enterprise version, this is just to inform people using Pandora FMS open source that it requires skilled people to maintain and keep it running smoothly without professional support. This does not imply open-source version is limited in any way. If you check the recently added code, it contains only warnings and messages, no limitations except one: we removed the option to add custom logo in header. In the Update Manager section, it warns about the 'danger of applying automated updates without a proper backup, remembering in the process that the Enterprise version comes with a human-tested package. Maintaining an OpenSource version with more than 500 agents is not so easy, that's why someone using a Pandora with 8000 agents should consider asking for support. It's not a joke, we know of many setups with a huge number of agents, and we hate to hear that “its becoming unstable and slow” :(
@ -10214,6 +10208,20 @@ You can of course remove the warnings, that's why we include the source and do n
'</legend>' .
html_print_table($table_srv, true) . '</fieldset>';
$output .= '<script type="text/javascript">';
$output .= '$(document).ready(function () {';
$output .= 'var parameters = {};';
$output .= 'parameters["page"] = "include/ajax/events";';
$output .= 'parameters["total_events"] = 1;';
$output .= '$.ajax({type: "GET",url: "ajax.php",data: parameters,';
$output .= 'success: function(data) {';
$output .= '$("#total_events").text(data);';
$output .= '}';
$output .= '});';
$output .= '});';
$output .= '</script>';
return $output;
}

View File

@ -183,7 +183,11 @@ if (check_acl($config['id_user'],0,'ER')) {
if (!empty($tags_condition)) {
$event_filter .= " AND ($tags_condition)";
}
$event_filter .= " AND utimestamp > (UNIX_TIMESTAMP(NOW()) - " . SECONDS_1DAY . ")";
if ($config['event_view_hr']) {
$event_filter .= " AND utimestamp > (UNIX_TIMESTAMP(NOW()) - " . $config['event_view_hr'] * SECONDS_1HOUR . ")";
}
$events = events_print_event_table ($event_filter, 10, "100%",true,false,true);
ui_toggle($events, __('Latest events'),false,false);
}
@ -197,20 +201,44 @@ if ($is_admin) {
}
$out = '<table cellpadding=0 cellspacing=0 class="databox pies" style="margin-top:15px;" width=100%><tr><td>';
$out .= '<fieldset class="databox tactical_set">
$out .= '<fieldset class="databox tactical_set" id="total_event_graph">
<legend>' .
__('Event graph') .
'</legend>' .
grafico_eventos_total("", 280, 150, false, true) . '</fieldset>';
html_print_image('images/spinner.gif',true,array('id' => 'spinner_total_event_graph')) . '</fieldset>';
$out .="</td><td>";
$out .= '<fieldset class="databox tactical_set">
$out .= '<fieldset class="databox tactical_set" id="graphic_event_group">
<legend>' .
__('Event graph by agent') .
'</legend>' .
grafico_eventos_grupo(280, 150, "", false, true) . '</fieldset>';
html_print_image('images/spinner.gif', true, array('id' => 'spinner_graphic_event_group')) . '</fieldset>';
$out .= '</td></tr></table>';
echo $out;
echo '</td>';
echo '</tr></table>';
?>
<script type="text/javascript">
$(document).ready(function () {
var parameters = {};
parameters["page"] = "include/ajax/events";
parameters["total_event_graph"] = 1;
$.ajax({type: "GET",url: "ajax.php",data: parameters,
success: function(data) {
$("#spinner_total_event_graph").hide();
$("#total_event_graph").append(data);
}
});
delete parameters["total_event_graph"];
parameters["graphic_event_group"] = 1;
$.ajax({type: "GET",url: "ajax.php",data: parameters,
success: function(data) {
$("#spinner_graphic_event_group").hide();
$("#graphic_event_group").append(data);
}
});
});
</script>