How to implement and analyze the region where ip is located in the apache log of Shell scripts
This article mainly explains "how to achieve and analyze the Shell script apache log in the region", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "how to achieve and analyze the Shell script apache log in the ip area" bar!
Query the components used by the ip address
The code is as follows:
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 those of nginx, except that the method of getting the ip address in the log is different.
The code is as follows:
#! / bin/bash
# rfyiamcool
IPSUMFILE=access_ip.log
SAVEFILE=ipaddress.txt
Echo-e "IP address\ t\ t Source\ nMurray -" > $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
Thank you for your reading, the above is "how to achieve and analyze the Shell script apache log in the ip region" content, after the study of this article, I believe you on how to achieve and analyze the Shell script apache log in the region of this problem has a more profound experience, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!