Merge remote-tracking branch 'origin/ent-4461-Configuracion-integracion-integria' into ent-4642-Listado-de-tickets-integración-Integria
This commit is contained in:
commit
ca6fe42298
|
@ -295,6 +295,9 @@ if (check_acl($config['id_user'], 0, 'PM')) {
|
|||
$sub2['godmode/setup/setup&section=ehorus']['text'] = __('eHorus');
|
||||
$sub2['godmode/setup/setup&section=ehorus']['refr'] = 0;
|
||||
|
||||
$sub2['godmode/setup/setup&section=integria']['text'] = __('Integria IMS');
|
||||
$sub2['godmode/setup/setup&section=ehorus']['refr'] = 0;
|
||||
|
||||
$sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications');
|
||||
$sub2['godmode/setup/setup&section=notifications']['refr'] = 0;
|
||||
|
||||
|
|
|
@ -117,6 +117,11 @@ if (check_acl($config['id_user'], 0, 'AW')) {
|
|||
}
|
||||
}
|
||||
|
||||
$buttons['integria'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=integria').'">'.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('Integria IMS')]).'</a>',
|
||||
];
|
||||
|
||||
$buttons['ehorus'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=ehorus').'">'.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'</a>',
|
||||
|
@ -167,6 +172,12 @@ switch ($section) {
|
|||
$help_header = 'setup_ehorus_tab';
|
||||
break;
|
||||
|
||||
case 'integria':
|
||||
$buttons['integria']['active'] = true;
|
||||
$subpage = ' » '.__('Integria IMS');
|
||||
$help_header = 'setup_integria_tab';
|
||||
break;
|
||||
|
||||
case 'notifications':
|
||||
$buttons['notifications']['active'] = true;
|
||||
$subpage = ' » '.__('Notifications');
|
||||
|
@ -228,6 +239,10 @@ switch ($section) {
|
|||
include_once $config['homedir'].'/godmode/setup/setup_ehorus.php';
|
||||
break;
|
||||
|
||||
case 'integria':
|
||||
include_once $config['homedir'].'/godmode/setup/setup_integria.php';
|
||||
break;
|
||||
|
||||
case 'notifications':
|
||||
include_once $config['homedir'].'/godmode/setup/setup_notifications.php';
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,529 @@
|
|||
<?php
|
||||
/**
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
|
||||
db_pandora_audit('ACL Violation', 'Trying to access Setup Management');
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_ajax()) {
|
||||
$integria_user = get_parameter('integria_user', '');
|
||||
$integria_pass = get_parameter('integria_pass', '');
|
||||
$integria_api_hostname = get_parameter('api_hostname', '');
|
||||
$integria_api_pass = get_parameter('api_pass', '');
|
||||
|
||||
$login_result = integria_api_call($integria_api_hostname, $integria_user, $integria_pass, $integria_api_pass, 'get_login', []);
|
||||
|
||||
if ($login_result != false) {
|
||||
echo json_encode(['login' => 1]);
|
||||
} else {
|
||||
echo json_encode(['login' => 0]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
|
||||
|
||||
if ($has_connection === false) {
|
||||
ui_print_error_message(__('Integria IMS API is not reachable'));
|
||||
}
|
||||
|
||||
if (get_parameter('update_config', 0) == 1) {
|
||||
// Try to retrieve event response 'Create incident in IntegriaIMS from event' to check if it exists.
|
||||
$event_response_exists = db_get_row_filter('tevent_response', ['name' => io_safe_input('Create incident in IntegriaIMS from event')]);
|
||||
|
||||
// Try to retrieve command 'Integia IMS Ticket' to check if it exists.
|
||||
$command_exists = db_get_row_filter('talert_commands', ['name' => io_safe_input('Integria IMS Ticket')]);
|
||||
|
||||
if ($config['integria_enabled'] == 1) {
|
||||
if ($event_response_exists === false) {
|
||||
// Create 'Create incident in IntegriaIMS from event' event response only when user enables IntegriaIMS integration and it does not exist in database.
|
||||
db_process_sql_insert('tevent_response', ['name' => io_safe_input('Create incident in IntegriaIMS from event'), 'description' => io_safe_input('Create an incident in Integria IMS from an event'), 'target' => io_safe_input('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&from_event=_event_id_'), 'type' => 'url', 'id_group' => '0', 'modal_width' => '0', 'modal_height' => '0', 'new_window' => '1', 'params' => '', 'server_to_exec' => '0']);
|
||||
}
|
||||
|
||||
if ($command_exists === false) {
|
||||
// Create 'Integria IMS Ticket' command only when user enables IntegriaIMS integration and it does not exist in database.
|
||||
$id_command_inserted = db_process_sql_insert('talert_commands', ['name' => io_safe_input('Integria IMS Ticket'), 'command' => io_safe_input('perl /usr/share/pandora_server/util/integria_rticket.pl -p '.$config['integria_hostname'].'/integria/include/api.php -u '.$config['integria_api_pass'].','.$config['integria_user'].','.$config['integria_pass'].' -create_ticket -name "_field1_" -desc "_field2_" -group _field3_ -priority _field4_ -owner _field5_ -type _field6_'), 'description' => io_safe_input('Create an incident in Integria IMS'), 'fields_descriptions' => '["'.io_safe_input('Ticket title').'","'.io_safe_input('Ticket description').'","'.io_safe_input('Ticket group ID').'","'.io_safe_input('Ticket priority').'","'.io_safe_input('Ticket owner').'","'.io_safe_input('Ticket type').'"]', 'fields_values' => '["'.io_safe_input($config['incident_title']).'", "'.io_safe_input($config['incident_content']).'", "'.io_safe_input($config['default_group']).'", "'.io_safe_input($config['default_criticity']).'", "'.io_safe_input($config['default_owner']).'", "'.io_safe_input($config['incident_type']).'"]', 'fields_hidden' => '["","","","","","","","","",""]']);
|
||||
|
||||
// Create 'Create Integria IMS Ticket' action only when user enables IntegriaIMS integration and command exists in database.
|
||||
$action_values = [
|
||||
'field1' => io_safe_input($config['incident_title']),
|
||||
'field1_recovery' => io_safe_input($config['incident_title']),
|
||||
'field2' => io_safe_input($config['incident_content']),
|
||||
'field2_recovery' => io_safe_input($config['incident_content']),
|
||||
'field3' => io_safe_input($config['default_group']),
|
||||
'field3_recovery' => io_safe_input($config['default_group']),
|
||||
'field4' => io_safe_input($config['default_criticity']),
|
||||
'field4_recovery' => io_safe_input($config['default_criticity']),
|
||||
'field5' => io_safe_input($config['default_owner']),
|
||||
'field5_recovery' => io_safe_input($config['default_owner']),
|
||||
'id_group' => 0,
|
||||
'action_threshold' => 0,
|
||||
];
|
||||
|
||||
alerts_create_alert_action(io_safe_input('Create Integria IMS ticket'), $id_command_inserted, $action_values);
|
||||
} else {
|
||||
// Update 'Integria IMS Ticket' command setup when setup data is updated, user enables IntegriaIMS integration and it does exist in database.
|
||||
db_process_sql_update(
|
||||
'talert_commands',
|
||||
[
|
||||
'command' => io_safe_input('perl /usr/share/pandora_server/util/integria_rticket.pl -p '.$config['integria_hostname'].'/integria/include/api.php -u '.$config['integria_api_pass'].','.$config['integria_user'].','.$config['integria_pass'].' -create_ticket -name "_field1_" -desc "_field2_" -group _field3_ -priority _field4_ -owner _field5_ -type _field6_'),
|
||||
'fields_values' => '["'.io_safe_input($config['incident_title']).'", "'.io_safe_input($config['incident_content']).'", "'.io_safe_input($config['default_group']).'", "'.io_safe_input($config['default_criticity']).'", "'.io_safe_input($config['default_owner']).'", "'.io_safe_input($config['incident_type']).'"]',
|
||||
],
|
||||
['name' => io_safe_input('Integria IMS Ticket')]
|
||||
);
|
||||
|
||||
// Update 'Create Integria IMS Ticket' action when setup data is updated, user enables IntegriaIMS integration and command does exist in database.
|
||||
db_process_sql_update(
|
||||
'talert_actions',
|
||||
[
|
||||
'field1' => io_safe_input($config['incident_title']),
|
||||
'field1_recovery' => io_safe_input($config['incident_title']),
|
||||
'field2' => io_safe_input($config['incident_content']),
|
||||
'field2_recovery' => io_safe_input($config['incident_content']),
|
||||
'field3' => io_safe_input($config['default_group']),
|
||||
'field3_recovery' => io_safe_input($config['default_group']),
|
||||
'field4' => io_safe_input($config['default_criticity']),
|
||||
'field4_recovery' => io_safe_input($config['default_criticity']),
|
||||
'field5' => io_safe_input($config['default_owner']),
|
||||
'field5_recovery' => io_safe_input($config['default_owner']),
|
||||
],
|
||||
['name' => io_safe_input('Create Integria IMS ticket')]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if ($event_response_exists != false) {
|
||||
// Delete 'Create incident in IntegriaIMS from event' event response if it does exist and IntegriaIMS integration is disabled.
|
||||
db_process_sql_delete('tevent_response', ['name' => io_safe_input('Create incident in IntegriaIMS from event')]);
|
||||
}
|
||||
|
||||
if ($command_exists != false) {
|
||||
// Delete 'Integria IMS Ticket' command if it does exist and IntegriaIMS integration is disabled.
|
||||
db_process_sql_delete('talert_commands', ['name' => io_safe_input('Integria IMS Ticket')]);
|
||||
|
||||
// Delete 'Create Integria IMS Ticket' action if command exists and IntegriaIMS integration is disabled.
|
||||
db_process_sql_delete('talert_actions', ['name' => io_safe_input('Create Integria IMS ticket')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get parameters from Integria IMS API.
|
||||
$group_values = [];
|
||||
$integria_criticity_values = [];
|
||||
$integria_users_values = [];
|
||||
$integria_types_values = [];
|
||||
|
||||
$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', []);
|
||||
|
||||
get_array_from_csv_data($integria_groups_csv, $group_values);
|
||||
|
||||
$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', []);
|
||||
|
||||
get_array_from_csv_data($integria_criticity_levels_csv, $integria_criticity_values);
|
||||
|
||||
$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []);
|
||||
|
||||
$csv_array = explode("\n", $integria_users_csv);
|
||||
|
||||
foreach ($csv_array as $csv_line) {
|
||||
if (!empty($csv_line)) {
|
||||
$integria_users_values[$csv_line] = $csv_line;
|
||||
}
|
||||
}
|
||||
|
||||
$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', []);
|
||||
|
||||
get_array_from_csv_data($integria_types_csv, $integria_types_values);
|
||||
|
||||
// Enable table.
|
||||
$table_enable = new StdClass();
|
||||
$table_enable->data = [];
|
||||
$table_enable->width = '100%';
|
||||
$table_enable->id = 'integria-enable-setup';
|
||||
$table_enable->class = 'databox filters';
|
||||
$table_enable->size['name'] = '30%';
|
||||
$table_enable->style['name'] = 'font-weight: bold';
|
||||
|
||||
// Enable Integria.
|
||||
$row = [];
|
||||
$row['name'] = __('Enable Integria');
|
||||
$row['control'] = html_print_checkbox_switch('integria_enabled', 1, $config['integria_enabled'], true);
|
||||
$table_enable->data['integria_enabled'] = $row;
|
||||
|
||||
// Remote config table.
|
||||
$table_remote = new StdClass();
|
||||
$table_remote->data = [];
|
||||
$table_remote->width = '100%';
|
||||
$table_remote->styleTable = 'margin-bottom: 10px;';
|
||||
$table_remote->id = 'integria-remote-setup';
|
||||
$table_remote->class = 'databox filters';
|
||||
$table_remote->size['name'] = '30%';
|
||||
$table_remote->style['name'] = 'font-weight: bold';
|
||||
|
||||
// Integria user.
|
||||
$row = [];
|
||||
$row['name'] = __('User');
|
||||
$row['control'] = html_print_input_text('integria_user', $config['integria_user'], '', 30, 100, true);
|
||||
$table_remote->data['integria_user'] = $row;
|
||||
|
||||
// Integria password.
|
||||
$row = [];
|
||||
$row['name'] = __('Password');
|
||||
$row['control'] = html_print_input_password('integria_pass', io_output_password($config['integria_pass']), '', 30, 100, true);
|
||||
$table_remote->data['integria_pass'] = $row;
|
||||
|
||||
// Integria hostname.
|
||||
$row = [];
|
||||
$row['name'] = __('API Hostname');
|
||||
$row['control'] = html_print_input_text('integria_hostname', $config['integria_hostname'], '', 30, 100, true);
|
||||
$row['control'] .= ui_print_help_tip(__('Hostname of Integria IMS\' API (scheme must be specified. Example: http://192.168.0.0)'), true);
|
||||
$table_remote->data['integria_hostname'] = $row;
|
||||
|
||||
// API password.
|
||||
$row = [];
|
||||
$row['name'] = __('API Password');
|
||||
$row['control'] = html_print_input_text('integria_api_pass', $config['integria_api_pass'], '', 30, 100, true);
|
||||
$row['control'] .= ui_print_help_tip(__('Password of Integria IMS\' API'), true);
|
||||
$table_remote->data['integria_api_pass'] = $row;
|
||||
|
||||
// Request timeout.
|
||||
$row = [];
|
||||
$row['name'] = __('Request timeout');
|
||||
$row['control'] = html_print_input_text('integria_req_timeout', $config['integria_req_timeout'], '', 3, 10, true);
|
||||
$row['control'] .= ui_print_help_tip(__('Time in seconds to set the maximum time of the requests to the Integria API').'. '.__('0 to disable'), true);
|
||||
$table_remote->data['integria_req_timeout'] = $row;
|
||||
|
||||
// Custom response settings.
|
||||
$table_cr_settings = new StdClass();
|
||||
$table_cr_settings->data = [];
|
||||
$table_cr_settings->width = '100%';
|
||||
$table_cr_settings->styleTable = 'margin-bottom: 10px;';
|
||||
$table_cr_settings->id = 'integria-cr-settings-setup';
|
||||
$table_cr_settings->class = 'databox filters';
|
||||
$table_cr_settings->size['name'] = '30%';
|
||||
$table_cr_settings->style['name'] = 'font-weight: bold';
|
||||
|
||||
// Custom response default group.
|
||||
$row = [];
|
||||
$row['name'] = __('Default group');
|
||||
$row['control'] = html_print_select(
|
||||
$group_values,
|
||||
'default_group',
|
||||
$config['default_group'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_cr_settings->data['custom_response_def_group'] = $row;
|
||||
|
||||
// Custom response default criticity.
|
||||
$row = [];
|
||||
$row['name'] = __('Default criticity');
|
||||
$row['control'] = html_print_select(
|
||||
$integria_criticity_values,
|
||||
'default_criticity',
|
||||
$config['default_criticity'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_cr_settings->data['custom_response_def_criticity'] = $row;
|
||||
|
||||
// Custom response default owner.
|
||||
$row = [];
|
||||
$row['name'] = __('Default owner');
|
||||
$row['control'] = html_print_select(
|
||||
$integria_users_values,
|
||||
'default_owner',
|
||||
$config['default_owner'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_cr_settings->data['custom_response_def_owner'] = $row;
|
||||
|
||||
// Custom response default incident type.
|
||||
$row = [];
|
||||
$row['name'] = __('Incident type');
|
||||
$row['control'] = html_print_select(
|
||||
$integria_types_values,
|
||||
'incident_type',
|
||||
$config['incident_type'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table_cr_settings->data['custom_response_incident_type'] = $row;
|
||||
|
||||
// Custom response incident title.
|
||||
$row = [];
|
||||
$row['name'] = __('Incident title');
|
||||
$row['control'] = html_print_input_text(
|
||||
'incident_title',
|
||||
$config['incident_title'],
|
||||
__('Name'),
|
||||
50,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).ui_print_help_icon('response_macros', true);
|
||||
$table_cr_settings->data['custom_response_incident_title'] = $row;
|
||||
|
||||
// Custom response incident content.
|
||||
$row = [];
|
||||
$row['name'] = __('Incident content');
|
||||
$row['control'] = html_print_input_text(
|
||||
'incident_content',
|
||||
$config['incident_content'],
|
||||
'',
|
||||
50,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).ui_print_help_icon('response_macros', true);
|
||||
$table_cr_settings->data['custom_response_incident_content'] = $row;
|
||||
|
||||
// Test.
|
||||
$row = [];
|
||||
$row['name'] = __('Test');
|
||||
$row['control'] = html_print_button(__('Start'), 'test-integria', false, '', 'class="sub next"', true);
|
||||
$row['control'] .= '<span id="test-integria-spinner" style="display:none;"> '.html_print_image('images/spinner.gif', true).'</span>';
|
||||
$row['control'] .= '<span id="test-integria-success" style="display:none;"> '.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
|
||||
$row['control'] .= '<span id="test-integria-failure" style="display:none;"> '.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
|
||||
$row['control'] .= ' <span id="test-integria-message" style="display:none;"></span>';
|
||||
$table_remote->data['integria_test'] = $row;
|
||||
|
||||
// Print.
|
||||
echo '<div style="text-align: center; padding-bottom: 20px;">';
|
||||
echo '<a target="_blank" rel="noopener noreferrer" href="http://ehorus.com">';
|
||||
html_print_image('images/integria_logo.png');
|
||||
echo '</a>';
|
||||
echo '<br />';
|
||||
echo '<div style="font-family: lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: #515151;">';
|
||||
echo __('Integria IMS');
|
||||
echo '</div>';
|
||||
echo '<a target="_blank" rel="noopener noreferrer" href="https://integriaims.com">';
|
||||
echo 'https://integriaims.com';
|
||||
echo '</a>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<form method='post'>";
|
||||
html_print_input_hidden('update_config', 1);
|
||||
|
||||
// Form enable.
|
||||
echo '<div id="form_enable">';
|
||||
html_print_table($table_enable);
|
||||
echo '</div>';
|
||||
|
||||
// Form remote.
|
||||
echo '<div id="form_remote">';
|
||||
echo '<fieldset>';
|
||||
echo '<legend>'.__('Integria API settings').'</legend>';
|
||||
|
||||
html_print_table($table_remote);
|
||||
|
||||
echo '</fieldset>';
|
||||
echo '</div>';
|
||||
|
||||
if ($has_connection != false) {
|
||||
// Form custom response settings.
|
||||
echo '<div id="form_custom_response_settings">';
|
||||
echo '<fieldset>';
|
||||
echo '<legend>'.__('Custom response settings').'</legend>';
|
||||
|
||||
html_print_table($table_cr_settings);
|
||||
|
||||
echo '</fieldset>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table_remote->width.'">';
|
||||
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<div class="action-buttons" style="width: '.$table_remote->width.'">';
|
||||
html_print_submit_button(__('Update and continue'), 'update_button', false, 'class="sub next"');
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
echo '</form>';
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
if(!$('input:checkbox[name="integria_enabled"]').is(':checked')) {
|
||||
$('#form_remote').hide();
|
||||
$('#form_custom_response_settings').hide();
|
||||
} else {
|
||||
$('#form_remote').show();
|
||||
$('#form_custom_response_settings').show();
|
||||
}
|
||||
|
||||
$('#form_enable').css('margin-bottom','20px');
|
||||
var showFields = function () {
|
||||
$('#form_remote').show();
|
||||
$('#form_custom_response_settings').show();
|
||||
}
|
||||
var hideFields = function () {
|
||||
$('#form_remote').hide();
|
||||
$('#form_custom_response_settings').hide();
|
||||
}
|
||||
|
||||
var hideUserPass = function () {
|
||||
$('#integria-remote-setup-integria_user').hide();
|
||||
$('#integria-remote-setup-integria_pass').hide();
|
||||
}
|
||||
|
||||
var showUserPass = function () {
|
||||
$('#integria-remote-setup-integria_user').show();
|
||||
$('#integria-remote-setup-integria_pass').show();
|
||||
}
|
||||
|
||||
var handleEnable = function (event) {
|
||||
var is_checked = $('input:checkbox[name="integria_enabled"]').is(':checked');
|
||||
|
||||
if (event.target.value == '1' && is_checked) {
|
||||
showFields();
|
||||
$('input:checkbox[name="integria_enabled"]').attr('checked', true);
|
||||
}
|
||||
else {
|
||||
hideFields();
|
||||
$('input:checkbox[name="integria_enabled"]').attr('checked', false);
|
||||
};
|
||||
}
|
||||
|
||||
$('input:checkbox[name="integria_enabled"]').change(handleEnable);
|
||||
|
||||
var handleTest = function (event) {
|
||||
var user = $('input#text-integria_user').val();
|
||||
var pass = $('input#password-integria_pass').val();
|
||||
var host = $('input#text-integria_hostname').val();
|
||||
var timeout = Number.parseInt($('input#text-integria_req_timeout').val(), 10);
|
||||
|
||||
var timeoutMessage = '<?php echo __('Connection timeout'); ?>';
|
||||
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';
|
||||
var notFoundMessage = '<?php echo __('User not found'); ?>';
|
||||
var invalidPassMessage = '<?php echo __('Invalid password'); ?>';
|
||||
|
||||
var hideLoadingImage = function () {
|
||||
$('span#test-integria-spinner').hide();
|
||||
}
|
||||
var showLoadingImage = function () {
|
||||
$('span#test-integria-spinner').show();
|
||||
}
|
||||
var hideSuccessImage = function () {
|
||||
$('span#test-integria-success').hide();
|
||||
}
|
||||
var showSuccessImage = function () {
|
||||
$('span#test-integria-success').show();
|
||||
}
|
||||
var hideFailureImage = function () {
|
||||
$('span#test-integria-failure').hide();
|
||||
}
|
||||
var showFailureImage = function () {
|
||||
$('span#test-integria-failure').show();
|
||||
}
|
||||
var hideMessage = function () {
|
||||
$('span#test-integria-message').hide();
|
||||
}
|
||||
var showMessage = function () {
|
||||
$('span#test-integria-message').show();
|
||||
}
|
||||
var changeTestMessage = function (message) {
|
||||
$('span#test-integria-message').text(message);
|
||||
}
|
||||
|
||||
hideSuccessImage();
|
||||
hideFailureImage();
|
||||
hideMessage();
|
||||
showLoadingImage();
|
||||
|
||||
var integria_user = $('input[name=integria_user]').val();
|
||||
var integria_pass = $('input[name=integria_pass]').val();
|
||||
var api_hostname = $('input[name=integria_hostname]').val();
|
||||
var api_pass = $('input[name=integria_api_pass]').val();
|
||||
|
||||
var data = {
|
||||
page: "godmode/setup/setup_integria",
|
||||
check_api_access: 1,
|
||||
integria_user: integria_user,
|
||||
integria_pass: integria_pass,
|
||||
api_hostname: api_hostname,
|
||||
api_pass: api_pass,
|
||||
}
|
||||
|
||||
// AJAX call to check API connection.
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
dataType: "json",
|
||||
data: data
|
||||
})
|
||||
.done(function(data, textStatus, xhr) {
|
||||
if (data.login == '1') {
|
||||
showSuccessImage();
|
||||
} else {
|
||||
showFailureImage();
|
||||
showMessage();
|
||||
}
|
||||
|
||||
})
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
showFailureImage();
|
||||
showMessage();
|
||||
})
|
||||
.always(function(xhr, textStatus) {
|
||||
hideLoadingImage();
|
||||
});
|
||||
}
|
||||
$('input#button-test-integria').click(handleTest);
|
||||
|
||||
|
||||
|
||||
</script>
|
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
|
@ -4086,7 +4086,7 @@ function mask2cidr($mask)
|
|||
function get_help_info($section_name)
|
||||
{
|
||||
global $config;
|
||||
// hd($section_name);
|
||||
|
||||
$user_language = get_user_language($id_user);
|
||||
|
||||
$es = false;
|
||||
|
@ -5439,3 +5439,84 @@ if (!function_exists('getallheaders')) {
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform an API call to Integria IMS.
|
||||
*
|
||||
* @param string API host URL.
|
||||
* @param string User name.
|
||||
* @param string User password.
|
||||
* @param string API password.
|
||||
* @param string API Operation.
|
||||
* @param array Array with parameters required by the API function.
|
||||
*
|
||||
* @return boolean True if API request succeeded, false if API request failed.
|
||||
*/
|
||||
function integria_api_call($api_hostname, $user, $user_pass, $api_pass, $operation, $params_array, $show_credentials_error_msg=false)
|
||||
{
|
||||
$params_string = implode(',', $params_array);
|
||||
|
||||
$url_data = [
|
||||
'user' => $user,
|
||||
'user_pass' => $user_pass,
|
||||
'pass' => $api_pass,
|
||||
'op' => $operation,
|
||||
'params' => html_entity_decode($params_string),
|
||||
];
|
||||
|
||||
// Build URL for API request.
|
||||
$url = $api_hostname.'/integria/include/api.php';
|
||||
|
||||
ob_start();
|
||||
$out = fopen('php://output', 'w');
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $url_data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_STDERR, $out);
|
||||
$result = curl_exec($ch);
|
||||
|
||||
fclose($out);
|
||||
$debug = ob_get_clean();
|
||||
|
||||
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
$error = false;
|
||||
|
||||
if ($result === false) {
|
||||
$error = curl_error($ch);
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
if ($error === true || $http_status !== 200) {
|
||||
if ($show_credentials_error_msg === true) {
|
||||
ui_print_error_message(__('API request failed. Please check Integria IMS\' access credentials in Pandora setup.'));
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Parse CSV consisting of one or more lines of the form key-value pair into an array.
|
||||
function get_array_from_csv_data($csv_data, &$array_values)
|
||||
{
|
||||
$csv_array = explode("\n", $csv_data);
|
||||
|
||||
foreach ($csv_array as $csv_value) {
|
||||
if (empty($csv_value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$new_csv_value = str_getcsv($csv_value);
|
||||
|
||||
$array_values[$new_csv_value[0]] = $new_csv_value[1];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1434,6 +1434,56 @@ function config_update_config()
|
|||
}
|
||||
break;
|
||||
|
||||
case 'integria':
|
||||
if (!config_update_value('integria_enabled', (int) get_parameter('integria_enabled', 0))) {
|
||||
$error_update[] = __('Enable Integria');
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_user', (string) get_parameter('integria_user', $config['integria_user']))) {
|
||||
$error_update[] = __('Integria user');
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_pass', io_input_password((string) get_parameter('integria_pass', $config['integria_pass'])))) {
|
||||
$error_update[] = __('Integria password');
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_hostname', (string) get_parameter('integria_hostname', $config['integria_hostname']))) {
|
||||
$error_update[] = __('integria API hostname');
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_api_pass', io_input_password((string) get_parameter('integria_api_pass', $config['integria_api_pass'])))) {
|
||||
$error_update[] = __('Integria API password');
|
||||
}
|
||||
|
||||
if (!config_update_value('integria_req_timeout', (int) get_parameter('integria_req_timeout', $config['integria_req_timeout']))) {
|
||||
$error_update[] = __('Integria request timeout');
|
||||
}
|
||||
|
||||
if (!config_update_value('default_group', (int) get_parameter('default_group', $config['default_group']))) {
|
||||
$error_update[] = __('Integria default group');
|
||||
}
|
||||
|
||||
if (!config_update_value('default_criticity', (int) get_parameter('default_criticity', $config['default_criticity']))) {
|
||||
$error_update[] = __('Integria default criticity');
|
||||
}
|
||||
|
||||
if (!config_update_value('default_owner', (string) get_parameter('default_owner', $config['default_owner']))) {
|
||||
$error_update[] = __('Integria default owner');
|
||||
}
|
||||
|
||||
if (!config_update_value('incident_type', (int) get_parameter('incident_type', $config['incident_type']))) {
|
||||
$error_update[] = __('Integria default incident type');
|
||||
}
|
||||
|
||||
if (!config_update_value('incident_title', (string) get_parameter('incident_title', $config['incident_title']))) {
|
||||
$error_update[] = __('Integria default incident title');
|
||||
}
|
||||
|
||||
if (!config_update_value('incident_content', (string) get_parameter('incident_content', $config['incident_content']))) {
|
||||
$error_update[] = __('Integria default incident content');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
|
@ -2820,6 +2870,19 @@ function config_process_config()
|
|||
}
|
||||
}
|
||||
|
||||
// Integria.
|
||||
if (!isset($config['integria_enabled'])) {
|
||||
config_update_value('integria_enabled', 0);
|
||||
}
|
||||
|
||||
if (!isset($config['integria_req_timeout'])) {
|
||||
config_update_value('integria_req_timeout', 5);
|
||||
}
|
||||
|
||||
if (!isset($config['integria_hostname'])) {
|
||||
config_update_value('integria_hostname', '');
|
||||
}
|
||||
|
||||
// Finally, check if any value was overwritten in a form.
|
||||
config_update_config();
|
||||
}
|
||||
|
|
|
@ -6634,3 +6634,249 @@ function events_get_secondary_groups_left_join($table)
|
|||
return 'LEFT JOIN tmetaconsole_agent_secondary_group tasg
|
||||
ON te.id_agente = tasg.id_tagente AND te.server_id = tasg.id_tmetaconsole_setup';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace macros in any string given an event id.
|
||||
* If server_id > 0, it's a metaconsole query.
|
||||
*
|
||||
* @param integer $event_id Event identifier.
|
||||
* @param integer $value String value in which we want to apply macros.
|
||||
*
|
||||
* @return string The response text with the macros applied.
|
||||
*/
|
||||
function events_get_field_value_by_event_id(
|
||||
int $event_id,
|
||||
$value
|
||||
) {
|
||||
global $config;
|
||||
|
||||
$return = '';
|
||||
$meta = false;
|
||||
$event = db_get_row('tevento', 'id_evento', $event_id);
|
||||
|
||||
// Replace each macro.
|
||||
if (strpos($value, '_agent_address_') !== false) {
|
||||
if ($meta) {
|
||||
$agente_table_name = 'tmetaconsole_agent';
|
||||
$filter = [
|
||||
'id_tagente' => $event['id_agente'],
|
||||
'id_tmetaconsole_setup' => $server_id,
|
||||
];
|
||||
} else {
|
||||
$agente_table_name = 'tagente';
|
||||
$filter = ['id_agente' => $event['id_agente']];
|
||||
}
|
||||
|
||||
$ip = db_get_value_filter('direccion', $agente_table_name, $filter);
|
||||
// If agent does not have an IP, display N/A.
|
||||
if ($ip === false) {
|
||||
$ip = __('N/A');
|
||||
}
|
||||
|
||||
$return = str_replace('_agent_address_', $ip, $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_agent_id_') !== false) {
|
||||
$return = str_replace('_agent_id_', $event['id_agente'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_module_address_') !== false) {
|
||||
if ($event['id_agentmodule'] != 0) {
|
||||
if ($meta) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
|
||||
$module = db_get_row('tagente_modulo', 'id_agente_modulo', $event['id_agentmodule']);
|
||||
if (empty($module['ip_target'])) {
|
||||
$module['ip_target'] = __('N/A');
|
||||
}
|
||||
|
||||
$return = str_replace('_module_address_', $module['ip_target'], $value);
|
||||
if (empty($module['nombre'])) {
|
||||
$module['nombre'] = __('N/A');
|
||||
}
|
||||
|
||||
if ($meta) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
} else {
|
||||
$return = str_replace('_module_address_', __('N/A'), $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($value, '_module_name_') !== false) {
|
||||
if ($event['id_agentmodule'] != 0) {
|
||||
if ($meta) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
|
||||
$module = db_get_row('tagente_modulo', 'id_agente_modulo', $event['id_agentmodule']);
|
||||
if (empty($module['ip_target'])) {
|
||||
$module['ip_target'] = __('N/A');
|
||||
}
|
||||
|
||||
$return = str_replace(
|
||||
'_module_name_',
|
||||
io_safe_output($module['nombre']),
|
||||
$value
|
||||
);
|
||||
|
||||
if ($meta) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
} else {
|
||||
$return = str_replace('_module_name_', __('N/A'), $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_id_') !== false) {
|
||||
$return = str_replace('_event_id_', $event['id_evento'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_user_id_') !== false) {
|
||||
if (!empty($event['id_usuario'])) {
|
||||
$return = str_replace('_user_id_', $event['id_usuario'], $value);
|
||||
} else {
|
||||
$return = str_replace('_user_id_', __('N/A'), $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($value, '_group_id_') !== false) {
|
||||
$return = str_replace('_group_id_', $event['id_grupo'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_group_name_') !== false) {
|
||||
$return = str_replace(
|
||||
'_group_name_',
|
||||
groups_get_name($event['id_grupo'], true),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_utimestamp_') !== false) {
|
||||
$return = str_replace(
|
||||
'_event_utimestamp_',
|
||||
$event['utimestamp'],
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_date_') !== false) {
|
||||
$return = str_replace(
|
||||
'_event_date_',
|
||||
date($config['date_format'], $event['utimestamp']),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_text_') !== false) {
|
||||
$return = str_replace(
|
||||
'_event_text_',
|
||||
events_display_name($event['evento']),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_type_') !== false) {
|
||||
$return = str_replace(
|
||||
'_event_type_',
|
||||
events_print_type_description($event['event_type'], true),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_alert_id_') !== false) {
|
||||
$return = str_replace(
|
||||
'_alert_id_',
|
||||
empty($event['is_alert_am']) ? __('N/A') : $event['is_alert_am'],
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_severity_id_') !== false) {
|
||||
$return = str_replace('_event_severity_id_', $event['criticity'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_severity_text_') !== false) {
|
||||
$return = str_replace(
|
||||
'_event_severity_text_',
|
||||
get_priority_name($event['criticity']),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_module_id_') !== false) {
|
||||
$return = str_replace('_module_id_', $event['id_agentmodule'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_tags_') !== false) {
|
||||
$return = str_replace('_event_tags_', $event['tags'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_extra_id_') !== false) {
|
||||
if (empty($event['id_extra'])) {
|
||||
$return = str_replace('_event_extra_id_', __('N/A'), $value);
|
||||
} else {
|
||||
$return = str_replace('_event_extra_id_', $event['id_extra'], $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_source_') !== false) {
|
||||
$return = str_replace('_event_source_', $event['source'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_instruction_') !== false) {
|
||||
$return = str_replace(
|
||||
'_event_instruction_',
|
||||
events_display_instructions($event['event_type'], $event, false),
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($value, '_owner_user_') !== false) {
|
||||
if (empty($event['owner_user'])) {
|
||||
$return = str_replace('_owner_user_', __('N/A'), $value);
|
||||
} else {
|
||||
$return = str_replace('_owner_user_', $event['owner_user'], $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($value, '_event_status_') !== false) {
|
||||
$event_st = events_display_status($event['estado']);
|
||||
$return = str_replace('_event_status_', $event_st['title'], $value);
|
||||
}
|
||||
|
||||
if (strpos($value, '_group_custom_id_') !== false) {
|
||||
$group_custom_id = db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT custom_id FROM tgrupo WHERE id_grupo=%s',
|
||||
$event['id_grupo']
|
||||
)
|
||||
);
|
||||
$event_st = events_display_status($event['estado']);
|
||||
$return = str_replace('_group_custom_id_', $group_custom_id, $value);
|
||||
}
|
||||
|
||||
// Parse the event custom data.
|
||||
if (!empty($event['custom_data'])) {
|
||||
$custom_data = json_decode(base64_decode($event['custom_data']));
|
||||
foreach ($custom_data as $key => $val) {
|
||||
$return = str_replace('_customdata_'.$key.'_', $val, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// This will replace the macro with the current logged user.
|
||||
if (strpos($value, '_current_user_') !== false) {
|
||||
$return = str_replace('_current_user_', $config['id_user'], $value);
|
||||
}
|
||||
|
||||
if (empty($return)) {
|
||||
return $value;
|
||||
} else {
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], 0, 'IW') && ! check_acl($config['id_user'], 0, 'IM')) {
|
||||
// Doesn't have access to this page.
|
||||
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
ui_print_page_header(__('Create Integria IMS Incident'), '', false, '', false, '');
|
||||
|
||||
// Check if Integria integration enabled.
|
||||
if ($config['integria_enabled'] == 0) {
|
||||
ui_print_error_message(__('Integria integration must be enabled in Pandora setup'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check connection to Integria IMS API.
|
||||
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
|
||||
|
||||
if ($has_connection === false) {
|
||||
ui_print_error_message(__('Integria IMS API is not reachable'));
|
||||
return;
|
||||
}
|
||||
|
||||
// If everything OK, get parameters from Integria IMS API.
|
||||
$group_values = [];
|
||||
$integria_criticity_values = [];
|
||||
$integria_users_values = [];
|
||||
$integria_types_values = [];
|
||||
|
||||
$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', []);
|
||||
|
||||
get_array_from_csv_data($integria_groups_csv, $group_values);
|
||||
|
||||
$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', []);
|
||||
|
||||
get_array_from_csv_data($integria_criticity_levels_csv, $integria_criticity_values);
|
||||
|
||||
$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []);
|
||||
|
||||
$csv_array = explode("\n", $integria_users_csv);
|
||||
|
||||
foreach ($csv_array as $csv_line) {
|
||||
if (!empty($csv_line)) {
|
||||
$integria_users_values[$csv_line] = $csv_line;
|
||||
}
|
||||
}
|
||||
|
||||
$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', []);
|
||||
|
||||
get_array_from_csv_data($integria_types_csv, $integria_types_values);
|
||||
|
||||
$event_id = (int) get_parameter('from_event');
|
||||
$create_incident = (int) get_parameter('create_incident', 0);
|
||||
$incident_group_id = (int) get_parameter('default_group');
|
||||
$incident_default_criticity_id = (int) get_parameter('default_criticity');
|
||||
$incident_default_owner = (int) get_parameter('default_owner');
|
||||
$incident_type = (int) get_parameter('incident_type');
|
||||
$incident_title = events_get_field_value_by_event_id($event_id, get_parameter('incident_title'));
|
||||
$incident_content = events_get_field_value_by_event_id($event_id, get_parameter('incident_content'));
|
||||
|
||||
if ($create_incident === 1) {
|
||||
// Call Integria IMS API method to create an incident.
|
||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'create_incident', [$incident_title, $incident_group_id, $incident_default_criticity_id, $incident_content, '', '0', '', 'admin', '0', '1']);
|
||||
|
||||
$incident_created_ok = ($result_api_call != false) ? true : false;
|
||||
|
||||
ui_print_result_message(
|
||||
$incident_created_ok,
|
||||
__('Successfully created'),
|
||||
__('Could not be created')
|
||||
);
|
||||
}
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->id = 'add_alert_table';
|
||||
$table->class = 'databox filters';
|
||||
$table->head = [];
|
||||
|
||||
$table->data = [];
|
||||
$table->size = [];
|
||||
$table->size = [];
|
||||
$table->size[0] = '15%';
|
||||
$table->size[1] = '90%';
|
||||
|
||||
$table->data[0][0] = __('Group');
|
||||
$table->data[0][1] = html_print_select(
|
||||
$group_values,
|
||||
'default_group',
|
||||
$config['default_group'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
|
||||
$table->data[1][0] = __('Default Criticity');
|
||||
$table->data[1][1] = html_print_select(
|
||||
$integria_criticity_values,
|
||||
'default_criticity',
|
||||
$config['default_criticity'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
|
||||
$table->data[2][0] = __('Default Owner');
|
||||
$table->data[2][1] = html_print_select(
|
||||
$integria_users_values,
|
||||
'default_owner',
|
||||
$config['default_owner'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
|
||||
$table->data[0][2] = __('Incident Type');
|
||||
$table->data[0][3] = html_print_select(
|
||||
$integria_types_values,
|
||||
'incident_type',
|
||||
$config['incident_type'],
|
||||
'',
|
||||
__('Select'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
|
||||
$table->data[1][2] = __('Incident title').ui_print_help_icon('response_macros', true);
|
||||
$table->data[1][3] = html_print_input_text(
|
||||
'incident_title',
|
||||
$config['incident_title'],
|
||||
__('Name'),
|
||||
50,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[2][2] = __('Incident content').ui_print_help_icon('response_macros', true);
|
||||
$table->data[2][3] = html_print_input_text(
|
||||
'incident_content',
|
||||
$config['incident_content'],
|
||||
'',
|
||||
50,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
echo '<form name="create_integria_incident_form" method="POST">';
|
||||
html_print_table($table);
|
||||
html_print_input_hidden('create_incident', 1);
|
||||
echo '<div style="width: 100%; text-align:right;">';
|
||||
html_print_submit_button(__('Create'), 'accion', false, 'class="sub wand"');
|
||||
echo '</div>';
|
||||
echo '</form>';
|
|
@ -479,6 +479,7 @@ if (check_acl($config['id_user'], 0, 'IR')
|
|||
$sub2 = [];
|
||||
$sub2['operation/incidents/incident']['text'] = __('List of Incidents');
|
||||
$sub2[$sec2sub]['text'] = __('Statistics');
|
||||
$sub2['operation/incidents/configure_integriaims_incident']['text'] = __('Create Integria IMS Incident');
|
||||
|
||||
$sub[$sec2]['sub2'] = $sub2;
|
||||
$sec2 = $temp_sec2;
|
||||
|
|
|
@ -38,6 +38,7 @@ Where options:
|
|||
Optional parameters:
|
||||
|
||||
[-priority <priority>] : 10 Maintance, 0 Informative, 1 Low, 2 Medium, 3 Serious, 4 Very serious
|
||||
[-owner <owner>] : Free text
|
||||
[-desc <description>] : Free text
|
||||
[-type <ticket_type>] : Type ID (must exist in Integria IMS)
|
||||
[-inventory <inventory_id>] : Inventory ID (must exist in Integria IMS)
|
||||
|
@ -94,6 +95,7 @@ sub tool_api_main () {
|
|||
my $ticket_name = "";
|
||||
my $group_id = -1;
|
||||
my $ticket_priority = 0;
|
||||
my $ticket_owner = '';
|
||||
my $ticket_description = '';
|
||||
my $ticket_type = '';
|
||||
my $ticket_inventory = '';
|
||||
|
@ -155,6 +157,9 @@ sub tool_api_main () {
|
|||
if ($line eq '-priority') {
|
||||
$ticket_priority = $ARGV[$i + 1];
|
||||
}
|
||||
if ($line eq '-owner') {
|
||||
$ticket_owner = $ARGV[$i + 1];
|
||||
}
|
||||
if ($line eq '-desc') {
|
||||
$ticket_description = $ARGV[$i + 1];
|
||||
}
|
||||
|
@ -193,6 +198,7 @@ sub tool_api_main () {
|
|||
$data_ticket = $ticket_name .
|
||||
"|;|" . $group_id .
|
||||
"|;|" . $ticket_priority .
|
||||
"|;|" . $ticket_owner .
|
||||
"|;|" . $ticket_description .
|
||||
"|;|" . $ticket_inventory .
|
||||
"|;|" . $ticket_type .
|
||||
|
|
Loading…
Reference in New Issue