#!/bin/bash echo "Analyzing GC logs for Web Lab 4" # Find GC log files in current directory GC_LOG_FILE=$(ls -t gc.log* 2>/dev/null | head -n1) if [ -z "$GC_LOG_FILE" ]; then echo "No GC log files found" exit 1 fi echo "=== GC Log Analysis Report ===" echo "Log file: $GC_LOG_FILE" echo "Generated at: $(date)" echo "" echo "=== GC Collection Counts ===" echo "Young Generation collections:" grep -c "Pause Young" $GC_LOG_FILE || echo "0" echo "Mixed collections:" grep -c "Pause Mixed" $GC_LOG_FILE || echo "0" echo "Full GC collections:" grep -c "Pause Full" $GC_LOG_FILE || echo "0" echo "" echo "=== Timing Analysis ===" echo "Recent pause times:" grep -o "[0-9.]*ms" $GC_LOG_FILE | tail -10 echo "" echo "=== Memory Analysis ===" echo "Recent GC events:" grep "GC(" $GC_LOG_FILE | tail -5 echo "" echo "=== Recommendations ===" YOUNG_GC=$(grep -c "Pause Young" $GC_LOG_FILE || echo "0") FULL_GC=$(grep -c "Pause Full" $GC_LOG_FILE || echo "0") if [ "$FULL_GC" -gt 0 ]; then echo "⚠️ Full GC detected ($FULL_GC times) - consider increasing heap size" fi if [ "$YOUNG_GC" -gt 50 ]; then echo "⚠️ High GC frequency ($YOUNG_GC young collections)" fi echo "" echo "=== Current JVM Settings ===" ps aux | grep wildfly | grep -o '\-X[^ ]*' EOF