โปรแกรมดู Logs files จาก Squid

โปรแกรมดู Logs files จาก Squid 

1. Lightsquid 1.7.1_1

bansang#cd /usr/ports/www/lightsquid
bansang#make install clean
bansang#cd /usr/local/www/lightsquid

 
ตั้งค่าให้ .cgi และ perl ทำงาน
bansang# chmod +x *.cgi
bansang# chmod +x *.pl

bansang#pico  /usr/local/etc/lightsquid/lightsquid.cfg   
แก้ไขรายการ ดังนี้

#path to tpl folder
$tplpath             ="/usr/local/www/lightsquid/tpl";
#path to lang folder
$langpath            ="/usr/local/www/lightsquid/lang";
#path to report folder
$reportpath          ="/usr/local/www/lightsquid/report";
#path to access.log
$logpath             ="/usr/local/squid/logs"; ## ที่อยู่ log Files

จากนั้นก็ Save 
ตรวจสอบ path
bansang#/usr/local/www/lightsquid/check-setup.pl
ลองสั่งโปรแกรมทำงาน
bansang#/usr/local/www/lightsquid/lightparser.pl

# pico /usr/local/etc/apache22/httpd.conf  เพิ่ม

Alias /lightsquid/ "/usr/local/www/lightsquid/"

<Directory "/usr/local/www/lightsquid/">
    Options Indexes MultiViews
   AddHandler cgi-script .cgi
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

/usr/local/etc/rc.d/apache22 restart  

เรียกใช้งาน http://bansang.ath.cx/lightsquid/

เพิ่มลงใน Crontab
bansang#pico /etc/crontab
59 23    * * *  root  /usr/local/www/lightsquid/lightparser.pl

2. mySAR-2.1.4

bansang# cd /usr/ports/www/mysar/
bansang# make install

 pico /usr/local/etc/apache22/httpd.conf  เพิ่ม

Alias /mysar/ "/usr/local/mysar/www/"

<Directory "/usr/local/mysar/www/">
    Options Indexes MultiViews
      AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

/usr/local/etc/rc.d/apache22 restart  

สร้าง mysql database ชื่อ mysar
Add the following contents to /usr/local/mysar/etc/config.ini
        dbUser = mysar
        dbPass = mysar
        dbHost = localhost
        dbName = mysar

Point your webbrowser to http://localhost/mysar/ and the program  will configure itself.

เปิด
mysar-importer.php mysar-resolver.php mysar-maintenance.php   เพื่อแก้  path to php
แก้ เป็น #!/usr/local/bin/php    path to php

เพิ่ม crond
0 0 * * * /usr/local/mysar/bin/mysar-importer.php > /usr/local/mysar/www/mysar-importer.log 2>&1
0 0 * * * /usr/local/mysar/bin/mysar-resolver.php > /usr/local/mysar/www/mysar-resolver.log 2>&1
0 0 * * * /usr/local/mysar/bin/mysar-maintenance.php /usr/local/mysar/www/mysar-maintenance.log 2>&1

 

3. Sarg 2.2.5

bansang #cd  /usr/ports/www/sarg

bansang # make install clean
bansang #cd /usr/local/etc/sarg
pico sarg.conf

แก้บรรทัดต่อไปนี้ ให้มีส่วนที่ต้องตั้งค่าดังต่อไปนี้

access_log /usr/local/squid/logs/access.log #เก็บ log ของ squid
output_dir /usr/local/www/sarg                         #จะตั้งเป็นชื่ออะไรก็ได้
resolve_ip no                                               #ถ้าต้องการให้แสดงชื่อเครื่องแทนเบอร์ ip ก็ให้เปลี่ยนเป็น yes
user_ip yes #กำหนดให้ใช้ ip แทน user id ครับ
remove_temp_files yes #กำหนดให้ลบไฟล์ชั่วคราวอัตโนมัติ
index yes #กำหนดให้ใส่ไฟล์ index.html อัตโนมัติใน sub folder
overwrite_report yes #กำหนดให้เขียนรายงานทับอัตโนมัติ
records_without_userid ip #กำหนดให้ใช้ ip หากไม่มี user id
use_comma yes #ใช้เครื่องหมายลูกน้ำคั่นหลักพัน
mail_utility mail #กำหนดโปรแกรมที่ใช้ส่งอีเมล
displayed_values abbreviation #กำหนดให้ใช้หน่วย K M แทนการแสดงผลเป็นหน่วย byte ตรงๆ ครับ
usertab /usr/local/etc/sarg/sarg.usertab   #เป็นการ map ip ให้ตรงกับชื่อ เพื่อเวลาสร้างรายงานออกมา จะทำให้ดูง่ายขึ้น

จากนั้นให้เราสร้างไฟล์ sarg.usertab
#pico /usr/local/etc/sarg/sarg.usertab  

แก้ไขไฟล์ เช่น
192.168.254.10   pancake
192.168.254.69   iGid

 จากนั้นให้ ดาวน์โหลด Script จาก
fetch http://www.initzero.it/products/opensource/sarg-reports/download/sarg-reports

- แก้ชื่อไฟล์เป็น  sarg.reports
- copy ไปไว้ที่ /usr/local/bin/sarg.reports
- chmod 755 /usr/local/bin/sarg.reports
- แก้ไข script ส่วนต่างๆ เป็นดังนี้

#@@@@@@@@@@@@@@@@@
SARG=/usr/local/bin/sarg # ที่อยู่ของ sarg
CONFIG=/usr/local/etc/sarg/sarg.conf # ที่อยู่ของ config file
HTMLOUT=/usr/local/www/sarg # ที่อยู่ของ sarg ใน apache
PAGETITLE="Reports for $(hostname)" # Title ที่จะให้แสดงในหน้าแรกของ script
#LOGOIMG=logo.png # Logo สำหรับหน้าแรกของ script
#LOGOLINK=../# # Link เมื่อคลิกที่โลโก้
DAILY=Daily # ข้อความในหน้าแรกของ script Daily ปิดได้ เมื่อไม่ใช้งาน
WEEKLY=Weekly # ข้อความในหน้าแรกของ script Weekly ปิดได้ เมื่อไม่ใช้งาน
MONTHLY=Monthly # ข้อความในหน้าแรกของ script Monthly ปิดได้ เมื่อไม่ใช้งาน
EXCLUDELOG1="SARG: Records not found."
EXCLUDELOG2="SARG: Fine"
#@@@@@@

pico /usr/local/etc/apache22/httpd.conf  เพิ่ม

Alias /sarg/ "/usr/local/www/sarg/"

<Directory "/usr/local/www/sarg/">
    Options Indexes MultiViews
      AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

/usr/local/etc/rc.d/apache22 restart  

- เพิ่มการทำงานของ script ใน crontab ตามการใช้งานที่ต้องการ
- คำสั่ง crontab-e

00 08-23/5 * * * /usr/local/bin/sarg.reports today
59 23 * * * /usr/local/bin/sarg.reports daily
00 01 * * 1 /usr/local/bin/sarg.reports weekly
30 02 1 * * /usr/local/bin/sarg.reports monthly

- ทดลองเรียก script เพื่อสร้างรายงาน
ด้วยคำสั่ง
/usr/local/bin/sarg.reports daily

 

แสดงความคิดเห็น

เนื้อหาของข้อมูลนี้ถูกรักษาเป็นความลับและไม่แสดงต่อสาธารณะ
CAPTCHA
กรุณาป้อนคำตอบ เพื่อพิสูจน์ว่าท่านเป็นมนุษย์ มิใช่ Spam Bot
16 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Calendar

ล็อกอิน

สมาชิกใหม่

  • ปัตตานี
  • sadis
  • Jameball
  • andy99
  • pook