Shell script to analyze the region where the ip is located in the apache log

Time:2022-8-5

The component used to query the ip address

copy codecode show as below:
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 

The steps are similar to nginx, but the method of getting the ip address in the log is different~~~

copy codecode show as below:
#!/bin/bash 
#rfyiamcool 
IPSUMFILE=access_ip.log 
SAVEFILE=ipaddress.txt 
echo -e "IP address\t\t\t\t\tsource\n——————————- ———————">$SAVEFILE
#log path 
LOG_DIR=/usr/local/apache/logs/ 
for i in $LOG_DIR/*.log 
do 
 cat /etc/httpd/logs/access_log|awk ‘{print $1}’|sort|uniq -c|sort -nr|awk ‘{print $2}’>>$IPSUMFILE
done 
for i in `cat $IPSUMFILE` 
do 
nali $i >> $SAVEFILE 
done 

Finally cat view~~