Add history search of events in reports, only when history event db is active. Ticket: #85
This commit is contained in:
parent
70f609b204
commit
935b426a83
pandora_console/include
|
@ -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]);
|
||||
|
@ -633,7 +634,7 @@ function events_comment ($id_event, $comment = '', $action = 'Added comment', $m
|
|||
case 'oracle':
|
||||
$sql_validation = "UPDATE $event_table
|
||||
SET user_comment='" . $comment . "' || user_comment)
|
||||
WHERE id_evento in (" . implode(',', $id_event) . ")";
|
||||
WHERE id_evento in (" . implode(',', $id_event) . ")";
|
||||
|
||||
$ret = db_process_sql($sql_validation);
|
||||
break;
|
||||
|
@ -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
|
||||
|
|
|
@ -1177,6 +1177,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'])) {
|
||||
|
@ -1202,7 +1206,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');
|
||||
|
@ -2065,6 +2069,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']);
|
||||
|
@ -2092,7 +2099,8 @@ function reporting_event_report_agent($report, $content,
|
|||
$filter_event_critical,
|
||||
$filter_event_warning,
|
||||
$filter_event_no_validated,
|
||||
true);
|
||||
true,
|
||||
$history);
|
||||
|
||||
|
||||
|
||||
|
@ -5456,7 +5464,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;
|
||||
|
||||
|
@ -5488,7 +5496,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;
|
||||
|
@ -5594,11 +5602,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);
|
||||
}
|
||||
|
@ -5681,7 +5692,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;
|
||||
|
||||
|
@ -5707,7 +5718,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();
|
||||
|
@ -6205,7 +6217,7 @@ You can of course remove the warnings, that's why we include the source and do n
|
|||
$table_al->rowclass[] = '';
|
||||
$table_al->data[] = $tdata;
|
||||
|
||||
if (!defined('METACONSOLE')) {
|
||||
if (!is_metaconsole()) {
|
||||
$output = '<fieldset class="databox tactical_set">
|
||||
<legend>' .
|
||||
__('Defined and fired alerts') .
|
||||
|
|
Loading…
Reference in New Issue