Added timeoout option to command event responses
This commit is contained in:
parent
325eff607e
commit
6ba4a26564
|
@ -0,0 +1,5 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tevent_response` ADD COLUMN `command_timeout` int(5) unsigned NOT NULL DEFAULT 90;
|
||||
|
||||
COMMIT;
|
|
@ -1776,6 +1776,7 @@ ALTER TABLE tserver ADD COLUMN exec_proxy tinyint(1) UNSIGNED NOT NULL default 0
|
|||
-- Table `tevent_response`
|
||||
-- ---------------------------------------------------------------------
|
||||
ALTER TABLE tevent_response ADD COLUMN server_to_exec int(10) unsigned NOT NULL DEFAULT 0;
|
||||
ALTER TABLE tevent_response ADD COLUMN command_timeout int(5) unsigned NOT NULL DEFAULT 90;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tmodule`
|
||||
|
|
|
@ -52,6 +52,7 @@ if ($event_response_id > 0) {
|
|||
$event_response['modal_height'] = 0;
|
||||
$event_response['params'] = '';
|
||||
$event_response['server_to_exec'] = '';
|
||||
$event_response['command_timeout'] = 90;
|
||||
}
|
||||
|
||||
$table = new stdClass();
|
||||
|
@ -175,6 +176,11 @@ $data[3] = '<div id="server_to_exec_value" style="display:none;">'.html_print_se
|
|||
|
||||
$table->data[4] = $data;
|
||||
|
||||
$data = [];
|
||||
$data[0] = '<div id="command_timeout_label" style="display:none;" class="labels">'.__('Command timeout (s)');
|
||||
$data[1] = '<div id="command_timeout_value" style="display:none;">'.html_print_input_text('command_timeout', $event_response['command_timeout'], '', 4, 5, true);
|
||||
|
||||
$table->data[5] = $data;
|
||||
if ($event_response_id == 0) {
|
||||
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/events§ion=responses&mode=list&action=create_response&pure='.$config['pure'].'">';
|
||||
html_print_table($table);
|
||||
|
@ -214,11 +220,17 @@ $('#type').change(function() {
|
|||
$('#new_window').attr('disabled','disabled');
|
||||
$('#server_to_exec_label').css('display','');
|
||||
$('#server_to_exec_value').css('display','');
|
||||
$('#command_timeout_label').css('display','');
|
||||
$('#command_timeout_value').css('display','');
|
||||
|
||||
break;
|
||||
case 'url':
|
||||
$('#new_window').removeAttr('disabled');
|
||||
$('#server_to_exec_label').css('display','none');
|
||||
$('#server_to_exec_value').css('display','none');
|
||||
$('#command_timeout_label').css('display','none');
|
||||
$('#command_timeout_value').css('display','none');
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -42,6 +42,7 @@ switch ($action) {
|
|||
$values['new_window'] = get_parameter('new_window');
|
||||
$values['params'] = get_parameter('params');
|
||||
$values['server_to_exec'] = get_parameter('server_to_exec');
|
||||
$values['command_timeout'] = get_parameter('command_timeout', 90);
|
||||
|
||||
$result = event_responses_create_response($values);
|
||||
|
||||
|
@ -65,6 +66,8 @@ switch ($action) {
|
|||
$values['params'] = get_parameter('params');
|
||||
$values['server_to_exec'] = get_parameter('server_to_exec');
|
||||
$response_id = get_parameter('id_response', 0);
|
||||
$values['command_timeout'] = get_parameter('command_timeout', '90');
|
||||
|
||||
|
||||
$result = event_responses_update_response($response_id, $values);
|
||||
|
||||
|
|
|
@ -921,6 +921,8 @@ if ($perform_event_response) {
|
|||
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
|
||||
$command_timeout = $event_response['command_timeout'];
|
||||
|
||||
if (enterprise_installed()) {
|
||||
if ($event_response['server_to_exec'] != 0 && $event_response['type'] == 'command') {
|
||||
$commandExclusions = [
|
||||
|
@ -952,7 +954,7 @@ if ($perform_event_response) {
|
|||
break;
|
||||
}
|
||||
|
||||
system('ssh pandora_exec_proxy@'.$server_data['ip_address'].' "'.$timeout_bin.' 90 '.io_safe_output($command).' 2>&1"', $ret_val);
|
||||
system('ssh pandora_exec_proxy@'.$server_data['ip_address'].' "'.$timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1"', $ret_val);
|
||||
}
|
||||
} else {
|
||||
switch (PHP_OS) {
|
||||
|
@ -969,7 +971,7 @@ if ($perform_event_response) {
|
|||
break;
|
||||
}
|
||||
|
||||
system($timeout_bin.' 90 '.io_safe_output($command).' 2>&1');
|
||||
system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val);
|
||||
}
|
||||
} else {
|
||||
switch (PHP_OS) {
|
||||
|
@ -986,7 +988,13 @@ if ($perform_event_response) {
|
|||
break;
|
||||
}
|
||||
|
||||
system($timeout_bin.' 90 '.io_safe_output($command).' 2>&1');
|
||||
system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val);
|
||||
}
|
||||
|
||||
if ($ret_val != 0) {
|
||||
echo "<div style='text-align:left'>";
|
||||
echo __('Error executing response');
|
||||
echo '</div><br>';
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -14426,7 +14426,7 @@ function api_set_delete_event_response($id_response, $trash1, $trash2, $returnTy
|
|||
* @param mixed $other. Serialized params
|
||||
* @param $returnType
|
||||
* Example:
|
||||
* api.php?op=set&op2=create_event_response&other=response%7Cdescription%20response%7Ctouch%7Ccommand%7C0%7C650%7C400%7C0%7Cresponse%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
|
||||
* api.php?op=set&op2=create_event_response&other=response%7Cdescription%20response%7Ctouch%7Ccommand%7C0%7C650%7C400%7C0%7Cresponse%7C0%7C90&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
|
||||
*/
|
||||
function api_set_create_event_response($trash1, $trash2, $other, $returnType)
|
||||
{
|
||||
|
@ -14449,6 +14449,7 @@ function api_set_create_event_response($trash1, $trash2, $other, $returnType)
|
|||
$values['new_window'] = $other['data'][7];
|
||||
$values['params'] = $other['data'][8];
|
||||
$values['server_to_exec'] = $other['data'][9];
|
||||
$values['command_timeout'] = $other['data'][10];
|
||||
|
||||
// Error if user has not permission for the group.
|
||||
if (!check_acl($config['id_user'], $values['id_group'], 'PM')) {
|
||||
|
@ -14468,7 +14469,7 @@ function api_set_create_event_response($trash1, $trash2, $other, $returnType)
|
|||
* @param mixed $other. Serialized params
|
||||
* @param $returnType
|
||||
* Example:
|
||||
* api.php?op=set&op2=update_event_response&id=7&other=response%7Cdescription%20response%7Ctouch%7Ccommand%7C0%7C650%7C400%7C0%7Cresponse%7C0&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
|
||||
* api.php?op=set&op2=update_event_response&id=7&other=response%7Cdescription%20response%7Ctouch%7Ccommand%7C0%7C650%7C400%7C0%7Cresponse%7C0%7C90&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
|
||||
*/
|
||||
function api_set_update_event_response($id_response, $trash1, $other, $returnType)
|
||||
{
|
||||
|
@ -14504,6 +14505,7 @@ function api_set_update_event_response($id_response, $trash1, $other, $returnTyp
|
|||
$values['new_window'] = $other['data'][7] == '' ? $event_response['new_window'] : $other['data'][7];
|
||||
$values['params'] = $other['data'][8] == '' ? $event_response['params'] : $other['data'][8];
|
||||
$values['server_to_exec'] = $other['data'][9] == '' ? $event_response['server_to_exec'] : $other['data'][9];
|
||||
$values['command_timeout'] = $other['data'][10] == '' ? $event_response['command_timeout'] : $other['data'][10];
|
||||
|
||||
// Error if user has not permission for the group.
|
||||
if (!check_acl($config['id_user'], $values['id_group'], 'PM')) {
|
||||
|
|
|
@ -2069,6 +2069,7 @@ CREATE TABLE IF NOT EXISTS `tevent_response` (
|
|||
`new_window` TINYINT(4) NOT NULL DEFAULT 0,
|
||||
`params` TEXT NOT NULL,
|
||||
`server_to_exec` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
`command_timeout` int(5) unsigned NOT NULL DEFAULT 90,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
|
@ -1184,7 +1184,7 @@ INSERT INTO `tagent_custom_fields` VALUES (1,'Serial Number',0,0,''),(2,'De
|
|||
|
||||
INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://artica.es','',''),(2,'critical','Critical modules','','',''),(3,'dmz','DMZ Network Zone','','',''),(4,'performance','Performance anda capacity modules','','',''),(5,'configuration','','','','');
|
||||
|
||||
INSERT INTO `tevent_response` VALUES (1,'Ping to host','Ping to the agent host','ping -c 5 _agent_address_','command',0,620,500,0,'',0),(3,'Create incident from event','Create a incident from the event with the standard incidents system of Pandora FMS','index.php?sec=workspace&sec2=operation/incidents/incident_detail&insert_form&from_event=_event_id_','url',0,0,0,1,'',0),(5,'Restart agent','Restart the agent with using UDP protocol.

To use this response is necessary to have installed Pandora FMS server and console in the same machine.','/usr/share/pandora_server/util/udp_client.pl _agent_address_ 41122 "REFRESH AGENT"','command',0,620,500,0,'',0),(6,'Ping to module agent host','Ping to the module agent host','ping -c 5 _module_address_','command',0,620,500,0,'',0);
|
||||
INSERT INTO `tevent_response` VALUES (1,'Ping to host','Ping to the agent host','ping -c 5 _agent_address_','command',0,620,500,0,'',0,90),(3,'Create incident from event','Create a incident from the event with the standard incidents system of Pandora FMS','index.php?sec=workspace&sec2=operation/incidents/incident_detail&insert_form&from_event=_event_id_','url',0,0,0,1,'',0,90),(5,'Restart agent','Restart the agent with using UDP protocol.

To use this response is necessary to have installed Pandora FMS server and console in the same machine.','/usr/share/pandora_server/util/udp_client.pl _agent_address_ 41122 "REFRESH AGENT"','command',0,620,500,0,'',0,90),(6,'Ping to module agent host','Ping to the module agent host','ping -c 5 _module_address_','command',0,620,500,0,'',0,90);
|
||||
|
||||
INSERT INTO `tupdate_settings` VALUES ('current_update', '412'), ('customer_key', 'PANDORA-FREE'), ('updating_binary_path', 'Path where the updated binary files will be stored'), ('updating_code_path', 'Path where the updated code is stored'), ('dbname', ''), ('dbhost', ''), ('dbpass', ''), ('dbuser', ''), ('dbport', ''), ('proxy', ''), ('proxy_port', ''), ('proxy_user', ''), ('proxy_pass', '');
|
||||
|
||||
|
|
Loading…
Reference in New Issue