-
-
Save 3014zhangshuo/3958da4fcd56344bce0f4425c88547d6 to your computer and use it in GitHub Desktop.
awk/grep commands for Rails log analysis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Access number | |
cat production.log | grep "^Processing" | wc | awk '{print $1}' | |
# Each IP access number | |
cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq -c | |
# Independent IP number | |
cat production.log | grep "^Processing" | awk '{print $4}' | uniq | wc | awk '{print $1}' | |
cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq | wc -l | |
# Account number for each pages | |
cat production.log |grep “200 OK” | awk ‘{print $17}’ | sort | uniq -c | |
# Exception info | |
cat production.log | grep "Error" -6 -n > error.log | |
# Send exception info to specify email | |
cat production.log | grep "Error" -6 -n | mail -s "Error Logs" [email protected] | |
# Time-consuming actions | |
cat production.log | grep "200 OK" | awk '{print $17}'| sort | uniq -c | sort -r -n | head -n 500 > stat.log | |
# Top 200 IPs | |
grep Processing production.log | awk '{print $4}' | sort | uniq -c | sort -r -n | head -n 200 > top-200-ip.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment