diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index f70859d134..50eec14bc8 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -31,8 +31,6 @@ function extension_db_status_extension_tables() { function extension_db_status() { global $config; - - $db_user = get_parameter('db_user', ''); $db_password = get_parameter('db_password', ''); $db_host = get_parameter('db_host', ''); @@ -40,11 +38,11 @@ function extension_db_status() { $db_status_execute = (bool)get_parameter('db_status_execute', false); - ui_print_page_header (__("DB Status"), + ui_print_page_header (__("DB Schema check"), "images/extensions.png", false, "", true, ""); - if (! check_acl ($config['id_user'], 0, "DM")) { + if (!is_user_admin($config['id_user'])) { db_pandora_audit("ACL Violation", "Trying to access db status"); require ("general/noaccess.php"); @@ -367,5 +365,5 @@ function extension_db_status_execute_sql_file($url, $connection) { } extensions_add_godmode_function('extension_db_status'); -extensions_add_godmode_menu_option(__('DB Status'), 'DM', 'gextensions', null, "v1r1", 'gdbman'); +extensions_add_godmode_menu_option(__('DB Schema check'), 'DM', 'gextensions', null, "v1r1", 'gdbman'); ?> \ No newline at end of file diff --git a/pandora_console/extensions/dbmanager.php b/pandora_console/extensions/dbmanager.php index ccc4c77c65..114c3bf709 100644 --- a/pandora_console/extensions/dbmanager.php +++ b/pandora_console/extensions/dbmanager.php @@ -114,7 +114,7 @@ function dbmgr_extension_main () { global $config; - if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_user'])) { + if (!is_user_admin($config['id_user'])) { db_pandora_audit("ACL Violation", "Trying to access Setup Management"); require ("general/noaccess.php"); return; diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index 5eff93bc65..4f9dc102db 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -38,9 +38,10 @@ function render_row ($data, $label) { } else { echo ""; - echo "" . $label; - echo "" . $data; - echo ""; + echo "
" . $label; + echo "
"; + echo "
" . $data; + echo "
"; echo ""; } } @@ -89,35 +90,154 @@ else { // Header ui_print_page_header (__('Pandora FMS Diagnostic tool'), "", false, "", true); - echo ""; - echo ""; - echo ""; + echo "
".__("Item")."".__("Data value")."
"; + echo ""; } render_row ($build_version, "Pandora FMS Build"); render_row ($pandora_version, "Pandora FMS Version"); +render_info_data ("SELECT value FROM tconfig where token ='MR'","Minor Release"); render_row ($config["homedir"], "Homedir"); render_row ($config["homeurl"], "HomeUrl"); +render_info_data ("SELECT `value` + FROM tconfig + WHERE `token` = 'enterprise_installed'", "Enterprise installed"); + + $full_key = db_get_sql("SELECT value + FROM tupdate_settings + WHERE `key` = 'customer_key'"); + + $compressed_key = substr($full_key, 0,5).'...'.substr($full_key, -5); + + render_row ($compressed_key,"Update Key"); + + render_info_data ("SELECT value + FROM tupdate_settings + WHERE `key` = 'updating_code_path'", "Updating code path"); + + render_info_data ("SELECT value + FROM tupdate_settings + WHERE `key` = 'current_update'", "Current Update #"); + + +echo ""; + + render_row (phpversion(), "PHP Version"); -render_info ("tagente"); -render_info ("tagent_access"); -render_info ("tagente_datos"); -render_info ("tagente_datos_string"); -render_info ("tagente_estado"); -render_info ("tagente_modulo"); -render_info ("talert_actions"); -render_info ("talert_commands"); -render_info ("talert_template_modules"); -render_info ("tevento"); -render_info ("tlayout"); +render_row (ini_get('max_execution_time'), "PHP Max ejecution time"); + +render_row (ini_get('max_input_time'), "PHP Max input time"); + +render_row (ini_get('memory_limit'), "PHP Memory limit"); + +render_row (ini_get('session.cookie_lifetime'), "Session cookie lifetime"); + +echo ""; + +render_info_data ("SELECT COUNT(*) FROM tagente","Total agents"); +render_info_data ("SELECT COUNT(*) FROM tagente_modulo","Total modules"); +render_info_data ("SELECT COUNT(*) FROM tgrupo","Total groups"); +render_info_data ("SELECT COUNT(*) FROM tagente_datos","Total module data records"); +// render_info_data ("SELECT COUNT(*) FROM tagente_datos_string","Total module string data records"); +// render_info_data ("SELECT COUNT(*) FROM tagente_datos_log4x","Total module log4x data records"); +render_info_data ("SELECT COUNT(*) FROM tagent_access","Total agent access record"); +// render_info ("tagente_estado"); +// render_info ("talert_template_modules"); +render_info_data ("SELECT COUNT(*) FROM tevento","Total events"); + if($config['enterprise_installed']) - render_info ("tlocal_component"); -render_info ("tserver"); -render_info ("treport"); -render_info ("ttrap"); -render_info ("tusuario"); -render_info ("tsesion"); +render_info_data ("SELECT COUNT(*) FROM ttrap","Total traps"); +render_info_data ("SELECT COUNT(*) FROM tusuario","Total users"); +render_info_data ("SELECT COUNT(*) FROM tsesion","Total sessions"); + +echo ""; + +render_info_data ("SELECT COUNT( DISTINCT tagente.id_agente) + FROM tagente_estado, tagente, tagente_modulo + WHERE tagente.disabled = 0 + AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND tagente_modulo.disabled = 0 + AND tagente_estado.id_agente = tagente.id_agente + AND tagente_estado.estado = 3","Total unknown agents"); + +render_info_data ("SELECT COUNT( DISTINCT tagente.id_agente) + FROM tagente_estado, tagente, tagente_modulo + WHERE tagente.disabled = 0 + AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND tagente_modulo.disabled = 0 + AND tagente_estado.id_agente = tagente.id_agente + AND tagente_estado.estado = 4","Total not-init modules"); + + +$last_run_difference = ''; + +$diferencia = time() - date ( + db_get_sql ("SELECT `value` + FROM tconfig + WHERE `token` = 'db_maintance'")); + +$last_run_difference_months = 0; +$last_run_difference_weeks = 0; +$last_run_difference_days = 0; +$last_run_difference_minutos = 0; +$last_run_difference_seconds = 0; + +while($diferencia >= 2419200){ + $diferencia -= 2419200; + $last_run_difference_months++; +} + +while($diferencia >= 604800){ + $diferencia -= 604800; + $last_run_difference_weeks++; +} + +while($diferencia >= 86400){ + $diferencia -= 86400; + $last_run_difference_days++; +} + +while($diferencia >= 3600){ + $diferencia -= 3600; + $last_run_difference_hours++; +} + +while($diferencia >= 60){ + $diferencia -= 60; + $last_run_difference_minutes++; +} + +$last_run_difference_seconds = $diferencia; + +if($last_run_difference_months > 0){ + $last_run_difference .= $last_run_difference_months.'month/s '; +} + +if ($last_run_difference_weeks > 0) { + $last_run_difference .= $last_run_difference_weeks.' week/s '; +} + +if ($last_run_difference_days > 0) { + $last_run_difference .= $last_run_difference_days.' day/s '; +} + +if ($last_run_difference_hours > 0) { + $last_run_difference .= $last_run_difference_hours.' hour/s '; +} + +if ($last_run_difference_minutes > 0) { + $last_run_difference .= $last_run_difference_minutes.' minute/s '; +} + +$last_run_difference .= $last_run_difference_seconds.' second/s ago'; + +render_row ( date ("Y/m/d H:i:s", +db_get_sql ("SELECT `value` + FROM tconfig + WHERE `token` = 'db_maintance'")).' ('.$last_run_difference.')'.' *', "PandoraDB Last run"); + +echo ""; switch ($config["dbtype"]) { case "mysql": @@ -130,23 +250,22 @@ switch ($config["dbtype"]) { render_info_data ("SELECT `value` FROM tconfig WHERE `token` = 'db_scheme_build'", "DB Schema Build"); - render_info_data ("SELECT `value` - FROM tconfig - WHERE `token` = 'enterprise_installed'", "Enterprise installed"); - render_row ( date ("Y/m/d H:i:s", - db_get_sql ("SELECT `value` - FROM tconfig - WHERE `token` = 'db_maintance'")), "PandoraDB Last run"); + + if(strpos($_SERVER['HTTP_USER_AGENT'],'Windows') == false){ + + echo ""; + + $output = 'cat /proc/cpuinfo | grep "model name" | tail -1 | cut -f 2 -d ":"'; + $output2 = 'cat /proc/cpuinfo | grep "processor" | wc -l'; + + render_row(exec($output).' x '.exec($output2),'CPU'); + + $output = 'cat /proc/meminfo | grep "MemTotal"'; + + render_row(exec($output),'RAM'); + + } - render_info_data ("SELECT value - FROM tupdate_settings - WHERE `key` = 'customer_key';", "Update Key"); - render_info_data ("SELECT value - FROM tupdate_settings - WHERE `key` = 'updating_code_path'", "Updating code path"); - render_info_data ("SELECT value - FROM tupdate_settings - WHERE `key` = 'current_update'", "Current Update #"); break; case "postgresql": render_info_data ("SELECT \"value\" @@ -201,4 +320,12 @@ switch ($config["dbtype"]) { if ($console_mode == 0) { echo "
".__("Pandora status info")."
".__("PHP setup")."
".__("Database size stats")."
".__("Database sanity")."
".__("Database status info")."
".__("System info")."
"; } + +echo "
"; + +echo "".__('(*) Please check your Pandora Server setup and be sure that database maintenance daemon is running. It\' very important to +keep up-to-date database to get the best performance and results in Pandora')."


"; + + + ?> \ No newline at end of file diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index b929a1ec84..bb6b610a19 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -285,6 +285,7 @@ if (check_acl ($config['id_user'], 0, "PM")) { } if (check_acl ($config['id_user'], 0, "PM") || check_acl ($config['id_user'], 0, "DM")) { + $menu_godmode["gextensions"]["text"] = __('Admin tools'); $menu_godmode["gextensions"]["sec2"] = "godmode/extensions"; $menu_godmode["gextensions"]["id"] = "god-extensions"; @@ -305,18 +306,13 @@ if (check_acl ($config['id_user'], 0, "PM") || check_acl ($config['id_user'], 0, $sub["godmode/setup/file_manager"]["id"] = 'File manager'; } - if (check_acl ($config['id_user'], 0, "DM") || check_acl ($config['id_user'], 0, "PM")) { - $sub["gdbman"]["text"] = __('DB maintenance'); + if (is_user_admin($config['id_user'])) { + $sub["gdbman"]["text"] = __('Admin tools'); $sub["gdbman"]["id"] = 'DB maintenance'; $sub["gdbman"]["type"] = "direct"; $sub["gdbman"]["subtype"] = "nolink"; $sub2 = array (); - $sub2["godmode/db/db_info"]["text"] = __('DB information'); - $sub2["godmode/db/db_purge"]["text"] = __('Database purge'); - $sub2["godmode/db/db_refine"]["text"] = __('Database debug'); - $sub2["godmode/db/db_audit"]["text"] = __('Database audit'); - $sub2["godmode/db/db_event"]["text"] = __('Database event'); $sub["gdbman"]["sub2"] = $sub2; } @@ -330,14 +326,24 @@ if (is_array ($config['extensions'])) { $sub2 = array (); foreach ($config['extensions'] as $extension) { + // html_debug($extension); + //If no godmode_menu is a operation extension if ($extension['godmode_menu'] == '') { continue; } + if ($extension['godmode_menu']['name'] == 'System Info') { + continue; + } + $extmenu = $extension['godmode_menu']; - if ($extmenu["name"] == 'DB interface' && !check_acl ($config['id_user'], 0, "DM")) { + if ($extmenu["name"] == 'DB interface' && !is_user_admin($config['id_user'])) { + continue; + } + + if ($extmenu["name"] == 'DB Schema check' && !is_user_admin($config['id_user'])) { continue; }