mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
refactor events meta pandora_enterprise#9086
This commit is contained in:
parent
951a1703bf
commit
8dbc860f4a
@ -57,7 +57,6 @@ if (! check_acl($config['id_user'], 0, 'ER')
|
|||||||
}
|
}
|
||||||
|
|
||||||
$get_events_details = (bool) get_parameter('get_events_details');
|
$get_events_details = (bool) get_parameter('get_events_details');
|
||||||
$get_list_events_agents = (bool) get_parameter('get_list_events_agents');
|
|
||||||
$get_extended_event = (bool) get_parameter('get_extended_event');
|
$get_extended_event = (bool) get_parameter('get_extended_event');
|
||||||
$change_status = (bool) get_parameter('change_status');
|
$change_status = (bool) get_parameter('change_status');
|
||||||
$change_owner = (bool) get_parameter('change_owner');
|
$change_owner = (bool) get_parameter('change_owner');
|
||||||
@ -1892,53 +1891,6 @@ if ($table_events) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($get_list_events_agents) {
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
$id_agent = get_parameter('id_agent');
|
|
||||||
$server_id = get_parameter('server_id');
|
|
||||||
$event_type = get_parameter('event_type');
|
|
||||||
$severity = implode(',', get_parameter('severity', -1));
|
|
||||||
$status = get_parameter('status');
|
|
||||||
$search = get_parameter('search');
|
|
||||||
$id_agent_module = get_parameter('id_agent_module');
|
|
||||||
$event_view_hr = get_parameter('event_view_hr');
|
|
||||||
$id_user_ack = get_parameter('id_user_ack');
|
|
||||||
$tag_with = get_parameter('tag_with');
|
|
||||||
$tag_without = get_parameter('tag_without');
|
|
||||||
$filter_only_alert = get_parameter('filter_only_alert');
|
|
||||||
$date_from = get_parameter('date_from');
|
|
||||||
$time_from = get_parameter('time_from', '00:00:00');
|
|
||||||
$date_to = get_parameter('date_to');
|
|
||||||
$time_to = get_parameter('time_to', '23:59:59');
|
|
||||||
$id_user = $config['id_user'];
|
|
||||||
|
|
||||||
$returned_sql = events_sql_events_grouped_agents(
|
|
||||||
$id_agent,
|
|
||||||
$server_id,
|
|
||||||
$event_type,
|
|
||||||
$severity,
|
|
||||||
$status,
|
|
||||||
$search,
|
|
||||||
$id_agent_module,
|
|
||||||
$event_view_hr,
|
|
||||||
$id_user_ack,
|
|
||||||
$tag_with,
|
|
||||||
$tag_without,
|
|
||||||
$filter_only_alert,
|
|
||||||
$date_from,
|
|
||||||
$time_from,
|
|
||||||
$date_to,
|
|
||||||
$time_to,
|
|
||||||
$id_user
|
|
||||||
);
|
|
||||||
|
|
||||||
$returned_list = events_list_events_grouped_agents($returned_sql);
|
|
||||||
|
|
||||||
echo $returned_list;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($total_events) {
|
if ($total_events) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3286,73 +3286,6 @@ function series_suffix_leyend($series_name, $series_suffix, $id_agent, $data_mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function graph_events_validated($width=300, $height=200, $extra_filters=[], $meta=false, $history=false)
|
|
||||||
{
|
|
||||||
global $config;
|
|
||||||
global $graphic_type;
|
|
||||||
|
|
||||||
$event_type = false;
|
|
||||||
if (array_key_exists('event_type', $extra_filters)) {
|
|
||||||
$event_type = $extra_filters['event_type'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$event_severity = false;
|
|
||||||
if (array_key_exists('event_severity', $extra_filters)) {
|
|
||||||
$event_severity = $extra_filters['event_severity'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$event_status = false;
|
|
||||||
if (array_key_exists('event_status', $extra_filters)) {
|
|
||||||
$event_status = $extra_filters['event_status'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$event_filter_search = false;
|
|
||||||
if (array_key_exists('event_filter_search', $extra_filters)) {
|
|
||||||
$event_filter_search = $extra_filters['event_filter_search'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$data_graph = events_get_count_events_validated(
|
|
||||||
['id_group' => array_keys(users_get_groups())],
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
$event_severity,
|
|
||||||
$event_type,
|
|
||||||
$event_status,
|
|
||||||
$event_filter_search
|
|
||||||
);
|
|
||||||
|
|
||||||
$colors = [];
|
|
||||||
foreach ($data_graph as $k => $v) {
|
|
||||||
if ($k == __('Validated')) {
|
|
||||||
$colors[$k] = COL_NORMAL;
|
|
||||||
} else {
|
|
||||||
$colors[$k] = COL_CRITICAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($config['fixed_graph'] == false) {
|
|
||||||
$water_mark = [
|
|
||||||
'file' => $config['homedir'].'/images/logo_vertical_water.png',
|
|
||||||
'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
echo pie_graph(
|
|
||||||
$data_graph,
|
|
||||||
$width,
|
|
||||||
$height,
|
|
||||||
__('other'),
|
|
||||||
'',
|
|
||||||
$water_mark,
|
|
||||||
$config['fontpath'],
|
|
||||||
$config['font_size'],
|
|
||||||
1,
|
|
||||||
'bottom',
|
|
||||||
$colors
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a pie graph with events data of group
|
* Print a pie graph with events data of group
|
||||||
*
|
*
|
||||||
@ -3365,13 +3298,13 @@ function grafico_eventos_grupo($width=300, $height=200, $url='', $noWaterMark=tr
|
|||||||
global $config;
|
global $config;
|
||||||
global $graphic_type;
|
global $graphic_type;
|
||||||
|
|
||||||
// It was urlencoded, so we urldecode it
|
// It was urlencoded, so we urldecode it.
|
||||||
$url = html_entity_decode(rawurldecode($url), ENT_QUOTES);
|
$url = html_entity_decode(rawurldecode($url), ENT_QUOTES);
|
||||||
$data = [];
|
$data = [];
|
||||||
$loop = 0;
|
$loop = 0;
|
||||||
define('NUM_PIECES_PIE', 6);
|
define('NUM_PIECES_PIE', 6);
|
||||||
|
|
||||||
// Hotfix for the id_agente_modulo
|
// Hotfix for the id_agente_modulo.
|
||||||
$url = str_replace(
|
$url = str_replace(
|
||||||
'SELECT id_agente_modulo',
|
'SELECT id_agente_modulo',
|
||||||
'SELECT_id_agente_modulo',
|
'SELECT_id_agente_modulo',
|
||||||
@ -3386,22 +3319,24 @@ function grafico_eventos_grupo($width=300, $height=200, $url='', $noWaterMark=tr
|
|||||||
'INSERT ',
|
'INSERT ',
|
||||||
'EXEC',
|
'EXEC',
|
||||||
];
|
];
|
||||||
// remove bad strings from the query so queries like ; DELETE FROM don't pass
|
// remove bad strings from the query so queries like ; DELETE FROM don't pass.
|
||||||
$url = str_ireplace($badstrings, '', $url);
|
$url = str_ireplace($badstrings, '', $url);
|
||||||
|
|
||||||
// Hotfix for the id_agente_modulo
|
// Hotfix for the id_agente_modulo.
|
||||||
$url = str_replace(
|
$url = str_replace(
|
||||||
'SELECT_id_agente_modulo',
|
'SELECT_id_agente_modulo',
|
||||||
'SELECT id_agente_modulo',
|
'SELECT id_agente_modulo',
|
||||||
$url
|
$url
|
||||||
);
|
);
|
||||||
|
|
||||||
$event_table = 'tevento';
|
// Add tags condition to filter.
|
||||||
$field_extra = '';
|
$tags_condition = tags_get_acl_tags(
|
||||||
$groupby_extra = '';
|
$config['id_user'],
|
||||||
|
0,
|
||||||
// Add tags condition to filter
|
'ER',
|
||||||
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND');
|
'event_condition',
|
||||||
|
'AND'
|
||||||
|
);
|
||||||
|
|
||||||
if ($time_limit && $config['event_view_hr']) {
|
if ($time_limit && $config['event_view_hr']) {
|
||||||
$tags_condition .= ' AND utimestamp > (UNIX_TIMESTAMP(NOW()) - '.($config['event_view_hr'] * SECONDS_1HOUR).')';
|
$tags_condition .= ' AND utimestamp > (UNIX_TIMESTAMP(NOW()) - '.($config['event_view_hr'] * SECONDS_1HOUR).')';
|
||||||
@ -3409,14 +3344,14 @@ function grafico_eventos_grupo($width=300, $height=200, $url='', $noWaterMark=tr
|
|||||||
|
|
||||||
// This will give the distinct id_agente, give the id_grupo that goes
|
// This will give the distinct id_agente, give the id_grupo that goes
|
||||||
// with it and then the number of times it occured. GROUP BY statement
|
// with it and then the number of times it occured. GROUP BY statement
|
||||||
// is required if both DISTINCT() and COUNT() are in the statement
|
// is required if both DISTINCT() and COUNT() are in the statement.
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
'SELECT DISTINCT(id_agente) AS id_agente,
|
'SELECT DISTINCT(id_agente) AS id_agente,
|
||||||
COUNT(id_agente) AS count'.$field_extra.'
|
COUNT(id_agente) AS count
|
||||||
FROM '.$event_table.' te LEFT JOIN tagent_secondary_group tasg
|
FROM tevento te LEFT JOIN tagent_secondary_group tasg
|
||||||
ON te.id_grupo = tasg.id_group
|
ON te.id_grupo = tasg.id_group
|
||||||
WHERE 1=1 %s %s
|
WHERE 1=1 %s %s
|
||||||
GROUP BY id_agente'.$groupby_extra.'
|
GROUP BY id_agente
|
||||||
ORDER BY count DESC LIMIT 8',
|
ORDER BY count DESC LIMIT 8',
|
||||||
$url,
|
$url,
|
||||||
$tags_condition
|
$tags_condition
|
||||||
@ -3456,7 +3391,7 @@ function grafico_eventos_grupo($width=300, $height=200, $url='', $noWaterMark=tr
|
|||||||
$data[$name] = $system_events;
|
$data[$name] = $system_events;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the data
|
// Sort the data.
|
||||||
arsort($data);
|
arsort($data);
|
||||||
if ($noWaterMark) {
|
if ($noWaterMark) {
|
||||||
$water_mark = [
|
$water_mark = [
|
||||||
|
@ -67,6 +67,7 @@ define('REPORT_STATUS_DOWNTIME', 4);
|
|||||||
define('REPORT_STATUS_IGNORED', 5);
|
define('REPORT_STATUS_IGNORED', 5);
|
||||||
|
|
||||||
// Clases.
|
// Clases.
|
||||||
|
use PandoraFMS\Event;
|
||||||
use PandoraFMS\Module;
|
use PandoraFMS\Module;
|
||||||
|
|
||||||
|
|
||||||
@ -1959,7 +1960,10 @@ function reporting_event_report_group(
|
|||||||
$event_graph_by_criticity = $event_filter['event_graph_by_criticity'];
|
$event_graph_by_criticity = $event_filter['event_graph_by_criticity'];
|
||||||
$event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated'];
|
$event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated'];
|
||||||
|
|
||||||
if (isset($content['recursion']) && $content['recursion'] == 1 && $content['id_group'] != 0) {
|
if (isset($content['recursion'])
|
||||||
|
&& $content['recursion'] == 1
|
||||||
|
&& $content['id_group'] != 0
|
||||||
|
) {
|
||||||
$propagate = db_get_value(
|
$propagate = db_get_value(
|
||||||
'propagate',
|
'propagate',
|
||||||
'tgrupo',
|
'tgrupo',
|
||||||
@ -2029,27 +2033,26 @@ function reporting_event_report_group(
|
|||||||
$return['chart']['by_user_validator'] = null;
|
$return['chart']['by_user_validator'] = null;
|
||||||
$return['chart']['by_criticity'] = null;
|
$return['chart']['by_criticity'] = null;
|
||||||
$return['chart']['validated_vs_unvalidated'] = null;
|
$return['chart']['validated_vs_unvalidated'] = null;
|
||||||
$server_name = $content['server_name'];
|
|
||||||
$metaconsole_dbtable = false;
|
|
||||||
if (is_metaconsole() === true && empty($server_name) === true) {
|
|
||||||
$metaconsole_dbtable = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($event_graph_by_agent) {
|
if ($event_graph_by_agent) {
|
||||||
$data_graph = events_get_count_events_by_agent(
|
$data_graph_by_agent = [];
|
||||||
$content['id_group'],
|
if (empty($data) === false) {
|
||||||
$content['period'],
|
foreach ($data as $value) {
|
||||||
$report['datetime'],
|
$k = $value['alias'];
|
||||||
$filter_event_severity,
|
if (is_metaconsole() === true) {
|
||||||
$filter_event_type,
|
$k = '('.$value['server_name'].') '.$value['alias'];
|
||||||
$filter_event_status,
|
}
|
||||||
$filter_event_filter_search,
|
|
||||||
$metaconsole_dbtable,
|
if (isset($data_graph_by_agent[$k]) === true) {
|
||||||
$filter_event_filter_exclude
|
$data_graph_by_agent[$k]++;
|
||||||
);
|
} else {
|
||||||
|
$data_graph_by_agent[$k] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$return['chart']['by_agent'] = pie_graph(
|
$return['chart']['by_agent'] = pie_graph(
|
||||||
$data_graph,
|
$data_graph_by_agent,
|
||||||
500,
|
500,
|
||||||
150,
|
150,
|
||||||
__('other'),
|
__('other'),
|
||||||
@ -2062,20 +2065,9 @@ function reporting_event_report_group(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($event_graph_by_user_validator) {
|
if ($event_graph_by_user_validator) {
|
||||||
$data_graph = events_get_count_events_validated_by_user(
|
$data_graph_by_user = events_get_count_events_validated_by_user($data);
|
||||||
['id_group' => $content['id_group']],
|
|
||||||
$content['period'],
|
|
||||||
$report['datetime'],
|
|
||||||
$filter_event_severity,
|
|
||||||
$filter_event_type,
|
|
||||||
$filter_event_status,
|
|
||||||
$filter_event_filter_search,
|
|
||||||
$metaconsole_dbtable,
|
|
||||||
$filter_event_filter_exclude
|
|
||||||
);
|
|
||||||
|
|
||||||
$return['chart']['by_user_validator'] = pie_graph(
|
$return['chart']['by_user_validator'] = pie_graph(
|
||||||
$data_graph,
|
$data_graph_by_user,
|
||||||
500,
|
500,
|
||||||
150,
|
150,
|
||||||
__('other'),
|
__('other'),
|
||||||
@ -2088,21 +2080,22 @@ function reporting_event_report_group(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($event_graph_by_criticity) {
|
if ($event_graph_by_criticity) {
|
||||||
$data_graph = events_get_count_events_by_criticity(
|
$data_graph_by_criticity = [];
|
||||||
['id_group' => $content['id_group']],
|
if (empty($data) === false) {
|
||||||
$content['period'],
|
foreach ($data as $value) {
|
||||||
$report['datetime'],
|
$k = get_priority_name($value['criticity']);
|
||||||
$filter_event_severity,
|
if (isset($data_graph_by_criticity[$k]) === true) {
|
||||||
$filter_event_type,
|
$data_graph_by_criticity[$k]++;
|
||||||
$filter_event_status,
|
} else {
|
||||||
$filter_event_filter_search,
|
$data_graph_by_criticity[$k] = 1;
|
||||||
$metaconsole_dbtable
|
}
|
||||||
);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$colors = get_criticity_pie_colors($data_graph);
|
$colors = get_criticity_pie_colors($data_graph_by_criticity);
|
||||||
|
|
||||||
$return['chart']['by_criticity'] = pie_graph(
|
$return['chart']['by_criticity'] = pie_graph(
|
||||||
$data_graph,
|
$data_graph_by_criticity,
|
||||||
500,
|
500,
|
||||||
150,
|
150,
|
||||||
__('other'),
|
__('other'),
|
||||||
@ -2117,20 +2110,24 @@ function reporting_event_report_group(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($event_graph_validated_vs_unvalidated) {
|
if ($event_graph_validated_vs_unvalidated) {
|
||||||
$data_graph = events_get_count_events_validated(
|
$data_graph_by_status = [];
|
||||||
['id_group' => $content['id_group']],
|
if (empty($data) === false) {
|
||||||
$content['period'],
|
$status = [
|
||||||
$report['datetime'],
|
1 => __('Validated'),
|
||||||
$filter_event_severity,
|
0 => __('Not validated'),
|
||||||
$filter_event_type,
|
];
|
||||||
$filter_event_status,
|
foreach ($data as $value) {
|
||||||
$filter_event_filter_search,
|
$k = $status[$value['estado']];
|
||||||
$metaconsole_dbtable,
|
if (isset($data_graph_by_status[$k]) === true) {
|
||||||
$filter_event_filter_exclude
|
$data_graph_by_status[$k]++;
|
||||||
);
|
} else {
|
||||||
|
$data_graph_by_status[$k] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$return['chart']['validated_vs_unvalidated'] = pie_graph(
|
$return['chart']['validated_vs_unvalidated'] = pie_graph(
|
||||||
$data_graph,
|
$data_graph_by_status,
|
||||||
500,
|
500,
|
||||||
150,
|
150,
|
||||||
__('other'),
|
__('other'),
|
||||||
@ -2142,10 +2139,6 @@ function reporting_event_report_group(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_metaconsole() === true) {
|
|
||||||
metaconsole_restore_db();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Total events.
|
// Total events.
|
||||||
if ($return['data'] != '') {
|
if ($return['data'] != '') {
|
||||||
$return['total_events'] = count($return['data']);
|
$return['total_events'] = count($return['data']);
|
||||||
@ -3670,15 +3663,29 @@ function reporting_groups_nodes($content)
|
|||||||
if (empty($id_group)) {
|
if (empty($id_group)) {
|
||||||
$events = [];
|
$events = [];
|
||||||
} else {
|
} else {
|
||||||
$sql_where = sprintf(
|
// ID group.
|
||||||
' WHERE id_grupo IN (%s) AND estado<>1 ',
|
if (empty($id_group) === false) {
|
||||||
implode(',', $id_group)
|
$filters['id_group_filter'] = $id_group;
|
||||||
);
|
}
|
||||||
$events = events_get_events_grouped(
|
|
||||||
$sql_where,
|
// Status.
|
||||||
|
if (empty($filter_event_status) === false) {
|
||||||
|
$filters['status'] = EVENT_NO_VALIDATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grouped.
|
||||||
|
$filters['group_rep'] = 1;
|
||||||
|
|
||||||
|
$events = Event::search(
|
||||||
|
[
|
||||||
|
'te.*',
|
||||||
|
'ta.alias',
|
||||||
|
],
|
||||||
|
$filters,
|
||||||
0,
|
0,
|
||||||
1000,
|
1000,
|
||||||
false
|
'desc',
|
||||||
|
'te.utimestamp'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3835,28 +3842,10 @@ function reporting_event_report_agent(
|
|||||||
$return['chart']['by_criticity'] = null;
|
$return['chart']['by_criticity'] = null;
|
||||||
$return['chart']['validated_vs_unvalidated'] = null;
|
$return['chart']['validated_vs_unvalidated'] = null;
|
||||||
|
|
||||||
$server_name = $content['server_name'];
|
|
||||||
if (is_metaconsole() && $server_name != '') {
|
|
||||||
$metaconsole_dbtable = true;
|
|
||||||
} else {
|
|
||||||
$metaconsole_dbtable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($event_graph_by_user_validator) {
|
if ($event_graph_by_user_validator) {
|
||||||
$data_graph = events_get_count_events_validated_by_user(
|
$data_graph_by_user = events_get_count_events_validated_by_user($return['data']);
|
||||||
['id_agent' => $content['id_agent']],
|
|
||||||
$content['period'],
|
|
||||||
$report['datetime'],
|
|
||||||
$filter_event_severity,
|
|
||||||
$filter_event_type,
|
|
||||||
$filter_event_status,
|
|
||||||
$filter_event_filter_search,
|
|
||||||
$metaconsole_dbtable,
|
|
||||||
$filter_event_filter_exclude
|
|
||||||
);
|
|
||||||
|
|
||||||
$return['chart']['by_user_validator'] = pie_graph(
|
$return['chart']['by_user_validator'] = pie_graph(
|
||||||
$data_graph,
|
$data_graph_by_user,
|
||||||
500,
|
500,
|
||||||
150,
|
150,
|
||||||
__('other'),
|
__('other'),
|
||||||
@ -3869,22 +3858,22 @@ function reporting_event_report_agent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($event_graph_by_criticity) {
|
if ($event_graph_by_criticity) {
|
||||||
$data_graph = events_get_count_events_by_criticity(
|
$data_graph_by_criticity = [];
|
||||||
['id_agent' => $content['id_agent']],
|
if (empty($return['data']) === false) {
|
||||||
$content['period'],
|
foreach ($return['data'] as $value) {
|
||||||
$report['datetime'],
|
$k = get_priority_name($value['criticity']);
|
||||||
$filter_event_severity,
|
if (isset($data_graph_by_criticity[$k]) === true) {
|
||||||
$filter_event_type,
|
$data_graph_by_criticity[$k]++;
|
||||||
$filter_event_status,
|
} else {
|
||||||
$filter_event_filter_search,
|
$data_graph_by_criticity[$k] = 1;
|
||||||
$metaconsole_dbtable,
|
}
|
||||||
$filter_event_filter_exclude
|
}
|
||||||
);
|
}
|
||||||
|
|
||||||
$colors = get_criticity_pie_colors($data_graph);
|
$colors = get_criticity_pie_colors($data_graph_by_criticity);
|
||||||
|
|
||||||
$return['chart']['by_criticity'] = pie_graph(
|
$return['chart']['by_criticity'] = pie_graph(
|
||||||
$data_graph,
|
$data_graph_by_criticity,
|
||||||
500,
|
500,
|
||||||
150,
|
150,
|
||||||
__('other'),
|
__('other'),
|
||||||
@ -3899,20 +3888,24 @@ function reporting_event_report_agent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($event_graph_validated_vs_unvalidated) {
|
if ($event_graph_validated_vs_unvalidated) {
|
||||||
$data_graph = events_get_count_events_validated(
|
$data_graph_by_status = [];
|
||||||
['id_agent' => $content['id_agent']],
|
if (empty($return['data']) === false) {
|
||||||
$content['period'],
|
$status = [
|
||||||
$report['datetime'],
|
1 => __('Validated'),
|
||||||
$filter_event_severity,
|
0 => __('Not validated'),
|
||||||
$filter_event_type,
|
];
|
||||||
$filter_event_status,
|
foreach ($return['data'] as $value) {
|
||||||
$filter_event_filter_search,
|
$k = $status[$value['estado']];
|
||||||
$metaconsole_dbtable,
|
if (isset($data_graph_by_status[$k]) === true) {
|
||||||
$filter_event_filter_exclude
|
$data_graph_by_status[$k]++;
|
||||||
);
|
} else {
|
||||||
|
$data_graph_by_status[$k] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$return['chart']['validated_vs_unvalidated'] = pie_graph(
|
$return['chart']['validated_vs_unvalidated'] = pie_graph(
|
||||||
$data_graph,
|
$data_graph_by_status,
|
||||||
500,
|
500,
|
||||||
150,
|
150,
|
||||||
__('other'),
|
__('other'),
|
||||||
@ -10478,20 +10471,9 @@ function reporting_get_module_detailed_event(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($event_graph_by_user_validator) {
|
if ($event_graph_by_user_validator) {
|
||||||
$data_graph = events_get_count_events_validated_by_user(
|
$data_graph_by_user = events_get_count_events_validated_by_user($event['data']);
|
||||||
['id_agentmodule' => $id_module],
|
|
||||||
$period,
|
|
||||||
$date,
|
|
||||||
$filter_event_severity,
|
|
||||||
$filter_event_type,
|
|
||||||
$filter_event_status,
|
|
||||||
$filter_event_filter_search,
|
|
||||||
$metaconsole_dbtable,
|
|
||||||
$filter_event_filter_exclude
|
|
||||||
);
|
|
||||||
|
|
||||||
$event['chart']['by_user_validator'] = pie_graph(
|
$event['chart']['by_user_validator'] = pie_graph(
|
||||||
$data_graph,
|
$data_graph_by_user,
|
||||||
500,
|
500,
|
||||||
150,
|
150,
|
||||||
__('other'),
|
__('other'),
|
||||||
@ -10504,22 +10486,22 @@ function reporting_get_module_detailed_event(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($event_graph_by_criticity) {
|
if ($event_graph_by_criticity) {
|
||||||
$data_graph = events_get_count_events_by_criticity(
|
$data_graph_by_criticity = [];
|
||||||
['id_agentmodule' => $id_module],
|
if (empty($event['data']) === false) {
|
||||||
$period,
|
foreach ($event['data'] as $value) {
|
||||||
$date,
|
$k = get_priority_name($value['criticity']);
|
||||||
$filter_event_severity,
|
if (isset($data_graph_by_criticity[$k]) === true) {
|
||||||
$filter_event_type,
|
$data_graph_by_criticity[$k]++;
|
||||||
$filter_event_status,
|
} else {
|
||||||
$filter_event_filter_search,
|
$data_graph_by_criticity[$k] = 1;
|
||||||
$metaconsole_dbtable,
|
}
|
||||||
$filter_event_filter_exclude
|
}
|
||||||
);
|
}
|
||||||
|
|
||||||
$colors = get_criticity_pie_colors($data_graph);
|
$colors = get_criticity_pie_colors($data_graph_by_criticity);
|
||||||
|
|
||||||
$event['chart']['by_criticity'] = pie_graph(
|
$event['chart']['by_criticity'] = pie_graph(
|
||||||
$data_graph,
|
$data_graph_by_criticity,
|
||||||
500,
|
500,
|
||||||
150,
|
150,
|
||||||
__('other'),
|
__('other'),
|
||||||
@ -10534,20 +10516,24 @@ function reporting_get_module_detailed_event(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($event_graph_validated_vs_unvalidated) {
|
if ($event_graph_validated_vs_unvalidated) {
|
||||||
$data_graph = events_get_count_events_validated(
|
$data_graph_by_status = [];
|
||||||
['id_agentmodule' => $id_module],
|
if (empty($event['data']) === false) {
|
||||||
$period,
|
$status = [
|
||||||
$date,
|
1 => __('Validated'),
|
||||||
$filter_event_severity,
|
0 => __('Not validated'),
|
||||||
$filter_event_type,
|
];
|
||||||
$filter_event_status,
|
foreach ($event['data'] as $value) {
|
||||||
$filter_event_filter_search,
|
$k = $status[$value['estado']];
|
||||||
$metaconsole_dbtable,
|
if (isset($data_graph_by_status[$k]) === true) {
|
||||||
$filter_event_filter_exclude
|
$data_graph_by_status[$k]++;
|
||||||
);
|
} else {
|
||||||
|
$data_graph_by_status[$k] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$event['chart']['validated_vs_unvalidated'] = pie_graph(
|
$event['chart']['validated_vs_unvalidated'] = pie_graph(
|
||||||
$data_graph,
|
$data_graph_by_status,
|
||||||
500,
|
500,
|
||||||
150,
|
150,
|
||||||
__('other'),
|
__('other'),
|
||||||
@ -10664,6 +10650,7 @@ function reporting_get_agents_detailed_event(
|
|||||||
'validated_by' => $e['id_usuario'],
|
'validated_by' => $e['id_usuario'],
|
||||||
'timestamp' => $e['timestamp'],
|
'timestamp' => $e['timestamp'],
|
||||||
'id_evento' => $e['id_evento'],
|
'id_evento' => $e['id_evento'],
|
||||||
|
'id_usuario' => $e['id_usuario'],
|
||||||
'custom_data' => ($show_custom_data === true) ? $e['custom_data'] : '',
|
'custom_data' => ($show_custom_data === true) ? $e['custom_data'] : '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -1068,20 +1068,26 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
|||||||
foreach ($item['data'] as $k => $event) {
|
foreach ($item['data'] as $k => $event) {
|
||||||
// First pass along the class of this row.
|
// First pass along the class of this row.
|
||||||
if ($item['show_summary_group']) {
|
if ($item['show_summary_group']) {
|
||||||
$table1->cellclass[$k][1] = $table1->cellclass[$k][2] = $table1->cellclass[$k][4] = $table1->cellclass[$k][5] = $table1->cellclass[$k][6] = $table1->cellclass[$k][7] = get_priority_class($event['criticity']);
|
$table1->cellclass[$k][1] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$k][2] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$k][4] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$k][5] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$k][6] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$k][7] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$k][8] = get_priority_class($event['criticity']);
|
||||||
} else {
|
} else {
|
||||||
$table1->cellclass[$k][1] = $table1->cellclass[$k][3] = $table1->cellclass[$k][4] = $table1->cellclass[$k][5] = $table1->cellclass[$k][6] = get_priority_class($event['criticity']);
|
$table1->cellclass[$k][1] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$k][3] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$k][4] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$k][5] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$k][6] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$k][7] = get_priority_class($event['criticity']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
// Colored box.
|
// Colored box.
|
||||||
switch ($event['estado']) {
|
switch ($event['estado']) {
|
||||||
case 0:
|
|
||||||
$img_st = 'images/star.png';
|
|
||||||
$title_st = __('New event');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
$img_st = 'images/tick.png';
|
$img_st = 'images/tick.png';
|
||||||
$title_st = __('Event validated');
|
$title_st = __('Event validated');
|
||||||
@ -1091,6 +1097,12 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
|||||||
$img_st = 'images/hourglass.png';
|
$img_st = 'images/hourglass.png';
|
||||||
$title_st = __('Event in process');
|
$title_st = __('Event in process');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
$img_st = 'images/star.png';
|
||||||
|
$title_st = __('New event');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[] = html_print_image(
|
$data[] = html_print_image(
|
||||||
@ -1117,17 +1129,29 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
|||||||
|
|
||||||
$data[] = events_print_type_img($event['event_type'], true);
|
$data[] = events_print_type_img($event['event_type'], true);
|
||||||
|
|
||||||
if (!empty($event['id_agente'])) {
|
if (empty($event['alias']) === false) {
|
||||||
$data[] = agents_get_alias($event['id_agente']);
|
$alias = $event['alias'];
|
||||||
|
if (is_metaconsole() === true) {
|
||||||
|
$alias = '('.$event['server_name'].') '.$event['alias'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data[] = $alias;
|
||||||
} else {
|
} else {
|
||||||
$data[] = __('%s System', get_product_name());
|
$data[] = __('%s System', get_product_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[] = get_priority_name($event['criticity']);
|
$data[] = get_priority_name($event['criticity']);
|
||||||
if (empty($event['id_usuario']) && $event['estado'] == EVENT_VALIDATE) {
|
if (empty($event['id_usuario']) === true
|
||||||
|
&& $event['estado'] == EVENT_VALIDATE
|
||||||
|
) {
|
||||||
$data[] = '<i>'.__('System').'</i>';
|
$data[] = '<i>'.__('System').'</i>';
|
||||||
} else {
|
} else {
|
||||||
$user_name = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']);
|
$user_name = db_get_value(
|
||||||
|
'fullname',
|
||||||
|
'tusuario',
|
||||||
|
'id_user',
|
||||||
|
$event['id_usuario']
|
||||||
|
);
|
||||||
$data[] = io_safe_output($user_name);
|
$data[] = io_safe_output($user_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1138,10 +1162,14 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($show_custom_data === true) {
|
if ($show_custom_data === true) {
|
||||||
$custom_data = json_decode($event['custom_data'], true);
|
|
||||||
$custom_data_text = '';
|
$custom_data_text = '';
|
||||||
foreach ($custom_data as $key => $value) {
|
if (empty($event['custom_data']) === false) {
|
||||||
$custom_data_text .= $key.' = '.$value.'<br>';
|
$custom_data = json_decode($event['custom_data'], true);
|
||||||
|
if (empty($custom_data) === false) {
|
||||||
|
foreach ($custom_data as $key => $value) {
|
||||||
|
$custom_data_text .= $key.' = '.$value.'<br>';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[] = $custom_data_text;
|
$data[] = $custom_data_text;
|
||||||
@ -1306,9 +1334,17 @@ function reporting_html_event_report_module($table, $item, $pdf=0)
|
|||||||
foreach ($item_data as $i => $event) {
|
foreach ($item_data as $i => $event) {
|
||||||
$data = [];
|
$data = [];
|
||||||
if ($show_summary_group) {
|
if ($show_summary_group) {
|
||||||
$table1->cellclass[$i][1] = $table1->cellclass[$i][2] = $table1->cellclass[$i][3] = $table1->cellclass[$i][4] = $table1->cellclass[$i][5] = get_priority_class($event['criticity']);
|
$table1->cellclass[$i][1] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][2] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][3] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][4] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][5] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][6] = get_priority_class($event['criticity']);
|
||||||
} else {
|
} else {
|
||||||
$table1->cellclass[$i][1] = $table1->cellclass[$i][3] = $table1->cellclass[$i][4] = get_priority_class($event['criticity']);
|
$table1->cellclass[$i][1] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][3] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][4] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][6] = get_priority_class($event['criticity']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colored box.
|
// Colored box.
|
||||||
@ -2397,9 +2433,18 @@ function reporting_html_event_report_agent($table, $item, $pdf=0)
|
|||||||
|
|
||||||
foreach ($item['data'] as $i => $event) {
|
foreach ($item['data'] as $i => $event) {
|
||||||
if ($item['show_summary_group']) {
|
if ($item['show_summary_group']) {
|
||||||
$table1->cellclass[$i][1] = $table1->cellclass[$i][2] = $table1->cellclass[$i][4] = $table1->cellclass[$i][5] = $table1->cellclass[$i][6] = get_priority_class($event['criticity']);
|
$table1->cellclass[$i][1] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][2] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][4] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][5] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][6] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][7] = get_priority_class($event['criticity']);
|
||||||
} else {
|
} else {
|
||||||
$table1->cellclass[$i][1] = $table1->cellclass[$i][3] = $table1->cellclass[$i][4] = $table1->cellclass[$i][5] = get_priority_class($event['criticity']);
|
$table1->cellclass[$i][1] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][3] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][4] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][5] = get_priority_class($event['criticity']);
|
||||||
|
$table1->cellclass[$i][6] = get_priority_class($event['criticity']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
@ -2454,7 +2499,7 @@ function reporting_html_event_report_agent($table, $item, $pdf=0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($item['show_summary_group']) {
|
if ($item['show_summary_group']) {
|
||||||
$data[] = '<font class="font_6pt">'.date($config['date_format'], $event['timestamp']).'</font>';
|
$data[] = '<font class="font_6pt">'.date($config['date_format'], strtotime($event['timestamp'])).'</font>';
|
||||||
} else {
|
} else {
|
||||||
$data[] = '<font class="font_6pt">'.date($config['date_format'], strtotime($event['timestamp'])).'</font>';
|
$data[] = '<font class="font_6pt">'.date($config['date_format'], strtotime($event['timestamp'])).'</font>';
|
||||||
}
|
}
|
||||||
|
@ -653,60 +653,6 @@ function event_comment(current_event) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Show event list when fielter repetead is Group agents
|
|
||||||
function show_events_group_agent(id_insert, id_agent, server_id) {
|
|
||||||
var parameter = [];
|
|
||||||
parameter.push({ name: "id_agent", value: id_agent });
|
|
||||||
parameter.push({ name: "server_id", value: server_id });
|
|
||||||
parameter.push({ name: "event_type", value: $("#event_type").val() });
|
|
||||||
parameter.push({ name: "severity", value: $("#severity").val() });
|
|
||||||
parameter.push({ name: "status", value: $("#status").val() });
|
|
||||||
parameter.push({ name: "search", value: $("#text-search").val() });
|
|
||||||
parameter.push({
|
|
||||||
name: "id_agent_module",
|
|
||||||
value: $("input:hidden[name=module_search_hidden]").val()
|
|
||||||
});
|
|
||||||
parameter.push({
|
|
||||||
name: "event_view_hr",
|
|
||||||
value: $("#text-event_view_hr").val()
|
|
||||||
});
|
|
||||||
parameter.push({ name: "id_user_ack", value: $("#id_user_ack").val() });
|
|
||||||
parameter.push({
|
|
||||||
name: "tag_with",
|
|
||||||
value: Base64.decode($("#hidden-tag_with").val())
|
|
||||||
});
|
|
||||||
parameter.push({
|
|
||||||
name: "tag_without",
|
|
||||||
value: Base64.decode($("#hidden-tag_without").val())
|
|
||||||
});
|
|
||||||
parameter.push({
|
|
||||||
name: "filter_only_alert",
|
|
||||||
value: $("#filter_only_alert").val()
|
|
||||||
});
|
|
||||||
parameter.push({ name: "date_from", value: $("#text-date_from").val() });
|
|
||||||
parameter.push({ name: "date_to", value: $("#text-date_to").val() });
|
|
||||||
parameter.push({ name: "server_id_search", value: $("#server_id").val() });
|
|
||||||
parameter.push({
|
|
||||||
name: "page",
|
|
||||||
value: "include/ajax/events"
|
|
||||||
});
|
|
||||||
parameter.push({
|
|
||||||
name: "get_list_events_agents",
|
|
||||||
value: 1
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: $("#hidden-ajax_file").val(),
|
|
||||||
data: parameter,
|
|
||||||
dataType: "html",
|
|
||||||
success: function(data) {
|
|
||||||
$("#" + id_insert).html(data);
|
|
||||||
$("#" + id_insert).toggle();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_event_response_command_dialog(id, response, total_checked) {
|
function show_event_response_command_dialog(id, response, total_checked) {
|
||||||
var params = [];
|
var params = [];
|
||||||
params.push("page=include/ajax/events");
|
params.push("page=include/ajax/events");
|
||||||
|
@ -367,8 +367,6 @@ class TopNEventByGroupWidget extends Widget
|
|||||||
|
|
||||||
$this->values['groupId'] = explode(',', $this->values['groupId'][0]);
|
$this->values['groupId'] = explode(',', $this->values['groupId'][0]);
|
||||||
|
|
||||||
$event_table = (is_metaconsole() === true) ? 'tmetaconsole_event' : 'tevento';
|
|
||||||
|
|
||||||
if (empty($this->values['groupId']) === true) {
|
if (empty($this->values['groupId']) === true) {
|
||||||
$output .= '<div class="container-center">';
|
$output .= '<div class="container-center">';
|
||||||
$output .= \ui_print_info_message(
|
$output .= \ui_print_info_message(
|
||||||
@ -390,13 +388,12 @@ class TopNEventByGroupWidget extends Widget
|
|||||||
if ($all_group === false) {
|
if ($all_group === false) {
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
'SELECT id_agente, COUNT(*) AS count
|
'SELECT id_agente, COUNT(*) AS count
|
||||||
FROM %s
|
FROM tevento
|
||||||
WHERE utimestamp >= %d
|
WHERE utimestamp >= %d
|
||||||
AND id_grupo IN (%s)
|
AND id_grupo IN (%s)
|
||||||
GROUP BY id_agente
|
GROUP BY id_agente
|
||||||
ORDER BY count DESC
|
ORDER BY count DESC
|
||||||
LIMIT %d',
|
LIMIT %d',
|
||||||
$event_table,
|
|
||||||
$timestamp,
|
$timestamp,
|
||||||
implode(',', $this->values['groupId']),
|
implode(',', $this->values['groupId']),
|
||||||
$this->values['amountShow']
|
$this->values['amountShow']
|
||||||
@ -404,12 +401,11 @@ class TopNEventByGroupWidget extends Widget
|
|||||||
} else {
|
} else {
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
'SELECT id_agente, COUNT(*) AS count
|
'SELECT id_agente, COUNT(*) AS count
|
||||||
FROM %s
|
FROM tevento
|
||||||
WHERE utimestamp >= %d
|
WHERE utimestamp >= %d
|
||||||
GROUP BY id_agente
|
GROUP BY id_agente
|
||||||
ORDER BY count DESC
|
ORDER BY count DESC
|
||||||
LIMIT %d',
|
LIMIT %d',
|
||||||
$event_table,
|
|
||||||
$timestamp,
|
$timestamp,
|
||||||
$this->values['amountShow']
|
$this->values['amountShow']
|
||||||
);
|
);
|
||||||
|
@ -365,8 +365,6 @@ class TopNEventByModuleWidget extends Widget
|
|||||||
|
|
||||||
$this->values['groupId'] = explode(',', $this->values['groupId'][0]);
|
$this->values['groupId'] = explode(',', $this->values['groupId'][0]);
|
||||||
|
|
||||||
$event_table = (is_metaconsole() === true) ? 'tmetaconsole_event' : 'tevento';
|
|
||||||
|
|
||||||
if (empty($this->values['groupId']) === true) {
|
if (empty($this->values['groupId']) === true) {
|
||||||
$output = '<div class="container-center">';
|
$output = '<div class="container-center">';
|
||||||
$output .= \ui_print_info_message(
|
$output .= \ui_print_info_message(
|
||||||
@ -391,13 +389,12 @@ class TopNEventByModuleWidget extends Widget
|
|||||||
id_agentmodule,
|
id_agentmodule,
|
||||||
event_type,
|
event_type,
|
||||||
COUNT(*) AS count
|
COUNT(*) AS count
|
||||||
FROM %s
|
FROM tevento
|
||||||
WHERE utimestamp >= %d
|
WHERE utimestamp >= %d
|
||||||
AND id_grupo IN (%s)
|
AND id_grupo IN (%s)
|
||||||
GROUP BY id_agentmodule, event_type
|
GROUP BY id_agentmodule, event_type
|
||||||
ORDER BY count DESC
|
ORDER BY count DESC
|
||||||
LIMIT %d',
|
LIMIT %d',
|
||||||
$event_table,
|
|
||||||
$timestamp,
|
$timestamp,
|
||||||
implode(',', $this->values['groupId']),
|
implode(',', $this->values['groupId']),
|
||||||
$this->values['amountShow']
|
$this->values['amountShow']
|
||||||
@ -408,12 +405,11 @@ class TopNEventByModuleWidget extends Widget
|
|||||||
id_agentmodule,
|
id_agentmodule,
|
||||||
event_type,
|
event_type,
|
||||||
COUNT(*) AS count
|
COUNT(*) AS count
|
||||||
FROM %s
|
FROM tevento
|
||||||
WHERE utimestamp >= %d
|
WHERE utimestamp >= %d
|
||||||
GROUP BY id_agentmodule, event_type
|
GROUP BY id_agentmodule, event_type
|
||||||
ORDER BY count DESC
|
ORDER BY count DESC
|
||||||
LIMIT %d',
|
LIMIT %d',
|
||||||
$event_table,
|
|
||||||
$timestamp,
|
$timestamp,
|
||||||
$this->values['amountShow']
|
$this->values['amountShow']
|
||||||
);
|
);
|
||||||
|
@ -60,7 +60,7 @@ class Event extends Entity
|
|||||||
*/
|
*/
|
||||||
public function __construct(?int $event_id=null)
|
public function __construct(?int $event_id=null)
|
||||||
{
|
{
|
||||||
$this->table = ((bool) \is_metaconsole() === true) ? 'tmetaconsole_event' : 'tevento';
|
$this->table = 'tevento';
|
||||||
|
|
||||||
if ($event_id === 0) {
|
if ($event_id === 0) {
|
||||||
parent::__construct($this->table);
|
parent::__construct($this->table);
|
||||||
|
@ -731,95 +731,51 @@ class Events
|
|||||||
{
|
{
|
||||||
$system = System::getInstance();
|
$system = System::getInstance();
|
||||||
|
|
||||||
// --------------Fill the SQL POST-------------------------------
|
$filters = [];
|
||||||
$sql_post = ' WHERE 1=1 ';
|
|
||||||
|
|
||||||
if ($this->status != null) {
|
// Status.
|
||||||
switch ($this->status) {
|
if (empty($this->status) === false) {
|
||||||
case 0:
|
$filters['status'] = $this->status;
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
$sql_post .= ' AND estado = '.$this->status;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
$sql_post .= ' AND (estado = 0 OR estado = 2)';
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Not posible.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->free_search != '') {
|
// Filter search.
|
||||||
$sql_post .= " AND evento LIKE '%".io_safe_input($this->free_search)."%'";
|
if (empty($this->free_search) === false) {
|
||||||
|
$filters['search'] = $this->free_search;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->severity != null && $this->severity != -1) {
|
// Severity.
|
||||||
switch ($this->severity) {
|
if (empty($this->severity) === false) {
|
||||||
case EVENT_CRIT_WARNING_OR_CRITICAL:
|
$filters['severity'] = $this->severity;
|
||||||
$sql_post .= ' AND (criticity = '.EVENT_CRIT_WARNING.' OR
|
|
||||||
criticity = '.EVENT_CRIT_CRITICAL.')';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVENT_CRIT_NOT_NORMAL:
|
|
||||||
$sql_post .= ' AND criticity != '.EVENT_CRIT_NORMAL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
$sql_post .= ' AND criticity = '.$this->severity;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->hours_old > 0) {
|
// Hours.
|
||||||
$unixtime = (get_system_time() - ($this->hours_old * SECONDS_1HOUR));
|
if (empty($this->hours_old) === false) {
|
||||||
$sql_post .= ' AND (utimestamp > '.$unixtime.')';
|
$filters['event_view_hr'] = $this->hours_old;
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->type != '') {
|
|
||||||
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
|
|
||||||
// for the user so for him is presented only "warning, critical and normal"
|
|
||||||
if ($this->type == 'warning' || $this->type == 'critical'
|
|
||||||
|| $this->type == 'normal'
|
|
||||||
) {
|
|
||||||
$sql_post .= " AND event_type LIKE '%".$this->type."%' ";
|
|
||||||
} else if ($this->type == 'not_normal') {
|
|
||||||
$sql_post .= " AND event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%' ";
|
|
||||||
} else if ($this->type != 'all') {
|
|
||||||
$sql_post .= " AND event_type = '".$this->type."'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$system = System::getInstance();
|
|
||||||
$groups = users_get_groups($system->getConfig('id_user'), 'ER');
|
|
||||||
|
|
||||||
// Group selection
|
|
||||||
if ($this->group > 0 && in_array($this->group, array_keys($groups))) {
|
|
||||||
// If a group is selected and it's in the groups allowed
|
|
||||||
$sql_post .= ' AND id_grupo = '.$this->group;
|
|
||||||
} else {
|
} else {
|
||||||
if (is_user_admin($system->getConfig('id_user'))) {
|
$filters['event_view_hr'] = 8;
|
||||||
// Do nothing if you're admin, you get full access
|
|
||||||
$sql_post .= '';
|
|
||||||
} else {
|
|
||||||
// Otherwise select all groups the user has rights to.
|
|
||||||
$sql_post .= ' AND id_grupo IN ('.implode(',', array_keys($groups)).')';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->id_agent > 0) {
|
// Type.
|
||||||
$sql_post .= ' AND id_agente = '.$this->id_agent;
|
if (empty($this->type) === false) {
|
||||||
|
$filters['event_type'] = $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip system messages if user is not PM
|
// ID group.
|
||||||
if (!check_acl($system->getConfig('id_user'), 0, 'PM')) {
|
if (empty($this->group) === false) {
|
||||||
$sql_post .= ' AND id_grupo != 0';
|
$filters['id_group_filter'] = $this->group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Id Agent.
|
||||||
|
if ($this->id_agent !== false && empty($this->id_agent) === false) {
|
||||||
|
$filters['id_agent'] = $this->id_agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
$filters['group_rep'] = 1;
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
if (isset($this->limit) && $this->limit != -1) {
|
if (isset($this->limit) === true
|
||||||
|
&& $this->limit !== -1
|
||||||
|
) {
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
$pagination = $this->limit;
|
$pagination = $this->limit;
|
||||||
} else {
|
} else {
|
||||||
@ -827,24 +783,41 @@ class Events
|
|||||||
$pagination = $system->getPageSize();
|
$pagination = $system->getPageSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
$meta = false;
|
$events_db = events_get_all(
|
||||||
if ($system->getConfig('metaconsole')) {
|
// Fields.
|
||||||
$meta = true;
|
[
|
||||||
}
|
'te.*',
|
||||||
|
'ta.alias',
|
||||||
$events_db = events_get_events_grouped(
|
],
|
||||||
$sql_post,
|
// Filter.
|
||||||
|
$filters,
|
||||||
|
// Offset.
|
||||||
$offset,
|
$offset,
|
||||||
|
// Limit.
|
||||||
$pagination,
|
$pagination,
|
||||||
$meta,
|
// Order.
|
||||||
false
|
'desc',
|
||||||
|
// Sort field.
|
||||||
|
'timestamp'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (empty($events_db)) {
|
if (is_metaconsole() === false) {
|
||||||
$events_db = [];
|
$count = events_get_all(
|
||||||
|
'count',
|
||||||
|
$filters,
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($count !== false) {
|
||||||
|
$total_events = $count['0']['nitems'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$total_events = $events_db['total'];
|
||||||
|
$events_db = $events_db['data'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$total_events = events_get_total_events_grouped($sql_post, $meta);
|
if (empty($events_db) === true) {
|
||||||
|
$events_db = [];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'events' => $events_db,
|
'events' => $events_db,
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -424,8 +424,12 @@ if (is_ajax() === true) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$tmp->timestamp = $max_event['timestamp'];
|
if ($max_event !== false
|
||||||
$tmp->criticity = $max_event['criticity'];
|
&& empty($max_event) === false
|
||||||
|
) {
|
||||||
|
$tmp->timestamp = $max_event['timestamp'];
|
||||||
|
$tmp->criticity = $max_event['criticity'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp->agent_name = io_safe_output($tmp->agent_name);
|
$tmp->agent_name = io_safe_output($tmp->agent_name);
|
||||||
@ -1588,34 +1592,9 @@ try {
|
|||||||
'class' => 'no-padding',
|
'class' => 'no-padding',
|
||||||
],
|
],
|
||||||
'id_evento',
|
'id_evento',
|
||||||
// 'id_agente',
|
|
||||||
// 'id_usuario',
|
|
||||||
// 'id_grupo',
|
|
||||||
// 'estado',
|
|
||||||
'agent_name',
|
'agent_name',
|
||||||
'timestamp',
|
'timestamp',
|
||||||
// 'utimestamp',
|
|
||||||
// 'event_type',
|
|
||||||
// 'id_agentmodule',
|
|
||||||
// 'id_alert_am',
|
|
||||||
'event_type',
|
'event_type',
|
||||||
// 'user_comment',
|
|
||||||
// 'tags',
|
|
||||||
// 'source',
|
|
||||||
// 'id_extra',
|
|
||||||
// 'critical_instructions',
|
|
||||||
// 'warning_instructions',
|
|
||||||
// 'unknown_instructions',
|
|
||||||
// 'owner_user',
|
|
||||||
// 'ack_utimestamp',
|
|
||||||
// 'custom_data',
|
|
||||||
// 'data',
|
|
||||||
// 'module_status',
|
|
||||||
// 'similar_ids',
|
|
||||||
// 'event_rep',
|
|
||||||
// 'timestamp_rep',
|
|
||||||
// 'timestamp_rep_min',
|
|
||||||
// 'module_name',
|
|
||||||
[
|
[
|
||||||
'text' => 'options',
|
'text' => 'options',
|
||||||
'class' => 'action_buttons w120px',
|
'class' => 'action_buttons w120px',
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user