Merge branch 'develop' into ent-10012-item-grafico-coincidencias-informe-logs

This commit is contained in:
Daniel Cebrian 2023-07-10 16:02:02 +02:00
commit f3ee738fcc
13 changed files with 602 additions and 113 deletions

View File

@ -113,7 +113,8 @@ if ($id_policy_module > 0) {
$plugin_parameter_split = explode('
', $plugin_parameter);
$plugin_parameter_final_split = '';
foreach ($plugin_parameter_split as $key => $value) {
$new_plugin_parameter_split = array_filter($plugin_parameter_split, 'strlen');
foreach ($new_plugin_parameter_split as $key => $value) {
if (strpos($value, 'http_auth_user') === false && strpos($value, 'http_auth_pass') === false) {
$plugin_parameter_final_split .= $value.'
';
}
@ -317,8 +318,7 @@ foreach ($texts as $code => $text) {
return;
}
$(plugin_parameter).val(
'task_begin\ncookie 0\nresource 0\ntask_end');
$(plugin_parameter).val('task_begin\ncookie 0\nresource 0\ntask_end');
$('#button-btn_loadbasic').attr('disabled', 'disabled');

View File

@ -333,7 +333,7 @@ $show_table_filter .= ui_toggle(
__('Search'),
'search',
true,
false,
true,
'',
'white-box-content no_border',
'filter-datatable-main box-flat white_table_graph fixed_filter_bar '

View File

@ -40,8 +40,25 @@ $table->size = [];
$table->style[0] = 'width: 50%';
$table->style[1] = 'width: 50%';
// Add an agent selector
if (! $id_agente) {
if (is_metaconsole() === true) {
$params = [];
$params['return'] = true;
$params['show_helptip'] = true;
$params['input_name'] = 'id_agent';
$params['selectbox_id'] = 'id_agent_module';
$params['javascript_is_function_select'] = true;
$params['metaconsole_enabled'] = true;
$params['use_hidden_input_idagent'] = true;
$params['print_hidden_input_idagent'] = true;
$params['javascript_page'] = 'enterprise/meta/include/ajax/events.ajax';
$table->data[0][0] = html_print_label_input_block(
__('Agent'),
'<div class="w100p">'.ui_print_agent_autocomplete_input($params).'</div>'
);
} else {
// Add an agent selector.
if (! $id_agente) {
$params = [];
$params['return'] = true;
$params['show_helptip'] = true;
@ -55,14 +72,15 @@ if (! $id_agente) {
__('Agent'),
ui_print_agent_autocomplete_input($params)
);
}
if ($id_agente) {
$modules = agents_get_modules($id_agente, false, ['delete_pending' => 0]);
}
}
$modules = [];
if ($id_agente) {
$modules = agents_get_modules($id_agente, false, ['delete_pending' => 0]);
}
$table->data[0][1] = html_print_label_input_block(
__('Module'),
html_print_select(
@ -319,7 +337,8 @@ $(document).ready (function () {
jQuery.post (<?php echo "'".ui_get_full_url(false, false, false, false)."'"; ?> + "ajax.php",
{"page" : "operation/agentes/estado_agente",
"get_agent_module_last_value" : 1,
"id_agent_module" : this.value
"id_agent_module" : this.value,
"server_name" : $('#text-id_agent').val(),
},
function (data, status) {
if (data === false) {
@ -338,5 +357,4 @@ $(document).ready (function () {
);
});
});
/* ]]> */
</script>

View File

@ -99,6 +99,19 @@ if ($update_alert) {
}
if ($create_alert) {
if (is_metaconsole()) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0];
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) !== NOERR) {
echo json_encode(false);
// Restore db connection.
metaconsole_restore_db();
return;
}
}
}
$id_alert_template = (int) get_parameter('template');
$id_agent_module = (int) get_parameter('id_agent_module');
@ -203,9 +216,28 @@ if ($create_alert) {
}
}
}
if (is_metaconsole()) {
// Restore db connection.
metaconsole_restore_db();
echo '<script>window.location.assign("index.php?sec=estado&sec2=operation/agentes/alerts_status")</script>';
}
}
if ($delete_alert) {
if (is_metaconsole()) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0];
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) !== NOERR) {
echo json_encode(false);
// Restore db connection.
metaconsole_restore_db();
return;
}
}
}
$id_alert_agent_module = (int) get_parameter('id_alert');
$temp = db_get_row('talert_template_modules', 'id', $id_alert_agent_module);
@ -241,9 +273,27 @@ if ($delete_alert) {
'',
true
);
if (is_metaconsole()) {
// Restore db connection.
metaconsole_restore_db();
echo '<script>window.location.assign("index.php?sec=estado&sec2=operation/agentes/alerts_status")</script>';
}
}
if ($add_action) {
if (is_metaconsole()) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0];
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) !== NOERR) {
echo json_encode(false);
// Restore db connection.
metaconsole_restore_db();
return;
}
}
}
$id_action = (int) get_parameter('action_select');
$id_alert_module = (int) get_parameter('id_alert_module');
$fires_min = (int) get_parameter('fires_min');
@ -280,9 +330,28 @@ if ($add_action) {
'',
true
);
if (is_metaconsole()) {
// Restore db connection.
metaconsole_restore_db();
echo '<script>window.location.assign("index.php?sec=estado&sec2=operation/agentes/alerts_status")</script>';
}
}
if ($update_action) {
if (is_metaconsole()) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0];
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) !== NOERR) {
echo json_encode(false);
// Restore db connection.
metaconsole_restore_db();
return;
}
}
}
$alert_id = (int) get_parameter('alert_id');
$id_action = (int) get_parameter('action_select_ajax-'.$alert_id);
$id_module_action = (int) get_parameter('id_module_action_ajax');
@ -321,9 +390,28 @@ if ($update_action) {
'',
true
);
if (is_metaconsole()) {
// Restore db connection.
metaconsole_restore_db();
echo '<script>window.location.assign("index.php?sec=estado&sec2=operation/agentes/alerts_status")</script>';
}
}
if ($delete_action) {
if (is_metaconsole()) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0];
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) !== NOERR) {
echo json_encode(false);
// Restore db connection.
metaconsole_restore_db();
return;
}
}
}
$id_action = (int) get_parameter('id_action');
$id_alert = (int) get_parameter('id_alert');
@ -348,6 +436,12 @@ if ($delete_action) {
'',
true
);
if (is_metaconsole()) {
// Restore db connection.
metaconsole_restore_db();
echo '<script>window.location.assign("index.php?sec=estado&sec2=operation/agentes/alerts_status")</script>';
}
}
if ($enable_alert) {

View File

@ -326,9 +326,22 @@ if (count($actions) == 1 && isset($actions[0])) {
}
foreach ($action['escalation'] as $k => $v) {
if (count($table->head) >= count($action['escalation'])) {
if ($k === count($action['escalation'])) {
if ($k === 1) {
if ($v > 0) {
$table->data[$kaction][$k] .= html_print_image(
'images/tick.png',
true,
['class' => 'invert_filter']
);
} else {
$table->data[$kaction][$k] = html_print_image(
'images/blade.png',
true
);
}
if (count($table->head) <= count($action['escalation'])) {
if ($k == count($action['escalation'])) {
if ($k == 1) {
$table->head[$kaction] = __('Every time that the alert is fired');
} else {
$table->head[$kaction] = '>#'.($kaction - 1);

View File

@ -287,7 +287,7 @@ foreach ($extensions as $file => $extension) {
[
'href' => 'index.php?sec=godmode/extensions&amp;sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&enabled='.$file,
'image' => 'images/lightbulb_off.png',
'title' => __('Delete'),
'title' => __('Enable'),
],
true
);
@ -305,7 +305,7 @@ foreach ($extensions as $file => $extension) {
[
'href' => 'index.php?sec=godmode/extensions&amp;sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&disabled='.$file,
'image' => 'images/lightbulb.png',
'title' => __('Delete'),
'title' => __('Disable'),
],
true
);

View File

@ -419,6 +419,19 @@ if ($get_actions_module) {
}
if ($show_update_action_menu) {
if (is_metaconsole()) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0];
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) !== NOERR) {
echo json_encode(false);
// Restore db connection.
metaconsole_restore_db();
return;
}
}
}
if (! check_acl($config['id_user'], 0, 'LW')) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
@ -449,7 +462,12 @@ if ($show_update_action_menu) {
$id_action
);
if (is_metaconsole()) {
$data .= '<form id="update_action-'.$id_alert.'" method="post" action="index.php?sec=galertas&sec2=godmode/alerts/alert_list">';
} else {
$data .= '<form id="update_action-'.$id_alert.'" method="post" style="height:85%;">';
}
$data .= '<table class="w100p bg_color222" style="height:100%;">';
$data .= html_print_input_hidden(
'update_action',
@ -466,6 +484,11 @@ if ($show_update_action_menu) {
$id_action,
true
);
$data .= html_print_input_hidden(
'id_agent',
$server_name,
true
);
if (! $id_agente) {
$data .= '<tr class="datos2">';
$data .= '<td class="datos2 bolder pdd_6px font_10pt">';
@ -548,6 +571,11 @@ if ($show_update_action_menu) {
);
$data .= '</td>';
$data .= '</tr>';
if (isset($action_option['module_action_threshold']) === false) {
$action_option['module_action_threshold'] = '300';
}
$data .= '<tr class="datos2">';
$data .= '<td class="datos2 bolder pdd_6px font_10pt">';
$data .= __('Threshold').ui_print_help_tip(__('If a value of 0 is assigned, the Threshold of the action will be used.'), true);
@ -568,7 +596,7 @@ if ($show_update_action_menu) {
false,
'',
false,
true
false
);
$data .= '</td>';
$data .= '</tr>';
@ -584,6 +612,11 @@ if ($show_update_action_menu) {
true
);
$data .= '</form>';
if (is_metaconsole()) {
// Restore db connection.
metaconsole_restore_db();
}
echo $data;
return;
}
@ -954,6 +987,7 @@ if ($get_agent_alerts_datatable === true) {
$tmp->last_fired = $row[8];
$tmp->status = $row[9];
$tmp->validate = $row[10];
$tmp->actions = $row[11];
} else {
// Open.
$tmp->standby = $row[0];

View File

@ -1562,13 +1562,13 @@ function alerts_delete_alert_agent_module_action($id_alert_agent_module_action)
*
* @return mixed Actions associated or false if something goes wrong.
*/
function alerts_get_alert_agent_module_actions($id_alert_agent_module, $fields=false, $server_id=-1)
function alerts_get_alert_agent_module_actions($id_alert_agent_module, $fields=false, $server_id=-1, $ignore_metaconsole=false)
{
if (empty($id_alert_agent_module)) {
return false;
}
if (defined('METACONSOLE')) {
if (defined('METACONSOLE') && $ignore_metaconsole === false) {
$server = db_get_row('tmetaconsole_setup', 'id', $server_id);
if (metaconsole_connect($server) == NOERR) {
@ -1602,6 +1602,7 @@ function alerts_get_alert_agent_module_actions($id_alert_agent_module, $fields=f
$action['fires_min'] = $element['fires_min'];
$action['fires_max'] = $element['fires_max'];
$action['module_action_threshold'] = $element['module_action_threshold'];
$action['original_id'] = $element['id'];
if (isset($element['id'])) {
$retval[$element['id']] = $action;

View File

@ -1148,6 +1148,7 @@ function ui_format_alert_row(
'last_fired' => 8,
'status' => 9,
'validate' => 10,
'actions' => 11,
];
} else {
$index = [
@ -1417,7 +1418,8 @@ function ui_format_alert_row(
);
}
$data[$index['module_name']] = ui_print_truncate_text(isset($alert['agent_module_name']) ? $alert['agent_module_name'] : modules_get_agentmodule_name($alert['id_agent_module']), 'module_small', false, true, true, '[&hellip;]', '');
$alert_module_name = isset($alert['agent_module_name']) ? $alert['agent_module_name'] : modules_get_agentmodule_name($alert['id_agent_module']);
$data[$index['module_name']] = ui_print_truncate_text($alert_module_name, 'module_small', false, true, true, '[&hellip;]', '');
}
$data[$index['agent_name']] .= $disabledHtmlEnd;
@ -1431,7 +1433,24 @@ function ui_format_alert_row(
$data[$index['description']] .= $disabledHtmlStart.ui_print_truncate_text(io_safe_output($description), 'description', false, true, true, '[&hellip;]', '').$disabledHtmlEnd;
$actions = alerts_get_alert_agent_module_actions($alert['id'], false, $alert['server_data']['id']);
if (is_metaconsole()) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$connection = metaconsole_get_connection($agente['server_name']);
if (metaconsole_load_external_db($connection) !== NOERR) {
echo json_encode(false);
// Restore db connection.
metaconsole_restore_db();
return;
}
}
}
$actions = alerts_get_alert_agent_module_actions($alert['id'], false, -1, true);
if (is_metaconsole()) {
// Restore db connection.
metaconsole_restore_db();
}
if (empty($actions) === false || $actionDefault != '') {
$actionText = '<div><ul class="action_list">';
@ -1441,12 +1460,44 @@ function ui_format_alert_row(
$actionText .= ' ('.$action['fires_min'].' / '.$action['fires_max'].')';
}
$actionText .= ui_print_help_tip(__('The default actions will be executed every time that the alert is fired and no other action is executed'), true);
// Is possible manage actions if have LW permissions in the agent group of the alert module.
if (check_acl($config['id_user'], $id_group, 'LM')) {
$actionText .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=list&delete_action=1&id_alert='.$alert['id'].'&id_agent='.$agente['alias'].'&id_action='.$action['original_id'].'" onClick="if (!confirm(\' '.__('Are you sure you want to delete alert action?').'\')) return false;">'.html_print_image(
'images/delete.svg',
true,
[
'alt' => __('Delete action'),
'title' => __('Delete action'),
'class' => 'main_menu_icon invert_filter vertical_baseline',
]
).'</a>';
}
if (check_acl($config['id_user'], $id_group, 'LW')) {
$actionText .= html_print_input_image(
'update_action',
'/images/edit.svg',
1,
'padding:0px;',
true,
[
'title' => __('Update action'),
'class' => 'main_menu_icon invert_filter',
'onclick' => 'show_display_update_action(\''.$action['original_id'].'\',\''.$alert['id'].'\',\''.$alert['id_agent_module'].'\',\''.$action['original_id'].'\',\''.$alert['agent_name'].'\')',
]
);
$actionText .= html_print_input_hidden('id_agent_module', $alert['id_agent_module'], true);
}
$actionText .= '<div id="update_action-div-'.$alert['id'].'" class="invisible">';
$actionText .= '</div>';
$actionText .= '</li></span></div>';
}
$actionText .= '</ul></div>';
if ($actionDefault !== '') {
if ($actionDefault !== '' && $actionDefault !== false) {
$actionDefault_name = db_get_sql(
sprintf(
'SELECT name FROM talert_actions WHERE id = %d',
@ -1456,6 +1507,8 @@ function ui_format_alert_row(
foreach ($actions as $action) {
if ($actionDefault_name === $action['name']) {
$hide_actionDefault = true;
} else {
$hide_actionDefault = false;
}
}
@ -1484,6 +1537,182 @@ function ui_format_alert_row(
}
$data[$index['status']] = ui_print_status_image($status, $title, true);
$data[$index['status']] .= '<div id="update_action-div-'.$alert['id'].'" class="invisible">';
if (is_metaconsole()) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$connection = metaconsole_get_connection($agente['server_name']);
if (metaconsole_load_external_db($connection) !== NOERR) {
echo json_encode(false);
// Restore db connection.
metaconsole_restore_db();
return;
}
}
$action = db_get_all_rows_filter(
'talert_template_module_actions',
['id_alert_template_module' => $alert['id']],
'id'
)[0];
if (is_metaconsole()) {
// Restore db connection.
metaconsole_restore_db();
}
$tableActionButtons[] = '';
// Edit.
if (check_acl($config['id_user'], $id_group, 'LM')) {
$tableActionButtons[] = html_print_input_hidden('id_agent_module', $alert['id_agent_module'], true);
$tableActionButtons[] = '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=list&delete_alert=1&id_alert='.$alert['id'].'&id_agent='.$alert['agent_name'].'" onClick="if (!confirm(\' '.__('Are you sure you want to delete alert?').'\')) return false;">'.html_print_image(
'images/delete.svg',
true,
[
'alt' => __('Delete'),
'title' => __('Delete'),
'class' => 'main_menu_icon invert_filter vertical_baseline',
]
).'</a>';
$tableActionButtons[] = '<a href="javascript:show_add_action(\''.$alert['id'].'\');">'.html_print_image(
'images/plus-black.svg',
true,
[
'title' => __('Add action'),
'class' => 'invert_filter main_menu_icon',
'style' => 'margin-bottom: 12px;',
]
).'</a>';
}
$data[$index['actions']] = html_print_div(
[
'style' => 'padding-top: 8px;',
'content' => implode('', $tableActionButtons),
],
true
);
}
// Is possible manage actions if have LW permissions in the agent group of the alert module.
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'LW') || check_acl($config['id_user'], $template_group, 'LM')) {
if (check_acl($config['id_user'], $template_group, 'LW')) {
$own_groups = users_get_groups($config['id_user'], 'LW', true);
} else if (check_acl($config['id_user'], $template_group, 'LM')) {
$own_groups = users_get_groups($config['id_user'], 'LM', true);
}
$filter_groups = '';
$filter_groups = implode(',', array_keys($own_groups));
if ($filter_groups != null) {
$actions = alerts_get_alert_actions_filter(true, 'id_group IN ('.$filter_groups.')');
}
$data[$index['actions']] .= '<div id="add_action-div-'.$alert['id'].'" class="invisible">';
$data[$index['actions']] .= '<form id="add_action_form-'.$alert['id'].'" method="post" style="height:85%;" action="index.php?sec=galertas&sec2=godmode/alerts/alert_list">';
$data[$index['actions']] .= '<table class="w100p bg_color222 filter-table-adv">';
$data[$index['actions']] .= html_print_input_hidden('add_action', 1, true);
$data[$index['actions']] .= html_print_input_hidden('id_agent', $agente['alias'], true);
$data[$index['actions']] .= html_print_input_hidden('id_alert_module', $alert['id'], true);
if (! $id_agente) {
$data[$index['actions']] .= '<tr class="datos2">';
$data[$index['actions']] .= '<td class="w50p">'.html_print_label_input_block(
__('Agent'),
ui_print_truncate_text($agente['alias'], 'agent_small', false, true, true, '[&hellip;]')
).'</td>';
$data[$index['actions']] .= '<td class="w50p">'.html_print_label_input_block(
__('Module'),
ui_print_truncate_text($alert_module_name, 'module_small', false, true, true, '[&hellip;]')
).'</td>';
$data[$index['actions']] .= '</tr>';
}
$data[$index['actions']] .= '<tr class="datos2">';
$data[$index['actions']] .= '<td class="w50p">'.html_print_label_input_block(
__('Action'),
html_print_select(
$actions,
'action_select',
'',
'',
__('None'),
0,
true,
false,
true,
'',
false,
'width:100%'
)
).'</td>';
$data[$index['actions']] .= '<td class="w50p">'.html_print_label_input_block(
__('Number of alerts match from'),
'<div class="inline">'.html_print_input_text(
'fires_min',
0,
'',
4,
10,
true,
false,
false,
'',
'w40p'
).' '.__('to').' '.html_print_input_text(
'fires_max',
0,
'',
4,
10,
true,
false,
false,
'',
'w40p'
).'</div>'
).'</td>';
$data[$index['actions']] .= '</tr>';
$data[$index['actions']] .= '<tr class="datos2">';
$data[$index['actions']] .= '<td class="w50p">'.html_print_label_input_block(
__('Threshold'),
html_print_extended_select_for_time(
'module_action_threshold',
0,
'',
'',
'',
false,
true,
false,
true,
'',
false,
false,
'',
false,
true
)
).'</td>';
$data[$index['actions']] .= '</tr>';
$data[$index['actions']] .= '</table>';
$data[$index['actions']] .= html_print_submit_button(
__('Add'),
'addbutton',
false,
[
'icon' => 'next',
'class' => 'mini float-right',
],
true
);
$data[$index['actions']] .= '</form>';
$data[$index['actions']] .= '</div>';
}
return $data;
}
@ -3652,6 +3881,8 @@ function ui_print_datatable(array $parameters)
} else {
$pagination_options = [
[
// There is a limit of (2^32)^2 (18446744073709551615) rows in a MyISAM table, show for show all use max nrows.
// -1 Retun error or only 1 row.
$parameters['default_pagination'],
5,
10,
@ -3660,7 +3891,7 @@ function ui_print_datatable(array $parameters)
200,
500,
1000,
-1,
18446744073709551615,
],
[
$parameters['default_pagination'],

View File

@ -7303,6 +7303,9 @@ div.graph div.legend table {
.vertical_middle {
vertical-align: middle;
}
.vertical_baseline {
vertical-align: baseline !important;
}
.mrg_btt_7 {
margin-bottom: 7px;

View File

@ -312,12 +312,18 @@ if (is_metaconsole() === false) {
}
}
if (is_metaconsole()) {
array_push($column_names, ['text' => 'actions']);
array_push($columns, 'actions');
}
if (is_metaconsole() === true) {
$no_sortable_columns = [
0,
1,
2,
5,
-1,
];
} else {
if (enterprise_installed() === true) {
@ -466,7 +472,17 @@ if (is_metaconsole() === false) {
}
}
} else {
html_print_action_buttons('');
echo "<form method='post' action='index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=builder&pure=0'>";
html_print_action_buttons(
html_print_submit_button(
__('Create alert'),
'submit',
false,
[ 'icon' => 'next'],
true
)
);
echo '</form>';
}
$html_content = ob_get_clean();
@ -534,16 +550,16 @@ function alerts_table_controls() {
}
});
}
}
$(document).ready ( function () {
$(document).ready ( function () {
alerts_table_controls();
$('#button-alert_validate').on('click', function () {
validateAlerts();
});
});
});
$('table.alert-status-filter #ag_group').change (function () {
$('table.alert-status-filter #ag_group').change (function () {
var strict_user = $("#text-strict_user_hidden").val();
var is_meta = $("#text-is_meta_hidden").val();
@ -562,10 +578,9 @@ function alerts_table_controls() {
$("table.alert-status-filter #table2-0-4").show();
}
}
}).change();
}).change();
function validateAlerts() {
function validateAlerts() {
var alert_ids = [];
$('[id^=checkbox-validate]:checked').each(function() {
@ -600,6 +615,63 @@ function alerts_table_controls() {
},
});
}
function show_display_update_action(id_module_action, alert_id, alert_id_agent_module, action_id,id_agent='') {
$.each($('[id^="update_action-div"]'), function(){
$(this).html('');
});
var params = [];
params.push("show_update_action_menu=1");
params.push("id_agent_module=" + alert_id_agent_module);
params.push("id_module_action=" + id_module_action);
params.push("id_alert=" + alert_id);
params.push("id_action=" + action_id);
params.push("id_agent=" + id_agent);
params.push("page=include/ajax/alert_list.ajax");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action="<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
success: function (data) {
$('#update_action-div-'+alert_id).html(data);
$('#update_action-div-'+alert_id).dialog ({
resizable: true,
draggable: true,
title: '<?php echo __('Update action'); ?>',
modal: true,
overlay: {
opacity: 0.5,
background: "black"
},
open: function() {
$('#action_select_ajax-'+alert_id).select2();
},
onclose: function() {
$('#update_action-div-'+alert_id).html("");
},
width: 600,
height: 350,
})
.show ();
}
});
}
function show_add_action(id_alert) {
$("#add_action-div-" + id_alert).hide ()
.dialog ({
resizable: true,
draggable: true,
modal: true,
width: 700,
title: '<?php echo __('Add action'); ?>',
modal: true,
overlay: {
opacity: 0.5,
background: "black"
}
})
.show ();
}
</script>

View File

@ -94,6 +94,19 @@ if (is_ajax() === true) {
}
if ($get_agent_module_last_value === true) {
if (is_metaconsole()) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$server_name = explode(' ', io_safe_output(get_parameter('server_name')))[0];
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) !== NOERR) {
echo json_encode(false);
// Restore db connection.
metaconsole_restore_db();
return;
}
}
}
$id_module = (int) get_parameter('id_agent_module');
$id_agent = (int) modules_get_agentmodule_agent((int) $id_module);
if (! check_acl_one_of_groups($config['id_user'], agents_get_all_groups_agent($id_agent), 'AR')) {
@ -132,6 +145,11 @@ if (is_ajax() === true) {
}
}
if (is_metaconsole()) {
// Restore db connection.
metaconsole_restore_db();
}
echo json_encode($value);
return;
}

View File

@ -942,7 +942,12 @@ if (is_ajax()) {
if (is_metaconsole() && !$force_local_modules) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
if (empty($server_name)) {
$server_name = explode(' ', io_safe_output($agentName))[0];
}
$connection = metaconsole_get_connection($server_name);
if ($server_id > 0) {
$connection = metaconsole_get_connection_by_id($server_id);
}