웹서버 모니터링 툴 awststs

by 조쉬 posted Mar 26, 2014
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄
참조 : http://awstats.sourceforge.net
###########Trouble Shooting############
awstats가 정상적으로 동작하기 위해서는 perl script가 필요하며,
apache에 perl module을 올리던지 아니면 아래에 경로의 pl 소스에서 perl이 설치된 경로를 수정해준다.
a) /usr/local/awstats/wwwroot/cgi-bin
b) /usr/local/awstats/wwwroot/cgi-bin/lib
c) /usr/local/awstats/wwwroot/cgi-bin/plugins
펄 설치 됐나?? -- 확인
[root@ns wwwroot]# find / -name perl -print
/usr/bin/perl
[root@ns wwwroot]#
#####################################
[root@ns sausage]# tar xvfz awstats-6.5.tar.gz
[root@ns sausage]# mv awstats-6.5 /usr/local/awstats
[root@ns sausage]# chmod 755 /usr/local/awstats -R
[root@ns sausage]# mkdir /etc/awstats
[root@ns sausage]# mkdir /var/lib/awstats
[root@ns sausage]# cd /usr/local/awstats/tools/
[root@ns tools]# perl awstats_configure.pl
----- AWStats awstats_configure 1.0 (build 1.6) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).
-----> Running OS detected: Linux, BSD or Unix
-----> Check for web server install
Found Web server Apache config file '/usr/local/apache/conf/httpd.conf'
-----> Check and complete web server config file '/usr/local/apache/conf/httpd.conf'
Warning: You Apache config file contains directives to write 'common' log files
This means that some features can't work (os, browsers and keywords detection).
Do you want me to setup Apache to write 'combined' log files [y/N] ? y
Add 'Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"'
Add 'Alias /awstatscss "/usr/local/awstats/wwwroot/css/"'
Add 'Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"'
Add 'ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"'
Add '<Directory>' directive
AWStats directives added to Apache config file.
-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
File awstats.model.conf updated.
-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y
-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.suhilelec.co.kr
-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
>
-----> Create config file '/etc/awstats/awstats.www.suhilelec.co.kr.conf'
Config file /etc/awstats/awstats.www.suhilelec.co.kr.conf created.
-----> Restart Web server with '/sbin/service httpd restart'
httpd: unrecognized service
-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.suhilelec.co.kr
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...
A SIMPLE config file has been created: /etc/awstats/awstats.www.suhilelec.co.kr.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.suhilelec.co.kr' with command:
> perl awstats.pl -update -config=www.suhilelec.co.kr
You can also read your statistics for 'www.suhilelec.co.kr' with URL:
> http://localhost/awstats/awstats.pl?config=www.suhilelec.co.kr
Press ENTER to finish...
---------------- 일단 설치 완료 / 설정 시작 -----------------
configure.pl 을 잘 실행 시켰으면 자신이 정한 name으로
awstats.[정한 name].conf 파일이 /etc/awstats디렉토리 아래로 생성되어 있을겁니다.
(우리는 awstats.www.suhilelec.co.kr.conf )
# vi /etc/awstats/awstats.www.suhilelec.co.kr.conf
....수정
LogFile="[자신이 사용하는 웹서버의 access 로그]"
우리는
LogFile="/usr/local/apache/log/new-access_log"
를 지정하시면 됩니다.
[root@ns cgi-bin]# pwd
/usr/local/awstats/wwwroot/cgi-bin
[root@ns cgi-bin]# perl awstats.pl -update -config=www.suhilelec.co.kr
.
.
.
. 오류난다...
Your AWStats LogFormat parameter is:
1
This means each line in your web server log file need to have "combined log format" like this:
111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] "GET / HTTP/1.1" 200 1234 "http://www.fromserver.com/from.htm" "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"
And this is an example of records AWStats found in your log file (the record number 50 in your log):
222.97.239.121 - - [01/Apr/2006:00:05:20 +0900] "GET /images/factory/03_p01_03.gif HTTP/1.1" 200 19940
Setup ('/etc/awstats/awstats.www.suhilelec.co.kr.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).

오류 타입이 틀려서 오류나니까 다시 수정

[root@ns wwwroot]#vi /etc/awstats/awstats.www.suhilelec.co.kr.conf (로그 Format 수정하기)
.
.
.
LogFormat = "%host %other %logname %time1 %methodurl %code %bytesd
.
.
.
[root@ns wwwroot]# /usr/local/awstats/tools/awstats_updateall.pl now
Running '"/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -update -config=www.suhilelec.co.kr -configdir="/etc/awstats"' to update config www.suhilelec.co.kr
Update for config "/etc/awstats/awstats.www.suhilelec.co.kr.conf"
With data in log file "/usr/local/apache/logs/new-access_log.200604"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 67480
Found 29 dropped records,
Found 13 corrupted records,
Found 0 old records,
Found 67438 new qualified records.
[root@ns wwwroot]#
성공한듯.....!!!!!!!!!!!!!!!!!!

-----------------------로그 누락없이 로테이트 돌리기 추가 -----------------------
# vi /etc/logrotate.d/apache
/usr/local/apache/logs/*log
{
notifempty
daily
rotate 7
compress
sharedscripts
prerotate
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mydomainconfig
endscript
postrotate
/usr/bin/killall -HUP httpd
endscript
}
#
--------------------- 크론으로 자동 업데이트 하루한번 6시에.. ---------------------
# vi /etc/crontab
.
.
.
00 6 * * * root /usr/local/awstats/tools/awstats_updateall.pl now > /dev/null //추가
#