#アクセスの多いIP順にランキング less /var/log/nginx/access.log | cut -f 1 -d " " | sort | uniq -c | sort -g -r | more #過去ログの場合 zcat /var/log/nginx/access.log-20240907.gz | cut -f 1 -d " " | sort | uniq -c | sort -g -r | more #アクセスログから2024/10/04のアクセス数を時間帯ごとに表示 for i in `seq -w 0 23`; do echo $i `cat /var/log/nginx/access.log | grep "04/Oct/2024:$i" | grep "GET \/" | grep -ive "GET /.*\.\(css\|js\|jpg\|gif\|png\|ico\)\ HTTP" | egrep -iv "dummy connection|robots\.txt" | wc -l`; done; #エラーログの場合 for i in `seq -w 0 23`; do echo $i `cat /var/log/nginx/error.log | grep "2024/10/04 $i" | wc -l`; done;
参考:https://blog.jicoman.info/2014/04/access-log_extract/
コメント