Skip to main content
การวิเคราะห์ Log Files แบบ Real-time ของ Application Server ด้วย AWstats

AWstats เป็นทูลในการวิเคราะห์ Log Files ของ Application Server อาทิ Web Server, Streamming Server, FTP Server, Proxy และ Mail Server แบบ Real-time มีขนาดเล็กและความเร็วในการใช้งาน แสดงผลในรูปแบบกราฟิก ผู้ดูแลระบบสามารถตรวจสอบการใช้งานได้ผ่านทางหน้าเว็บไซต์ AWstats พัฒนามาแนว CGI จากภาษา PERL มีลิขสิทธิ์แบบ GPL สามารถนำไปติดตั้งใช้งานได้ฟรี อีกทั้งสามารถติดตั้งใช้งานได้ทั้งระบบ Linux Server และ Windows Server

** สามารถดู Demo ได้ที่เว็บ http://www.nltechno.com/awstats/awstats.pl?config=destailleur.fr
** อ่านรายละเอียดเพิ่มเติมได้ที่เว็บไซต์ www.awstats.org

ไฟล์ล็อกที่สามารถกำหนดค่าเพิ่มเติมได้
1. Apache หรือ Lotus Notes/Domino native combined log format (NCSA combined/XLF/ELF log format)
2. IIS หรือ ISA format (IIS W3C log format). See FAQ-COM115 For ISA.
3. Webstar native log format
4. Apache or Squid native common log format (NCSA common/CLF log format)

ความสามารถของ AWstats
AWstats สามารถช่วยในการวิเคราะห์ข้อมูลสารสนเทศต่างๆ ได้ดังนี้
o Number of visits, and number of unique visitors
o Visits duration and last visits
o Authenticated users, and last authenticated visits
o Days of week and rush hours (pages, hits, KB for each hour and day of week)
o Domains/countries of hosts visitors (pages, hits, KB, 269 domains/countries detected, GeoIp detection)
o Hosts list, last visits and unresolved IP addresses list
o Most viewed, entry and exit pages,
o Files type,
o Web compression statistics (for mod_gzip or mod_deflate)
o OS used (pages, hits, KB for each OS, 35 OS detected)
o Browsers used (pages, hits, KB for each browser, each version (Web, Wap, Media browsers: 97 browsers, more than 450 if using browsers_phone.pm library file)
o Visits of robots (319 robots detected)
o Worms attacks (5 worm's families)
o Search engines, keyphrases and keywords used to find your site (The 115 most famous search engines are detected like yahoo, google, altavista, etc...)
o HTTP errors (Page Not Found with last referrer, ...)
o Other personalized reports based on url, url parameters, referer field for miscellanous/marketing purpose
o Number of times your site is "added to favourites bookmarks"
o Screen size (need to add some HTML tags in index page).
o Ratio of Browsers with support of: Java, Flash, RealG2 reader, Quicktime reader, WMA reader, PDF reader (need to add some HTML tags in index page)
o Cluster report for load balanced servers ratio

ความต้องการของ AWstats 6.9 up
ภาษา PERL 5.x ขึ้นไป (สำหรับรันไฟล์ .pl, .cgi)
o Perl สำหรับ Linux/BSD/Unix (Solaris, AIX, HPUX or UNIX-like system) > https://www.perl.org/get.html
o Active Perl สำหรับระบบ Windows > http://www.activestate.com/activeperl

ค่าพื้นฐาน (Possible values) ในการกำหนด
o W = web log file
o S = streaming log file
o M = mail log file
o F = ftp log file

ขั้นตอนการติดตั้ง
1. ทำการติดตั้งแพ็กเกจ EPEL ก่อนหากยังไม่ได้ติดตั้ง
# rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-7.noarch...

2. ติดตั้งแพ็กเกจ awstats
# yum --enablerepo=epel install -y awstats

3. ทำการตัดลอกไฟล์คอนฟิก พร้อมเปิดแก้ไขไฟล์ (logs01.sysadmin.in.th เปลี่ยนเป็นชื่อโฮสต์ที่ใช้งานอยู่)
# cp /etc/awstats/awstats.localhost.localdomain.conf /etc/awstats/awstats.logs01.sysadmin.in.th.conf
# vi /etc/awstats/awstats.logs01.sysadmin.in.th.conf

แก้ไขไฟล์ดังนี้
บรรทัดที่ 50 พาทในการเก็บไฟล์ล็อกของ Web Server
LogFile="/var/log/httpd/access_log"

บรรทัดที่ 62 กำหนดชนิดไฟล์ล็อก ในที่นี้เลือกเป็น W
LogType=W

บรรทัดที่ 122 เลือกรูปแบบ Apache เป็น 1 (IIS LogFormat = 2)
LogFormat=1

บรรทัดที่ 153 กำหนดโดเมนเนม
SiteDomain="logs01.sysadmin.in.th"

บรรทัดที่ 168 กำหนดชื่อย่อโฮสต์
HostAliases="logs01.sysadmin.in.th logs01 localhost 127.0.0.1"

บรรทัด 203, 212, 222 กำหนดพาทในการเก็บข้อมูล
DirData="/var/lib/awstats"
DirCgi="/awstats"
DirIcons="/awstatsicons"

บรรทัดที่ 239, 259, 279 กำหนดการอัปเดทเว็บเบราเซอร์
AllowToUpdateStatsFromBrowser=1
AllowFullYearView=2
EnableLockForUpdate=1

บรรทัดที่ 372, 382, 450 กำหนดการแสดงรายงาน
BuildHistoryFormat=text
BuildReportFormat=html
DefaultFile="index.php index.html"

4. ปรับแต่งไฟล์ awstats.conf ให้สามารถทำงานร่วมกับ Apache พร้อมทั้งกำหนดสิทธิโซนไอพีของกลุ่มผู้ให้ที่อนุญาติให้เข้าใช้งาน
# vi /etc/httpd/conf.d/awstats.conf
แก้ไขส่วนของ
Require ip 192.168.1.0/24
Allow from 127.0.0.1 192.168.1.0/24

5. ทำการรีสต๊าท Apache
# systemctl restart httpd

6. เริ่มสร้างรายงานด้วยสคริปต์ awstats.pl
# /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=logs01.sysadmin.in.th -update

Create/Update database for config "/etc/awstats/awstats.logs01.sysadmin.in.th.conf" by AWStats version 7.4 (build 20150714)
From data in log file "/var/log/httpd/access_log"...
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: 305
Found 0 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 0 old records,
Found 305 new qualified records.

7. ตรวจสอบรายงานที่เว็บเบราเซอร์
รูปแบบ
http://your-server-ip/ awstats/awstats.pl?config=mysite
ตัวอย่าง

http://192.168.1.5/awstats/awstats.pl?config=logs01.sysadmin.in.th

ตัวอย่างหน้าตรวจสอบรายงานที่เว็บเบราเซอร์

บทสรุป
AWstats นับเป็นทูลในการวิเคราะห์ Log Files ในระดับ Application Server ที่มีขนาดเล็ก และมีความเร็วในการใช้งานอีกตัวหนึ่ง พัฒนาจากภาษา PERL เหมาะสำหรับนำมาเก็บไฟล์ล็อกซ์ของ Web Server(Apache, IIS), Mail Server, FTP Server, Streamming Server ใช้งานสำหรับหน่วยงานที่ติดตั้งเซิร์ฟเวอร์เหล่านี้ไว้ การติดตั้งใช้เวลาเพียงเล็กน้อยเท่านั้น

----
แหล่งข้อมูลอ้างอิง
- http://www.awstats.org/
- https://en.wikipedia.org/wiki/AWStats
- https://sourceforge.net/projects/awstats/

---
Write by Dr.Arnut Ruttanatirakul
(c) by SysAdmin Knowledge.
http://www.sysadmin.in.th
July 01, 2016