首先,下载安装nail工具,查询IP地址所用的组件:
wget http://rfyiamcool.googlecode.com/files/nali-0.1.tar.gz
tar zxvf nali-0.1.tar.gz
cd nali-0.1
./configure && make && make install
日志分析用shell/ target=_blank class=infotextkey>shell脚本:
#!/bin/bash
#rfyiamcool
IPSUMFILE=access_ip.log
SAVEFILE=ipaddress.txt
echo -e "IP地址ttttt来源n----------------------------------------------------">$SAVEFILE
#log path
LOG_DIR=/usr/local/
apache/logs/
for i in $LOG_DIR/*.log
do
cat /etc/httpd/logs/access_log|
linuxjishu/13830.html target=_blank class=infotextkey>awk '{print $1}'|sort|uniq -c|sort -nr|awk '{print $2}'>>$IPSUMFILE
done
for i in `cat $IPSUMFILE`
do
nali $i >> $SAVEFILE
done
生成文件后,用cat命令查看结果即可。
>> 查看更多shell脚本进行apache日志分析的方法。