2006-03-27 05:37:27 +02:00
|
|
|
<?php
|
2008-08-22 20:07:32 +02:00
|
|
|
|
2009-06-08 20:21:21 +02:00
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
2010-03-04 17:08:09 +01:00
|
|
|
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
2009-06-08 20:21:21 +02:00
|
|
|
// Please see http://pandorafms.org for full contribution list
|
2006-07-17 10:17:58 +02:00
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
2008-08-22 20:07:32 +02:00
|
|
|
// as published by the Free Software Foundation for version 2.
|
2006-07-17 10:17:58 +02:00
|
|
|
// 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
|
2010-03-03 18:10:37 +01:00
|
|
|
global $config;
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
require_once 'include/functions_servers.php';
|
|
|
|
require_once 'include/functions_graph.php';
|
2006-07-17 10:17:58 +02:00
|
|
|
|
2008-07-25 20:37:32 +02:00
|
|
|
check_login();
|
2006-03-27 05:37:27 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if (! check_acl($config['id_user'], 0, 'AW')) {
|
|
|
|
db_pandora_audit(
|
|
|
|
'ACL Violation',
|
|
|
|
'Trying to access Server Management'
|
|
|
|
);
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
exit;
|
2008-07-25 20:37:32 +02:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if (isset($_GET['server'])) {
|
|
|
|
$id_server = get_parameter_get('server');
|
2020-05-29 11:37:06 +02:00
|
|
|
// Headers.
|
2019-01-30 16:18:44 +01:00
|
|
|
ui_print_page_header(__('Update Server'), 'images/gm_servers.png', false, 'servers', true);
|
2020-01-14 15:43:17 +01:00
|
|
|
$sql = sprintf('SELECT name, ip_address, description, server_type, exec_proxy, port FROM tserver WHERE id_server = %d', $id_server);
|
2019-01-30 16:18:44 +01:00
|
|
|
$row = db_get_row_sql($sql);
|
|
|
|
echo '<form name="servers" method="POST" action="index.php?sec=gservers&sec2=godmode/servers/modificar_server&update=1">';
|
|
|
|
html_print_input_hidden('server', $id_server);
|
|
|
|
|
|
|
|
$server_type = __('Standard');
|
|
|
|
if ($row['server_type'] == 13) {
|
|
|
|
$server_type = __('Satellite');
|
|
|
|
}
|
|
|
|
|
|
|
|
$exec_server_enable = __('No');
|
|
|
|
if ($row['exec_proxy'] == 1) {
|
|
|
|
$exec_server_enable = __('Yes');
|
|
|
|
}
|
|
|
|
|
|
|
|
$table->cellpadding = 4;
|
|
|
|
$table->cellspacing = 4;
|
|
|
|
$table->width = '100%';
|
|
|
|
$table->class = 'databox filters';
|
|
|
|
|
|
|
|
$table->data[] = [
|
|
|
|
__('Name'),
|
|
|
|
$row['name'],
|
|
|
|
];
|
|
|
|
$table->data[] = [
|
|
|
|
__('IP Address'),
|
|
|
|
html_print_input_text('address', $row['ip_address'], '', 50, 0, true),
|
|
|
|
];
|
|
|
|
$table->data[] = [
|
|
|
|
__('Description'),
|
|
|
|
html_print_input_text('description', $row['description'], '', 50, 0, true),
|
|
|
|
];
|
|
|
|
|
|
|
|
if (enterprise_installed()) {
|
|
|
|
$table->data[] = [
|
|
|
|
__('Type'),
|
|
|
|
$server_type,
|
|
|
|
];
|
|
|
|
if ($row['server_type'] == 13 || $row['server_type'] == 1) {
|
|
|
|
$table->data[] = [
|
|
|
|
__('Exec Server'),
|
|
|
|
html_print_checkbox('exec_proxy', 1, $row['exec_proxy'], true),
|
|
|
|
];
|
2020-01-14 15:43:17 +01:00
|
|
|
|
|
|
|
$port_number = empty($row['port']) ? '' : $row['port'];
|
|
|
|
|
|
|
|
$table->data[] = [
|
|
|
|
__('Port'),
|
|
|
|
html_print_input_text('port', $port_number, '', 10, 0, true).ui_print_help_tip(__('Leave blank to use SSH default port (22)'), true),
|
|
|
|
];
|
2020-01-15 15:37:42 +01:00
|
|
|
|
|
|
|
if ($row['exec_proxy']) {
|
|
|
|
$table->data[] = [
|
|
|
|
__('Check Exec Server'),
|
|
|
|
'<a id="check_exec_server">'.html_print_image('images/dot_red.disabled.png', true).'</a>'.'<div id="check_error_message"></div>',
|
|
|
|
];
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
html_print_table($table);
|
|
|
|
|
|
|
|
echo '<div class="action-buttons" style="width: 100%">';
|
|
|
|
echo '<input type="submit" class="sub upd" value="'.__('Update').'">';
|
|
|
|
echo '</div>';
|
|
|
|
} else if (isset($_GET['server_remote'])) {
|
2020-05-29 11:37:06 +02:00
|
|
|
// Headers.
|
2019-01-30 16:18:44 +01:00
|
|
|
$id_server = get_parameter_get('server_remote');
|
|
|
|
$ext = get_parameter('ext', '');
|
|
|
|
ui_print_page_header(__('Remote Configuration'), 'images/gm_servers.png', false, 'servers', true);
|
|
|
|
enterprise_include('godmode/servers/server_disk_conf_editor.php');
|
|
|
|
} else {
|
2020-05-29 11:37:06 +02:00
|
|
|
// Header.
|
|
|
|
ui_print_page_header(__('%s servers', get_product_name()), 'images/gm_servers.png', false, '', true);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2020-05-29 11:37:06 +02:00
|
|
|
// Move SNMP modules back to the enterprise server.
|
2019-01-30 16:18:44 +01:00
|
|
|
if (isset($_GET['server_reset_snmp_enterprise'])) {
|
|
|
|
$result = db_process_sql('UPDATE tagente_estado SET last_error=0');
|
|
|
|
|
|
|
|
if ($result === false) {
|
|
|
|
ui_print_error_message(__('Unsuccessfull action'));
|
|
|
|
} else {
|
|
|
|
ui_print_success_message(__('Successfully action'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-29 11:37:06 +02:00
|
|
|
// Reset module count.
|
2019-01-30 16:18:44 +01:00
|
|
|
if (isset($_GET['server_reset_counts'])) {
|
|
|
|
$reslt = db_process_sql('UPDATE tagente SET update_module_count=1, update_alert_count=1');
|
|
|
|
|
|
|
|
if ($result === false) {
|
|
|
|
ui_print_error_message(__('Unsuccessfull action'));
|
|
|
|
} else {
|
|
|
|
ui_print_success_message(__('Successfully action'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_GET['delete'])) {
|
|
|
|
$id_server = get_parameter_get('server_del');
|
|
|
|
|
|
|
|
$result = db_process_sql_delete('tserver', ['id_server' => $id_server]);
|
|
|
|
|
|
|
|
if ($result !== false) {
|
|
|
|
ui_print_success_message(__('Server deleted successfully'));
|
|
|
|
} else {
|
|
|
|
ui_print_error_message(__('There was a problem deleting the server'));
|
|
|
|
}
|
|
|
|
} else if (isset($_GET['update'])) {
|
2020-06-26 10:11:41 +02:00
|
|
|
$address = trim(get_parameter_post('address'), ' ');
|
|
|
|
$description = trim(get_parameter_post('description'), ' ');
|
2019-01-30 16:18:44 +01:00
|
|
|
$id_server = get_parameter_post('server');
|
|
|
|
$exec_proxy = get_parameter_post('exec_proxy');
|
2020-01-14 15:43:17 +01:00
|
|
|
$port = get_parameter_post('port');
|
|
|
|
|
|
|
|
$port_number = empty($port) ? 0 : $port;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
$values = [
|
|
|
|
'ip_address' => $address,
|
|
|
|
'description' => $description,
|
|
|
|
'exec_proxy' => $exec_proxy,
|
2020-01-14 15:43:17 +01:00
|
|
|
'port' => $port_number,
|
2019-01-30 16:18:44 +01:00
|
|
|
];
|
|
|
|
$result = db_process_sql_update('tserver', $values, ['id_server' => $id_server]);
|
|
|
|
if ($result !== false) {
|
|
|
|
ui_print_success_message(__('Server updated successfully'));
|
|
|
|
} else {
|
|
|
|
ui_print_error_message(__('There was a problem updating the server'));
|
|
|
|
}
|
|
|
|
} else if (isset($_GET['delete_conf_file'])) {
|
|
|
|
$correct = false;
|
|
|
|
$id_server = get_parameter('id_server');
|
|
|
|
$ext = get_parameter('ext', '');
|
|
|
|
$server_md5 = md5(io_safe_output(servers_get_name($id_server, 'none').$ext), false);
|
|
|
|
|
|
|
|
if (file_exists($config['remote_config'].'/md5/'.$server_md5.'.srv.md5')) {
|
2020-05-29 11:37:06 +02:00
|
|
|
// Server remote configuration editor.
|
2019-01-30 16:18:44 +01:00
|
|
|
$file_name = $config['remote_config'].'/conf/'.$server_md5.'.srv.conf';
|
|
|
|
$correct = @unlink($file_name);
|
|
|
|
|
|
|
|
$file_name = $config['remote_config'].'/md5/'.$server_md5.'.srv.md5';
|
|
|
|
$correct = @unlink($file_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui_print_result_message(
|
|
|
|
$correct,
|
|
|
|
__('Conf file deleted successfully'),
|
|
|
|
__('Could not delete conf file')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$tiny = false;
|
|
|
|
include $config['homedir'].'/godmode/servers/servers.build_table.php';
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
2013-03-19 19:32:25 +01:00
|
|
|
?>
|
2017-08-23 15:01:09 +02:00
|
|
|
|
|
|
|
<script language="javascript" type="text/javascript">
|
|
|
|
|
|
|
|
$(document).ready (function () {
|
2019-01-30 16:18:44 +01:00
|
|
|
$("#check_exec_server img").on("click", function () {
|
|
|
|
$("#check_exec_server img").attr("src", "images/spinner.gif");
|
2017-08-23 15:01:09 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
check_process("<?php echo $id_server; ?>");
|
|
|
|
});
|
2017-08-23 15:01:09 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
function check_process (id_server) {
|
2019-01-30 16:18:44 +01:00
|
|
|
var parameters = {};
|
|
|
|
parameters['page'] = 'enterprise/include/ajax/servers.ajax';
|
|
|
|
parameters['check_exec_server'] = 1;
|
|
|
|
parameters['id_server'] = id_server;
|
|
|
|
|
|
|
|
jQuery.post(
|
|
|
|
"ajax.php",
|
|
|
|
parameters,
|
|
|
|
function (data) {
|
|
|
|
if (data['correct']) {
|
|
|
|
$("#check_exec_server img").attr("src", "images/dot_green.png");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#check_exec_server img").attr("src", "images/dot_red.png");
|
|
|
|
$("#check_error_message").empty();
|
|
|
|
$("#check_error_message").append("<span>" + data['message'] + "</span>");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
2017-08-23 15:01:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|