Add history search of events in reports, only when history event db is active. Ticket: #85

(cherry picked from commit 935b426a83)
This commit is contained in:
m-lopez-f 2016-11-24 15:28:21 +01:00
parent a4ebffaa6b
commit 556008f37c
2 changed files with 34 additions and 15 deletions

View File

@ -111,7 +111,8 @@ function events_get_event ($id, $fields = false) {
}
function events_get_events_grouped($sql_post, $offset = 0,
$pagination = 1, $meta = false, $history = false, $total = false) {
$pagination = 1, $meta = false, $history = false, $total = false,
$history_db = false) {
global $config;
@ -211,7 +212,7 @@ function events_get_events_grouped($sql_post, $offset = 0,
}
//Extract the events by filter (or not) from db
$events = db_get_all_rows_sql ($sql);
$events = db_get_all_rows_sql ($sql, $history_db);
if ($total) {
return reset($events[0]);
@ -1186,7 +1187,7 @@ function events_print_type_description ($type, $return = false) {
function events_get_group_events ($id_group, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_search = false, $meta = false) {
$filter_event_search = false, $meta = false, $history = false) {
global $config;
@ -1228,7 +1229,8 @@ function events_get_group_events ($id_group, $period, $date,
AND utimestamp <= %d ',
implode (",", $id_group), $datelimit, $date);
return events_get_events_grouped($sql_where, 0, 1000, $meta);
return events_get_events_grouped(($sql_where, 0, 1000, $meta,
false, false, $history);
}
/**
@ -1305,7 +1307,8 @@ function events_get_group_events_steps ($begin, &$result, $id_group, $period, $d
*/
function events_get_agent ($id_agent, $period, $date = 0,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
$filter_event_warning = false, $filter_event_no_validated = false,
$history = false) {
if (!is_numeric ($date)) {
$date = strtotime ($date);
@ -1345,7 +1348,8 @@ function events_get_agent ($id_agent, $period, $date = 0,
$sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d
AND utimestamp <= %d ', $id_agent, $datelimit, $date);
return events_get_events_grouped($sql_where, 0, 1000, is_metaconsole());
return events_get_events_grouped($sql_where, 0, 1000,
is_metaconsole(), false, false, $history);
}
/**
@ -1359,7 +1363,9 @@ function events_get_agent ($id_agent, $period, $date = 0,
*
* @return array An array with all the events happened.
*/
function events_get_module ($id_agent_module, $period, $date = 0) {
function events_get_module ($id_agent_module, $period, $date = 0, $history = false) {
global $config;
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
@ -1372,7 +1378,8 @@ function events_get_module ($id_agent_module, $period, $date = 0) {
$sql_where = sprintf(' AND id_agentmodule = %d AND utimestamp > %d
AND utimestamp <= %d ', $id_agent_module, $datelimit, $date);
return events_get_events_grouped($sql_where, 0, 1000);
return events_get_events_grouped($sql_where, 0, 1000, false,
false, false, $history);
$sql = sprintf ('SELECT evento, event_type, criticity, count(*) as count_rep, max(timestamp) AS time2
FROM tevento

View File

@ -1169,6 +1169,10 @@ function reporting_event_report_group($report, $content,
metaconsole_connect($server);
}
$history = false;
if ($config['history_event_enabled'])
$history = true;
$return['title'] = $content['name'];
$return['subtitle'] = groups_get_name($content['id_group'], true);
if (!empty($content['style']['event_filter_search'])) {
@ -1194,7 +1198,7 @@ function reporting_event_report_group($report, $content,
$content['id_group'], $content['period'], $report["datetime"],
true, true, $filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search, 'hash');
$filter_event_filter_search, 'hash', $history);
if (empty($data)) {
$return['failed'] = __('No events');
@ -2084,6 +2088,9 @@ function reporting_event_report_agent($report, $content,
$content['name'] = __('Event Report Agent');
}
$history = false;
if ($config['history_event_enabled'])
$history = true;
$return['title'] = $content['name'];
$return['subtitle'] = agents_get_name($content['id_agent']);
@ -2111,7 +2118,8 @@ function reporting_event_report_agent($report, $content,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated,
true);
true,
$history);
@ -4759,7 +4767,7 @@ function reporting_get_group_detailed_event ($id_group, $period = 0,
$date = 0, $return = false, $html = true,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null, $return_type = false) {
$filter_event_filter_search = null, $return_type = false, $history = false) {
global $config;
@ -4791,7 +4799,7 @@ function reporting_get_group_detailed_event ($id_group, $period = 0,
$events = events_get_group_events($id_group, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search);
$filter_event_filter_search, false, $history);
if ($return_type === 'hash') {
return $events;
@ -4897,11 +4905,14 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
$date = get_system_time ();
}
$history = false;
if ($config['history_event_enabled'])
$history = true;
$events = array ();
foreach ($id_modules as $id_module) {
$event = events_get_module ($id_module, (int) $period, (int) $date);
$event = events_get_module ($id_module, (int) $period, (int) $date, $history);
if (!empty ($event)) {
array_push ($events, $event);
}
@ -4984,7 +4995,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
function reporting_get_agents_detailed_event ($id_agents, $period = 0,
$date = 0, $return = false, $filter_event_validated = false,
$filter_event_critical = false, $filter_event_warning = false,
$filter_event_no_validated = false, $only_data = false) {
$filter_event_no_validated = false, $only_data = false, $history = false) {
global $config;
@ -5010,7 +5021,8 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0,
(int)$period,
(int)$date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated);
$filter_event_warning, $filter_event_no_validated,
$history);
if (empty($event)) {
$event = array();