mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Merge branch 'ent-7972-funcionalidad-historico-de-alertas-lanzadas' into 'develop'
Ent 7972 funcionalidad historico de alertas lanzadas See merge request artica/pandorafms!4465
This commit is contained in:
commit
704403fd52
@ -1378,7 +1378,7 @@ if ($get_extended_event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tabs.
|
// Tabs.
|
||||||
$tabs = "<ul class=''>";
|
$tabs = "<ul class='event_detail_tab_menu'>";
|
||||||
$tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image(
|
$tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image(
|
||||||
'images/lightning_go.png',
|
'images/lightning_go.png',
|
||||||
true,
|
true,
|
||||||
@ -1436,7 +1436,7 @@ if ($get_extended_event) {
|
|||||||
).'<span>'.__('Responses').'</span></a></li>';
|
).'<span>'.__('Responses').'</span></a></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event['custom_data'] != '') {
|
if (empty($event['custom_data']) === false) {
|
||||||
$tabs .= "<li><a href='#extended_event_custom_data_page' id='link_custom_data'>".html_print_image(
|
$tabs .= "<li><a href='#extended_event_custom_data_page' id='link_custom_data'>".html_print_image(
|
||||||
'images/custom_field_col.png',
|
'images/custom_field_col.png',
|
||||||
true,
|
true,
|
||||||
|
@ -4662,6 +4662,8 @@ function events_page_custom_data($event)
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$table = new stdClass();
|
||||||
|
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->data = [];
|
$table->data = [];
|
||||||
$table->head = [];
|
$table->head = [];
|
||||||
@ -4669,14 +4671,31 @@ function events_page_custom_data($event)
|
|||||||
|
|
||||||
$json_custom_data = base64_decode($event['custom_data']);
|
$json_custom_data = base64_decode($event['custom_data']);
|
||||||
$custom_data = json_decode($json_custom_data);
|
$custom_data = json_decode($json_custom_data);
|
||||||
|
|
||||||
if ($custom_data === null) {
|
if ($custom_data === null) {
|
||||||
return '<div id="extended_event_custom_data_page" class="extended_event_pages">'.__('Invalid custom data: %s', $json_custom_data).'</div>';
|
// Try again because is possible that info not come coded.
|
||||||
|
$custom_data = json_decode(io_safe_output($event['custom_data']));
|
||||||
|
|
||||||
|
if ($custom_data === null) {
|
||||||
|
return '<div id="extended_event_custom_data_page" class="extended_event_pages">'.__('Invalid custom data: %s', $json_custom_data).'</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($custom_data as $field => $value) {
|
foreach ($custom_data as $field => $value) {
|
||||||
$table->data[$i][0] = io_safe_output($field);
|
$table->data[$i][0] = ucfirst(io_safe_output($field));
|
||||||
$table->data[$i][1] = io_safe_output($value);
|
|
||||||
|
if (is_array($value) === true) {
|
||||||
|
$table->data[$i][1] = '<ul>';
|
||||||
|
foreach ($value as $individualValue) {
|
||||||
|
$table->data[$i][1] .= sprintf('<li>%s</li>', $individualValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
$table->data[$i][1] .= '</ul>';
|
||||||
|
} else {
|
||||||
|
$table->data[$i][1] = io_safe_output($value);
|
||||||
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ function show_event_dialog(event, dialog_page, result) {
|
|||||||
resizable: true,
|
resizable: true,
|
||||||
draggable: true,
|
draggable: true,
|
||||||
modal: true,
|
modal: true,
|
||||||
minWidth: 710,
|
minWidth: 875,
|
||||||
minHeight: 600,
|
minHeight: 600,
|
||||||
close: function() {
|
close: function() {
|
||||||
$("#refrcounter").countdown("resume");
|
$("#refrcounter").countdown("resume");
|
||||||
|
@ -311,3 +311,7 @@ div.multi-response-buttons {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.event_detail_tab_menu li {
|
||||||
|
max-width: 160px;
|
||||||
|
}
|
||||||
|
@ -840,7 +840,7 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
|
|||||||
if ($alert_mode == RECOVERED_ALERT) {
|
if ($alert_mode == RECOVERED_ALERT) {
|
||||||
# Avoid the use of alias bigger than 30 characters.
|
# Avoid the use of alias bigger than 30 characters.
|
||||||
@actions = get_db_rows ($dbh,
|
@actions = get_db_rows ($dbh,
|
||||||
'SELECT taa.*, tac.*, tatma.id AS id_alert_templ_module_actions,
|
'SELECT taa.name as action_name, taa.*, tac.*, tatma.id AS id_alert_templ_module_actions,
|
||||||
tatma.id_alert_template_module, tatma.id_alert_action, tatma.fires_min,
|
tatma.id_alert_template_module, tatma.id_alert_action, tatma.fires_min,
|
||||||
tatma.fires_max, tatma.module_action_threshold, tatma.last_execution
|
tatma.fires_max, tatma.module_action_threshold, tatma.last_execution
|
||||||
FROM talert_template_module_actions tatma, talert_actions taa, talert_commands tac
|
FROM talert_template_module_actions tatma, talert_actions taa, talert_commands tac
|
||||||
@ -854,7 +854,7 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
|
|||||||
# Avoid the use of alias bigger than 30 characters.
|
# Avoid the use of alias bigger than 30 characters.
|
||||||
if ($forced_alert){
|
if ($forced_alert){
|
||||||
@actions = get_db_rows ($dbh,
|
@actions = get_db_rows ($dbh,
|
||||||
'SELECT taa.*, tac.*, tatma.id AS id_alert_templ_module_actions,
|
'SELECT taa.name as action_name, taa.*, tac.*, tatma.id AS id_alert_templ_module_actions,
|
||||||
tatma.id_alert_template_module, tatma.id_alert_action, tatma.fires_min,
|
tatma.id_alert_template_module, tatma.id_alert_action, tatma.fires_min,
|
||||||
tatma.fires_max, tatma.module_action_threshold, tatma.last_execution
|
tatma.fires_max, tatma.module_action_threshold, tatma.last_execution
|
||||||
FROM talert_template_module_actions tatma, talert_actions taa, talert_commands tac
|
FROM talert_template_module_actions tatma, talert_actions taa, talert_commands tac
|
||||||
@ -865,7 +865,7 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
@actions = get_db_rows ($dbh,
|
@actions = get_db_rows ($dbh,
|
||||||
'SELECT taa.*, tac.*, tatma.id AS id_alert_templ_module_actions,
|
'SELECT taa.name as action_name, taa.*, tac.*, tatma.id AS id_alert_templ_module_actions,
|
||||||
tatma.id_alert_template_module, tatma.id_alert_action, tatma.fires_min,
|
tatma.id_alert_template_module, tatma.id_alert_action, tatma.fires_min,
|
||||||
tatma.fires_max, tatma.module_action_threshold, tatma.last_execution
|
tatma.fires_max, tatma.module_action_threshold, tatma.last_execution
|
||||||
FROM talert_template_module_actions tatma, talert_actions taa, talert_commands tac
|
FROM talert_template_module_actions tatma, talert_actions taa, talert_commands tac
|
||||||
@ -881,7 +881,7 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
|
|||||||
|
|
||||||
# Get default action
|
# Get default action
|
||||||
if ($#actions < 0) {
|
if ($#actions < 0) {
|
||||||
@actions = get_db_rows ($dbh, 'SELECT * FROM talert_actions, talert_commands
|
@actions = get_db_rows ($dbh, 'SELECT talert_actions.name as action_name, * FROM talert_actions, talert_commands
|
||||||
WHERE talert_actions.id = ?
|
WHERE talert_actions.id = ?
|
||||||
AND talert_actions.id_alert_command = talert_commands.id',
|
AND talert_actions.id_alert_command = talert_commands.id',
|
||||||
$alert->{'id_alert_action'});
|
$alert->{'id_alert_action'});
|
||||||
@ -890,7 +890,7 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
|
|||||||
# Event alert
|
# Event alert
|
||||||
else {
|
else {
|
||||||
if ($alert_mode == RECOVERED_ALERT) {
|
if ($alert_mode == RECOVERED_ALERT) {
|
||||||
@actions = get_db_rows ($dbh, 'SELECT * FROM tevent_alert_action, talert_actions, talert_commands
|
@actions = get_db_rows ($dbh, 'SELECT talert_actions.name as action_name, * FROM tevent_alert_action, talert_actions, talert_commands
|
||||||
WHERE tevent_alert_action.id_alert_action = talert_actions.id
|
WHERE tevent_alert_action.id_alert_action = talert_actions.id
|
||||||
AND talert_actions.id_alert_command = talert_commands.id
|
AND talert_actions.id_alert_command = talert_commands.id
|
||||||
AND tevent_alert_action.id_event_alert = ?
|
AND tevent_alert_action.id_event_alert = ?
|
||||||
@ -898,7 +898,7 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
|
|||||||
OR ? >= fires_min)',
|
OR ? >= fires_min)',
|
||||||
$alert->{'id'}, $alert->{'times_fired'});
|
$alert->{'id'}, $alert->{'times_fired'});
|
||||||
} else {
|
} else {
|
||||||
@actions = get_db_rows ($dbh, 'SELECT * FROM tevent_alert_action, talert_actions, talert_commands
|
@actions = get_db_rows ($dbh, 'SELECT talert_actions.name as action_name, * FROM tevent_alert_action, talert_actions, talert_commands
|
||||||
WHERE tevent_alert_action.id_alert_action = talert_actions.id
|
WHERE tevent_alert_action.id_alert_action = talert_actions.id
|
||||||
AND talert_actions.id_alert_command = talert_commands.id
|
AND talert_actions.id_alert_command = talert_commands.id
|
||||||
AND tevent_alert_action.id_event_alert = ?
|
AND tevent_alert_action.id_event_alert = ?
|
||||||
@ -910,7 +910,7 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
|
|||||||
|
|
||||||
# Get default action
|
# Get default action
|
||||||
if ($#actions < 0) {
|
if ($#actions < 0) {
|
||||||
@actions = get_db_rows ($dbh, 'SELECT * FROM talert_actions, talert_commands
|
@actions = get_db_rows ($dbh, 'SELECT talert_actions.name as action_name, * FROM talert_actions, talert_commands
|
||||||
WHERE talert_actions.id = ?
|
WHERE talert_actions.id = ?
|
||||||
AND talert_actions.id_alert_command = talert_commands.id',
|
AND talert_actions.id_alert_command = talert_commands.id',
|
||||||
$alert->{'id_alert_action'});
|
$alert->{'id_alert_action'});
|
||||||
@ -927,6 +927,13 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Additional execution information for the console.
|
||||||
|
my $custom_data = {
|
||||||
|
'actions' => [],
|
||||||
|
'forced' => $forced_alert ? 1 : 0,
|
||||||
|
'recovered' => $alert_mode == RECOVERED_ALERT ? 1 : 0
|
||||||
|
};
|
||||||
|
|
||||||
# Critical_instructions, warning_instructions, unknown_instructions
|
# Critical_instructions, warning_instructions, unknown_instructions
|
||||||
my $critical_instructions = get_db_value ($dbh, 'SELECT critical_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
|
my $critical_instructions = get_db_value ($dbh, 'SELECT critical_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
|
||||||
my $warning_instructions = get_db_value ($dbh, 'SELECT warning_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
|
my $warning_instructions = get_db_value ($dbh, 'SELECT warning_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
|
||||||
@ -953,6 +960,7 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pandora_execute_action ($pa_config, $data, $agent, $alert, $alert_mode, $action, $module, $dbh, $timestamp, $extra_macros);
|
pandora_execute_action ($pa_config, $data, $agent, $alert, $alert_mode, $action, $module, $dbh, $timestamp, $extra_macros);
|
||||||
|
push(@{$custom_data->{'actions'}}, safe_output($action->{'action_name'}));
|
||||||
} else {
|
} else {
|
||||||
if (defined ($module)) {
|
if (defined ($module)) {
|
||||||
logger ($pa_config, "Skipping action " . safe_output($action->{'name'}) . " for alert '" . safe_output($alert->{'name'}) . "' module '" . safe_output($module->{'nombre'}) . "'.", 10);
|
logger ($pa_config, "Skipping action " . safe_output($action->{'name'}) . " for alert '" . safe_output($alert->{'name'}) . "' module '" . safe_output($module->{'nombre'}) . "'.", 10);
|
||||||
@ -989,7 +997,8 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
|
|||||||
'',
|
'',
|
||||||
$critical_instructions,
|
$critical_instructions,
|
||||||
$warning_instructions,
|
$warning_instructions,
|
||||||
$unknown_instructions
|
$unknown_instructions,
|
||||||
|
p_encode_json($pa_config, $custom_data)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
pandora_event (
|
pandora_event (
|
||||||
@ -1010,7 +1019,8 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
|
|||||||
'',
|
'',
|
||||||
$critical_instructions,
|
$critical_instructions,
|
||||||
$warning_instructions,
|
$warning_instructions,
|
||||||
$unknown_instructions
|
$unknown_instructions,
|
||||||
|
p_encode_json($pa_config, $custom_data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4208,14 +4218,20 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Execute alert
|
# Execute alert
|
||||||
my $action = get_db_single_row ($dbh, 'SELECT *
|
my $action = get_db_single_row ($dbh, 'SELECT talert_actions.name as action_name, *
|
||||||
FROM talert_actions, talert_commands
|
FROM talert_actions, talert_commands
|
||||||
WHERE talert_actions.id_alert_command = talert_commands.id
|
WHERE talert_actions.id_alert_command = talert_commands.id
|
||||||
AND talert_actions.id = ?', $alert->{'id_alert'});
|
AND talert_actions.id = ?', $alert->{'id_alert'});
|
||||||
|
|
||||||
my $trap_rcv_full = $trap_oid . " " . $trap_value. " ". $trap_type. " " . $trap_custom_oid;
|
my $trap_rcv_full = $trap_oid . " " . $trap_value. " ". $trap_type. " " . $trap_custom_oid;
|
||||||
|
|
||||||
|
# Additional execution information for the console.
|
||||||
|
my $custom_data = {
|
||||||
|
'actions' => [],
|
||||||
|
};
|
||||||
|
|
||||||
pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert, 1, $action, undef, $dbh, $timestamp, \%macros) if (defined ($action));
|
pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert, 1, $action, undef, $dbh, $timestamp, \%macros) if (defined ($action));
|
||||||
|
push(@{$custom_data->{'actions'}}, safe_output($action->{'action_name'}));
|
||||||
|
|
||||||
# Generate an event, ONLY if our alert action is different from generate an event.
|
# Generate an event, ONLY if our alert action is different from generate an event.
|
||||||
if ($action->{'id_alert_command'} != 3 && $alert->{'disable_event'} == 0){
|
if ($action->{'id_alert_command'} != 3 && $alert->{'disable_event'} == 0){
|
||||||
@ -4236,7 +4252,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
|
|||||||
$alert->{'id_as'});
|
$alert->{'id_as'});
|
||||||
|
|
||||||
foreach my $other_alert (@more_actions_snmp) {
|
foreach my $other_alert (@more_actions_snmp) {
|
||||||
my $other_action = get_db_single_row ($dbh, 'SELECT *
|
my $other_action = get_db_single_row ($dbh, 'SELECT talert_actions.name as action_name, *
|
||||||
FROM talert_actions, talert_commands
|
FROM talert_actions, talert_commands
|
||||||
WHERE talert_actions.id_alert_command = talert_commands.id
|
WHERE talert_actions.id_alert_command = talert_commands.id
|
||||||
AND talert_actions.id = ?', $other_alert->{'alert_type'});
|
AND talert_actions.id = ?', $other_alert->{'alert_type'});
|
||||||
@ -4277,11 +4293,30 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert_action, 1, $other_action, undef, $dbh, $timestamp, \%macros) if (defined ($other_action));
|
pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert_action, 1, $other_action, undef, $dbh, $timestamp, \%macros) if (defined ($other_action));
|
||||||
|
push(@{$custom_data->{'actions'}}, safe_output($other_action->{'action_name'}));
|
||||||
|
|
||||||
# Generate an event, ONLY if our alert action is different from generate an event.
|
# Generate an event, ONLY if our alert action is different from generate an event.
|
||||||
if ($other_action->{'id_alert_command'} != 3 && $alert->{'disable_event'} == 0){
|
if ($other_action->{'id_alert_command'} != 3 && $alert->{'disable_event'} == 0){
|
||||||
pandora_event ($pa_config, "SNMP alert fired (" . safe_output($alert->{'description'}) . ")",
|
pandora_event (
|
||||||
0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh);
|
$pa_config,
|
||||||
|
"SNMP alert fired (" . safe_output($alert->{'description'}) . ")",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
$alert->{'priority'},
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
'alert_fired',
|
||||||
|
0,
|
||||||
|
$dbh,
|
||||||
|
undef,
|
||||||
|
undef,
|
||||||
|
undef,
|
||||||
|
undef,
|
||||||
|
undef,
|
||||||
|
undef,
|
||||||
|
undef,,
|
||||||
|
undef,
|
||||||
|
p_encode_json($pa_config, $custom_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update alert status
|
# Update alert status
|
||||||
|
Loading…
x
Reference in New Issue
Block a user