Powered By Blogger

Sunday, 19 April 2015

Installation of sarg report.

1. apt-get install sarg
2. backup of sarg.conf file.
3. open sarg.conf
4. insert below mentions parameters

# sarg.conf

# TAG: access_log file
access_log /var/log/squid/access.log

# TAG: graphs yes|no
graphs yes
graph_days_bytes_bar_color orange

# TAG: title
title "Squid User Access Reports"

# TAG: font_face
font_face Tahoma,Verdana,Arial

# TAG: header_color
header_color darkblue

# TAG: header_bgcolor
header_bgcolor blanchedalmond

# TAG: font_size
font_size 9px

# TAG: background_color
background_color white

# TAG: text_color
text_color #000000

# TAG: text_bgcolor
text_bgcolor lavender

# TAG: title_color
title_color green

# TAG: temporary_dir
temporary_dir /tmp

# TAG: output_dir
#output_dir /var/www/html/squid-reports
output_dir /var/www/sarg

# TAG: resolve_ip yes/no
resolve_ip

# TAG: user_ip yes/no
user_ip no

# TAG: topuser_sort_field field normal/reverse
topuser_sort_field BYTES reverse

# TAG: user_sort_field field normal/reverse
user_sort_field BYTES reverse

# TAG: exclude_users file
exclude_users /etc/squid3/sarg.users

# TAG: exclude_hosts file
exclude_hosts /etc/squid/sarg.hosts

# TAG: date_format
date_format u

# TAG: lastlog n
lastlog 0

# TAG: remove_temp_files yes
remove_temp_files yes

# TAG: index yes|no|only
index yes

# TAG: index_tree date|file
index_tree file

# TAG: overwrite_report yes|no
overwrite_report yes

# TAG: records_without_userid ignore|ip|everybody
records_without_userid ip

# TAG: use_comma no|yes
use_comma yes

# TAG: mail_utility mail|mailx
mail_utility mailx

# TAG: topsites_num n
topsites_num 100

# TAG: topsites_sort_order CONNECT|BYTES A|D
topsites_sort_order CONNECT D

# TAG: index_sort_order A/D
index_sort_order D

# TAG: exclude_codes file
exclude_codes /etc/squid/sarg.exclude_codes

# TAG: max_elapsed milliseconds
max_elapsed 28800000

# TAG: report_type type
#report_type topusers topsites sites_users users_sites date_time denied auth_failures site_user_time_date downloads
report_type topusers topsites sites_users users_sites date_time denied auth_failures site_user_time_date downloads

# TAG: usertab filename
usertab /etc/squid/sarg.usertab

# TAG: long_url yes|no
long_url no

# TAG: date_time_by bytes|elap
date_time_by bytes

# TAG: charset name
charset Latin1

# TAG: show_successful_message yes|no
show_successful_message yes

# TAG: show_read_statistics yes|no
show_read_statistics yes

# TAG: topuser_fields
topuser_fields NUM DATE_TIME USERID CONNECT BYTES %BYTES IN-CACHE-OUT USED_TIME MILISEC %TIME TOTAL AVERAGE

# TAG: user_report_fields
user_report_fields CONNECT BYTES %BYTES IN-CACHE-OUT USED_TIME MILISEC %TIME TOTAL AVERAGE

# TAG: topuser_num n
topuser_num 0

# TAG: site_user_time_date_type list|table

site_user_time_date_type table

# TAG: external_css_file path
download_suffix "zip,arj,bzip,gz,ace,doc,iso,adt,bin,cab,com,dot,drv$,lha,lzh,mdb,mso,ppt,rtf,src,shs,sys,exe,dll,mp3,avi,mpg,mpeg"


save & exit.

5. make new 3 files for exclude host/users.

exclude_codes, exclude_hosts, exclude_users

6. make new execute script for daily basis report generate.
7. vim /usr/sbin/sarg-daily-report     ### insert below mentioned parameters.

TODAY=$(date +%d/%m/%Y)
YESTERDAY=$(date --date "1 day ago" +%d/%m/%Y)
sarg /var/log/squid/access.log -o /var/www/squid-reports/daily -z -d $YESTERDAY-$TODAY
/usr/sbin/squid -k rotate
exit 0

save & exit

8. vim /usr/sbin/sarg-weekly-report     ### insert below mentioned parameters.

TODAY=$(date +%d/%m/%Y)
YESTERDAY=$(date --date "1 week ago" +%d/%m/%Y)
sarg /var/log/squid/access.log -o /var/www/squid-reports/weekly -z -d $YESTERDAY-$TODAY
/usr/sbin/squid -k rotate
exit 0

save & exit

9.  vim /usr/sbin/sarg-monthly-report ### insert below mentioned parameters.

TODAY=$(date +%d/%m/%Y)
YESTERDAY=$(date --date "1 month ago" +%d/%m/%Y)
sarg /var/log/squid/access.log -o /var/www/squid-reports/monthly -z -d $YESTERDAY-$TODAY
/usr/sbin/squid -k rotate
exit 0

save & exit

10. change permissions of sarg reporter. chmod o+x /usr/sbin/sarg*

11. test sarg reporter software. run "sarg" in terminal..

12. open browser and insert          http://server ip/sarg-report/daily

13. go to crontab -e

paste below mentioned lines.

00 00 * * * /usr/sbin/sarg-daily-report
00 01 * * 1 /usr/sbin/sarg-weekly-report
03 02 1 * * /usr/sbin/sarg-monthly-report

save & exit

check report on webbrowser

No comments:

Post a Comment