Merge branch '1350-Eliminación-y-mejora-de-las-secciones-de-diagnóstico-de-pandora' into 'develop'
Db maintenance section is now called Admin tools with only admin access permissi… See merge request !885
This commit is contained in:
commit
53bb048673
|
@ -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');
|
||||
?>
|
|
@ -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;
|
||||
|
|
|
@ -38,9 +38,10 @@ function render_row ($data, $label) {
|
|||
}
|
||||
else {
|
||||
echo "<tr>";
|
||||
echo "<td>" . $label;
|
||||
echo "<td>" . $data;
|
||||
echo "</td>";
|
||||
echo "<td style='padding:2px;border:0px;' width='60%'><div style='padding:5px;background-color:#f2f2f2;border-radius:2px;text-align:left;border:0px;'>" . $label;
|
||||
echo "</div></td>";
|
||||
echo "<td style='font-weight:bold;padding:2px;border:0px;' width='40%'><div style='padding:5px;background-color:#f2f2f2;border-radius:2px;text-align:left;border:0px;'>" . $data;
|
||||
echo "</div></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
}
|
||||
|
@ -89,35 +90,154 @@ else {
|
|||
// Header
|
||||
ui_print_page_header (__('Pandora FMS Diagnostic tool'), "", false, "", true);
|
||||
|
||||
echo "<table with='100%' class='databox data' cellpadding='4' cellspacing='4'>";
|
||||
echo "<tr><th align=left>".__("Item")."</th>";
|
||||
echo "<th>".__("Data value")."</th></tr>";
|
||||
echo "<table width='1000px' border='0' style='border:0px;' class='databox data' cellpadding='4' cellspacing='4'>";
|
||||
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__("Pandora status info")."</th></tr>";
|
||||
}
|
||||
|
||||
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 "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__("PHP setup")."</th></tr>";
|
||||
|
||||
|
||||
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 "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__("Database size stats")."</th></tr>";
|
||||
|
||||
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 "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__("Database sanity")."</th></tr>";
|
||||
|
||||
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 "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__("Database status info")."</th></tr>";
|
||||
|
||||
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 "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__("System info")."</th></tr>";
|
||||
|
||||
$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 "</table>";
|
||||
}
|
||||
|
||||
echo "<hr color='#b1b1b1' size=1 width=1000 align=left>";
|
||||
|
||||
echo "<span>".__('(*) 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')."</span><br><br><br>";
|
||||
|
||||
|
||||
|
||||
?>
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue