#12344 Fixed log source

This commit is contained in:
Daniel Maya 2023-10-30 15:15:53 +01:00
parent c48414ac8a
commit ed1ae83770
2 changed files with 55 additions and 23 deletions

View File

@ -1718,3 +1718,5 @@ operation/incidents/list_integriaims_incidents.php
include/functions_incidents.php
include/functions_integriaims.php
include/ajax/integria_incidents.ajax.php
enterprise/operation/log/log_source.php
enterprise/include/class/LogSource.class.php

View File

@ -16,6 +16,8 @@ global $config;
// Login check.
check_login();
enterprise_include('include/functions_elasticsearch.php');
?>
<script type="text/javascript">
@ -62,30 +64,58 @@ $table->style['source'] = 'width: 80%;';
$table->data = [];
$data = [];
$data['agent_id'] = [0 => $agent_id];
$filter = elasticsearch_filter_build($data, 0);
$filter['aggs'] = [
'results' => [
'composite' => [
'sources' => [
[
'source_id' => [
'terms' => [
'script' => ['source' => "params['_source'].source_id"],
],
],
],
],
],
],
];
$logs = elasticsearch_curl(
$filter,
$config['elasticsearch_ip'],
$config['elasticsearch_port'],
0,
false,
false,
false,
'desc',
false,
);
$logs = json_decode($logs);
$row = [];
// Get most recent sources for active agent.
$sql = "select source, MAX(utimestamp) AS last_contact from tagent_module_log where id_agent=$agent_id GROUP BY source";
$logs = mysql_db_get_all_rows_sql($sql);
foreach ($logs as $log) {
$row['source'] = $log['source'];
$row['review'] = '<a href="javascript:void(0)">'.html_print_image('images/zoom.png', true, ['title' => __('Review in log viewer'), 'alt' => '', 'onclick' => "send_form('".$log['source'].'-'.$agent_id."')"]).'</a>';
$row['last_contact'] = html_print_image(
'images/spinner.gif',
true,
[
'id' => 'img-'.$log['source'],
'border' => '0',
'width' => '20px',
'heigth' => '20px',
'onload' => "get_last_contact('".$log['source']."', '".$agent_id."')",
]
);
$table->data[$log['source']] = $row;
if (empty($logs->aggregations) === false) {
$buckets = $logs->aggregations->results->buckets;
foreach ($buckets as $key => $bucket) {
$source = $bucket->key->source_id;
$row['source'] = $source;
$row['review'] = '<a href="javascript:void(0)">'.html_print_image('images/zoom.png', true, ['title' => __('Review in log viewer'), 'alt' => '', 'onclick' => "send_form('".$source.'-'.$agent_id."')"]).'</a>';
$row['last_contact'] = html_print_image(
'images/spinner.gif',
true,
[
'id' => 'img-'.$source,
'border' => '0',
'width' => '20px',
'heigth' => '20px',
'onload' => "get_last_contact('".$source."', '".$agent_id."')",
]
);
$table->data[$source] = $row;
}
}
ob_start();