2009-12-07 14:25:30 +01:00
< ? php
2021-11-04 16:28:15 +01:00
// Pandora FMS - http://pandorafms.com
2009-12-07 14:25:30 +01:00
// ==================================================
2020-11-27 13:52:35 +01:00
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
2011-03-17 Raul Mateos <raulofpandora@gmail.com>
* extensions/dbmanager.php, extensions/pandora_logs.php, general/*.php,
index.php, ajax.php, operation/search_*.php, operation/menu.php,
operation/extensions.php, godmode/menu.php, godmode/extensions.php,
admin_access_logs.php: Cleaned code and updated page disclaimers.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-03-17 23:01:01 +01:00
// Please see http://pandorafms.org for full contribution list
2009-12-07 14:25:30 +01:00
// This program is free software; you can redistribute it and/or
2011-03-23 Raul Mateos <raulofpandora@gmail.com>
* extensions/ssh_console.php, extensions/vnc_view.php,
extensions/update_manager.php, extensions/users_connected.php,
extensions/extension_uploader.php, extensions/insert_data.php,
extensions/module_groups.php, extensions/plugin_registration.php,
extensions/agent_modules.php, extensions/resource_registration.php,
extensions/resource_exportation.php, extensions/dbmanager.php,
extensions/pandora_logs.php, general/*.php, ajax.php,
operation/search_*.php, operation/menu.php, operation/extensions.php,
godmode/menu.php, godmode/extensions.php, godmode/admin_access_logs.php:
CReverted unwanted license changes.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4126 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-03-23 17:13:28 +01:00
// modify it under the terms of the GNU General Public License
2011-03-17 Raul Mateos <raulofpandora@gmail.com>
* extensions/dbmanager.php, extensions/pandora_logs.php, general/*.php,
index.php, ajax.php, operation/search_*.php, operation/menu.php,
operation/extensions.php, godmode/menu.php, godmode/extensions.php,
admin_access_logs.php: Cleaned code and updated page disclaimers.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-03-17 23:01:01 +01:00
// as published by the Free Software Foundation; version 2
2009-12-07 14:25:30 +01:00
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
2011-03-17 Raul Mateos <raulofpandora@gmail.com>
* extensions/dbmanager.php, extensions/pandora_logs.php, general/*.php,
index.php, ajax.php, operation/search_*.php, operation/menu.php,
operation/extensions.php, godmode/menu.php, godmode/extensions.php,
admin_access_logs.php: Cleaned code and updated page disclaimers.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-03-17 23:01:01 +01:00
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2009-12-07 14:25:30 +01:00
// GNU General Public License for more details.
2019-01-30 16:18:44 +01:00
function view_logfile ( $file_name )
{
global $config ;
$memory_limit = ini_get ( 'memory_limit' );
if ( strstr ( $memory_limit , 'M' ) !== false ) {
$memory_limit = str_replace ( 'M' , '' , $memory_limit );
$memory_limit = ( $memory_limit * 1024 * 1024 );
2009-12-07 14:25:30 +01:00
2019-01-30 16:18:44 +01:00
// Arbitrary size for the PHP program
$memory_limit = ( $memory_limit - ( 8 * 1024 * 1024 ));
}
if ( ! file_exists ( $file_name )) {
ui_print_error_message ( __ ( 'Cannot find file' ) . '(' . $file_name . ')' );
} else {
$file_size = filesize ( $file_name );
if ( $memory_limit < $file_size ) {
echo " <h2> $file_name ( " . __ ( 'File is too large than PHP memory allocated in the system.' ) . ')</h2>' ;
echo '<h2>' . __ ( 'The preview file is imposible.' ) . '</h2>' ;
} else if ( $file_size > ( $config [ 'max_log_size' ] * 1000 )) {
$data = file_get_contents ( $file_name , false , null , ( $file_size - ( $config [ 'max_log_size' ] * 1000 )));
2020-05-29 11:37:06 +02:00
echo " <h2> $file_name ( " . format_numeric ( filesize ( $file_name ) / 1024 ) . ' KB) ' . ui_print_help_tip ( __ ( 'The folder /var/log/pandora must have pandora:apache and its content too.' ), true ) . ' </h2>' ;
2021-03-11 15:40:23 +01:00
echo " <textarea class='pandora_logs' name=' $file_name '> " ;
2019-01-30 16:18:44 +01:00
echo '... ' ;
echo $data ;
echo '</textarea><br><br>' ;
} else {
$data = file_get_contents ( $file_name );
2020-05-29 11:37:06 +02:00
echo " <h2> $file_name ( " . format_numeric ( filesize ( $file_name ) / 1024 ) . ' KB) ' . ui_print_help_tip ( __ ( 'The folder /var/log/pandora must have pandora:apache and its content too.' ), true ) . ' </h2>' ;
2021-03-11 15:40:23 +01:00
echo " <textarea class='pandora_logs' name=' $file_name '> " ;
2019-01-30 16:18:44 +01:00
echo $data ;
echo '</textarea><br><br>' ;
}
}
2009-12-07 14:25:30 +01:00
}
2019-01-30 16:18:44 +01:00
function pandoralogs_extension_main ()
{
global $config ;
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 ;
}
ui_print_page_header ( __ ( 'System logfile viewer' ), 'images/extensions.png' , false , '' , true , '' );
echo '<p>' . __ ( 'Use this tool to view your %s logfiles directly on the console' , get_product_name ()) . '</p>' ;
echo '<p>' . __ ( 'You can choose the amount of information shown in general setup (Log size limit in system logs viewer extension), ' . ( $config [ 'max_log_size' ] * 1000 ) . 'B at the moment' ) . '</p>' ;
$logs_directory = ( ! empty ( $config [ 'server_log_dir' ])) ? io_safe_output ( $config [ 'server_log_dir' ]) : '/var/log/pandora' ;
2020-06-08 10:48:48 +02:00
// Do not attempt to show console log if disabled.
if ( $config [ 'console_log_enabled' ]) {
view_logfile ( $config [ 'homedir' ] . '/log/console.log' );
}
2019-01-30 16:18:44 +01:00
view_logfile ( $logs_directory . '/pandora_server.log' );
view_logfile ( $logs_directory . '/pandora_server.error' );
2009-12-07 14:25:30 +01:00
}
2019-01-30 16:18:44 +01:00
extensions_add_godmode_menu_option ( __ ( 'System logfiles' ), 'PM' , '' , null , 'v1r1' );
extensions_add_godmode_function ( 'pandoralogs_extension_main' );