Last active
February 10, 2019 22:39
-
-
Save sowe/438539d857b5e65be3bf68a1876518e6 to your computer and use it in GitHub Desktop.
script apache status
This file contains 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/bash | |
# https://i-heart-geek.blogspot.com.es/2011/10/top-command-line-tips-apache-access-log.html?m=1 | |
# http://www.the-art-of-web.com/system/logs/ | |
ip = ifconfig | awk '/inet addr/{print substr($2,6)}' | |
clear | |
while : | |
do | |
echo "1) Most Common 404s (Page Not Found)" | |
echo "2) Count requests by HTTP code" | |
echo "3) Largest Images" | |
echo "4) Filter Your IPs Requests (parameter IP)" | |
echo "5) Top Referring URLS" | |
echo "6) Top Crawlers" | |
echo "7) Numero of ip" | |
echo "8) Numero of Error" | |
echo "9) Exit" | |
echo -n "Seleccione una opcion [1 - 9]" | |
read opcion | |
case $opcion in | |
1) | |
echo "1) Most Common 404s (Page Not Found)" | |
cut -d'"' -f2,3 /home/aquiactualidad/logs/aquiactualidad.com/http/access.log | awk '$4=404{print $4" "$2}' | sort | uniq -c | sort -rg | head -20 | |
;; | |
2) | |
echo "2) Count requests by HTTP code" | |
cut -d'"' -f3 /home/aquiactualidad/logs/aquiactualidad.com/http/access.log | cut -d' ' -f2 | sort | uniq -c | sort -rg | |
;; | |
3) | |
echo "3) Largest Images" | |
cut -d'"' -f2,3 /home/aquiactualidad/logs/aquiactualidad.com/http/access.log | grep -E '\.jpg|\.png|\.gif' | awk '{print $5" "$2}' | sort | uniq | sort -rg | head -50 | |
;; | |
4) | |
echo "4) Filter Your IPs Requests" | |
cat /home/aquiactualidad/logs/aquiactualidad.com/http/access.log | grep 173.236.240.64 | sort | uniq | sort -rg | | |
;; | |
5) | |
echo "5) Top Referring URLS" | |
cut -d'"' -f4 /home/aquiactualidad/logs/aquiactualidad.com/http/access.log | grep -v '^-$' | grep -v '^http://aquiactualidad.com' | sort | uniq -c | sort -rg | |
;; | |
6) | |
echo "6) Top Crawlers" | |
cut -d'"' -f6 /home/aquiactualidad/logs/aquiactualidad.com/http/access.log | grep -f bots.txt | sort | uniq -c | sort -rg | |
;; | |
7) | |
echo "7) Num of ip" | |
cat /home/aquiactualidad/logs/aquiactualidad.com/http/access.log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -20 | |
;; | |
8) | |
echo "8) Numero of Error" | |
sed -e "s/\[.*\]\([^:]*\)\(.*\)/\1/" /home/aquiactualidad/logs/aquiactualidad.com/http/error.log | sort | uniq -cd | |
;; | |
9) | |
echo "9) exit" | |
exit 1 | |
;; | |
*) echo "$opc no es una opcion válida."; | |
echo "Presiona una tecla para continuar..."; | |
read foo;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment