หน้าเว็บ

แสดงบทความที่มีป้ายกำกับ log แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ log แสดงบทความทั้งหมด

วันศุกร์ที่ 16 ตุลาคม พ.ศ. 2552

Squid Analysis Report Generator ( SARG ) Tool For Enterprise

ความสำเร็จในการนำลีนุกซ์มาใช้ในองค์กร

คุณสมชาย โสภิตปิยกุล
Thai Yazaki Corporation Co.,Ltd

"เรื่องราวของการประยุกต์ใช้งานลีนุกซ์เป็น Proxy Server อีกหนึ่งบริการพื้นฐานที่ทุก ๆ องค์กรจำเป็นต้องใช้งาน "

ใน วันนี้การเชื่อมโยงองค์กรเข้าสู่อินเตอร์เน็ตดูเหมือนเป็นเรื่องธรรมดาเป็น เสียแล้ว ทุก ๆ หน่วยงานในองค์กรมีความต้องการที่จะใช้งานอินเตอร์เน็ตเพิ่มขึ้น จนกลายเป็นส่วนหนึ่งของการทำงานประจำวัน ที่ฝ่ายคอมพิวเตอร์จะต้องจัดสร้างระบบขึ้นเพื่อรองรับความต้องการดังกล่าว

เรื่อง ราวของลีนุกซ์โซลูชั่นในฉบับนี้ จะนำเรื่องราวความสำเร็จของลีนุกซ์ในองค์กรเอกชน บ.ไทยยาซากิ จก. ผู้ผลิตสายไฟฟ้า สวิทช์ไฟฟ้ารายใหญ่ของเมืองไทย ซึ่งมีบริษัทในเครืออีกประมาณ 6 บริษัท และมีจำนวนเครื่องลูกข่ายมากกว่า 100 เครื่อง จึงต้องมีใช้ซอฟต์แวร์ในส่วนงานต่าง ๆ เป็นจำนวนมาก รวมทั้งต้องอาศัยการสื่อสารที่มีประสิทธิภาพเพื่อการประสานงานอย่างเป็นระบบ ภาระหน้าที่ของเจ้าหน้าที่ผู้อยู่เบื้องหลังคงหนีไม่พ้นฝ่ายคอมพิวเตอร์และ ไอทีนั่นเอง

ไม่เพียงด้านประสิทธิภาพของงาน และความเชื่อถือได้ของระบบเท่านั้น การเลือกใช้ซอฟต์แวร์ที่เหมาะสมกับองค์กรเป็นอีกภาระกิจหนึ่งของฝ่าย คอมพิวเตอร์ทุกคนที่จะสามารถช่วยลดต้นทุนและสร้างผลกำไรให้เกิดขึ้นแก่ องค์กรได้ จึงเป็นเหตุผลสำคัญที่ทำให้ระบบปฏิบัติการลีนุกซ์ได้รับการคัดเลือกเพื่อนำ มาใช้งานเป็นเซิร์ฟเวอร์ในองค์กรแห่งนี้

อินเตอร์เน็ตเกตเวย์ และ Proxy Server

การ สื่อสารใช้งานอินเตอร์เน็ตถือเป็นงานบริการพื้นฐานที่พนักงานทุกคนจะต้อง สามารถเข้าถึงและใช้งานได้อย่างสะดวก ไม่ว่าจะเป็นการสืบค้นข้อมูลจากเว็บไซต์ต่าง ๆ การติดต่อด้วยอีเมล์ เพื่อทำให้งานในส่วนต่าง ๆ สามารถดำเนินไปได้ตามเป้าหมายของบริษัท สำหรับโซลูชั่นที่จะสนองความต้องการเช่นนี้ ลีนุกซ์สามารถทำหน้าที่เป็นอินเตอร์เน็ตเซิร์ฟเวอร์ได้เป็นอย่างดีอยู่แล้ว โดยอาศัยคุณสมบัติของ Packet Filter เช่น โปรแกรม ipchains หรือ NetFilter / iptables เครื่องพีซีธรรมดาก็จะทำงานเป็น NAT ( Network Address Translation ) ช่วยให้เครื่องลูกข่ายในเน็ตเวิร์กทั้งหมดออกสู่อินเตอร์เน็ตพร้อมกันด้วย โมเด็มหรือเราต์เตอร์เพียงชุดเดียวเท่านั้น

ถึงแม้ว่า เครื่องลูกข่ายทั้งหมดจะสามารถใช้งานอินเตอร์เน็ตได้อย่างที่ต้องการแล้วก็ ตาม แต่ก็ยังมีบางสิ่งที่ควรเสริมเข้าไปอีกคือ คุณสมบัติในด้านการจำกัดสิทธิที่จะเข้าถึงเว็บไซต์บางแห่งที่มีเนื้อหาไม่ สมควรเข้าชม การจำกัดยูสเซอร์ใช้งานในเวลาที่นอกเหนือจากเวลางาน หรือข้อจำกัดอื่น ๆ ที่ทำให้สิ้นเปลืองค่าใช้จ่ายไปโดยไม่ก่อให้เกิดประโยชน์ คุณสมบัติเช่นนี้ลำพังอินเตอร์เน็ตเกตเวย์คงยังไม่เพียงพอ จะต้องอาศัยพร๊อกซี่เซิร์ฟเวอร์ ( Proxy Server ) เข้ามาช่วยเสริมอีกแรงหนึ่ง ซึ่งภายในลีนุกซ์ทุกดิสทริบิวชั่นจะมีโปรแกรมพร๊อกซี่เซิร์ฟเวอร์ที่มี ประสิทธิภาพสูงให้มาพร้อมแล้ว คือ โปรแกรม Squid

โปรแกรม Squid เป็น Proxy Server ที่มีคุณสมบัติในการจำกัด ควบคุมการแอกเซสเข้าสู่เว็บไซต์ภายนอกองค์กรได้เป็นอย่างดีและมีประสิทธิภาพ ที่เรียกว่า Access Control List ( ACL ) ซึ่งเป็นการนิยามชื่อลิสต์ขึ้นแทนคุณสมบัติของสิ่งที่ต้องการอ้างอิง จากนั้นจึงตั้งข้อกำหนดลงไปว่าต้องการให้ลิสต์นั้นสามารถแอกเซสผ่านพร๊อกซี่ ได้หรือไม่ ตัวอย่างเช่น

acl floor1 src 192.168.1.0/255.255.255.0
acl blacklist urlpath_regex sex hack casino chat download
http_access deny blacklist
http_access allow floor1

  • จะมีความหมายดังนี้ - floor1 เป็นชื่อลิสต์ที่ตั้งขึ้นมา หมายถึง ทุกโฮสต์ที่อยู่ในเน็ตเวิร์ก 192.168.1.0
  • blacklist เป็นชื่อลิสต์ที่เป็นตัวแทนของ URL ที่มีคำว่า sex hack casino chat download เป็นส่วนประกอบ
  • ในบรรทัดที่ 3 เป็นการกำหนดว่า หากผู้ใช้งานอินเตอร์เน็ตต้องการเข้าสู่เว็บที่ตรงกับลิสต์ชื่อ blacklist ให้ปฏิเสธทันที
  • ส่วนบรรทัดที่ 4 เป็นการกำหนดว่า หากผู้ใช้งานอินเตอร์เน็ตเป็นโฮสต์ที่ตรงตามลิสต์ floor1 จะยินยอมให้แอกเซสพร๊อกซี่ ( ยินยอมให้เข้าไปสู่อินเตอร์เน็ต ) ได้
ดังนั้นการที่เสริมการทำงานของอินเตอร์เน็ตเซิร์ฟเวอร์ด้วย Squid Proxy Server จึงเป็นการควบคุมการเข้าสู่อินเตอร์เน็ตของผู้ใช้งานในองค์กรได้ตามต้องการ และยังช่วยเพิ่มประสิทธิภาพให้แก่ระบบอีกด้วยเพราะ Squid จะมีคุณสมบัติเป็น HTTP Object cache ที่ช่วยเก็บข้อมูลจากเว็บไซต์ภายนอกไว้ในหน่วยความจำ ( RAM และฮาร์ดดิสก์ ) ของตัวเซิร์ฟเวอร์เองอีกด้วย ช่วยให้การเรียกเว็บไซต์ที่เคยเข้าถึงมาก่อนทำได้รวดเร็วยิ่งขึ้นเนื่องจาก มีข้อมูลบางส่วนของเว็บเพจที่ยังคงอยู่ในแคชนั่นเอง

ข้อมูลการแอกเซสสู่เว็บไซต์
เนื่อง จาก Squid Proxy Server ทำหน้าที่เป็นประตูที่กั้นกลางระหว่างผู้ใช้งานภายในองค์กร กับเครือข่ายอินเตอร์เน็ตภายนอก ดังนั้นข้อมูลจากล๊อกไฟล์ของ Squid ที่จะมีการบันทึกไว้ทุก ๆ ครั้งที่เครื่องลูกข่ายมีการร้องขอเพื่อเข้าสู่เว็บไซต์ต่าง ๆ จึงเป็นข้อมูลที่เป็นประโยชน์ต่อผู้ดูแลระบบในการวิเคราะห์ดูพฤติกรรมการใช้ งานอินเตอร์เน็ตได้เป็นอย่างดี โดยจะสามารถเฝ้าดูความเคลื่อนไหวของล๊อกไฟล์ดังกล่าวได้ด้วยคำสั่ง

# tail -f /var/log/squid/access.log

คำ สั่งดังกล่าวจะทำการรายงานข้อมูลล่าสุดจากล๊อกไฟล์ของ Squid คือ /var/log/squid/access.log อย่างต่อเนื่อง ( เป็นผลมาจากพารามิเตอร์ -f ของคำสั่ง tail หมายถึง Follow ) ผลลัพธ์จะปรากฏดังตัวอย่างดังรูป



จาก รูปจะเห็นว่าเราสามารถทราบได้ว่าโฮสต์หมายเลข 192.168.0.9 ในเครือข่ายของเรา ออกไปชมเว็บไซต์ใดบ้าง โหลดไฟล์ใดมีขนาดเท่าไหร่บ้าง ไฟล์ access.log ของ Squid นี้จะอยู่ในรูปของไฟล์ข้อความธรรมดา ดังนั้นเราจึงสามารถอ่านได้โดยตรง และโดยปรกติแล้วไฟล์นี้จะมีการเปลี่ยนชื่อไฟล์ที่บันทึกข้อมูลเองโดย อัตโนมัติ โดยอาศัยบริการชื่อ logrotate ทุก ๆ สัปดาห์

สร้างรายงานที่ดีกว่าด้วย SARG

ถึง แม้ว่าการอ่านล๊อกไฟล์ของ Squid จะทำให้เราทราบการเรียกใช้งานเว็บไซต์ต่าง ๆ ของผู้ใช้ในระบบได้ก็ตาม แต่ก็ได้ข้อมูลที่ใช้ประโยชนได้ไม่มากนัก ทั้งนี้เนื่องจากเป็นข้อมูลดิบเกินไป รูปแบบก็อ่านได้ยาก ดังนั้นจึงมีโปรแกรมโอเพ่นซอร์สที่ถูกพัฒนาขึ้นเพื่อการวิเคราะห์ และสร้างรายงานในรูปแบบที่สะดวกต่อการนำข้อมูลมาใช้งานมากยิ่งขึ้น โปรแกรมประเภทนี้มีอยู่หลายตัว แต่ที่น่าสนใจและนำมาใช้งานได้อย่างดี คือ โปรแกรม SARG ( Squid Analysis Report Generator )

SARG เป็นโปรแกรมที่ออกแบบมาเพื่อทำงานร่วมกับ Squid โดยจะทำการวิเคราะห์ข้อมูลจากล๊อกไฟล์ของ Squid แล้วนำมาสร้างรายงานข้อมูลเชิงสถิติในหลาย ๆ ด้านเพื่อให้ผู้ดูแลระบบสามารถอ่านข้อมูลได้อย่างง่ายดายในรูปของเอกสารเว็บ เพจ ( HTML ) ดังนั้นจึงง่ายต่อการนำเสนอผ่านเว็บเซิร์ฟเวอร์ ( Apache Web Server ) ซึ่งลีนุกซ์เองมักจะติดตั้งให้มาพร้อมอยู่แล้วเช่นเดียวกับซอฟต์แวร์สำคัญ อื่น ๆ



รูปแผนผังการทำงานของ SARG ร่วมกับบริการ Squid และ Apache
ผู้ ดูแลระบบจึงสามารถมอนิเตอร์ดูข้อมูลสถิติการใช้งานเว็บไซต์ต่าง ๆ ผ่านทางโปรแกรมเว็บบราวเซอร์ได้จากเครื่องคอมพิวเตอร์เครื่องใดก็ได้ในเครือ ข่าย แน่นอนว่าจะสั่งพิมพ์รายงานนั้น ๆ ออกมาได้ไม่ยากเช่นกัน แต่ถ้าหากข้อมูลเหล่านี้ต้องการปิดเป็นความลับ ( ไม่ต้องการให้ผู้ใช้งานทั่วไปเปิดดูรายงานนี้ได้ ) ก็ควรป้องกันด้วยการควบคุมการเข้าถึงเว็บเซิร์ฟเวอร์ ( Host Access Control ) หรือกำหนด Restriction เฉพาะบุคคลที่ได้รับอนุญาติเท่านั้นก็ได้ ( HTTP User Authentication ) ซึ่งเป็นคอนฟิกในส่วนความปลอดภัยของเว็บเซิร์ฟเวอร์นั่นเอง

การติดตั้งและคอนฟิก SARG
โปรแกรม SARG นี้เป็นซอฟต์แวร์โอเพ่นซอร์ส สามารถหาดาวน์โหลดได้จากเว็บไซต์ของผู้พัฒนาโปรแกรมโดยตรงที่ http://web.onda.com.br/orso/ ซึ่งมีซอฟต์แวร์ที่น่าสนใจให้ดาวน์โหลดมาใช้งานได้ฟรีอีกหลายตัวทีเดียว สำหรับ SARG จะมีไฟล์ที่ให้เลือกดาวน์โหลดทั้งแบบที่เป็น Tarball และเป็นแพคเกจ RPM ในที่นี้ผู้เขียนเลือกที่จะติดตั้งจากไฟล์ชนิด Tarball ซึ่งโปรแกรมนี้สามารถทำงานได้ดีบน Red Hat Linux ทุกรุ่นรวมทั้ง รุ่น 9.0 ซึ่งเป็นรุ่นปัจจุบันที่ผู้เขียนใช้ในการทดสอบครั้งล่าสุดนี้ด้วย

หลัง จากดาวน์โหลดไฟล์โปรแกรม sarg-1.4.1.tar.gz ขนาด 123KB มาแล้ว การติดตั้งสามารถทำได้ง่ายมาก โดยใช้คำสั่ง Tar แตกไฟล์ออกมาจะปรากฏเป็นไดเร็คทอรี่ sarg-1.4.1 ให้เข้าไปในไดเร็คทอรี่นี้ แล้วพิมพ์คำสั่งตามลำดับนี้

# ./configure
# pico Makefile แก้ไขข้อความบรรทัด MANDIR ตามรูป
หลัง จากที่ใช้คำสั่ง ./configure แล้ว จำเป็นต้องปรับแก้ไขตำแหน่งของ Man page ของโปรแกรม SARG เล็กน้อย โดยแก้ไขข้อความบรรทัด MANDIR = /usr/local/man/man1 เป็น MANDIR = /usr/share/man/man1 แล้วบันทึกไว้ก่อนจะทำการคอมไพล์โปรแกรมต่อไป



ลำดับต่อมาให้พิมพ์คำสั่ง make และ make install ตามลำดับ โปรแกรมจะได้รับการคอมไพล์และติดตั้งในที่ ๆ กำหนดไว้ดังนี้

ตัวโปรแกรม SARG อยู่ที่ /usr/bin/sarg
คอนฟิกไฟล์อยู่ที่ /usr/local/sarg/sarg.conf

การ คอนฟิกเบื้องต้นเพื่อให้ SARG ทำงานได้ใน Red Hat 9.0 จะต้องแก้ไขไฟล์คอนฟิกเล็กน้อย โดยใช้ Text Editor ที่คุณถนัดแก้ไขไฟล์ /usr/local/sarg/sarg.conf ที่บรรทัดข้อความต่อไปนี้ โดยค้นหาแล้วลบเครื่องหมาย # ที่คอมเมนต์ไว้ออก และแก้ไขตำแหน่งอ้างอิงใหม่ให้ตรงกับความเป็นจริงในระบบของเรา

access_log /var/log/squid/access.log
output_dir /var/www/html/squid_reports

มี ข้อควรระวังคือ อย่าให้มีเครื่องหมายวรรค ( space ) หรือ Tab อยู่ท้ายบรรทัดข้อความทั้งสองเด็ดขาด มิฉะนั้นโปรแกรมจะทำงานผิดพลาด จุดนี้ทำให้ผู้เขียนเสียเวลาไปพอสมควรที่เดียว

ต่อจากนั้นให้ ทดสอบการทำงานของ SARG โดยพิมพ์คำสั่ง sarg แล้วกด Enter เพื่อให้ทำการสร้างรายงานเป็นครั้งแรก โดยก่อนจะทดสอบเช่นนี้ได้จะต้องมีการรัน Squid ให้บริการไปแล้วซักระยะหนึ่งเพื่อให้มีข้อมูลปรากฏอยู่ใน access.log ของ Squid เสียก่อน หาก SARG สามารถทำงานได้อย่างถูกต้องจะปรากฏไฟล์ที่เป็นเว็บเพจขึ้นที่ output_dir ดังรูป



ตั้งเวลากระตุ้น SARG ด้วย cron
โดย ปรกติ แล้ว เราควรให้ SARG สรุปรายงานให้ทุก ๆ ช่วงเวลา เช่น สรุปทุก ๆ วันเป็นต้น ดังนั้นจึงต้องใช้โปรแกรม crond ซึ่งเป็น Schedule Jab Daemon ช่วยในการกระตุ้นให้ SARG วิเคราะห์สรุปรายงานของ Squid ในเวลาเที่ยงคืนของทุกวัน โดยเพิ่มข้อความต่อไปนี้ลงในไฟล์ /etc/crontab

0 0 * * * root /usr/bin/sarg

หาก โปรแกรม Apache Web Server ในเครื่องเซิร์ฟเวอร์ลีนุกซ์ของเราทำงานอยู่ตามปรกติ ผู้ใช้งานจะสามารถเปิดหน้าเว็บเพจของ SARG ที่รายงานสถิติของ Squid ได้ผ่านโปรแกรมเว็บบราวเซอร์ทั่วไป มีหน้าจอที่รายงานข้อมูลให้หลากหลายรูปแบบ ดังรูปต่อไปนี้





สถิติเครื่องลูกข่าย( หรือยูสเซอร์ ) ที่ใช้งานเว็บมากที่สุด





รายชื่อเว็บไซต์ที่มีการเรียกใช้งานมากที่สุด







100 อันดับเว็บไซต์ที่ผู้ใช้นิยมเข้าชม




หน้าแรกของ SARG จะแสดงเรียงตามวันที่สรุปรายงาน


เปิดใจ..เปิดเผยซอร์สโค๊ดสู่เสรีภาพ
โปรแกรม SARG หรือ Squid Analysis Report Generator เป็นเครื่องมือสำหรับผู้ดูแลระบบเครือข่ายอีกชิ้นหนึ่งที่จะช่วยให้ทราบการ ใช้งานอินเตอร์เน็ตของยูสเซอร์ในองค์กรได้อย่างเป็นรูปธรรม ต้องขอขอบคุณประสบการณ์ที่เป็นประโยชน์อย่างยิ่งจากคุณสมชายที่ได้เอื้อ เฟื้อข้อมูลเกี่ยวกับการประยุกต์ใช้งานลีนุกซ์และซอฟต์แวร์โอเพ่นซอร์สใน บริษัท ถึงแม้ว่าจะมีเสรีภาพของการเผยแพร่มากแค่ไหนก็ตาม คุณค่าของซอฟต์แวร์โอเพ่นซอร์สไม่มีทางที่จะถูกนำมาใช้ประโยชน์ในวงกว้างได้ เลย หากปราศจากความรู้ความเข้าใจในวัฒนธรรมของสังคมโอเพ่นซอร์ส และความเสียสละจากพวกเราทุกคน
รูปแบบการประยุกต์ใช้งานลีนุกซ์ ในโซลูชั่นระดับองค์กรมีอีกมากมาย ท่านผู้อ่านสามารถติดตามได้จากเว็บไซต์ของผู้เขียน http://www.itdestination.com ในฉบับหน้าจะเป็นโซลูชั่นในด้านไหนโปรดติดตามในตอนต่อไป ฉบับนี้สวัสดีครับ


Thanks : คุณสมชาย โสภิตปิยกุล

วันพฤหัสบดีที่ 15 ตุลาคม พ.ศ. 2552

How to use AWStats together with LiteSpeed Web Server?

AWStats can be used as an add-on module of LiteSpeed web server. It has been seamlessly integrated into our web administration console, and the configuration and statistical updates has been automated as well.
To install AWStats as an add-on module, please run script:
lsws/admin/misc/awstats_install.sh
This script will try to download the latest AWStats package from www.awstats.org, expand it under lsws/add-ons/ directory and create a symbolic link from "./awstats-x.x" to "awstats". If it fails to download for any reason, you can manually do this step as well.

Next step is to enable AWStats add-on module for the virtual host that you would have AWStats analyze its access log.
From the Web Admin console, just select the virtual host on left, click "Add-on" tab on the right, then fill in configurations in "AWStats Integration" table. Configurations are
After applying the configuration changes, you can access the statistical results produced by AWStats by clicking "statistics" action link for that virtual host under "Server Manager" page.

Customize AWStats configuration file:

AWStats configuration file is generated automatically based on a model configuration file /conf/awstats.model.conf, which is copied from lsws/add-ons/awstats/wwwroot/cgi-bin/awstats.model.conf. The following configuration parameters are populated by LiteSpeed: "LogFile", "LogType", "LogFormat", "SiteDomain", "HostAliases", "DirData", "DirConfig" and "DirIcons". Other parameters can be customized by changing awstats.model.conf.
NOTE: Never edit the destination configuration file as it is always overwritten by LiteSpeed before invoking AWStats updates.

Thanks : litespeedtech.com

What is AWStats?

What is AWStats

AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a CGI or from command line and shows you all possible information your log contains, in few graphical web pages. It uses a partial information file to be able to process large log files, often and quickly. It can analyze log files from all major server tools like Apache log files (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C log format) and a lot of other web, proxy, wap, streaming servers, mail servers and some ftp servers.
Take a look at this comparison table for an idea on features and differences between most famous statistics tools (AWStats, Analog, Webalizer,...).
AWStats is a free software distributed under the GNU General Public License. You can have a look at this license chart to know what you can/can't do.
As AWStats works from the command line but also as a CGI, it can work with all web hosting providers which allow Perl, CGI and log access.


Example :
1. Demo for web server log files
2. Static demo for ftp log files
3. Static demo for mail log files


Features

A full log analysis enables AWStats to show you the following information:
* Number of visits, and number of unique visitors,
* Visits duration and last visits,
* Authenticated users, and last authenticated visits,
* Days of week and rush hours (pages, hits, KB for each hour and day of week),
* Domains/countries of hosts visitors (pages, hits, KB, 269 domains/countries detected, GeoIp detection),
* Hosts list, last visits and unresolved IP addresses list,
* Most viewed, entry and exit pages,
* Files type,
* Web compression statistics (for mod_gzip or mod_deflate),
* OS used (pages, hits, KB for each OS, 35 OS detected),
* 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),
* Visits of robots (319 robots detected),
* Worms attacks (5 worm's families),
* Search engines, keyphrases and keywords used to find your site (The 115 most famous search engines are detected like yahoo, google, altavista, etc...),
* HTTP errors (Page Not Found with last referrer, ...),
* Other personalized reports based on url, url parameters, referer field for miscellanous/marketing purpose,
* Number of times your site is "added to favourites bookmarks".
* Screen size (need to add some HTML tags in index page).
* 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).
* Cluster report for load balanced servers ratio.

AWStats also supports the following features:
* Can analyze a lot of log formats: Apache NCSA combined log files (XLF/ELF) or common (CLF), IIS log files (W3C), WebStar native log files and other web, proxy, wap or streaming servers log files (but also ftp or mail log files). See AWStats F.A.Q. for examples.
* Works from command line and from a browser as a CGI (with dynamic filters capabilities for some charts),
* Update of statistics can be made from a web browser and not only from your scheduler,
* Unlimited log file size, support split log files (load balancing system),
* Support 'not correctly sorted' log files even for entry and exit pages,
* Reverse DNS lookup before or during analysis, support DNS cache files,
* Plugin for country detection from IP location (use geoip country database or client domain name),
* Plugin for city detection from IP location (use geoip city database),
* Plugins for US/Canadian Region , ISP and/or Organizations reports (require non free third product geoipregion, geoipisp and/or geoiporg database)
* WhoIS links,
* A lot of options/filters and plugins can be used,
* Multi-named web sites supported (virtual servers, great for web-hosting providers),
* Cross Site Scripting Attacks protection,
* Several languages. See AWStats F.A.Q. for full list.
* No need of rare perl libraries. All basic perl interpreters can make AWStats working,
* Dynamic reports as CGI output.
* Static reports in one or framed HTML/XHTML pages, experimental PDF export,
* Look and colors can match your site design, can use CSS,
* Help and tooltips on HTML reported pages,
* Easy to use (Just one configuration file to edit),
* Analysis database can be stored in XML format for XSLT processing,
* A Webmin module,
* Absolutely free (even for web hosting providers), with sources (GNU General Public License),
* Available on all platforms,
* AWStats has a XML Portable Application Description.

Requirements:
To use AWStats, you need the following requirements:
* Your server must log web access in a log file you can read.
* You must be able to run perl scripts (.pl files) from command line and/or as CGI (Perl 5.007003 or higher required to run AWStats 6.9 or higher).
If not, you can solve this by downloading last Perl version at ActivePerl (Win32) or Perl.com (Unix/Linux/Other).
See AWStats F.A.Q. to have examples of supported OS and Web servers.

Download : Here!

Thanks : awstats.sourceforge.net

วันอังคารที่ 13 ตุลาคม พ.ศ. 2552

Force iptables to log messages to a different log file

By default, Iptables log message to a /var/log/messages file. However you can change this location. I will show you how to create a new logfile called /var/log/iptables.log. Changing or using a new file allows you to create better statistics and/or allows you to analyze the attacks.

Procedure to log the iptables messages to a different log file

Open your /etc/syslog.conf file:
# vi /etc/syslog.conf
Append following line
kern.warning /var/log/iptables.log

Save and close the file.

Restart the syslogd (Debian / Ubuntu Linux):

# /etc/init.d/sysklogd restart

On the other hand, use following command to restart syslogd under Red Hat/Cent OS/Fedora Core Linux:

# /etc/init.d/syslog restart

Now make sure you pass the log-level 4 option with log-prefix to iptables. For example:
# DROP everything and Log it
iptables -A INPUT -j LOG --log-level 4
iptables -A INPUT -j DROP

For example, drop and log all connections from IP address 1.1.1.1 to your /var/log/iptables.log file:
iptables -A INPUT -s 1.1.1.1 -m limit --limit 5/m --limit-burst 7 -j LOG --log-prefix '** HACKERS **'--log-level 4
iptables -A INPUT -s 1.1.1.1 -j DROP

Where,

  • --log-level 4: Level of logging. The level # 4 is for warning.
  • --log-prefix '*** TEXT ***': Prefix log messages with the specified prefix (TEXT); up to 29 letters long, and useful for distinguishing messages in the logs.

You can now see all iptables message logged to /var/log/iptables.log file:
# tail -f /var/log/iptables.log


Thanks : MG's Note