Home > LINUX > How to install SARG

How to install SARG

  • Sharebar

How to install SARG on Centos | Fedora | RedHat

Squid Analysis Report Generator (SARG) is a tool that allow you to view “where” your users are going to on the Internet. Sarg provides many informations about Squid users activities: times, bytes, sites, etc…

Note : Install and configure apache and squid on you server.

Sarg Installation
=====================

http://sourceforge.net/projects/sarg/files/sarg/sarg-2.3.1/sarg-2.3.1.tar.gz/download

# tar -zxvf sarg-2.3.1.tar.gz
# cd sarg-2.3.1/
# ./configure
# make
# make install

Configuration
=================

Main sarg configuration file: /usr/local/etc/sarg.conf
# vim /usr/local/etc/sarg.conf
# This is sample configuration, that you need to setup
access_log /var/log/squid/access.log
graphs yes
graph_days_bytes_bar_color orange
title “Squid User Access Reports”
temporary_dir /tmp
output_dir /var/www/html/reports/

Apache Configuration
========================

# vi /etc/httpd/conf.d/sarg.conf
Alias /sarg /var/www/html/reports/daily
DirectoryIndex index.html

# /etc/init.d/httpd restart

Script for daily log
======================

vim /scripts/sarglog.sh
#!/bin/bash
#Get current date
TODAY=$(date +%d/%m/%Y)
#Get one week ago today
YESTERDAY=$(date –date “1 day ago” +%d/%m/%Y)
/usr/local/bin/sarg -l /var/log/squid/access.log -o /var/www/html/reports/daily -z -d $YESTERDAY-$TODAY
exit 0

# chmod +x /scripts/sarglog.sh

Crontab Entry
================

# crontab -e
00 01 * * * /scripts/sarglog.sh

# /etc/init.d/crond restart

Access the site

http://server-address/sarg

or

http://192.168.1.1/sarg

===========================================================

Sample Scripts for Daily/Weekly/Monthly Reports
===================================================

Daily
—————

#!/bin/bash

#Get current date
TODAY=$(date +%d/%m/%Y)

#Get one week ago today
YESTERDAY=$(date –date “1 day ago” +%d/%m/%Y)
/usr/local/bin/sarg -l /var/log/squid/access.log -o /var/www/html/reports/daily -z -d $YESTERDAY-$TODAY
exit 0

Weekly
————————————-

#!/bin/bash

#Get current date
TODAY=$(date +%d/%m/%Y)

#Get one week ago today
YESTERDAY=$(date –date “1 week ago” +%d/%m/%Y)

/usr/local/bin/sarg -l /var/log/squid/access.log -o /var/www/html/reports/daily -z -d $YESTERDAY-$TODAY
exit 0

Monthly
————————————-

#!/bin/bash

#Get current date
TODAY=$(date +%d/%m/%Y)

#Get one week ago today
YESTERDAY=$(date –date “1 month ago” +%d/%m/%Y)

/usr/local/bin/sarg -l /var/log/squid/access.log -o /var/www/html/reports/daily -z -d $YESTERDAY-$TODAY
/usr/local/squid/bin/squid -k rotate #rotate log files
exit 0

And the same for the admin who want the report as an email (example for daily)

#!/bin/bash

#Get current date
TODAY=$(date +%d/%m/%Y)

#Get one week ago today
YESTERDAY=$(date –date “1 day ago” +%d/%m/%Y)

/usr/local/bin/sarg -l /var/log/squid/access.log -e user@site.com -z -d $YESTERDAY-$TODAY

exit 0

==============================================

 

 

DON’T FORGET TO SAY THANKS IF U LIKE MY POST

 

  1. manoj
    June 19th, 2012 at 12:33 | #1

    nice doc…

  2. sambamurty
    December 21st, 2013 at 12:49 | #2

    Thank you. Very useful post.

  1. No trackbacks yet.

Uses wordpress plugins developed by www.wpdevelop.com Copy Protected by Chetans WP-Copyprotect.