2014-05-27 Alejandro Gallardo <alejandro.gallardo@artica.es>

* extensions/files_repo.php: Fixed a weird error when
	uploading big files.

	* godmode/setup/setup_general.php,
	include/functions_config.php: Now is possible to set
	a custom path to the pandora server logs.

	* extensions/pandora_logs.php,
	extensions/system_info.php: Now the custom server log path
	is used if exists.

	* include/functions.php: Now the function "get_file_upload_status"
	returns -1 when the $_FILES array is empty.

	* include/config_process.php: Fixed an error that could
	avoid the log in pandora_console.log.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10023 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
alexhigh 2014-05-27 17:05:37 +00:00
parent e6c1085660
commit d99fee01ce
8 changed files with 60 additions and 13 deletions

View File

@ -1,3 +1,22 @@
2014-05-27 Alejandro Gallardo <alejandro.gallardo@artica.es>
* extensions/files_repo.php: Fixed a weird error when
uploading big files.
* godmode/setup/setup_general.php,
include/functions_config.php: Now is possible to set
a custom path to the pandora server logs.
* extensions/pandora_logs.php,
extensions/system_info.php: Now the custom server log path
is used if exists.
* include/functions.php: Now the function "get_file_upload_status"
returns -1 when the $_FILES array is empty.
* include/config_process.php: Fixed an error that could
avoid the log in pandora_console.log.
2014-05-27 Miguel de Dios <miguel.dedios@artica.es>
* godmode/reporting/graph_builder.main.php,

View File

@ -123,12 +123,18 @@ function pandora_files_repo_godmode () {
return;
}
// Check for an anoying error that causes the $_POST and $_FILES arrays
// were empty if the file is larger than the post_max_size
if (intval($_SERVER['CONTENT_LENGTH']) > 0 && empty($_POST)) {
ui_print_error_message(__('The file exceeds the maximum size'));
}
// GET and POST parameters
$file_id = (int) get_parameter ("file_id");
$add_file = (bool) get_parameter ("add_file");
$update_file = (bool) get_parameter ("update_file");
$delete_file = (bool) get_parameter ("delete");
// File add or update
if ( $add_file || ($update_file && $file_id > 0) ) {
$groups = get_parameter ("groups", array());

View File

@ -73,12 +73,14 @@ function pandoralogs_extension_main () {
echo "<p>" . __('This tool is used just to view your Pandora FMS system logfiles directly from console') . "</p>";
$logs_directory = (!empty($config["server_log_dir"])) ? io_safe_output($config["server_log_dir"]) : "/var/log/pandora";
view_logfile ($config["homedir"]."/pandora_console.log");
view_logfile ("/var/log/pandora/pandora_server.log");
view_logfile ("/var/log/pandora/pandora_server.error");
view_logfile ($logs_directory."/pandora_server.log");
view_logfile ($logs_directory."/pandora_server.error");
}
extensions_add_godmode_menu_option (__('System logfiles'), 'PM','glog', null, "v1r1");
extensions_add_godmode_function('pandoralogs_extension_main');
?>
?>

View File

@ -76,6 +76,8 @@ function getPandoraDiagnostic(&$systemInfo) {
}
function getSystemInfo(&$systemInfo, $script = false) {
global $config;
$systemInfo['system_name'] = php_uname('s');
$systemInfo['system_host'] = php_uname('n');
$systemInfo['system_release'] = php_uname('r');
@ -127,8 +129,10 @@ function getSystemInfo(&$systemInfo, $script = false) {
}
}
$systemInfo['process'] = $process;
$logs_directory = (!empty($config["server_log_dir"])) ? io_safe_output($config["server_log_dir"]) : "/var/log/pandora";
$result = shell_exec('du -h /var/log/pandora | cut -d"/" -f1');
$result = shell_exec('du -h ' . $logs_directory . ' | cut -d"/" -f1');
$systemInfo['size_var_log_pandora'] = $result;
$result = shell_exec('date');
@ -180,10 +184,12 @@ function logFilesLines($file_name, $numLines) {
function getLastLog($numLines = 2000) {
global $config;
$logs_directory = (!empty($config["server_log_dir"])) ? io_safe_output($config["server_log_dir"]) : "/var/log/pandora";
show_logfile($config["homedir"]."/pandora_console.log", $numLines);
show_logfile("/var/log/pandora/pandora_server.log", $numLines);
show_logfile("/var/log/pandora/pandora_server.error", $numLines);
show_logfile($logs_directory."/pandora_server.log", $numLines);
show_logfile($logs_directory."/pandora_server.error", $numLines);
show_logfile("/etc/mysql/my.cnf", $numLines);
show_logfile($config["homedir"]."/include/config.php", $numLines);
show_logfile("/etc/pandora/pandora_server.conf", $numLines);
@ -386,13 +392,15 @@ function mainSystemInfo() {
$zip->addFile($tempDir . 'system_info.txt', 'system_info.txt');
}
$server_logs_directory = (!empty($config["server_log_dir"])) ? io_safe_output($config["server_log_dir"]) : "/var/log/pandora";
if ($log_info) {
file_put_contents($tempDir . 'pandora_console.log.lines_' . $log_num_lines, getLastLinesLog($config["homedir"]."/pandora_console.log", $log_num_lines));
$zip->addFile($tempDir . 'pandora_console.log.lines_' . $log_num_lines, 'pandora_console.log.lines_' . $log_num_lines);
file_put_contents($tempDir . 'pandora_server.log.lines_' . $log_num_lines, getLastLinesLog("/var/log/pandora/pandora_server.log", $log_num_lines));
file_put_contents($tempDir . 'pandora_server.log.lines_' . $log_num_lines, getLastLinesLog($server_logs_directory."/pandora_server.log", $log_num_lines));
$zip->addFile($tempDir . 'pandora_server.log.lines_' . $log_num_lines, 'pandora_server.log.lines_' . $log_num_lines);
file_put_contents($tempDir . 'pandora_server.error.lines_' . $log_num_lines, getLastLinesLog("/var/log/pandora/pandora_server.error", $log_num_lines));
file_put_contents($tempDir . 'pandora_server.error.lines_' . $log_num_lines, getLastLinesLog($server_logs_directory."/pandora_server.error", $log_num_lines));
$zip->addFile($tempDir . 'pandora_server.error.lines_' . $log_num_lines, 'pandora_server.error.lines_' . $log_num_lines);
file_put_contents($tempDir . 'my.cnf.lines_' . $log_num_lines, getLastLinesLog("/etc/mysql/my.cnf", $log_num_lines));
$zip->addFile($tempDir . 'my.cnf.lines_' . $log_num_lines, 'my.cnf.lines_' . $log_num_lines);
@ -519,6 +527,8 @@ function consoleMode() {
if ($pandoraConfFiles) {
$lines = 2000;
$system_logs_directory = (!empty($config["server_log_dir"])) ? io_safe_output($config["server_log_dir"]) : "/var/log/pandora";
$file = fopen($tempDir . 'pandora_console.log' . $lines, 'w');
if ($file !== false) {
@ -532,7 +542,7 @@ function consoleMode() {
$file = fopen($tempDir . 'pandora_server.log' . $lines, 'w');
if ($file !== false) {
ob_start();
echo getLastLinesLog("/var/log/pandora/pandora_server.log", $lines);
echo getLastLinesLog($system_logs_directory."/pandora_server.log", $lines);
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
@ -541,7 +551,7 @@ function consoleMode() {
$file = fopen($tempDir . 'pandora_server.error' . $lines, 'w');
if ($file !== false) {
ob_start();
echo getLastLinesLog("/var/log/pandora/pandora_server.error", $lines);
echo getLastLinesLog($system_logs_directory."/pandora_server.error", $lines);
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
@ -586,7 +596,7 @@ function consoleMode() {
$file = fopen($tempDir . 'pandora_server.error' . $lines, 'w');
if ($file !== false) {
ob_start();
echo getLastLinesLog("/var/log/pandora/pandora_server.error", $lines);
echo getLastLinesLog($system_logs_directory."/pandora_server.error", $lines);
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
@ -595,7 +605,7 @@ function consoleMode() {
$file = fopen($tempDir . 'pandora_server.log' . $lines, 'w');
if ($file !== false) {
ob_start();
echo getLastLinesLog("/var/log/pandora/pandora_server.log", $lines);
echo getLastLinesLog($system_logs_directory."/pandora_server.log", $lines);
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);

View File

@ -244,6 +244,9 @@ $table->data[31][0] = __('Command Snapshot') .
$table->data[31][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('command_snapshot', 1, '', $config["command_snapshot"], true).'&nbsp;&nbsp;';
$table->data[31][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('command_snapshot', 0, '', $config["command_snapshot"], true);
$table->data[32][0] = __('Server logs directory') . ui_print_help_tip (__("Directory where the server logs are stored."), true);
$table->data[32][1] = html_print_input_text ('server_log_dir', $config["server_log_dir"], '', 50, 255, true);
echo '<form id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=general&amp;pure='.$config['pure'].'">';
echo "<fieldset>";

View File

@ -50,6 +50,7 @@ if ($develop_bypass != 1) {
}
ini_set("display_errors", 0);
ini_set("log_errors", 1);
ini_set("error_log", $config["homedir"]."/pandora_console.log");
}
else {
@ -63,6 +64,7 @@ else {
error_reporting(E_ALL);
}
ini_set("display_errors", 1);
ini_set("log_errors", 1);
ini_set("error_log", $config["homedir"]."/pandora_console.log");
}

View File

@ -1973,6 +1973,9 @@ function can_user_access_node () {
* Get the upload status code
*/
function get_file_upload_status ($file_input_name) {
if (!isset($_FILES[$file_input_name]))
return -1;
return $_FILES[$file_input_name]['error'];
}

View File

@ -179,6 +179,8 @@ function config_update_config () {
$error_update[] = __('Event storm protection');
if (!config_update_value ('command_snapshot', get_parameter('command_snapshot')))
$error_update[] = __('Command Snapshot');
if (!config_update_value ('server_log_dir', get_parameter('server_log_dir')))
$error_update[] = __('Server logs directory');
break;
case 'enterprise':
if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) {