下面分享一下我用Shell编写的分析Nginx日志的脚本,它可以快速得出排名最前的网 站和IP等,内容如下所示: Most of the ip: ------------------------------------------- 220 59.41.24.48 178 59.41.24.80 172 183.57.82.35 Most of the time: -------------------------------------------- 51 15:55 51 15:16 36
目录
名称
pgBadger-快速的PostgreSQL日志分析报告
概要
用法:pgbadger [选项]日志文件[...]
PostgreSQL log analyzer with fully detailed reports and graphs.
参数:
logfile can be a single log file, a list of files, or a shell command
returning a list of files. If you want to pass
下面的脚本能统计出网站的总访问量,以及404,500出现的次数。统计出来后,我们可以结合监控宝来进行记录,进而可以看出网站访问量是否异常,是否存在攻击,一目了然。还可以根据查看500出现的次数,进而判断网站程序是否出现异常。 代码如下:#!/bin/bash#purpose:count nginx or apache or other webserver status code using jiankongbao#how to:run the scr ipt every 5 minutes wi
本文将介绍用shell脚本来分析Nginx负载均衡器的日志,这样可以快速得出排名靠前的网站和IP等,推荐大家使用线上环境下的shell脚本。本文中的shell脚本又分为两种情况,第一种情况是Nginx作为前端的负载均衡器,其集群架构为Nginx+Keepalived时,脚本内容如下所示:
vim log-nginx.sh
#!/bin/bash
if [$# -eq 0 ]; then
echo Er