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_list_events_agents = (bool) get_parameter('get_list_events_agents');
|
||||
$get_extended_event = (bool) get_parameter('get_extended_event');
|
||||
$change_status = (bool) get_parameter('change_status');
|
||||
$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) {
|
||||
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
|
||||
*
|
||||
|
@ -3365,13 +3298,13 @@ function grafico_eventos_grupo($width=300, $height=200, $url='', $noWaterMark=tr
|
|||
global $config;
|
||||
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);
|
||||
$data = [];
|
||||
$loop = 0;
|
||||
define('NUM_PIECES_PIE', 6);
|
||||
|
||||
// Hotfix for the id_agente_modulo
|
||||
// Hotfix for the id_agente_modulo.
|
||||
$url = str_replace(
|
||||
'SELECT id_agente_modulo',
|
||||
'SELECT_id_agente_modulo',
|
||||
|
@ -3386,22 +3319,24 @@ function grafico_eventos_grupo($width=300, $height=200, $url='', $noWaterMark=tr
|
|||
'INSERT ',
|
||||
'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);
|
||||
|
||||
// Hotfix for the id_agente_modulo
|
||||
// Hotfix for the id_agente_modulo.
|
||||
$url = str_replace(
|
||||
'SELECT_id_agente_modulo',
|
||||
'SELECT id_agente_modulo',
|
||||
$url
|
||||
);
|
||||
|
||||
$event_table = 'tevento';
|
||||
$field_extra = '';
|
||||
$groupby_extra = '';
|
||||
|
||||
// Add tags condition to filter
|
||||
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND');
|
||||
// Add tags condition to filter.
|
||||
$tags_condition = tags_get_acl_tags(
|
||||
$config['id_user'],
|
||||
0,
|
||||
'ER',
|
||||
'event_condition',
|
||||
'AND'
|
||||
);
|
||||
|
||||
if ($time_limit && $config['event_view_hr']) {
|
||||
$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
|
||||
// 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(
|
||||
'SELECT DISTINCT(id_agente) AS id_agente,
|
||||
COUNT(id_agente) AS count'.$field_extra.'
|
||||
FROM '.$event_table.' te LEFT JOIN tagent_secondary_group tasg
|
||||
COUNT(id_agente) AS count
|
||||
FROM tevento te LEFT JOIN tagent_secondary_group tasg
|
||||
ON te.id_grupo = tasg.id_group
|
||||
WHERE 1=1 %s %s
|
||||
GROUP BY id_agente'.$groupby_extra.'
|
||||
GROUP BY id_agente
|
||||
ORDER BY count DESC LIMIT 8',
|
||||
$url,
|
||||
$tags_condition
|
||||
|
@ -3456,7 +3391,7 @@ function grafico_eventos_grupo($width=300, $height=200, $url='', $noWaterMark=tr
|
|||
$data[$name] = $system_events;
|
||||
}
|
||||
|
||||
// Sort the data
|
||||
// Sort the data.
|
||||
arsort($data);
|
||||
if ($noWaterMark) {
|
||||
$water_mark = [
|
||||
|
|
|
@ -67,6 +67,7 @@ define('REPORT_STATUS_DOWNTIME', 4);
|
|||
define('REPORT_STATUS_IGNORED', 5);
|
||||
|
||||
// Clases.
|
||||
use PandoraFMS\Event;
|
||||
use PandoraFMS\Module;
|
||||
|
||||
|
||||
|
@ -1959,7 +1960,10 @@ function reporting_event_report_group(
|
|||
$event_graph_by_criticity = $event_filter['event_graph_by_criticity'];
|
||||
$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',
|
||||
'tgrupo',
|
||||
|
@ -2029,27 +2033,26 @@ function reporting_event_report_group(
|
|||
$return['chart']['by_user_validator'] = null;
|
||||
$return['chart']['by_criticity'] = 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) {
|
||||
$data_graph = events_get_count_events_by_agent(
|
||||
$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
|
||||
);
|
||||
$data_graph_by_agent = [];
|
||||
if (empty($data) === false) {
|
||||
foreach ($data as $value) {
|
||||
$k = $value['alias'];
|
||||
if (is_metaconsole() === true) {
|
||||
$k = '('.$value['server_name'].') '.$value['alias'];
|
||||
}
|
||||
|
||||
if (isset($data_graph_by_agent[$k]) === true) {
|
||||
$data_graph_by_agent[$k]++;
|
||||
} else {
|
||||
$data_graph_by_agent[$k] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return['chart']['by_agent'] = pie_graph(
|
||||
$data_graph,
|
||||
$data_graph_by_agent,
|
||||
500,
|
||||
150,
|
||||
__('other'),
|
||||
|
@ -2062,20 +2065,9 @@ function reporting_event_report_group(
|
|||
}
|
||||
|
||||
if ($event_graph_by_user_validator) {
|
||||
$data_graph = events_get_count_events_validated_by_user(
|
||||
['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
|
||||
);
|
||||
|
||||
$data_graph_by_user = events_get_count_events_validated_by_user($data);
|
||||
$return['chart']['by_user_validator'] = pie_graph(
|
||||
$data_graph,
|
||||
$data_graph_by_user,
|
||||
500,
|
||||
150,
|
||||
__('other'),
|
||||
|
@ -2088,21 +2080,22 @@ function reporting_event_report_group(
|
|||
}
|
||||
|
||||
if ($event_graph_by_criticity) {
|
||||
$data_graph = events_get_count_events_by_criticity(
|
||||
['id_group' => $content['id_group']],
|
||||
$content['period'],
|
||||
$report['datetime'],
|
||||
$filter_event_severity,
|
||||
$filter_event_type,
|
||||
$filter_event_status,
|
||||
$filter_event_filter_search,
|
||||
$metaconsole_dbtable
|
||||
);
|
||||
$data_graph_by_criticity = [];
|
||||
if (empty($data) === false) {
|
||||
foreach ($data as $value) {
|
||||
$k = get_priority_name($value['criticity']);
|
||||
if (isset($data_graph_by_criticity[$k]) === true) {
|
||||
$data_graph_by_criticity[$k]++;
|
||||
} else {
|
||||
$data_graph_by_criticity[$k] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$colors = get_criticity_pie_colors($data_graph);
|
||||
$colors = get_criticity_pie_colors($data_graph_by_criticity);
|
||||
|
||||
$return['chart']['by_criticity'] = pie_graph(
|
||||
$data_graph,
|
||||
$data_graph_by_criticity,
|
||||
500,
|
||||
150,
|
||||
__('other'),
|
||||
|
@ -2117,20 +2110,24 @@ function reporting_event_report_group(
|
|||
}
|
||||
|
||||
if ($event_graph_validated_vs_unvalidated) {
|
||||
$data_graph = events_get_count_events_validated(
|
||||
['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
|
||||
);
|
||||
$data_graph_by_status = [];
|
||||
if (empty($data) === false) {
|
||||
$status = [
|
||||
1 => __('Validated'),
|
||||
0 => __('Not validated'),
|
||||
];
|
||||
foreach ($data as $value) {
|
||||
$k = $status[$value['estado']];
|
||||
if (isset($data_graph_by_status[$k]) === true) {
|
||||
$data_graph_by_status[$k]++;
|
||||
} else {
|
||||
$data_graph_by_status[$k] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return['chart']['validated_vs_unvalidated'] = pie_graph(
|
||||
$data_graph,
|
||||
$data_graph_by_status,
|
||||
500,
|
||||
150,
|
||||
__('other'),
|
||||
|
@ -2142,10 +2139,6 @@ function reporting_event_report_group(
|
|||
);
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
// Total events.
|
||||
if ($return['data'] != '') {
|
||||
$return['total_events'] = count($return['data']);
|
||||
|
@ -3670,15 +3663,29 @@ function reporting_groups_nodes($content)
|
|||
if (empty($id_group)) {
|
||||
$events = [];
|
||||
} else {
|
||||
$sql_where = sprintf(
|
||||
' WHERE id_grupo IN (%s) AND estado<>1 ',
|
||||
implode(',', $id_group)
|
||||
);
|
||||
$events = events_get_events_grouped(
|
||||
$sql_where,
|
||||
// ID group.
|
||||
if (empty($id_group) === false) {
|
||||
$filters['id_group_filter'] = $id_group;
|
||||
}
|
||||
|
||||
// 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,
|
||||
1000,
|
||||
false
|
||||
'desc',
|
||||
'te.utimestamp'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3835,28 +3842,10 @@ function reporting_event_report_agent(
|
|||
$return['chart']['by_criticity'] = 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) {
|
||||
$data_graph = events_get_count_events_validated_by_user(
|
||||
['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
|
||||
);
|
||||
|
||||
$data_graph_by_user = events_get_count_events_validated_by_user($return['data']);
|
||||
$return['chart']['by_user_validator'] = pie_graph(
|
||||
$data_graph,
|
||||
$data_graph_by_user,
|
||||
500,
|
||||
150,
|
||||
__('other'),
|
||||
|
@ -3869,22 +3858,22 @@ function reporting_event_report_agent(
|
|||
}
|
||||
|
||||
if ($event_graph_by_criticity) {
|
||||
$data_graph = events_get_count_events_by_criticity(
|
||||
['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
|
||||
);
|
||||
$data_graph_by_criticity = [];
|
||||
if (empty($return['data']) === false) {
|
||||
foreach ($return['data'] as $value) {
|
||||
$k = get_priority_name($value['criticity']);
|
||||
if (isset($data_graph_by_criticity[$k]) === true) {
|
||||
$data_graph_by_criticity[$k]++;
|
||||
} else {
|
||||
$data_graph_by_criticity[$k] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$colors = get_criticity_pie_colors($data_graph);
|
||||
$colors = get_criticity_pie_colors($data_graph_by_criticity);
|
||||
|
||||
$return['chart']['by_criticity'] = pie_graph(
|
||||
$data_graph,
|
||||
$data_graph_by_criticity,
|
||||
500,
|
||||
150,
|
||||
__('other'),
|
||||
|
@ -3899,20 +3888,24 @@ function reporting_event_report_agent(
|
|||
}
|
||||
|
||||
if ($event_graph_validated_vs_unvalidated) {
|
||||
$data_graph = events_get_count_events_validated(
|
||||
['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
|
||||
);
|
||||
$data_graph_by_status = [];
|
||||
if (empty($return['data']) === false) {
|
||||
$status = [
|
||||
1 => __('Validated'),
|
||||
0 => __('Not validated'),
|
||||
];
|
||||
foreach ($return['data'] as $value) {
|
||||
$k = $status[$value['estado']];
|
||||
if (isset($data_graph_by_status[$k]) === true) {
|
||||
$data_graph_by_status[$k]++;
|
||||
} else {
|
||||
$data_graph_by_status[$k] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return['chart']['validated_vs_unvalidated'] = pie_graph(
|
||||
$data_graph,
|
||||
$data_graph_by_status,
|
||||
500,
|
||||
150,
|
||||
__('other'),
|
||||
|
@ -10478,20 +10471,9 @@ function reporting_get_module_detailed_event(
|
|||
}
|
||||
|
||||
if ($event_graph_by_user_validator) {
|
||||
$data_graph = events_get_count_events_validated_by_user(
|
||||
['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
|
||||
);
|
||||
|
||||
$data_graph_by_user = events_get_count_events_validated_by_user($event['data']);
|
||||
$event['chart']['by_user_validator'] = pie_graph(
|
||||
$data_graph,
|
||||
$data_graph_by_user,
|
||||
500,
|
||||
150,
|
||||
__('other'),
|
||||
|
@ -10504,22 +10486,22 @@ function reporting_get_module_detailed_event(
|
|||
}
|
||||
|
||||
if ($event_graph_by_criticity) {
|
||||
$data_graph = events_get_count_events_by_criticity(
|
||||
['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
|
||||
);
|
||||
$data_graph_by_criticity = [];
|
||||
if (empty($event['data']) === false) {
|
||||
foreach ($event['data'] as $value) {
|
||||
$k = get_priority_name($value['criticity']);
|
||||
if (isset($data_graph_by_criticity[$k]) === true) {
|
||||
$data_graph_by_criticity[$k]++;
|
||||
} else {
|
||||
$data_graph_by_criticity[$k] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$colors = get_criticity_pie_colors($data_graph);
|
||||
$colors = get_criticity_pie_colors($data_graph_by_criticity);
|
||||
|
||||
$event['chart']['by_criticity'] = pie_graph(
|
||||
$data_graph,
|
||||
$data_graph_by_criticity,
|
||||
500,
|
||||
150,
|
||||
__('other'),
|
||||
|
@ -10534,20 +10516,24 @@ function reporting_get_module_detailed_event(
|
|||
}
|
||||
|
||||
if ($event_graph_validated_vs_unvalidated) {
|
||||
$data_graph = events_get_count_events_validated(
|
||||
['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
|
||||
);
|
||||
$data_graph_by_status = [];
|
||||
if (empty($event['data']) === false) {
|
||||
$status = [
|
||||
1 => __('Validated'),
|
||||
0 => __('Not validated'),
|
||||
];
|
||||
foreach ($event['data'] as $value) {
|
||||
$k = $status[$value['estado']];
|
||||
if (isset($data_graph_by_status[$k]) === true) {
|
||||
$data_graph_by_status[$k]++;
|
||||
} else {
|
||||
$data_graph_by_status[$k] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$event['chart']['validated_vs_unvalidated'] = pie_graph(
|
||||
$data_graph,
|
||||
$data_graph_by_status,
|
||||
500,
|
||||
150,
|
||||
__('other'),
|
||||
|
@ -10664,6 +10650,7 @@ function reporting_get_agents_detailed_event(
|
|||
'validated_by' => $e['id_usuario'],
|
||||
'timestamp' => $e['timestamp'],
|
||||
'id_evento' => $e['id_evento'],
|
||||
'id_usuario' => $e['id_usuario'],
|
||||
'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) {
|
||||
// First pass along the class of this row.
|
||||
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 {
|
||||
$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 = [];
|
||||
|
||||
// Colored box.
|
||||
switch ($event['estado']) {
|
||||
case 0:
|
||||
$img_st = 'images/star.png';
|
||||
$title_st = __('New event');
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$img_st = 'images/tick.png';
|
||||
$title_st = __('Event validated');
|
||||
|
@ -1091,6 +1097,12 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
|||
$img_st = 'images/hourglass.png';
|
||||
$title_st = __('Event in process');
|
||||
break;
|
||||
|
||||
default:
|
||||
case 0:
|
||||
$img_st = 'images/star.png';
|
||||
$title_st = __('New event');
|
||||
break;
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
if (!empty($event['id_agente'])) {
|
||||
$data[] = agents_get_alias($event['id_agente']);
|
||||
if (empty($event['alias']) === false) {
|
||||
$alias = $event['alias'];
|
||||
if (is_metaconsole() === true) {
|
||||
$alias = '('.$event['server_name'].') '.$event['alias'];
|
||||
}
|
||||
|
||||
$data[] = $alias;
|
||||
} else {
|
||||
$data[] = __('%s System', get_product_name());
|
||||
}
|
||||
|
||||
$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>';
|
||||
} 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);
|
||||
}
|
||||
|
||||
|
@ -1138,10 +1162,14 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
|
|||
}
|
||||
|
||||
if ($show_custom_data === true) {
|
||||
$custom_data = json_decode($event['custom_data'], true);
|
||||
$custom_data_text = '';
|
||||
foreach ($custom_data as $key => $value) {
|
||||
$custom_data_text .= $key.' = '.$value.'<br>';
|
||||
if (empty($event['custom_data']) === false) {
|
||||
$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;
|
||||
|
@ -1306,9 +1334,17 @@ function reporting_html_event_report_module($table, $item, $pdf=0)
|
|||
foreach ($item_data as $i => $event) {
|
||||
$data = [];
|
||||
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 {
|
||||
$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.
|
||||
|
@ -2397,9 +2433,18 @@ function reporting_html_event_report_agent($table, $item, $pdf=0)
|
|||
|
||||
foreach ($item['data'] as $i => $event) {
|
||||
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 {
|
||||
$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 = [];
|
||||
|
@ -2454,7 +2499,7 @@ function reporting_html_event_report_agent($table, $item, $pdf=0)
|
|||
}
|
||||
|
||||
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 {
|
||||
$data[] = '<font class="font_6pt">'.date($config['date_format'], strtotime($event['timestamp'])).'</font>';
|
||||
}
|
||||
|
|
|
@ -653,60 +653,6 @@ function event_comment(current_event) {
|
|||
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) {
|
||||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
|
|
|
@ -367,8 +367,6 @@ class TopNEventByGroupWidget extends Widget
|
|||
|
||||
$this->values['groupId'] = explode(',', $this->values['groupId'][0]);
|
||||
|
||||
$event_table = (is_metaconsole() === true) ? 'tmetaconsole_event' : 'tevento';
|
||||
|
||||
if (empty($this->values['groupId']) === true) {
|
||||
$output .= '<div class="container-center">';
|
||||
$output .= \ui_print_info_message(
|
||||
|
@ -390,13 +388,12 @@ class TopNEventByGroupWidget extends Widget
|
|||
if ($all_group === false) {
|
||||
$sql = sprintf(
|
||||
'SELECT id_agente, COUNT(*) AS count
|
||||
FROM %s
|
||||
FROM tevento
|
||||
WHERE utimestamp >= %d
|
||||
AND id_grupo IN (%s)
|
||||
GROUP BY id_agente
|
||||
ORDER BY count DESC
|
||||
LIMIT %d',
|
||||
$event_table,
|
||||
$timestamp,
|
||||
implode(',', $this->values['groupId']),
|
||||
$this->values['amountShow']
|
||||
|
@ -404,12 +401,11 @@ class TopNEventByGroupWidget extends Widget
|
|||
} else {
|
||||
$sql = sprintf(
|
||||
'SELECT id_agente, COUNT(*) AS count
|
||||
FROM %s
|
||||
FROM tevento
|
||||
WHERE utimestamp >= %d
|
||||
GROUP BY id_agente
|
||||
ORDER BY count DESC
|
||||
LIMIT %d',
|
||||
$event_table,
|
||||
$timestamp,
|
||||
$this->values['amountShow']
|
||||
);
|
||||
|
|
|
@ -365,8 +365,6 @@ class TopNEventByModuleWidget extends Widget
|
|||
|
||||
$this->values['groupId'] = explode(',', $this->values['groupId'][0]);
|
||||
|
||||
$event_table = (is_metaconsole() === true) ? 'tmetaconsole_event' : 'tevento';
|
||||
|
||||
if (empty($this->values['groupId']) === true) {
|
||||
$output = '<div class="container-center">';
|
||||
$output .= \ui_print_info_message(
|
||||
|
@ -391,13 +389,12 @@ class TopNEventByModuleWidget extends Widget
|
|||
id_agentmodule,
|
||||
event_type,
|
||||
COUNT(*) AS count
|
||||
FROM %s
|
||||
FROM tevento
|
||||
WHERE utimestamp >= %d
|
||||
AND id_grupo IN (%s)
|
||||
GROUP BY id_agentmodule, event_type
|
||||
ORDER BY count DESC
|
||||
LIMIT %d',
|
||||
$event_table,
|
||||
$timestamp,
|
||||
implode(',', $this->values['groupId']),
|
||||
$this->values['amountShow']
|
||||
|
@ -408,12 +405,11 @@ class TopNEventByModuleWidget extends Widget
|
|||
id_agentmodule,
|
||||
event_type,
|
||||
COUNT(*) AS count
|
||||
FROM %s
|
||||
FROM tevento
|
||||
WHERE utimestamp >= %d
|
||||
GROUP BY id_agentmodule, event_type
|
||||
ORDER BY count DESC
|
||||
LIMIT %d',
|
||||
$event_table,
|
||||
$timestamp,
|
||||
$this->values['amountShow']
|
||||
);
|
||||
|
|
|
@ -60,7 +60,7 @@ class Event extends Entity
|
|||
*/
|
||||
public function __construct(?int $event_id=null)
|
||||
{
|
||||
$this->table = ((bool) \is_metaconsole() === true) ? 'tmetaconsole_event' : 'tevento';
|
||||
$this->table = 'tevento';
|
||||
|
||||
if ($event_id === 0) {
|
||||
parent::__construct($this->table);
|
||||
|
|
|
@ -731,95 +731,51 @@ class Events
|
|||
{
|
||||
$system = System::getInstance();
|
||||
|
||||
// --------------Fill the SQL POST-------------------------------
|
||||
$sql_post = ' WHERE 1=1 ';
|
||||
$filters = [];
|
||||
|
||||
if ($this->status != null) {
|
||||
switch ($this->status) {
|
||||
case 0:
|
||||
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;
|
||||
}
|
||||
// Status.
|
||||
if (empty($this->status) === false) {
|
||||
$filters['status'] = $this->status;
|
||||
}
|
||||
|
||||
if ($this->free_search != '') {
|
||||
$sql_post .= " AND evento LIKE '%".io_safe_input($this->free_search)."%'";
|
||||
// Filter search.
|
||||
if (empty($this->free_search) === false) {
|
||||
$filters['search'] = $this->free_search;
|
||||
}
|
||||
|
||||
if ($this->severity != null && $this->severity != -1) {
|
||||
switch ($this->severity) {
|
||||
case EVENT_CRIT_WARNING_OR_CRITICAL:
|
||||
$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;
|
||||
}
|
||||
// Severity.
|
||||
if (empty($this->severity) === false) {
|
||||
$filters['severity'] = $this->severity;
|
||||
}
|
||||
|
||||
if ($this->hours_old > 0) {
|
||||
$unixtime = (get_system_time() - ($this->hours_old * SECONDS_1HOUR));
|
||||
$sql_post .= ' AND (utimestamp > '.$unixtime.')';
|
||||
}
|
||||
|
||||
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;
|
||||
// Hours.
|
||||
if (empty($this->hours_old) === false) {
|
||||
$filters['event_view_hr'] = $this->hours_old;
|
||||
} else {
|
||||
if (is_user_admin($system->getConfig('id_user'))) {
|
||||
// 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)).')';
|
||||
}
|
||||
$filters['event_view_hr'] = 8;
|
||||
}
|
||||
|
||||
if ($this->id_agent > 0) {
|
||||
$sql_post .= ' AND id_agente = '.$this->id_agent;
|
||||
// Type.
|
||||
if (empty($this->type) === false) {
|
||||
$filters['event_type'] = $this->type;
|
||||
}
|
||||
|
||||
// Skip system messages if user is not PM
|
||||
if (!check_acl($system->getConfig('id_user'), 0, 'PM')) {
|
||||
$sql_post .= ' AND id_grupo != 0';
|
||||
// ID group.
|
||||
if (empty($this->group) === false) {
|
||||
$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;
|
||||
$pagination = $this->limit;
|
||||
} else {
|
||||
|
@ -827,24 +783,41 @@ class Events
|
|||
$pagination = $system->getPageSize();
|
||||
}
|
||||
|
||||
$meta = false;
|
||||
if ($system->getConfig('metaconsole')) {
|
||||
$meta = true;
|
||||
}
|
||||
|
||||
$events_db = events_get_events_grouped(
|
||||
$sql_post,
|
||||
$events_db = events_get_all(
|
||||
// Fields.
|
||||
[
|
||||
'te.*',
|
||||
'ta.alias',
|
||||
],
|
||||
// Filter.
|
||||
$filters,
|
||||
// Offset.
|
||||
$offset,
|
||||
// Limit.
|
||||
$pagination,
|
||||
$meta,
|
||||
false
|
||||
// Order.
|
||||
'desc',
|
||||
// Sort field.
|
||||
'timestamp'
|
||||
);
|
||||
|
||||
if (empty($events_db)) {
|
||||
$events_db = [];
|
||||
if (is_metaconsole() === false) {
|
||||
$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 [
|
||||
'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'];
|
||||
$tmp->criticity = $max_event['criticity'];
|
||||
if ($max_event !== false
|
||||
&& empty($max_event) === false
|
||||
) {
|
||||
$tmp->timestamp = $max_event['timestamp'];
|
||||
$tmp->criticity = $max_event['criticity'];
|
||||
}
|
||||
}
|
||||
|
||||
$tmp->agent_name = io_safe_output($tmp->agent_name);
|
||||
|
@ -1588,34 +1592,9 @@ try {
|
|||
'class' => 'no-padding',
|
||||
],
|
||||
'id_evento',
|
||||
// 'id_agente',
|
||||
// 'id_usuario',
|
||||
// 'id_grupo',
|
||||
// 'estado',
|
||||
'agent_name',
|
||||
'timestamp',
|
||||
// 'utimestamp',
|
||||
// 'event_type',
|
||||
// 'id_agentmodule',
|
||||
// 'id_alert_am',
|
||||
'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',
|
||||
'class' => 'action_buttons w120px',
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue