From 72077738d6bfb62dcfce3be1ffc5c679bd632d05 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 11 Oct 2010 15:37:04 +0000 Subject: [PATCH] 2010-10-11 Miguel de Dios * extensions/system_info.php: finally I finished (I hope) the extension of get system info, now the console part run. Pending task: #3065357 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3386 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 + pandora_console/extensions/system_info.php | 204 ++++++++++----------- 2 files changed, 106 insertions(+), 105 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a235816032..cd8d4ab810 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2010-10-11 Miguel de Dios + + * extensions/system_info.php: finally I finished (I hope) the extension of + get system info, now the console part run. + + Pending task: #3065357 + 2010-10-11 Miguel de Dios * include/functions_db.php: cleaned source code style. diff --git a/pandora_console/extensions/system_info.php b/pandora_console/extensions/system_info.php index 9ee2bf3994..2f5a7e13ee 100644 --- a/pandora_console/extensions/system_info.php +++ b/pandora_console/extensions/system_info.php @@ -63,7 +63,6 @@ function getSystemInfo(&$systemInfo, $script = false) { $systemInfo['apache_modules'] = apache_get_modules(); } -// $systemInfo['php_load_extensions'] = get_loaded_extensions(); $systemInfo['php_ini'] = ini_get_all(); $systemInfo['phpversion'] = phpversion(); foreach (get_loaded_extensions() as $module) { @@ -123,27 +122,76 @@ function show_logfile($file_name, $numLines) { global $config; if (!file_exists($file_name)){ - echo "

".__("Cannot find file"). "(".$file_name; - echo ")

"; + echo "

" . __("Cannot find file") . "(" . $file_name . + ")

"; } else { - echo "

" . $file_name . "

"; - echo ""; + if (!is_readable($file_name)) { + echo "

" . __("Cannot read file") . "(" . $file_name . + ")

"; + } + else { + echo "

" . $file_name . "

"; + echo ""; + } } } -function getLinesLog($file, $numLines = 2000) { - -} - -function getLastLog($show = true, $numLines = 2000) { +function getLastLog($numLines = 2000) { global $config; 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("/etc/mysql/my.cnf", $numLines); + show_logfile($config["homedir"]."/include/config.php", $numLines); + show_logfile("/etc/pandora/pandora_server.conf", $numLines); + show_logfile("/var/log/syslog", $numLines); +} + +function show_array($title, $anchor, $array = array()) { + $table = null; + + $table->width = '100%'; + $table->titlestyle = 'border: 1px solid black;'; + $table->class = "databox_color"; + $table->data = array(); + + foreach ($array as $index => $item) { + if (!is_array($item)) { + $row = array(); + $row[] = $index; + $row[] = $item; + $table->data[] = $row; + } + else { + foreach ($item as $index2 => $item2) { + if (!is_array($item2)) { + $row = array(); + $row[] = $index; + $row[] = $index2; + $row[] = $item2; + $table->data[] = $row; + } + else { + foreach ($item2 as $index3 => $item3) { + $row = array(); + $row[] = $index; + $row[] = $index2; + $row[] = $index3; + $row[] = $item3; + $table->data[] = $row; + } + } + } + } + } + + echo "

" . $title . "

"; + + print_table($table); } function mainSystemInfo() { @@ -155,10 +203,7 @@ function mainSystemInfo() { return; } - debugPrint($_POST); - $show = (bool) get_parameter('show'); - $save = (bool) get_parameter('save'); $pandora_diag = (bool) get_parameter('pandora_diag', 0); $system_info = (bool) get_parameter('system_info', 0); $log_info = (bool) get_parameter('log_info', 0); @@ -170,111 +215,60 @@ function mainSystemInfo() { echo __("This extension can run as PHP script in a shell for extract more information, but it must be run as root or across sudo. For example: sudo php /var/www/pandora_console/extensions/system_info.php -d -s -c"); echo ''; - echo "
"; + echo "

" . __('This tool is used just to view your Pandora FMS system logfiles directly from console') . "

"; + + echo ""; $table = null; $table->width = '80%'; $table->align = array(); $table->align[1] = 'right'; - $table->data[0][0] = __('Pandora Diagnostic info'); + if ($pandora_diag) { + $table->data[0][0] = '' . __('Pandora Diagnostic info') . ""; + } + else { + $table->data[0][0] = __('Pandora Diagnostic info'); + } $table->data[0][1] = print_checkbox('pandora_diag', 1, $pandora_diag, true); - $table->data[1][0] = __('System info'); + if ($system_info) { + $table->data[1][0] = '' . __('System info') . ''; + } + else { + $table->data[1][0] = __('System info'); + } $table->data[1][1] = print_checkbox('system_info', 1, $system_info, true); - $table->data[2][0] = __('Log Info'); + if ($log_info) { + $table->data[2][0] = '' . __('Log Info') . ''; + } + else { + $table->data[2][0] = __('Log Info'); + } $table->data[2][1] = print_checkbox('log_info', 1, $log_info, true); $table->data[3][0] = __('Number lines of log'); $table->data[3][1] = print_input_text('log_num_lines', $log_num_lines, __('Number lines of log'), 5, 10, true); print_table($table); echo "
"; print_submit_button(__('Show'), 'show', false, 'class="sub next"'); - echo " "; - print_submit_button(__('Save'), 'save', false, 'class="sub wand"'); echo "
"; echo "
"; - echo "

" . __('This tool is used just to view your Pandora FMS system logfiles directly from console') . "

"; - -// $systemInfo = array(); - -// if ($pandora_diag) { -// getPandoraDiagnostic($systemInfo); -// } -// if ($system_info) { -// getSystemInfo(&$systemInfo); -// } -// -// if ($show) { -// $table = null; -// $table->width = '90%'; -// $table->head = array(); -// $table->head[0] = __('Info'); -// $table->head[1] = __('Value'); -// -// $table->valign = array(); -// $table->valign[0] = 'top'; -// -// $table->data = array(); -// foreach ($systemInfo as $name => $info) { -// $row = array(); -// -// switch ($name) { -// case 'apache_modules': -// foreach ($info as $name => $module) { -// $row = array(); -// -// $row[] = 'apache_module'; -// $row[] = $module; -// -// $table->data[] = $row; -// } -// break; -// case 'php_ini': -// foreach ($info as $name => $ini) { -// $row = array(); -// -// $row[] = $name; -// $row[] = __('Global value: ') . $ini['global_value'] . __(' Local value: ') . $ini['local_value']; -// -// $table->data[] = $row; -// } -// break; -// case 'php_load_extensions': -// foreach ($info as $name => $extension) { -// $row = array(); -// -// $row[] = $name; -// $row[] = $extension; -// -// $table->data[] = $row; -// } -// break; -// case 'disk': -// foreach ($info as $entry) { -// $row = array(); -// -// $row[] = 'system_disk'; -// $row[] = 'Filesystem: ' . $entry['Filesystem'] . '
' . -// 'Size: ' . $entry['Size'] . '
' . -// 'Used: ' . $entry['Used'] . '
' . -// 'Use%: ' . $entry['Use%'] . '
' . -// 'Avail: ' . $entry['Avail'] . '
' . -// 'Mounted on: ' . $entry['Mounted_on'] . '
'; -// $table->data[] = $row; -// } -// break; -// default: -// $row[] = $name; -// $row[] = $info; -// $table->data[] = $row; -// break; -// } -// } -// -// print_table($table); -// -// if ($log_info) { -// getLastLog($show, $log_num_lines); -// } -// } + if ($show) { + if ($pandora_diag) { + $info = array(); + getPandoraDiagnostic($info); + show_array(__('Pandora Diagnostic info'), 'diag_info', $info); + } + + if ($system_info) { + $info = array(); + getSystemInfo($info); + show_array(__('System info'), 'system_info', $info); + } + + if ($log_info) { + echo "

" . __('Log Info') . "

"; + getLastLog($log_num_lines); + } + } } function consoleMode() {