Fix AWK-UNINIT issues by initializing variables in BEGIN blocks
lib/php-analyzer.sh: - Line 364: Initialize sum=0 in awk for request counting - Line 1374: Initialize sum=0 in awk for MySQL memory calculation modules/diagnostics/loadwatch-analyzer.sh: - Lines 748-752: Initialize i=0 for memory velocity parsing - Lines 794-797: Initialize i=0 for load trend parsing modules/performance/hardware-health-check.sh: - Lines 1243, 1244, 1247: Initialize sum=0 for network error metrics Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -745,11 +745,11 @@ print_status "Phase 4/4: Generating report..."
|
||||
# Memory growth velocity
|
||||
if [ -f "$TEMP_DIR/memory_velocity.txt" ]; then
|
||||
read -r _ first_line < "$TEMP_DIR/memory_velocity.txt"
|
||||
FIRST_AVAIL=$(echo "$first_line" | awk '{for(i=1;i<=NF;i++) if($i ~ /^first=/) print $i}' | cut -d= -f2)
|
||||
LAST_AVAIL=$(echo "$first_line" | awk '{for(i=1;i<=NF;i++) if($i ~ /^last=/) print $i}' | cut -d= -f2)
|
||||
DELTA=$(echo "$first_line" | awk '{for(i=1;i<=NF;i++) if($i ~ /^delta=/) print $i}' | cut -d= -f2)
|
||||
RATE=$(echo "$first_line" | awk '{for(i=1;i<=NF;i++) if($i ~ /^rate_per_hour=/) print $i}' | cut -d= -f2)
|
||||
HOURS_TO_OOM=$(echo "$first_line" | awk '{for(i=1;i<=NF;i++) if($i ~ /^hours_to_oom=/) print $i}' | cut -d= -f2)
|
||||
FIRST_AVAIL=$(echo "$first_line" | awk 'BEGIN {i=0} {for(i=1;i<=NF;i++) if($i ~ /^first=/) print $i}' | cut -d= -f2)
|
||||
LAST_AVAIL=$(echo "$first_line" | awk 'BEGIN {i=0} {for(i=1;i<=NF;i++) if($i ~ /^last=/) print $i}' | cut -d= -f2)
|
||||
DELTA=$(echo "$first_line" | awk 'BEGIN {i=0} {for(i=1;i<=NF;i++) if($i ~ /^delta=/) print $i}' | cut -d= -f2)
|
||||
RATE=$(echo "$first_line" | awk 'BEGIN {i=0} {for(i=1;i<=NF;i++) if($i ~ /^rate_per_hour=/) print $i}' | cut -d= -f2)
|
||||
HOURS_TO_OOM=$(echo "$first_line" | awk 'BEGIN {i=0} {for(i=1;i<=NF;i++) if($i ~ /^hours_to_oom=/) print $i}' | cut -d= -f2)
|
||||
|
||||
echo "Memory Growth Velocity:"
|
||||
echo " First Available: ${FIRST_AVAIL} MiB"
|
||||
@@ -791,10 +791,10 @@ print_status "Phase 4/4: Generating report..."
|
||||
# Load trend direction
|
||||
if [ -f "$TEMP_DIR/load_trend.txt" ]; then
|
||||
read -r _ trend_line < "$TEMP_DIR/load_trend.txt"
|
||||
TREND_DIR=$(echo "$trend_line" | awk '{for(i=1;i<=NF;i++) if($i ~ /^direction=/) print $i}' | cut -d= -f2)
|
||||
RISING_COUNT=$(echo "$trend_line" | awk '{for(i=1;i<=NF;i++) if($i ~ /^rising=/) print $i}' | cut -d= -f2)
|
||||
FALLING_COUNT=$(echo "$trend_line" | awk '{for(i=1;i<=NF;i++) if($i ~ /^falling=/) print $i}' | cut -d= -f2)
|
||||
STABLE_COUNT=$(echo "$trend_line" | awk '{for(i=1;i<=NF;i++) if($i ~ /^stable=/) print $i}' | cut -d= -f2)
|
||||
TREND_DIR=$(echo "$trend_line" | awk 'BEGIN {i=0} {for(i=1;i<=NF;i++) if($i ~ /^direction=/) print $i}' | cut -d= -f2)
|
||||
RISING_COUNT=$(echo "$trend_line" | awk 'BEGIN {i=0} {for(i=1;i<=NF;i++) if($i ~ /^rising=/) print $i}' | cut -d= -f2)
|
||||
FALLING_COUNT=$(echo "$trend_line" | awk 'BEGIN {i=0} {for(i=1;i<=NF;i++) if($i ~ /^falling=/) print $i}' | cut -d= -f2)
|
||||
STABLE_COUNT=$(echo "$trend_line" | awk 'BEGIN {i=0} {for(i=1;i<=NF;i++) if($i ~ /^stable=/) print $i}' | cut -d= -f2)
|
||||
|
||||
echo "Load Trend Direction:"
|
||||
case "$TREND_DIR" in
|
||||
|
||||
Reference in New Issue
Block a user