Compare commits
3 Commits
cf391147bf
...
ff8c01a169
| Author | SHA1 | Date | |
|---|---|---|---|
| ff8c01a169 | |||
| a4adf9a398 | |||
| 729583581c |
+5
-5
@@ -1001,11 +1001,11 @@ calculate_server_memory_capacity() {
|
|||||||
done <<< "$user_domains"
|
done <<< "$user_domains"
|
||||||
done <<< "$users"
|
done <<< "$users"
|
||||||
|
|
||||||
# Add MySQL memory usage to total
|
# Add MySQL memory usage to total (with timeout to prevent hanging)
|
||||||
local mysql_memory_mb=0
|
local mysql_memory_mb=0
|
||||||
local mysql_status
|
local mysql_status
|
||||||
local mysql_info
|
local mysql_info
|
||||||
mysql_info=$(detect_mysql_memory_usage 2>/dev/null)
|
mysql_info=$(timeout 5 detect_mysql_memory_usage 2>/dev/null)
|
||||||
if [ $? -eq 0 ] && [ -n "$mysql_info" ]; then
|
if [ $? -eq 0 ] && [ -n "$mysql_info" ]; then
|
||||||
mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f3 || echo "0")
|
mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f3 || echo "0")
|
||||||
mysql_status=$(echo "$mysql_info" | cut -d'|' -f4)
|
mysql_status=$(echo "$mysql_info" | cut -d'|' -f4)
|
||||||
@@ -1391,9 +1391,9 @@ detect_mysql_memory_usage() {
|
|||||||
local max_connections=150 # Default
|
local max_connections=150 # Default
|
||||||
|
|
||||||
if command -v mysql >/dev/null 2>&1; then
|
if command -v mysql >/dev/null 2>&1; then
|
||||||
# Try to query MySQL directly
|
# Try to query MySQL directly (with 2 second timeout to prevent hanging)
|
||||||
buffer_pool_mb=$(mysql -Nse "SELECT ROUND(@@innodb_buffer_pool_size/1024/1024)" 2>/dev/null || echo "0")
|
buffer_pool_mb=$(timeout 2 mysql -Nse "SELECT ROUND(@@innodb_buffer_pool_size/1024/1024)" 2>/dev/null || echo "0")
|
||||||
max_connections=$(mysql -Nse "SELECT @@max_connections" 2>/dev/null || echo "150")
|
max_connections=$(timeout 2 mysql -Nse "SELECT @@max_connections" 2>/dev/null || echo "150")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If we couldn't get it from MySQL, try my.cnf
|
# If we couldn't get it from MySQL, try my.cnf
|
||||||
|
|||||||
@@ -122,8 +122,9 @@ calculate_max_children_memory_based() {
|
|||||||
local mysql_info
|
local mysql_info
|
||||||
mysql_info=$(detect_mysql_memory_usage 2>/dev/null)
|
mysql_info=$(detect_mysql_memory_usage 2>/dev/null)
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
# FIX: detect_mysql_memory_usage returns: memory|status (only 2 fields)
|
# FIX: detect_mysql_memory_usage returns: buffer_pool|connections|estimated_total_mb|status (4 fields)
|
||||||
mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f1)
|
# Extract field 3 (estimated_total_mb - the actual memory usage)
|
||||||
|
mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f3)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Available memory for PHP-FPM (after system + MySQL reserves)
|
# Available memory for PHP-FPM (after system + MySQL reserves)
|
||||||
@@ -372,8 +373,9 @@ calculate_server_capacity() {
|
|||||||
local mysql_info
|
local mysql_info
|
||||||
mysql_info=$(detect_mysql_memory_usage 2>/dev/null)
|
mysql_info=$(detect_mysql_memory_usage 2>/dev/null)
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
# FIX: detect_mysql_memory_usage returns: memory|status (only 2 fields)
|
# FIX: detect_mysql_memory_usage returns: buffer_pool|connections|estimated_total_mb|status (4 fields)
|
||||||
mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f1)
|
# Extract field 3 (estimated_total_mb - the actual memory usage)
|
||||||
|
mysql_memory_mb=$(echo "$mysql_info" | cut -d'|' -f3)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Available memory for PHP-FPM (after system + MySQL reserves)
|
# Available memory for PHP-FPM (after system + MySQL reserves)
|
||||||
|
|||||||
@@ -2672,7 +2672,7 @@ optimize_level_5_everything() {
|
|||||||
|
|
||||||
# Calculate server capacity for fair share allocation
|
# Calculate server capacity for fair share allocation
|
||||||
local server_capacity_result
|
local server_capacity_result
|
||||||
server_capacity_result=$(calculate_server_capacity "$TOTAL_RAM_MB")
|
server_capacity_result=$(calculate_server_capacity "$total_ram_mb")
|
||||||
local server_capacity
|
local server_capacity
|
||||||
server_capacity=$(echo "$server_capacity_result" | cut -d'|' -f1)
|
server_capacity=$(echo "$server_capacity_result" | cut -d'|' -f1)
|
||||||
local server_memory_per_process
|
local server_memory_per_process
|
||||||
@@ -2753,7 +2753,7 @@ optimize_level_5_everything() {
|
|||||||
|
|
||||||
# Call intelligent three-constraint function
|
# Call intelligent three-constraint function
|
||||||
local intel_result
|
local intel_result
|
||||||
intel_result=$(calculate_optimal_php_settings_intelligent "$username" "$TOTAL_RAM_MB" "$server_capacity" "$traffic_pct" 2>/dev/null || echo "20|dynamic|1|5|ERROR|Failed")
|
intel_result=$(calculate_optimal_php_settings_intelligent "$username" "$total_ram_mb" "$server_capacity" "$traffic_pct" 2>/dev/null || echo "20|dynamic|1|5|ERROR|Failed")
|
||||||
|
|
||||||
recommended_max=$(echo "$intel_result" | cut -d'|' -f1)
|
recommended_max=$(echo "$intel_result" | cut -d'|' -f1)
|
||||||
recommended_memory=$(calculate_optimal_memory_limit "$username" "$domain" "$recommended_max" 2>/dev/null || echo "128M")
|
recommended_memory=$(calculate_optimal_memory_limit "$username" "$domain" "$recommended_max" 2>/dev/null || echo "128M")
|
||||||
|
|||||||
Reference in New Issue
Block a user