From 962e793c1b032be45968f60b1959bbfc71dc3d8c Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 13 Aug 2018 12:52:01 +0200 Subject: [PATCH] Reupload the manuel.montes changes --- pandora_console/extras/pandora_diag.php | 129 ++++++++++++++---------- 1 file changed, 78 insertions(+), 51 deletions(-) diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index 6a37a9c9b1..d83e211a82 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -138,6 +138,7 @@ function execution_time(){ return "Normal Status   The execution time is correct. For a more extensive information of this data consult the Execution Time graph"; } + function get_logs_size($file){ $file_name = '/var'. $file .''; $size_server_log = filesize($file_name); @@ -149,9 +150,9 @@ function get_status_logs($path){ $status_server_log = ""; $size_server_log = get_logs_size($path); if ($size_server_log <= 10240){ - $status_server_log = "Normal Status   You have less than 10 MB of logs"; + $status_server_log = "Normal Status   You have less than 10 MB of logs"; }else{ - $status_server_log = "Warning Status   You have more than 10 MB of logs"; + $status_server_log = "Warning Status   You have more than 10 MB of logs"; } return $status_server_log; } @@ -161,9 +162,9 @@ function percentage_modules_per_agent(){ $total_modules = db_get_value_sql ('SELECT count(*) FROM tagente_modulo'); $average_modules_per_agent = $total_modules / $total_agents; if($average_modules_per_agent <= 40){ - $status_average_modules = "Normal Status   The average of modules per agent is less than 40 percent"; + $status_average_modules = "Normal Status   The average of modules per agent is less than 40 percent"; }else{ - $status_average_modules = "Warning Status  The average of modules per agent is more than 40 percent. You can have performance problems"; + $status_average_modules = "Warning Status  The average of modules per agent is more than 40 percent. You can have performance problems"; } return $status_average_modules; } @@ -174,9 +175,9 @@ function license_capacity(){ $status_license_capacity = ""; $current_count = db_get_value_sql ('SELECT count(*) FROM tagente'); if ($current_count > $license_limit * 90 /100){ - $status_license_capacity = "Warning Status   The license capacity is more than 90 percent"; + $status_license_capacity = "Warning Status   The license capacity is more than 90 percent"; }else{ - $status_license_capacity = "Normal Status   The license capacity is less than 90 percent"; + $status_license_capacity = "Normal Status   The license capacity is less than 90 percent"; } return $status_license_capacity; } @@ -195,12 +196,12 @@ function interval_average_of_network_modules(){ $average_time= (int) $total_module_interval_time / $total_network_modules; if($average_time < 180 ){ - $status_average_modules = "Warning Status   The system has a lot of load and a very fine configuration is required"; + $status_average_modules = "Warning Status   The system has a lot of load and a very fine configuration is required"; }else{ - $status_average_modules = "Normal Status   The system has an acceptable charge"; + $status_average_modules = "Normal Status   The system has an acceptable charge"; } if ($average_time == 0) - $status_average_modules = "Normal Status   The system has no load"; + $status_average_modules = "Normal Status   The system has no load"; return $status_average_modules; } @@ -208,9 +209,9 @@ $attachment_total_files = count(glob($config['homedir']."/attachment/{*.*}",GLOB function files_attachment_folder($total_files){ if($total_files <= 700){ - $status_total_files = "Normal Status   The attachment folder has less than 700 files."; + $status_total_files = "Normal Status   The attachment folder has less than 700 files."; }else{ - $status_total_files = "Warning Status   The attachment folder has more than 700 files."; + $status_total_files = "Warning Status   The attachment folder has more than 700 files."; } return $status_total_files; } @@ -218,14 +219,21 @@ function files_attachment_folder($total_files){ $tagente_datos_size = db_get_value_sql('SELECT COUNT(*) FROM tagente_datos'); function status_tagente_datos($tagente_datos_size){ - if ($tagente_datos_size <=3000){ - $tagente_datos_size = "Normal Status   The tagente_datos table has less than 3000 data."; + if ($tagente_datos_size <=3000000){ + $tagente_datos_size = "Normal Status   The tagente_datos table has an acceptable amount of data."; }else{ - $tagente_datos_size = "Warning Status   The tagente_datos table has more than 3000 data. A historical database is recommended."; + $tagente_datos_size = "Warning Status   The tagente_datos table has too much data. A historical database is recommended."; } return $tagente_datos_size; } +function status_values($val_rec, $val){ + if ($val_rec <= $val) + return $val . " (current value) Normal Status"; + else + return $val . " (current value) Warning Status"; +} + $tables_fragmentation=db_get_sql ("SELECT (data_free/(index_length+data_length)) as frag_ratio from information_schema.tables where DATA_FREE > 0 and table_name='tagente_datos' and table_schema='pandora'"); $db_size=db_get_all_rows_sql("SELECT table_schema, @@ -245,28 +253,30 @@ $path_console_logs ="/www/html/pandora_console/pandora_console.log"; $innodb_log_file_size_min_rec_value = "64M"; $innodb_log_buffer_size_min_rec_value = "16M"; $innodb_flush_log_at_trx_commit_min_rec_value = 0; -$query_cache_limit_min_rec_value = "2M"; -$max_allowed_packet_min_rec_value = "32M"; -$sort_buffer_size_min_rec_value = "32K"; -$join_buffer_size_min_rec_value = "265K"; +$query_cache_limit_min_rec_value = 2; +$max_allowed_packet_min_rec_value = 32; +$innodb_buffer_pool_size_min_rec_value = shell_exec("cat /proc/meminfo | grep -i total | head -1 | awk '{print $(NF-1)*0.4/1024}'"); +$sort_buffer_size_min_rec_value = 32; +$join_buffer_size_min_rec_value = 265; $query_cache_type_min_rec_value = "ON"; -$query_cache_size_min_rec_value = "24M"; -$innodb_lock_wait_timeout_max_rec_value = "120 seconds"; +$query_cache_size_min_rec_value = 24; +$innodb_lock_wait_timeout_max_rec_value = 120; $tables_fragmentation_max_rec_value = 10; -$thread_cache_size_max_rec_value = "8M"; -$thread_stack_min_rec_value = "256K"; -$max_connections_max_rec_value = "150"; -$key_buffer_size_min_rec_value = "256K"; -$read_buffer_size_min_rec_value = "32K"; -$read_rnd_buffer_size_min_rec_value = "32K"; -$query_cache_min_res_unit_min_rec_value = "2K"; +$thread_cache_size_max_rec_value = 8; +$thread_stack_min_rec_value = 256; +$max_connections_max_rec_value = 150; +$key_buffer_size_min_rec_value = 256; +$read_buffer_size_min_rec_value = 32; +$read_rnd_buffer_size_min_rec_value = 32; +$query_cache_min_res_unit_min_rec_value = 2; +$innodb_file_per_table_min_rec_value = 0; function status_fragmentation_tables($tables_fragmentation_max_rec_value, $tables_fragmentation){ $status_tables_frag = ""; if($tables_fragmentation > $tables_fragmentation_max_rec_value) - $status_tables_frag = "Warning Status   The fragmentation tables is higher than recommended. You should defragment them."; + $status_tables_frag = "Warning Status   The fragmentation tables is higher than recommended. You should defragment them."; else - $status_tables_frag = "Normal Status   The fragmentation tables is correct."; + $status_tables_frag = "Normal Status   The fragmentation tables is correct."; return $status_tables_frag; } @@ -536,29 +546,46 @@ switch ($config["dbtype"]) { WHERE \"key\" = 'current_update'", "Current Update #"); break; } - +$innodb_log_file_size =db_get_value_sql ("SELECT @@innodb_log_file_size")/1048576; +$innodb_log_buffer_size =db_get_value_sql("SELECT @@innodb_log_buffer_size")/1048576; +$innodb_flush_log_at_trx_commit =db_get_value_sql("SELECT @@innodb_flush_log_at_trx_commit"); +$max_allowed_packet =db_get_value_sql("SELECT @@max_allowed_packet")/1048576; +$innodb_buffer_pool_size = db_get_value_sql("SELECT @@innodb_buffer_pool_size")/1024; +$sort_buffer_size =number_format(db_get_value_sql("SELECT @@sort_buffer_size")/1024, 2); +$join_buffer_size =db_get_value_sql("SELECT @@join_buffer_size")/1024; +$query_cache_type =db_get_value_sql("SELECT @@query_cache_type"); +$query_cache_size =db_get_value_sql("SELECT @@query_cache_size")/1048576; +$query_cache_limit =db_get_value_sql("SELECT @@query_cache_limit")/1048576; +$innodb_lock_wait_timeout =db_get_value_sql("SELECT @@innodb_lock_wait_timeout"); +$thread_cache_size =db_get_value_sql("SELECT @@thread_cache_size"); +$thread_stack =db_get_value_sql("SELECT @@thread_stack")/1024; +$max_connections =db_get_value_sql("SELECT @@max_connections"); +$key_buffer_size =db_get_value_sql("SELECT @@key_buffer_size")/1024; +$read_buffer_size =db_get_value_sql("SELECT @@read_buffer_size")/1024; +$read_rnd_buffer_size =db_get_value_sql("SELECT @@read_rnd_buffer_size")/1024; +$query_cache_min_res_unit =db_get_value_sql("SELECT @@query_cache_min_res_unit")/1024; +$innodb_file_per_table = db_get_value_sql("SELECT @@innodb_file_per_table"); echo "".__("MySQL Performance metrics").""; -render_row_2($innodb_log_file_size_min_rec_value,'InnoDB log file size (minimum recommended value)',db_get_value_sql ("SELECT @@innodb_log_file_size")/1048576 . 'M', 'InnoDB log file size (current value)'); -render_row_2($innodb_log_buffer_size_min_rec_value,'InnoDB log buffer size (minimum recommended value)',db_get_value_sql("SELECT @@innodb_log_buffer_size")/1048576 . 'M', 'InnoDB log buffer size (current value)'); -render_row_2($innodb_flush_log_at_trx_commit_min_rec_value,'InnoDB flush log at trx-commit (minimum recommended value)',db_get_value_sql("SELECT @@innodb_flush_log_at_trx_commit"), 'InnoDB flush log at trx-commit (current value)'); -render_row_2($max_allowed_packet_min_rec_value,'Maximun allowed packet',db_get_value_sql("SELECT @@max_allowed_packet")/1048576 . 'M', 'Maximun allowed packet (current value)'); -render_row_2($innodb_buffer_pool_size_min_rec_value . 'M','InnoDB buffer pool size (minimum recommended value)',db_get_value_sql("SELECT @@innodb_buffer_pool_size")/1024 . 'M', 'InnoDB buffer pool size (current value)'); -render_row_2($sort_buffer_size_min_rec_value,'Sort buffer size (minimum recommended value)',number_format(db_get_value_sql("SELECT @@sort_buffer_size")/1024, 2) . 'K', 'Sort buffer size (current value)'); -render_row_2($join_buffer_size_min_rec_value,'Join buffer size (minimum recommended value)',db_get_value_sql("SELECT @@join_buffer_size")/1024 . 'K', 'Join buffer size (current value)'); -render_row_2($query_cache_type_min_rec_value,'Query cache type (recommended value)',db_get_value_sql("SELECT @@query_cache_type"), 'Query cache type (current value)'); -render_row_2($query_cache_size_min_rec_value,'Query cache size (minimum recommended value)',db_get_value_sql("SELECT @@query_cache_size")/1048576 . 'M', 'Query cache size (current value)'); -render_row_2($query_cache_limit_min_rec_value,'Query cache limit (minimum recommended value)',db_get_value_sql("SELECT @@query_cache_limit")/1048576 . 'M', 'Query cache limit (current value)'); -render_row_2($innodb_lock_wait_timeout_max_rec_value ,'InnoDB lock wait timeout (maximum recommended value)',db_get_value_sql("SELECT @@innodb_lock_wait_timeout") . ' seconds', 'InnoDB lock wait timeout (current value)'); -render_row_2($thread_cache_size_max_rec_value ,'Thread cache size (maximum recommended value)',db_get_value_sql("SELECT @@thread_cache_size") . 'M', 'Thread cache size (current value)'); -render_row_2($thread_stack_min_rec_value ,'Thread stack (minimum recommended value)',db_get_value_sql("SELECT @@thread_stack")/1024 . 'K', 'Thread stack (current value)'); -render_row_2($max_connections_max_rec_value ,'Maximun connections (maximum recommended value)',db_get_value_sql("SELECT @@max_connections"), 'Maximum connections (current value)'); -render_row_2($key_buffer_size_min_rec_value ,'Key buffer size (minimum recommended value)',db_get_value_sql("SELECT @@key_buffer_size")/1024 . 'K', 'Key buffer size (current value)'); -render_row_2($read_buffer_size_min_rec_value ,'Read buffer size (minimum recommended value)',db_get_value_sql("SELECT @@read_buffer_size")/1024 . 'K', 'Read buffer size (current value)'); -render_row_2($read_rnd_buffer_size_min_rec_value ,'Read rnd-buffer size (minimum recommended value)',db_get_value_sql("SELECT @@read_rnd_buffer_size")/1024 . 'K', 'Read rnd-buffer size (current value)'); -render_row_2($query_cache_min_res_unit_min_rec_value ,'Query cache min-res-unit (minimum recommended value)',db_get_value_sql("SELECT @@query_cache_min_res_unit")/1024 . 'K', 'Query cache min-res-unit (current value)'); -render_row(db_get_value_sql("SELECT @@innodb_file_per_table"), 'InnoDB file per table'); - +render_row($innodb_log_file_size.status_values($innodb_log_file_size_min_rec_value,$innodb_log_file_size),'InnoDB log file size ', 'InnoDB log file size '); +render_row($innodb_log_buffer_size.status_values($innodb_log_buffer_size_min_rec_value,$innodb_log_buffer_size),'InnoDB log buffer size ', 'InnoDB log buffer size '); +render_row($innodb_flush_log_at_trx_commit.status_values($innodb_flush_log_at_trx_commit_min_rec_value,$innodb_flush_log_at_trx_commit), 'InnoDB flush log at trx-commit ','InnoDB flush log at trx-commit '); +render_row($max_allowed_packet.status_values($max_allowed_packet_min_rec_value,$max_allowed_packet), 'Maximun allowed packet ','Maximun allowed packet '); +render_row($innodb_buffer_pool_size .status_values($innodb_buffer_pool_size_min_rec_value,$innodb_buffer_pool_size), 'InnoDB buffer pool size ','InnoDB buffer pool size '); +render_row($sort_buffer_size.status_values($sort_buffer_size_min_rec_value,$sort_buffer_size), 'Sort buffer size ','Sort buffer size '); +render_row($join_buffer_size.status_values($join_buffer_size_min_rec_value,$join_buffer_size), 'Join buffer size ','Join buffer size '); +render_row($query_cache_type.status_values($query_cache_type_min_rec_value,$query_cache_type), 'Query cache type ', 'Query cache type '); +render_row($query_cache_size.status_values($query_cache_size_min_rec_value,$query_cache_size), 'Query cache size ','Query cache size '); +render_row($query_cache_limit.status_values($query_cache_limit_min_rec_value,$query_cache_limit), 'Query cache limit ','Query cache limit '); +render_row($innodb_lock_wait_timeout.status_values($innodb_lock_wait_timeout_max_rec_value,$innodb_lock_wait_timeout), 'InnoDB lock wait timeout ','InnoDB lock wait timeout '); +render_row($thread_cache_size.status_values($thread_cache_size_max_rec_value,$thread_cache_size), 'Thread cache size ','Thread cache size '); +render_row($thread_stack .status_values($thread_stack_min_rec_value,$thread_stack), 'Thread stack ','Thread stack '); +render_row($max_connections.status_values($max_connections_max_rec_value,$max_connections), 'Maximum connections ','Maximun connections '); +render_row($key_buffer_size .status_values($key_buffer_size_min_rec_value,$key_buffer_size), 'Key buffer size ','Key buffer size '); +render_row($read_buffer_size.status_values($read_buffer_size_min_rec_value,$read_buffer_size), 'Read buffer size ','Read buffer size '); +render_row($read_rnd_buffer_size.status_values($read_rnd_buffer_size_min_rec_value,$read_rnd_buffer_size), 'Read rnd-buffer size ','Read rnd-buffer size '); +render_row($query_cache_min_res_unit.status_values($query_cache_min_res_unit_min_rec_value,$query_cache_min_res_unit), 'Query cache min-res-unit ','Query cache min-res-unit '); +render_row($innodb_file_per_table.status_values($innodb_file_per_table_min_rec_value,$innodb_file_per_table), 'InnoDB file per table ','InnoDB file per table '); echo "".__("Tables fragmentation in the PandoraFMS database").""; @@ -628,7 +655,7 @@ $agent_id= db_get_value_sql ("SELECT id_agente FROM tagente WHERE nombre = '$ser 'agent_module_id' => $id_module['id_agente_modulo'], 'period' => SECONDS_1MONTH, 'date' => time() , - 'height' => '200' + 'height' => '150' ); render_row(grafico_modulo_sparse ($params),"Graph of the " . $id_module['nombre']." module."); }