Created
July 10, 2012 13:05
-
-
Save alxf/3083119 to your computer and use it in GitHub Desktop.
Script to output 404 request summary per virtualhost.
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
#!/bin/dash | |
# Parse access log from a virtual host and output 404 requests. | |
# Logfile is $LOGDIR/host1.domain.tld/access.log for example. | |
# If you want this report by mail, set a crontab: | |
# | |
# 0 22 * * * 404stats.sh | mail -s "404 report" [email protected] | |
# | |
#apache log directory | |
LOGDIR="/var/log/apache2" | |
#virtual host domains log directories | |
SITENAMES="\ | |
host1.domain.tld | |
host2.domain.tld | |
" | |
for www in $SITENAMES; do | |
output=$(awk '{if ($9 == 404) {print $7}}' $LOGDIR/$www/access.log \ | |
| sort -rn | uniq -c | sort -rn) | |
if [ -n "$output" ]; then | |
echo " * 404 pages for http://$www" | |
echo "" | |
echo "$output" | |
else | |
echo " * no 404 request for http://$www" | |
fi | |
echo "" | |
done | |
echo "-- " | |
echo "$(basename $0)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment