diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index d5d7d24c20..bf26205d1d 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -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;
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index d746352d94..66f096d7bd 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -452,96 +452,6 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
}
-/**
- * Retrieves all events related to matching one.
- *
- * @param integer $id_evento Master event (max_id_evento).
- * @param array $filter Filters.
- * @param boolean $count Count results or get results.
- * @param boolean $history Apply on historical table.
- *
- * @return array Events or false in case of error.
- */
-function events_get_related_events(
- $id_evento,
- $filter=null,
- $count=false,
- $history=false
-) {
- global $config;
-
- if (!isset($id_evento) || $id_evento <= 0) {
- return false;
- }
-
- if (!isset($filter) || !is_array($filter)) {
- $filter = ['group_rep' => 0];
- }
-
- $table = 'tevento';
- $select = '*';
- if ($count === true) {
- $select = 'count(*) as n';
- };
-
- switch ($filter['group_rep']) {
- case '0':
- case '2':
- default:
- // No groups option direct update.
- $related_sql = sprintf(
- 'SELECT %s FROM %s
- WHERE id_evento = %d',
- $select,
- $table,
- $id_evento
- );
- break;
-
- case '1':
- // Group by events.
- $sql = events_get_all(
- ['te.*'],
- $filter,
- // Offset.
- null,
- // Limit.
- null,
- // Order.
- null,
- // Sort_field.
- null,
- // Historical table.
- $history,
- // Return_sql.
- true
- );
- $related_sql = sprintf(
- 'SELECT %s FROM %s tu INNER JOIN ( %s ) tf
- WHERE tu.estado = tf.estado
- AND tu.evento = tf.evento
- AND tu.id_agente = tf.id_agente
- AND tu.id_agentmodule = tf.id_agentmodule
- AND tf.max_id_evento = %d',
- $select,
- $table,
- $sql,
- $id_evento
- );
- break;
- }
-
- if ($count === true) {
- $r = db_get_all_rows_sql($related_sql);
-
- return $r[0]['n'];
- }
-
- return db_get_all_rows_sql($related_sql);
-
-}
-
-
/**
* Validates all events matching target filter.
*
@@ -1434,7 +1344,7 @@ function events_get_all(
$pagination = '';
if (is_metaconsole() === true) {
// TODO: XXX TOTAL 10000 - 10000000. settins meta 300000; TIP. capturra el error.
- $pagination = ' LIMIT 10 ';
+ $pagination = ' LIMIT 100000 ';
} else if (isset($limit, $offset) === true && $limit > 0) {
$pagination = sprintf(' LIMIT %d OFFSET %d', $limit, $offset);
}
@@ -1602,8 +1512,6 @@ function events_get_all(
('.$sql.') tbase';
}
- hd($sql, true);
-
if ($count !== true) {
if (is_metaconsole() === true) {
$result_meta = [];
@@ -1824,298 +1732,6 @@ function events_get_event($id, $fields=false, $meta=false, $history=false)
}
-/**
- * Retrieve all events ungrouped.
- *
- * @param string $sql_post Sql_post.
- * @param boolean $meta Meta.
- * @param boolean $history History.
- * @param boolean $returnSql Only Query.
- *
- * @return mixed Array of events or false.
- */
-function events_get_events_no_grouped(
- $sql_post,
- $meta=false,
- $history=false,
- $returnSql=false
-) {
- global $config;
-
- $table = 'tevento';
-
- $sql = 'SELECT * FROM '.$table.' te ';
- $sql .= events_get_secondary_groups_left_join($table);
- $sql .= $sql_post;
-
- if ($returnSql === true) {
- return $sql;
- }
-
- hd($sql);
-
- $events = db_get_all_rows_sql($sql, $history);
-
- return $events;
-}
-
-
-/**
- * Return all events matching sql_post grouped.
- *
- * @param string $sql_post Sql_post.
- * @param integer $offset Offset.
- * @param integer $pagination Pagination.
- * @param boolean $meta Meta.
- * @param boolean $history History.
- * @param boolean $total Total.
- * @param boolean $history_db History_db.
- * @param string $order Order.
- * @param string $sort_field Sort_field.
- *
- * @return mixed Array of events or false.
- */
-function events_get_events_grouped(
- $sql_post,
- $offset=0,
- $pagination=1,
- $meta=false,
- $history=false,
- $total=false,
- $history_db=false,
- $order='down',
- $sort_field='utimestamp'
-) {
- global $config;
-
- $table = 'tevento';
-
- if ($meta) {
- $groupby_extra = ', server_id';
- } else {
- $groupby_extra = '';
- }
-
- if (is_metaconsole()) {
- $id_source_event = get_parameter('id_source_event');
- if ($id_source_event != '') {
- $sql_post .= "AND id_source_event = $id_source_event";
- }
- }
-
- db_process_sql('SET group_concat_max_len = 9999999');
- $event_lj = events_get_secondary_groups_left_join($table);
- if ($total) {
- $sql = "SELECT COUNT(*) FROM (SELECT id_evento
- FROM $table te $event_lj ".$sql_post.'
- GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra.') AS t';
- } else {
- $sql = sprintf(
- 'SELECT *,
- MAX(id_evento) AS id_evento,
- GROUP_CONCAT(
- DISTINCT user_comment SEPARATOR "
"
- ) AS user_comment,
- GROUP_CONCAT(
- DISTINCT id_evento SEPARATOR ","
- ) AS similar_ids,
- COUNT(id_evento) AS event_rep, MAX(utimestamp) AS timestamp_rep,
- MIN(utimestamp) AS timestamp_rep_min,
- (SELECT owner_user
- FROM %s
- WHERE id_evento = MAX(te.id_evento)) AS owner_user,
- (SELECT id_usuario
- FROM %s
- WHERE id_evento = MAX(te.id_evento)) AS id_usuario,
- (SELECT id_agente
- FROM %s
- WHERE id_evento = MAX(te.id_evento)) AS id_agente,
- (SELECT criticity
- FROM %s
- WHERE id_evento = MAX(te.id_evento)) AS criticity,
- (SELECT ack_utimestamp
- FROM %s
- WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp,
- (SELECT nombre
- FROM tagente_modulo
- WHERE id_agente_modulo = te.id_agentmodule) AS module_name
- FROM %s te %s
- %s
- GROUP BY estado, evento, id_agente, id_agentmodule %s
- %s
- LIMIT %d, %d',
- $table,
- $table,
- $table,
- $table,
- $table,
- $table,
- $event_lj,
- $sql_post,
- $groupby_extra,
- events_get_sql_order($sort_field, $order, 2),
- $offset,
- $pagination
- );
- }
-
- // Extract the events by filter (or not) from db.
- $events = db_get_all_rows_sql($sql, $history_db);
-
- if ($total) {
- return reset($events[0]);
- } else {
- return $events;
- }
-}
-
-
-/**
- * Return count of events grouped.
- *
- * @param string $sql_post Sql_post.
- * @param boolean $meta Meta.
- * @param boolean $history History.
- *
- * @return integer Number of events or false if failed.
- */
-function events_get_total_events_grouped($sql_post, $meta=false, $history=false)
-{
- return events_get_events_grouped($sql_post, 0, 0, $meta, $history, true);
-}
-
-
-/**
- * Get all the events ids similar to a given event id.
- *
- * An event is similar then the event text (evento) and the id_agentmodule are
- * the same.
- *
- * @param integer $id Event id to get similar events.
- * @param boolean $meta Metaconsole mode flag.
- * @param boolean $history History mode flag.
- *
- * @return array A list of events ids.
- */
-function events_get_similar_ids($id, $meta=false, $history=false)
-{
- $events_table = 'tevento';
-
- $ids = [];
- if ($meta) {
- $event = events_meta_get_event(
- $id,
- [
- 'evento',
- 'id_agentmodule',
- ],
- $history
- );
- } else {
- $event = events_get_event($id, ['evento', 'id_agentmodule']);
- }
-
- if ($event === false) {
- return $ids;
- }
-
- $events = db_get_all_rows_filter(
- $events_table,
- [
- 'evento' => $event['evento'],
- 'id_agentmodule' => $event['id_agentmodule'],
- ],
- ['id_evento']
- );
- if ($events === false) {
- return $ids;
- }
-
- foreach ($events as $event) {
- $ids[] = $event['id_evento'];
- }
-
- return $ids;
-}
-
-
-/**
- * Delete events in a transresponse
- *
- * @param mixed $id_event Event ID or array of events.
- * @param boolean $similar Whether to delete similar events too.
- * @param boolean $meta Metaconsole mode flag.
- * @param boolean $history History mode flag.
- *
- * @return boolean Whether or not it was successful
- */
-function events_delete_event(
- $id_event,
- $similar=true,
- $meta=false,
- $history=false
-) {
- global $config;
-
- $table_event = 'tevento';
-
- // Cleans up the selection for all unwanted values also casts any single values as an array.
- $id_event = (array) safe_int($id_event, 1);
-
- // We must delete all events like the selected.
- if ($similar) {
- foreach ($id_event as $id) {
- $id_event = array_merge(
- $id_event,
- events_get_similar_ids($id, $meta, $history)
- );
- }
-
- $id_event = array_unique($id_event);
- }
-
- $errors = 0;
-
- foreach ($id_event as $event) {
- if ($meta) {
- $event_group = events_meta_get_group($event, $history);
- } else {
- $event_group = events_get_group($event);
- }
-
- if (check_acl($config['id_user'], $event_group, 'EM') == 0) {
- // Check ACL.
- db_pandora_audit(
- AUDIT_LOG_ACL_VIOLATION,
- 'Attempted deleting event #'.$event
- );
- $errors++;
- } else {
- $ret = db_process_sql_delete($table_event, ['id_evento' => $event]);
-
- if (!$ret) {
- $errors++;
- } else {
- db_pandora_audit(
- AUDIT_LOG_ALERT_MANAGEMENT,
- 'Deleted event #'.$event
- );
- // ACL didn't fail nor did return.
- continue;
- }
- }
-
- break;
- }
-
- if ($errors > 0) {
- return false;
- } else {
- return true;
- }
-}
-
-
/**
* Change the status of one or multiple events.
*
@@ -3034,88 +2650,6 @@ function events_print_type_description($type, $return=false)
}
-/**
- * Get all the events happened in a group during a period of time.
- *
- * The returned events will be in the time interval ($date - $period, $date]
- *
- * @param mixed $begin Begin.
- * @param mixed $result Result.
- * @param mixed $id_group Group id to get events for.
- * @param integer $period Period in seconds to get events.
- * @param integer $date Beginning date to get events.
- * @param boolean $filter_event_validated Filter_event_validated.
- * @param boolean $filter_event_critical Filter_event_critical.
- * @param boolean $filter_event_warning Filter_event_warning.
- * @param boolean $filter_event_no_validated Filter_event_no_validated.
- *
- * @return array An array with all the events happened.
- */
-function events_get_group_events_steps(
- $begin,
- &$result,
- $id_group,
- $period,
- $date,
- $filter_event_validated=false,
- $filter_event_critical=false,
- $filter_event_warning=false,
- $filter_event_no_validated=false
-) {
- global $config;
-
- $id_group = groups_safe_acl($config['id_user'], $id_group, 'ER');
-
- if (empty($id_group)) {
- // An empty array means the user doesn't have access.
- return false;
- }
-
- $datelimit = ($date - $period);
-
- $sql_where = ' AND 1 = 1 ';
- $criticities = [];
- if ($filter_event_critical) {
- $criticities[] = 4;
- }
-
- if ($filter_event_warning) {
- $criticities[] = 3;
- }
-
- if (!empty($criticities)) {
- $sql_where .= ' AND criticity IN ('.implode(', ', $criticities).')';
- }
-
- if ($filter_event_validated) {
- $sql_where .= ' AND estado = 1 ';
- }
-
- if ($filter_event_no_validated) {
- $sql_where .= ' AND estado = 0 ';
- }
-
- $sql = sprintf(
- 'SELECT *,
- (SELECT t2.nombre
- FROM tagente t2
- WHERE t2.id_agente = t3.id_agente) AS agent_name,
- (SELECT t2.fullname
- FROM tusuario t2
- WHERE t2.id_user = t3.id_usuario) AS user_name
- FROM tevento t3
- WHERE utimestamp > %d AND utimestamp <= %d
- AND id_grupo IN (%s) '.$sql_where.'
- ORDER BY utimestamp ASC',
- $datelimit,
- $date,
- implode(',', $id_group)
- );
-
- return db_get_all_row_by_steps_sql($begin, $result, $sql);
-}
-
-
/**
* Get all the events happened in an Agent during a period of time.
*
@@ -3211,7 +2745,6 @@ function events_get_agent(
}
if (empty($id_agent_module) === false) {
- // TODO: XXX por id_agente_modulo.
$filters['module_search'] = modules_get_agentmodule_name($id_agent_module);
}
@@ -3220,35 +2753,25 @@ function events_get_agent(
}
// Group by agent.
- // TODO: XXX constants.
- $filters['group_rep'] = 2;
-
- $max_register = 1000;
-
- // TODO: XXX
- if ($show_summary_group) {
- hd('tt');
- return events_get_events_grouped(
- $sql_where,
- 0,
- $max_register,
- is_metaconsole(),
- false,
- false,
- $history
- );
+ if ((bool) $show_summary_group === true) {
+ $filters['group_rep'] = 1;
} else {
- $events = Event::search(
- ['te.*'],
- $filters,
- 0,
- $max_register,
- 'desc',
- 'te.utimestamp'
- );
-
- return $events['data'];
+ $filters['group_rep'] = 2;
}
+
+ $events = Event::search(
+ [
+ 'te.*',
+ 'ta.alias',
+ ],
+ $filters,
+ 0,
+ 1000,
+ 'desc',
+ 'te.utimestamp'
+ );
+
+ return $events['data'];
}
@@ -4974,12 +4497,6 @@ function events_page_general($event)
{
global $img_sev;
global $config;
-
- /*
- Commented out (old)
- // $group_rep = $event['similar_ids'] == -1 ? 1 : count(explode(',',$event['similar_ids']));
- */
-
global $group_rep;
$secondary_groups = '';
@@ -5428,1913 +4945,59 @@ function events_clean_tags($tags)
/**
* Get all the events happened in a group during a period of time.
*
- * The returned events will be in the time interval ($date - $period, $date]
- *
- * @param mixed $id_group Group id to get events for.
- * @param integer $period Period in seconds to get events.
- * @param integer $date Beginning date to get events.
- * @param boolean $filter_event_severity Filter_event_severity.
- * @param boolean $filter_event_type Filter_event_type.
- * @param boolean $filter_event_status Filter_event_status.
- * @param boolean $filter_event_filter_search Filter_event_filter_search.
- * @param boolean $dbmeta Dbmeta.
- * @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
+ * @param array $data Data.
*
* @return array An array with all the events happened.
*/
-function events_get_count_events_by_agent(
- $id_group,
- $period,
- $date,
- $filter_event_severity=false,
- $filter_event_type=false,
- $filter_event_status=false,
- $filter_event_filter_search=false,
- $dbmeta=false,
- $filter_event_filter_exclude=false
-) {
- global $config;
-
- // Date.
- if (!is_numeric($date)) {
- $date = time_w_fixed_tz($date);
- }
-
- if (empty($date)) {
- $date = get_system_time();
- }
-
- // Group.
- $id_group = groups_safe_acl($config['id_user'], $id_group, 'AR');
-
- if (empty($id_group)) {
- // An empty array means the user doesn't have access.
- return false;
- }
-
- $datelimit = ($date - $period);
-
- $sql_where = '';
- $severity_all = 0;
- if (!empty($filter_event_severity)) {
- foreach ($filter_event_severity as $key => $value) {
- switch ($value) {
- case -1:
- $severity_all = 1;
- break;
-
- case 34:
- $filter_event_severity[$key] = '3, 4';
- break;
-
- case 20:
- $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
- break;
-
- case 21:
- $filter_event_severity[$key] = '4, 2';
- break;
-
- default:
- // Ignore.
- break;
- }
- }
-
- if (!$severity_all) {
- $sql_where .= ' AND criticity IN ('.implode(', ', $filter_event_severity).')';
- }
- }
-
- $status_all = 0;
- if (!empty($filter_event_status)) {
- foreach ($filter_event_status as $key => $value) {
- switch ($value) {
- case -1:
- $status_all = 1;
- break;
-
- case 3:
- $filter_event_status[$key] = ('0, 2');
- default:
- // Ignore.
- break;
- }
- }
-
- if (!$status_all) {
- $sql_where .= ' AND estado IN ('.implode(', ', $filter_event_status).')';
- }
- }
-
- if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
- $sql_where .= ' AND (';
- $type = [];
- foreach ($filter_event_type as $event_type) {
- if ($event_type != '') {
- // If normal, warning, could be several (going_up_warning, going_down_warning... too complex.
- // Shown to user only "warning, critical and normal".
- if ($event_type == 'warning' || $event_type == 'critical' || $event_type == 'normal') {
- $type[] = " event_type LIKE '%".$event_type."%' ";
- } else if ($event_type == 'not_normal') {
- $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
- } else if ($event_type != 'all') {
- $type[] = " event_type = '".$event_type."'";
- }
- }
- }
-
- $sql_where .= implode(' OR ', $type).')';
- }
-
- if (!empty($filter_event_filter_search)) {
- $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
- }
-
- if (!empty($filter_event_filter_exclude)) {
- $sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
- }
-
- $tagente = 'tagente';
- $tevento = 'tevento';
- $field_type = 'ta.id_agente';
- if ($dbmeta === true) {
- $tagente = 'tmetaconsole_agent';
- $tevento = 'tmetaconsole_event';
- $field_type = 'ta.id_tagente';
- }
-
- $sql = sprintf(
- 'SELECT
- ta.id_agente,
- ta.alias as agent_name,
- count(*) as count
- FROM %s te
- %s
- INNER JOIN %s ta
- ON te.id_agente = %s
- INNER JOIN tgrupo tg
- ON (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))
- OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s))
- WHERE utimestamp > %d AND utimestamp <= %d
- GROUP BY ta.id_agente',
- $tevento,
- events_get_secondary_groups_left_join($tevento),
- $tagente,
- $field_type,
- implode(',', $id_group),
- implode(',', $id_group),
- $datelimit,
- $date,
- $sql_where
- );
-
- $rows = db_get_all_rows_sql($sql);
-
- if ($rows == false) {
- $rows = [];
- }
-
- $return = [];
- foreach ($rows as $row) {
- $agent_name = $row['agent_name'];
- if (empty($row['agent_name'])) {
- $agent_name = __('Pandora System');
- }
-
- $return[$agent_name] = $row['count'];
- }
-
- return $return;
-}
-
-
-/**
- * Get all the events happened in a group during a period of time.
- *
- * The returned events will be in the time interval ($date - $period, $date]
- *
- * @param array $filter Use target filter.
- * @param integer $period Period in seconds to get events.
- * @param integer $date Beginning date to get events.
- * @param boolean $filter_event_severity Filter_event_severity.
- * @param boolean $filter_event_type Filter_event_type.
- * @param boolean $filter_event_status Filter_event_status.
- * @param boolean $filter_event_filter_search Filter_event_filter_search.
- * @param boolean $dbmeta Dbmeta.
- * @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
- *
- * @return array An array with all the events happened.
- */
-function events_get_count_events_validated_by_user(
- $filter,
- $period,
- $date,
- $filter_event_severity=false,
- $filter_event_type=false,
- $filter_event_status=false,
- $filter_event_filter_search=false,
- $dbmeta=false,
- $filter_event_filter_exclude=false
-) {
- global $config;
- $tevento = 'tevento';
- if ($dbmeta === true) {
- $tevento = 'tmetaconsole_event';
- }
-
- // Group.
- $tgroup_join = '';
- if (isset($filter['id_group'])) {
- $id_group = groups_safe_acl($config['id_user'], $filter['id_group'], 'AR');
-
- if (empty($id_group)) {
- // An empty array means the user doesn't have access.
- return false;
- }
-
- $tgroup_join = sprintf(
- '%s
- INNER JOIN tgrupo tg
- ON (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))
- OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s))',
- events_get_secondary_groups_left_join($tevento),
- implode(',', $id_group),
- implode(',', $id_group)
- );
- }
-
- $sql_filter = '';
- if (!empty($filter['id_agent'])) {
- $sql_filter .= sprintf(' AND id_agente = %d ', $filter['id_agent']);
- }
-
- if (!empty($filter['id_agentmodule'])) {
- $sql_filter .= sprintf(' AND id_agentmodule = %d ', $filter['id_agentmodule']);
- }
-
- // Date.
- if (!is_numeric($date)) {
- $date = time_w_fixed_tz($date);
- }
-
- if (empty($date)) {
- $date = get_system_time();
- }
-
- $datelimit = ($date - $period);
-
- $sql_where = '';
- $severity_all = 0;
- if (!empty($filter_event_severity)) {
- foreach ($filter_event_severity as $key => $value) {
- switch ($value) {
- case -1:
- $severity_all = 1;
- break;
-
- case 34:
- $filter_event_severity[$key] = '3, 4';
- break;
-
- case 20:
- $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
- break;
-
- case 21:
- $filter_event_severity[$key] = '4, 2';
- break;
-
- default:
- // Ignore.
- break;
- }
- }
-
- if (!$severity_all) {
- $sql_where .= ' AND criticity IN ('.implode(', ', $filter_event_severity).')';
- }
- }
-
- $status_all = 0;
- if (!empty($filter_event_status)) {
- foreach ($filter_event_status as $key => $value) {
- switch ($value) {
- case -1:
- $status_all = 1;
- break;
-
- case 3:
- $filter_event_status[$key] = ('0, 2');
- default:
- // Ignore.
- break;
- }
- }
-
- if (!$status_all) {
- $sql_where .= ' AND estado IN ('.implode(', ', $filter_event_status).')';
- }
- }
-
- if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
- $sql_where .= ' AND (';
- $type = [];
- foreach ($filter_event_type as $event_type) {
- if ($event_type != '') {
- // If normal, warning, could be several (going_up_warning, going_down_warning... too complex.
- // Shown to user only "warning, critical and normal".
- if ($event_type == 'warning' || $event_type == 'critical' || $event_type == 'normal') {
- $type[] = " event_type LIKE '%".$event_type."%' ";
- } else if ($event_type == 'not_normal') {
- $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
- } else if ($event_type != 'all') {
- $type[] = " event_type = '".$event_type."'";
- }
- }
- }
-
- $sql_where .= implode(' OR ', $type).')';
- }
-
- if (!empty($filter_event_filter_search)) {
- $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
- }
-
- if (!empty($filter_event_filter_exclude)) {
- $sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
- }
-
- $sql = sprintf(
- 'SELECT
- te.id_usuario,
- tu.fullname as user_name,
- count(*) as count
- FROM %s te
- %s
- LEFT JOIN tusuario tu
- ON te.owner_user = tu.id_user
- WHERE
- te.utimestamp > %d AND te.utimestamp <= %d
- AND te.estado = %d
- %s
- GROUP BY te.id_usuario',
- $tevento,
- $tgroup_join,
- $datelimit,
- $date,
- EVENT_VALIDATE,
- $sql_filter,
- $sql_where
- );
-
- $rows = db_get_all_rows_sql($sql);
-
- if ($rows == false) {
- $rows = [];
- }
-
- $return = [];
- foreach ($rows as $row) {
- $user_name = $row['user_name'];
- if (empty($row['user_name'])) {
- $user_name = __('Validated but not assigned');
- }
-
- $return[$user_name] = $row['count'];
- }
-
- return $return;
-}
-
-
-/**
- * Get all the events happened in a group during a period of time.
- *
- * The returned events will be in the time interval ($date - $period, $date]
- *
- * @param mixed $filter Target filter.
- * @param integer $period Period in seconds to get events.
- * @param integer $date Beginning date to get events.
- * @param boolean $filter_event_severity Filter_event_severity.
- * @param boolean $filter_event_type Filter_event_type.
- * @param boolean $filter_event_status Filter_event_status.
- * @param boolean $filter_event_filter_search Filter_event_filter_search.
- * @param boolean $dbmeta Dbmeta.
- * @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
- *
- * @return array An array with all the events happened.
- */
-function events_get_count_events_by_criticity(
- $filter,
- $period,
- $date,
- $filter_event_severity=false,
- $filter_event_type=false,
- $filter_event_status=false,
- $filter_event_filter_search=false,
- $dbmeta=false,
- $filter_event_filter_exclude=false
-) {
- global $config;
-
- $tevento = 'tevento';
- if ($dbmeta === true) {
- $tevento = 'tmetaconsole_event';
- }
-
- $sql_filter = '';
- $tgroup_join = '';
- if (isset($filter['id_group'])) {
- $id_group = groups_safe_acl($config['id_user'], $filter['id_group'], 'AR');
-
- if (empty($id_group)) {
- // An empty array means the user doesn't have access.
- return false;
- }
-
- $tgroup_join = sprintf(
- '%s
- INNER JOIN tgrupo tg
- ON (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))
- OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s))',
- events_get_secondary_groups_left_join($tevento),
- implode(',', $id_group),
- implode(',', $id_group)
- );
- }
-
- if (!empty($filter['id_agent'])) {
- $sql_filter .= sprintf(' AND id_agente = %d ', $filter['id_agent']);
- }
-
- if (!empty($filter['id_agentmodule'])) {
- $sql_filter .= sprintf(' AND id_agentmodule = %d ', $filter['id_agentmodule']);
- }
-
- if (!is_numeric($date)) {
- $date = time_w_fixed_tz($date);
- }
-
- if (empty($date)) {
- $date = get_system_time();
- }
-
- $datelimit = ($date - $period);
-
- $sql_where = '';
- $severity_all = 0;
- if (!empty($filter_event_severity)) {
- foreach ($filter_event_severity as $key => $value) {
- switch ($value) {
- case -1:
- $severity_all = 1;
- break;
-
- case 34:
- $filter_event_severity[$key] = '3, 4';
- break;
-
- case 20:
- $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
- break;
-
- case 21:
- $filter_event_severity[$key] = '4, 2';
- break;
-
- default:
- // Ignore.
- break;
- }
- }
-
- if (!$severity_all) {
- $sql_where .= ' AND criticity IN ('.implode(', ', $filter_event_severity).')';
- }
- }
-
- $status_all = 0;
- if (!empty($filter_event_status)) {
- foreach ($filter_event_status as $key => $value) {
- switch ($value) {
- case -1:
- $status_all = 1;
- break;
-
- case 3:
- $filter_event_status[$key] = ('0, 2');
- break;
-
- default:
- // Ignored.
- break;
- }
- }
-
- if (!$status_all) {
- $sql_where .= ' AND estado IN ('.implode(', ', $filter_event_status).')';
- }
- }
-
- if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
- $sql_where .= ' AND (';
- $type = [];
- foreach ($filter_event_type as $event_type) {
- if ($event_type != '') {
- // If normal, warning, could be several (going_up_warning, going_down_warning... too complex.
- // Shown to user only "warning, critical and normal".
- if ($event_type == 'warning' || $event_type == 'critical' || $event_type == 'normal') {
- $type[] = " event_type LIKE '%".$event_type."%' ";
- } else if ($event_type == 'not_normal') {
- $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
- } else if ($event_type != 'all') {
- $type[] = " event_type = '".$event_type."'";
- }
- }
- }
-
- $sql_where .= implode(' OR ', $type).')';
- }
-
- if (!empty($filter_event_filter_search)) {
- $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
- }
-
- if (!empty($filter_event_filter_exclude)) {
- $sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
- }
-
- $sql = sprintf(
- 'SELECT
- te.criticity,
- count(*) as count
- FROM %s te
- %s
- WHERE
- te.utimestamp > %d AND te.utimestamp <= %d
- %s
- %s
- GROUP BY te.id_usuario',
- $tevento,
- $tgroup_join,
- $datelimit,
- $date,
- $sql_filter,
- $sql_where
- );
-
- $rows = db_get_all_rows_sql($sql);
-
- if ($rows == false) {
- $rows = [];
- }
-
- $return = [];
- foreach ($rows as $row) {
- $return[get_priority_name($row['criticity'])] = $row['count'];
- }
-
- return $return;
-}
-
-
-/**
- * Get all the events happened in a group during a period of time.
- *
- * The returned events will be in the time interval ($date - $period, $date]
- *
- * @param mixed $filter Target filter.
- * @param integer $period Period in seconds to get events.
- * @param integer $date Beginning date to get events.
- * @param boolean $filter_event_severity Filter_event_severity.
- * @param boolean $filter_event_type Filter_event_type.
- * @param boolean $filter_event_status Filter_event_status.
- * @param boolean $filter_event_filter_search Filter_event_filter_search.
- * @param boolean $dbmeta Dbmeta.
- * @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
- *
- * @return array An array with all the events happened.
- */
-function events_get_count_events_validated(
- $filter,
- $period=null,
- $date=null,
- $filter_event_severity=false,
- $filter_event_type=false,
- $filter_event_status=false,
- $filter_event_filter_search=false,
- $dbmeta=false,
- $filter_event_filter_exclude=false
-) {
- global $config;
- $tevento = 'tevento';
- if ($dbmeta === true) {
- $tevento = 'tmetaconsole_event';
- }
-
- // Group.
- $sql_filter = '';
- $tgroup_join = '';
- if (isset($filter['id_group'])) {
- $id_group = groups_safe_acl($config['id_user'], $filter['id_group'], 'AR');
-
- if (empty($id_group)) {
- // An empty array means the user doesn't have access.
- return false;
- }
-
- $tgroup_join = sprintf(
- '%s
- INNER JOIN tgrupo tg
- ON (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))
- OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s))',
- events_get_secondary_groups_left_join($tevento),
- implode(',', $id_group),
- implode(',', $id_group)
- );
- }
-
- // Agent.
- if (!empty($filter['id_agent'])) {
- $sql_filter .= sprintf(
- ' AND id_agente = %d ',
- $filter['id_agent']
- );
- }
-
- // Module.
- if (!empty($filter['id_agentmodule'])) {
- $sql_filter .= sprintf(
- ' AND id_agentmodule = %d ',
- $filter['id_agentmodule']
- );
- }
-
- // Date.
- if (!is_numeric($date)) {
- $date = time_w_fixed_tz($date);
- }
-
- if (empty($date)) {
- $date = get_system_time();
- }
-
- $date_filter = '';
- if (!empty($date) && !empty($period)) {
- $datelimit = ($date - $period);
-
- $date_filter .= sprintf(
- ' AND utimestamp > %d AND utimestamp <= %d ',
- $datelimit,
- $date
- );
- } else if (!empty($period)) {
- $date = time();
- $datelimit = ($date - $period);
-
- $date_filter .= sprintf(
- ' AND utimestamp > %d AND utimestamp <= %d ',
- $datelimit,
- $date
- );
- } else if (!empty($date)) {
- $date_filter .= sprintf(' AND utimestamp <= %d ', $date);
- }
-
- $sql_where = '';
- $severity_all = 0;
- if (!empty($filter_event_severity)) {
- foreach ($filter_event_severity as $key => $value) {
- switch ($value) {
- case -1:
- $severity_all = 1;
- break;
-
- case 34:
- $filter_event_severity[$key] = '3, 4';
- break;
-
- case 20:
- $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6';
- break;
-
- case 21:
- $filter_event_severity[$key] = '4, 2';
- break;
-
- default:
- // Ingore.
- break;
- }
- }
-
- if (!$severity_all) {
- $sql_where .= ' AND criticity IN ('.implode(', ', $filter_event_severity).')';
- }
- }
-
- $status_all = 0;
- if (!empty($filter_event_status)) {
- foreach ($filter_event_status as $key => $value) {
- switch ($value) {
- case -1:
- $status_all = 1;
- break;
-
- case 3:
- $filter_event_status[$key] = ('0, 2');
- break;
-
- default:
- // Ignore.
- break;
- }
- }
-
- if (!$status_all) {
- $sql_where .= ' AND estado IN ('.implode(', ', $filter_event_status).')';
- }
- }
-
- if (!empty($filter_event_type) && $filter_event_type[0] != 'all') {
- $sql_where .= ' AND (';
- $type = [];
- foreach ($filter_event_type as $event_type) {
- if ($event_type != '') {
- // If normal, warning, could be several (going_up_warning, going_down_warning... too complex.
- // Shown to user only "warning, critical and normal".
- if ($event_type == 'warning' || $event_type == 'critical' || $event_type == 'normal') {
- $type[] = " event_type LIKE '%".$event_type."%' ";
- } else if ($event_type == 'not_normal') {
- $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
- } else if ($event_type != 'all') {
- $type[] = " event_type = '".$event_type."'";
- }
- }
- }
-
- $sql_where .= implode(' OR ', $type).')';
- }
-
- if (!empty($filter_event_filter_search)) {
- $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
- }
-
- if (!empty($filter_event_filter_exclude)) {
- $sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
- }
-
- $sql = sprintf(
- 'SELECT
- te.estado,
- count(*) as count
- FROM %s te
- %s
- WHERE
- te.utimestamp > %d AND te.utimestamp <= %d
- %s
- %s
- GROUP BY te.id_usuario',
- $tevento,
- $tgroup_join,
- $datelimit,
- $date,
- $sql_filter,
- $sql_where
- );
-
- $rows = db_get_all_rows_sql($sql);
-
- if ($rows == false) {
- $rows = [];
- }
-
- $return = array_reduce(
- $rows,
- function ($carry, $item) {
- $status = (int) $item['estado'];
- $count = (int) $item['count'];
-
- if ($status === 1) {
- $carry[__('Validated')] += $count;
- } else if ($status === 0) {
- $carry[__('Not validated')] += $count;
- }
-
- return $carry;
- },
- [
- __('Validated') => 0,
- __('Not validated') => 0,
- ]
- );
-
- return $return;
-}
-
-
-/**
- * Check event tags.
- *
- * @param array $event_data Event.
- * @param array $acltags Acl tags.
- *
- * @return boolean True or false.
- */
-function events_checks_event_tags($event_data, $acltags)
+function events_get_count_events_validated_by_user($data)
{
- global $config;
+ $data_graph_by_user = [];
+ if (empty($data) === false) {
+ foreach ($data as $value) {
+ $k = $value['id_usuario'];
- if (empty($acltags[$event_data['id_grupo']])) {
- return true;
- } else {
- $tags_arr_acl = explode(',', $acltags[$event_data['id_grupo']]);
- $tags_arr_event = explode(',', $event_data['tags']);
-
- foreach ($tags_arr_acl as $tag) {
- $tag_name = tags_get_name($tag);
- if (in_array($tag_name, $tags_arr_event)) {
- return true;
- } else {
- $has_tag = false;
+ if (empty($k) === true
+ && ($value['estado'] == EVENT_VALIDATE
+ || $value['status'] == EVENT_VALIDATE)
+ ) {
+ if (isset($data_graph_by_user['System']) === true) {
+ $data_graph_by_user['System']++;
+ } else {
+ $data_graph_by_user['System'] = 1;
+ }
+ } else if (empty($k) === false) {
+ if (isset($data_graph_by_user[$k]) === true) {
+ $data_graph_by_user[$k]++;
+ } else {
+ $data_graph_by_user[$k] = 1;
+ }
}
}
- if (!$has_tag) {
- return false;
- }
- }
-
- return false;
-}
-
-
-/**
- * Retrieves events grouped by agent.
- *
- * @param string $sql_post Sql_post.
- * @param integer $offset Offset.
- * @param integer $pagination Pagination.
- * @param boolean $meta Meta.
- * @param boolean $history History.
- * @param boolean $total Total.
- *
- * @return array Data.
- */
-function events_get_events_grouped_by_agent(
- $sql_post,
- $offset=0,
- $pagination=1,
- $meta=false,
- $history=false,
- $total=false
-) {
- global $config;
-
- $table = 'tevento';
-
- if ($meta) {
- $fields_extra = ', agent_name, server_id';
- $groupby_extra = ', server_id';
- } else {
- $groupby_extra = '';
- $fields_extra = '';
- }
-
- $event_lj = events_get_secondary_groups_left_join($table);
- if ($total) {
- $sql = 'SELECT COUNT(*) FROM (select id_agente from '.$table.' '.$event_lj.' WHERE 1=1
- '.$sql_post.' GROUP BY id_agente, event_type'.$groupby_extra.' ORDER BY id_agente ) AS t';
- } else {
- $sql = 'select id_agente, count(*) as total'.$fields_extra.' from '.$table.' te '.$event_lj.'
- WHERE id_agente > 0 '.$sql_post.' GROUP BY id_agente'.$groupby_extra.' ORDER BY id_agente LIMIT '.$offset.','.$pagination;
- }
-
- $result = [];
- // Extract the events by filter (or not) from db.
- $events = db_get_all_rows_sql($sql);
- $result = [];
-
- if ($events) {
- foreach ($events as $event) {
- if ($meta) {
- $sql = 'SELECT event_type FROM '.$table.' te '.$event_lj."
- WHERE agent_name = '".$event['agent_name']."' ".$sql_post.' ORDER BY utimestamp DESC ';
- $resultado = db_get_row_sql($sql);
-
- $id_agente = $event['agent_name'];
- $result[] = [
- 'total' => $event['total'],
- 'id_server' => $event['server_id'],
- 'id_agent' => $id_agente,
- 'event_type' => $resultado['event_type'],
- ];
- } else {
- $sql = 'SELECT event_type FROM '.$table.' te '.$event_lj.'
- WHERE id_agente = '.$event['id_agente'].' '.$sql_post.' ORDER BY utimestamp DESC ';
- $resultado = db_get_row_sql($sql);
-
- $id_agente = $event['id_agente'];
- $result[] = [
- 'total' => $event['total'],
- 'id_agent' => $id_agente,
- 'event_type' => $resultado['event_type'],
- ];
- }
- }
- }
-
- return $result;
-}
-
-
-/**
- * Return SQL query to group events by agents.
- *
- * @param mixed $id_agent Id_agent.
- * @param integer $server_id Server_id.
- * @param string $event_type Event_type.
- * @param integer $severity Severity.
- * @param integer $status Status.
- * @param string $search Search.
- * @param integer $id_agent_module Id_agent_module.
- * @param integer $event_view_hr Event_view_hr.
- * @param boolean $id_user_ack Id_user_ack.
- * @param array $tag_with Tag_with.
- * @param array $tag_without Tag_without.
- * @param boolean $filter_only_alert Filter_only_alert.
- * @param string $date_from Date_from.
- * @param string $time_from Time_from.
- * @param string $date_to Date_to.
- * @param string $time_to Time_to.
- * @param boolean $id_user Id_user.
- * @param boolean $server_id_search Server_id_search.
- *
- * @return string SQL.
- */
-function events_sql_events_grouped_agents(
- $id_agent,
- $server_id=-1,
- $event_type='',
- $severity=-1,
- $status=3,
- $search='',
- $id_agent_module=0,
- $event_view_hr=8,
- $id_user_ack=false,
- $tag_with=[],
- $tag_without=[],
- $filter_only_alert=false,
- $date_from='',
- $time_from='',
- $date_to='',
- $time_to='',
- $id_user=false,
- $server_id_search=false
-) {
- global $config;
-
- $sql_post = ' 1 = 1 ';
-
- $meta = false;
- if (is_metaconsole()) {
- $meta = true;
- }
-
- switch ($status) {
- case 0:
- case 1:
- case 2:
- $sql_post .= ' AND estado = '.$status;
- break;
-
- case 3:
- $sql_post .= ' AND (estado = 0 OR estado = 2)';
- break;
-
- default:
- // Ignore.
- break;
- }
-
- if ($search != '') {
- $sql_post .= " AND (evento LIKE '%".io_safe_input($search)."%' OR id_evento LIKE '%".$search."%')";
- }
-
- if ($event_type != '') {
- // If normal, warning, could be several (going_up_warning, going_down_warning... too complex
- // Shown to user only "warning, critical and normal".
- if ($event_type == 'warning' || $event_type == 'critical' || $event_type == 'normal') {
- $sql_post .= " AND event_type LIKE '%".$event_type."%' ";
- } else if ($event_type == 'not_normal') {
- $sql_post .= " AND (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
- } else if ($event_type != 'all') {
- $sql_post .= " AND event_type = '".$event_type."'";
- }
- }
-
- if ($severity != -1) {
- switch ($severity) {
- case EVENT_CRIT_WARNING_OR_CRITICAL:
- $sql_post .= '
- AND (criticity = '.EVENT_CRIT_WARNING.' OR
- criticity = '.EVENT_CRIT_CRITICAL.')';
- break;
-
- case EVENT_CRIT_OR_NORMAL:
- $sql_post .= '
- AND (criticity = '.EVENT_CRIT_NORMAL.' OR
- criticity = '.EVENT_CRIT_CRITICAL.')';
- break;
-
- case EVENT_CRIT_NOT_NORMAL:
- $sql_post .= ' AND criticity != '.EVENT_CRIT_NORMAL;
- break;
-
- default:
- $sql_post .= ' AND criticity = '.$severity;
- break;
- }
- }
-
- // In metaconsole mode the agent search is performed by name.
- if ($meta) {
- if ($id_agent != __('All')) {
- $sql_post .= " AND agent_name LIKE '%".$id_agent."%'";
- }
- } else {
- switch ($id_agent) {
- case 0:
- // Ignore.
- $__invalid_value = 1;
- break;
-
- case -1:
- // Agent doesnt exist. No results will returned.
- $sql_post .= ' AND 1 = 0';
- break;
-
- default:
- $sql_post .= ' AND id_agente = '.$id_agent;
- break;
- }
- }
-
- // There is another filter for if ($meta).
- if (!$meta) {
- if (!empty($text_module)) {
- $sql_post .= " AND id_agentmodule IN (
- SELECT id_agente_modulo
- FROM tagente_modulo
- WHERE nombre = '".$text_module."'
- )";
- }
- }
-
- if ($id_user_ack != '0') {
- $sql_post .= " AND id_usuario = '".$id_user_ack."'";
- }
-
- if (isset($date_from) === false) {
- $date_from = '';
- }
-
- if (isset($time_from) === false) {
- $time_from = '00:00:00';
- }
-
- if (isset($date_to) === false) {
- $date_to = '';
- }
-
- if (isset($time_to) === false || empty($time_to) === true) {
- $time_to = '23:59:59';
- }
-
- if (($date_from == '') && ($date_to == '')) {
- if ($event_view_hr > 0) {
- $unixtime = (get_system_time() - ($event_view_hr * SECONDS_1HOUR));
- $sql_post .= ' AND (utimestamp > '.$unixtime.')';
- }
- } else {
- if (empty($date_from) === false) {
- $udate_from = strtotime($date_from.' '.$time_from);
- $sql_post .= ' AND (utimestamp >= '.$udate_from.')';
- }
-
- if (empty($date_to) === false) {
- $udate_to = strtotime($date_to.' '.$time_to);
- $sql_post .= ' AND (utimestamp <= '.$udate_to.')';
- }
- }
-
- // Search by tag.
- if (!empty($tag_with) && (io_safe_output($tag_with) != '[]') && (io_safe_output($tag_with) != '["0"]')) {
- $sql_post .= ' AND ( ';
- $first = true;
- foreach ($tag_with as $id_tag) {
- if ($first) {
- $first = false;
- } else {
- $sql_post .= ' OR ';
- }
-
- $sql_post .= "tags = '".tags_get_name($id_tag)."'";
- }
-
- $sql_post .= ' ) ';
- }
-
- if (!empty($tag_without) && (io_safe_output($tag_without) != '[]') && (io_safe_output($tag_with) != '["0"]')) {
- $sql_post .= ' AND ( ';
- $first = true;
- foreach ($tag_without as $id_tag) {
- if ($first) {
- $first = false;
- } else {
- $sql_post .= ' AND ';
- }
-
- $sql_post .= "tags <> '".tags_get_name($id_tag)."'";
- }
-
- $sql_post .= ' ) ';
- }
-
- // Filter/Only alerts.
- if (isset($filter_only_alert)) {
- if ($filter_only_alert == 0) {
- $sql_post .= " AND event_type NOT LIKE '%alert%'";
- } else if ($filter_only_alert == 1) {
- $sql_post .= " AND event_type LIKE '%alert%'";
- }
- }
-
- // Tags ACLS.
- if ($id_group > 0 && in_array($id_group, array_keys($groups))) {
- $group_array = (array) $id_group;
- } else {
- $group_array = array_keys($groups);
- }
-
- $tags_acls_condition = tags_get_acl_tags(
- $id_user,
- $group_array,
- 'ER',
- 'event_condition',
- 'AND',
- '',
- $meta,
- [],
- true
- );
- // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
- if (($tags_acls_condition != ERR_WRONG_PARAMETERS) && ($tags_acls_condition != ERR_ACL) && ($tags_acls_condition != -110000)) {
- $sql_post .= $tags_acls_condition;
- }
-
- // Metaconsole filters.
- if ($meta) {
- if ($server_id_search) {
- $sql_post .= ' AND server_id = '.$server_id_search;
- } else {
- $enabled_nodes = db_get_all_rows_sql(
- '
- SELECT id
- FROM tmetaconsole_setup
- WHERE disabled = 0'
+ if (empty($data_graph_by_user) === false) {
+ $sql = sprintf(
+ 'SELECT fullname, id_user
+ FROM tusuario
+ WHERE id_user IN ("%s")',
+ implode('","', array_keys($data_graph_by_user))
);
- if (empty($enabled_nodes)) {
- $sql_post .= ' AND 1 = 0';
- } else {
- if ($strict_user == 1) {
- $enabled_nodes_id = [];
- } else {
- $enabled_nodes_id = [0];
- }
-
- foreach ($enabled_nodes as $en) {
- $enabled_nodes_id[] = $en['id'];
- }
-
- $sql_post .= ' AND server_id IN ('.implode(',', $enabled_nodes_id).')';
- }
- }
- }
-
- return $sql_post;
-}
-
-
-/**
- * Retrieve list of events grouped by agents.
- *
- * @param string $sql SQL.
- *
- * @return string HTML.
- */
-function events_list_events_grouped_agents($sql)
-{
- global $config;
-
- $table = 'tevento';
-
- $sql = sprintf(
- 'SELECT * FROM %s
- LEFT JOIN tagent_secondary_group
- ON tagent_secondary_group.id_agent = id_agente
- WHERE %s',
- $table,
- $sql
- );
-
- $result = db_get_all_rows_sql($sql);
- $group_rep = 0;
- $meta = is_metaconsole();
-
- // Fields that the user has selected to show.
- if ($meta) {
- $show_fields = events_meta_get_custom_fields_user();
- } else {
- $show_fields = explode(',', $config['event_fields']);
- }
-
- // Headers.
- $i = 0;
- $table = new stdClass();
- if (!isset($table->width)) {
- $table->width = '100%';
- }
-
- $table->id = 'eventtable';
- $table->cellpadding = 4;
- $table->cellspacing = 4;
- if (!isset($table->class)) {
- $table->class = 'databox data';
- }
-
- $table->head = [];
- $table->data = [];
-
- $table->head[$i] = __('ID');
- $table->align[$i] = 'left';
- $i++;
- if (in_array('server_name', $show_fields)) {
- $table->head[$i] = __('Server');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('estado', $show_fields)) {
- $table->head[$i] = __('Status');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('id_evento', $show_fields)) {
- $table->head[$i] = __('Event ID');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('evento', $show_fields)) {
- $table->head[$i] = __('Event Name');
- $table->align[$i] = 'left';
- $table->style[$i] = 'min-width: 200px; max-width: 350px; word-break: break-all;';
- $i++;
- }
-
- if (in_array('id_agente', $show_fields)) {
- $table->head[$i] = __('Agent name');
- $table->align[$i] = 'left';
- $table->style[$i] = 'max-width: 350px; word-break: break-all;';
- $i++;
- }
-
- if (in_array('timestamp', $show_fields)) {
- $table->head[$i] = __('Timestamp');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('id_usuario', $show_fields)) {
- $table->head[$i] = __('User');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('owner_user', $show_fields)) {
- $table->head[$i] = __('Owner');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('id_grupo', $show_fields)) {
- $table->head[$i] = __('Group');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('event_type', $show_fields)) {
- $table->head[$i] = __('Event type');
- $table->align[$i] = 'left';
- $table->style[$i] = 'min-width: 85px;';
- $i++;
- }
-
- if (in_array('id_agentmodule', $show_fields)) {
- $table->head[$i] = __('Agent Module');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('id_alert_am', $show_fields)) {
- $table->head[$i] = __('Alert');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('criticity', $show_fields)) {
- $table->head[$i] = __('Severity');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('user_comment', $show_fields)) {
- $table->head[$i] = __('Comment');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('tags', $show_fields)) {
- $table->head[$i] = __('Tags');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('source', $show_fields)) {
- $table->head[$i] = __('Source');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('id_extra', $show_fields)) {
- $table->head[$i] = __('Extra ID');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('ack_utimestamp', $show_fields)) {
- $table->head[$i] = __('ACK Timestamp');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('instructions', $show_fields)) {
- $table->head[$i] = __('Instructions');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('data', $show_fields)) {
- $table->head[$i] = __('Data');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if (in_array('module_status', $show_fields)) {
- $table->head[$i] = __('Module status');
- $table->align[$i] = 'left';
- $i++;
- }
-
- if ($i != 0 && $allow_action) {
- $table->head[$i] = __('Action');
- $table->align[$i] = 'left';
- $table->size[$i] = '90px';
- $i++;
- if (check_acl($config['id_user'], 0, 'EW') == 1 && !$readonly) {
- $table->head[$i] = html_print_checkbox('all_validate_box', '1', false, true);
- $table->align[$i] = 'left';
- }
- }
-
- if ($meta) {
- // Get info of the all servers to use it on hash auth.
- $servers_url_hash = metaconsole_get_servers_url_hash();
- $servers = metaconsole_get_servers();
- }
-
- $show_delete_button = false;
- $show_validate_button = false;
-
- $idx = 0;
- // Arrange data. We already did ACL's in the query.
- foreach ($result as $event) {
- $data = [];
-
- if ($meta) {
- $event['server_url_hash'] = $servers_url_hash[$event['server_id']];
- $event['server_url'] = $servers[$event['server_id']]['server_url'];
- $event['server_name'] = $servers[$event['server_id']]['server_name'];
- }
-
- // Clean url from events and store in array.
- $event['clean_tags'] = events_clean_tags($event['tags']);
-
- // First pass along the class of this row.
- $myclass = get_priority_class($event['criticity']);
-
- // Print status.
- $estado = $event['estado'];
-
- // Colored box.
- switch ($estado) {
- case EVENT_NEW:
- $img_st = 'images/star.png';
- $title_st = __('New event');
- break;
-
- case EVENT_VALIDATE:
- $img_st = 'images/tick.png';
- $title_st = __('Event validated');
- break;
-
- case EVENT_PROCESS:
- $img_st = 'images/hourglass.png';
- $title_st = __('Event in process');
- break;
-
- default:
- // Ignore.
- break;
- }
-
- $i = 0;
-
- $data[$i] = '#'.$event['id_evento'];
- $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3; color: #111 !important;';
-
- // Pass grouped values in hidden fields to use it from modal window.
- if ($group_rep) {
- $similar_ids = $event['similar_ids'];
- $timestamp_first = $event['timestamp_rep_min'];
- $timestamp_last = $event['timestamp_rep'];
- } else {
- $similar_ids = $event['id_evento'];
- $timestamp_first = $event['utimestamp'];
- $timestamp_last = $event['utimestamp'];
- }
-
- // Store group data to show in extended view.
- $data[$i] .= html_print_input_hidden('similar_ids_'.$event['id_evento'], $similar_ids, true);
- $data[$i] .= html_print_input_hidden('timestamp_first_'.$event['id_evento'], $timestamp_first, true);
- $data[$i] .= html_print_input_hidden('timestamp_last_'.$event['id_evento'], $timestamp_last, true);
- $data[$i] .= html_print_input_hidden('childrens_ids', json_encode($childrens_ids), true);
-
- // Store server id if is metaconsole. 0 otherwise.
- if ($meta) {
- $server_id = $event['server_id'];
-
- // If meta activated, propagate the id of the event on node (source id).
- $data[$i] .= html_print_input_hidden('source_id_'.$event['id_evento'], $event['id_source_event'], true);
- $table->cellclass[count($table->data)][$i] = $myclass;
- } else {
- $server_id = 0;
- }
-
- $data[$i] .= html_print_input_hidden('server_id_'.$event['id_evento'], $server_id, true);
-
- if (empty($event['event_rep'])) {
- $event['event_rep'] = 0;
- }
-
- $data[$i] .= html_print_input_hidden('event_rep_'.$event['id_evento'], $event['event_rep'], true);
- // Store concat comments to show in extended view.
- $data[$i] .= html_print_input_hidden('user_comment_'.$event['id_evento'], base64_encode($event['user_comment']), true);
-
- $i++;
-
- if (in_array('server_name', $show_fields)) {
- if ($meta) {
- if (can_user_access_node()) {
- $data[$i] = "".$event['server_name'].'';
- } else {
- $data[$i] = $event['server_name'];
- }
- } else {
- $data[$i] = db_get_value('name', 'tserver');
- }
-
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('estado', $show_fields)) {
- $data[$i] = html_print_image(
- $img_st,
- true,
- [
- 'class' => 'image_status',
- 'title' => $title_st,
- 'id' => 'status_img_'.$event['id_evento'],
- ]
- );
- $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;';
- $i++;
- }
-
- if (in_array('id_evento', $show_fields)) {
- $data[$i] = $event['id_evento'];
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- switch ($event['criticity']) {
- default:
- case 0:
- $img_sev = 'images/status_sets/default/severity_maintenance.png';
- break;
- case 1:
- $img_sev = 'images/status_sets/default/severity_informational.png';
- break;
-
- case 2:
- $img_sev = 'images/status_sets/default/severity_normal.png';
- break;
-
- case 3:
- $img_sev = 'images/status_sets/default/severity_warning.png';
- break;
-
- case 4:
- $img_sev = 'images/status_sets/default/severity_critical.png';
- break;
-
- case 5:
- $img_sev = 'images/status_sets/default/severity_minor.png';
- break;
-
- case 6:
- $img_sev = 'images/status_sets/default/severity_major.png';
- break;
- }
-
- if (in_array('evento', $show_fields)) {
- // Event description.
- $data[$i] = '';
- if ($allow_action) {
- $data[$i] .= '';
- }
-
- $data[$i] .= ''.ui_print_truncate_text(io_safe_output($event['evento']), 160).'';
- if ($allow_action) {
- $data[$i] .= '';
- }
-
- $data[$i] .= '';
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('id_agente', $show_fields)) {
- $data[$i] = '';
-
- if ($event['id_agente'] > 0) {
- // Agent name.
- if ($meta) {
- $agent_link = '';
- if (can_user_access_node()) {
- $data[$i] = ''.$agent_link.$event['agent_name'].'';
- } else {
- $data[$i] = $event['agent_name'];
- }
- } else {
- $data[$i] .= ui_print_agent_name($event['id_agente'], true);
- }
- } else {
- $data[$i] .= '';
- }
-
- $data[$i] .= '';
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('timestamp', $show_fields)) {
- // Time.
- $data[$i] = '';
- if ($group_rep == 1) {
- $data[$i] .= ui_print_timestamp($event['timestamp_rep'], true);
- } else {
- $data[$i] .= ui_print_timestamp($event['timestamp'], true);
- }
-
- $data[$i] .= '';
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('id_usuario', $show_fields)) {
- $user_name = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']);
- if (empty($user_name)) {
- $user_name = $event['id_usuario'];
- }
-
- $data[$i] = $user_name;
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('owner_user', $show_fields)) {
- $owner_name = db_get_value('fullname', 'tusuario', 'id_user', $event['owner_user']);
- if (empty($owner_name)) {
- $owner_name = $event['owner_user'];
- }
-
- $data[$i] = $owner_name;
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('id_grupo', $show_fields)) {
- if ($meta) {
- $data[$i] = $event['group_name'];
- } else {
- $id_group = $event['id_grupo'];
- $group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group);
- if ($id_group == 0) {
- $group_name = __('All');
- }
-
- $data[$i] = $group_name;
- }
-
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('event_type', $show_fields)) {
- $data[$i] = events_print_type_description($event['event_type'], true);
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('id_agentmodule', $show_fields)) {
- if ($meta) {
- $module_link = '';
- if (can_user_access_node()) {
- $data[$i] = ''.$module_link.$event['module_name'].'';
- } else {
- $data[$i] = $event['module_name'];
- }
- } else {
- $module_name = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $event['id_agentmodule']);
- $data[$i] = ''.$module_name.'';
- }
-
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('id_alert_am', $show_fields)) {
- if ($meta) {
- $data[$i] = $event['alert_template_name'];
- } else {
- if ($event['id_alert_am'] != 0) {
- $sql = 'SELECT name
- FROM talert_templates
- WHERE id IN (SELECT id_alert_template
- FROM talert_template_modules
- WHERE id = '.$event['id_alert_am'].');';
-
- $templateName = db_get_sql($sql);
- $data[$i] = ''.$templateName.'';
- } else {
- $data[$i] = '';
- }
- }
-
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('criticity', $show_fields)) {
- $data[$i] = get_priority_name($event['criticity']);
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('user_comment', $show_fields)) {
- $safe_event_user_comment = strip_tags(io_safe_output($event['user_comment']));
- $line_breaks = [
- "\r\n",
- "\n",
- "\r",
- ];
- $safe_event_user_comment = str_replace($line_breaks, '
', $safe_event_user_comment);
- $event_user_comments = json_decode($safe_event_user_comment, true);
- $event_user_comment_str = '';
-
- if (!empty($event_user_comments)) {
- $last_key = key(array_slice($event_user_comments, -1, 1, true));
- $date_format = $config['date_format'];
-
- foreach ($event_user_comments as $key => $event_user_comment) {
- $event_user_comment_str .= sprintf(
- '%s: %s
%s: %s
%s: %s
',
- __('Date'),
- date($date_format, $event_user_comment['utimestamp']),
- __('User'),
- $event_user_comment['id_user'],
- __('Comment'),
- $event_user_comment['comment']
- );
- if ($key != $last_key) {
- $event_user_comment_str .= '
';
+ $fullnames = db_get_all_rows_sql($sql);
+
+ if ($fullnames !== false
+ && empty($fullnames) === false
+ ) {
+ foreach ($fullnames as $value) {
+ if (isset($data_graph_by_user[$value['id_user']]) === true) {
+ $data_graph_by_user[$value['fullname']] = $data_graph_by_user[$value['id_user']];
+ unset($data_graph_by_user[$value['id_user']]);
}
}
}
-
- $comments_help_tip = '';
- if (!empty($event_user_comment_str)) {
- $comments_help_tip = ui_print_help_tip($event_user_comment_str, true);
- }
-
- $data[$i] = ''.$comments_help_tip.'';
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
}
-
- if (in_array('tags', $show_fields)) {
- $data[$i] = tags_get_tags_formatted($event['tags']);
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('source', $show_fields)) {
- $data[$i] = $event['source'];
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('id_extra', $show_fields)) {
- $data[$i] = $event['id_extra'];
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('ack_utimestamp', $show_fields)) {
- if ($event['ack_utimestamp'] == 0) {
- $data[$i] = '';
- } else {
- $data[$i] = date($config['date_format'], $event['ack_utimestamp']);
- }
-
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('instructions', $show_fields)) {
- switch ($event['event_type']) {
- case 'going_unknown':
- if (!empty($event['unknown_instructions'])) {
- $data[$i] = html_print_image('images/page_white_text.png', true, ['title' => str_replace("\n", '
', io_safe_output($event['unknown_instructions']))]);
- }
- break;
-
- case 'going_up_critical':
- case 'going_down_critical':
- if (!empty($event['critical_instructions'])) {
- $data[$i] = html_print_image('images/page_white_text.png', true, ['title' => str_replace("\n", '
', io_safe_output($event['critical_instructions']))]);
- }
- break;
-
- case 'going_down_warning':
- if (!empty($event['warning_instructions'])) {
- $data[$i] = html_print_image('images/page_white_text.png', true, ['title' => str_replace("\n", '
', io_safe_output($event['warning_instructions']))]);
- }
- break;
-
- case 'system':
- if (!empty($event['critical_instructions'])) {
- $data[$i] = html_print_image('images/page_white_text.png', true, ['title' => str_replace("\n", '
', io_safe_output($event['critical_instructions']))]);
- } else if (!empty($event['warning_instructions'])) {
- $data[$i] = html_print_image('images/page_white_text.png', true, ['title' => str_replace("\n", '
', io_safe_output($event['warning_instructions']))]);
- } else if (!empty($event['unknown_instructions'])) {
- $data[$i] = html_print_image('images/page_white_text.png', true, ['title' => str_replace("\n", '
', io_safe_output($event['unknown_instructions']))]);
- }
- break;
-
- default:
- // Ignore.
- break;
- }
-
- if (!isset($data[$i])) {
- $data[$i] = '';
- }
-
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('data', $show_fields)) {
- $data[$i] = $event['data'];
- if (($data[$i] % 1) == 0) {
- $data[$i] = number_format($data[$i], 0);
- } else {
- $data[$i] = number_format($data[$i], 2);
- }
-
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if (in_array('module_status', $show_fields)) {
- $data[$i] = modules_get_modules_status($event['module_status']);
- $table->cellclass[count($table->data)][$i] = $myclass;
- $i++;
- }
-
- if ($i != 0 && $allow_action) {
- // Actions.
- $data[$i] = '';
-
- if (!$readonly) {
- // Validate event.
- if (($event['estado'] != 1) && (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EW', $event['clean_tags'], $childrens_ids))) {
- $show_validate_button = true;
- $data[$i] .= '';
- $data[$i] .= html_print_image(
- 'images/ok.png',
- true,
- ['title' => __('Validate event')]
- );
- $data[$i] .= '';
- }
-
- // Delete event.
- if ((tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids) == 1)) {
- if ($event['estado'] != 2) {
- $show_delete_button = true;
- $data[$i] .= '';
- $data[$i] .= html_print_image(
- 'images/cross.png',
- true,
- [
- 'title' => __('Delete event'),
- 'id' => 'delete_cross_'.$event['id_evento'],
- ]
- );
- $data[$i] .= '';
- } else {
- $data[$i] .= html_print_image(
- 'images/cross.disabled.png',
- true,
- ['title' => __('Is not allowed delete events in process')]
- ).' ';
- }
- }
- }
-
- $data[$i] .= '';
- $data[$i] .= html_print_input_hidden('event_title_'.$event['id_evento'], '#'.$event['id_evento'].' - '.$event['evento'], true);
- $data[$i] .= html_print_image(
- 'images/eye.png',
- true,
- ['title' => __('Show more')]
- );
- $data[$i] .= '';
-
- $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;';
-
- $i++;
-
- if (!$readonly) {
- if (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids) == 1) {
- // Checkbox.
- // Class 'candeleted' must be the fist class to be parsed from javascript. Dont change.
- $data[$i] = html_print_checkbox_extended('validate_ids[]', $event['id_evento'], false, false, false, 'class="candeleted chk_val"', true);
- } else if (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EW', $event['clean_tags'], $childrens_ids) == 1) {
- // Checkbox.
- $data[$i] = html_print_checkbox_extended('validate_ids[]', $event['id_evento'], false, false, false, 'class="chk_val"', true);
- } else if (isset($table->header[$i]) || true) {
- $data[$i] = '';
- }
- }
-
- $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;';
- }
-
- array_push($table->data, $data);
-
- $idx++;
}
- return html_print_table($table, true);
+ return $data_graph_by_user;
}
diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php
index d9493a99b2..99dd0cad88 100644
--- a/pandora_console/include/functions_graph.php
+++ b/pandora_console/include/functions_graph.php
@@ -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 = [
diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php
index edc47dc02b..157cbf7b7b 100755
--- a/pandora_console/include/functions_reporting.php
+++ b/pandora_console/include/functions_reporting.php
@@ -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'] : '',
];
}
diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php
index e8502376c1..6f3fe071a7 100644
--- a/pandora_console/include/functions_reporting_html.php
+++ b/pandora_console/include/functions_reporting_html.php
@@ -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[] = ''.__('System').'';
} 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.'
';
+ 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.'
';
+ }
+ }
}
$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[] = ''.date($config['date_format'], $event['timestamp']).'';
+ $data[] = ''.date($config['date_format'], strtotime($event['timestamp'])).'';
} else {
$data[] = ''.date($config['date_format'], strtotime($event['timestamp'])).'';
}
diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js
index eda55136f5..d005316cca 100644
--- a/pandora_console/include/javascript/pandora_events.js
+++ b/pandora_console/include/javascript/pandora_events.js
@@ -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");
diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php
index 42cd059dc5..9329fb749a 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php
@@ -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 .= '