>>> I get below output, when I try to generate sarg reports.  I seache a
>>> lot in the web. many people have come acroos it. But, I still NOT be
>>> able to find the answer to it.
>>>
>>> I hope u will help


I also once submitted this issue. But, I also got no any answer. I
finally myself solved it by rewriting scripts and modifying sarg.conf
files.


here are steps I DID. It worked perfectly well in a production Server.


here are my sarg crontabs with permissions.

# ls -al /etc/cron.d/sarg
-rw-r--r-- 1 root root 114 Mar 23 11:27 /etc/cron.d/sarg

# ls -al /etc/cron.daily/sarg
-rwxr-xr-x 1 root root 200 Jul 18 12:15 /etc/cron.daily/sarg

# ls -al /etc/cron.weekly/sarg
-rwxr-xr-x 1 root root 807 Jul 18 11:48 /etc/cron.weekly/sarg

# ls -al /etc/cron.monthly/sarg
-rwxr-xr-x 1 root root 982 Jul 18 11:10 /etc/cron.monthly/sarg



here are contents of crontab named /etc/cron.d/sarg

# cat /etc/cron.d/sarg
0 10 * * * root /var/www/sarg/sarg.cron > /dev/null 2>&1
0 15 * * * root /var/www/sarg/sarg.cron > /dev/null 2>&1



pls see contents of /var/www/sarg/sarg.cron



# cat /var/www/sarg/sarg.cron

#!/bin/bash
cd /var/www/sarg/web-reports
rm -rf *
/usr/bin/sarg -z -x -f /etc/sarg/sarg.conf


here are contents of  /etc/cron.daily/sarg

# cat /etc/cron.daily/sarg
#!/bin/bash

# Get yesterday's date
YESTERDAY=$(date --date "1 days ago" +%d/%m/%Y)

exec /usr/bin/sarg -z -x -f /etc/sarg/sargdaily.conf \
       -o /var/www/sarg/daily \
       -d $YESTERDAY &>/dev/null
exit 0

here are contents of /etc/cron.weekly/sarg

# cat /etc/cron.weekly/sarg
#!/bin/bash
#
#Pls change to the below DIR
cd /var/log/squid/
#Then, copy log files as follows
/bin/cp access.log.1.gz access.log squidweekly/
#Pls change to Manually generated DIR
cd squidweekly/
#Pls gunzip log files
/bin/gunzip access.log.1.gz
#Here, I copy as follows
/bin/cp access.log.1 accessweekly.log
#Pls change permisions
/bin/chown squid:squid access.log*
/bin/chown squid:squid accessweekly.log
/bin/chmod 640 access.log*
/bin/chmod 640 accessweekly.log
#Pls append
/bin/cat access.log >> accessweekly.log
#Now, It's time to remove below files.
/bin/rm -f access.log.1 access.log
#Pls change back
cd
#Here I execute to generate reports
/usr/bin/sarg -z -x -f /etc/sarg/sargweekly.conf
#Finally remove , accessweekly.log  as follows
/bin/rm -f /var/log/squid/squidweekly/accessweekly.log


Here are contents of  /etc/cron.monthly/sarg

# cat /etc/cron.monthly/sarg
#!/bin/bash
#
#Pls change to the below DIR
cd /var/log/squid/
#Then, copy log files as follows
/bin/cp access.log* squidmonthly/
#Pls change to Manually generated DIR
cd squidmonthly/
#Pls gunzip log files
/bin/gunzip access.log.*
#Here, I copy as follows
/bin/cp access.log.4 accessmonthly.log
#Pls change permisions
/bin/chown squid:squid access.log*
/bin/chown squid:squid accessmonthly.log
/bin/chmod 640 access.log*
/bin/chmod 640 accessmonthly.log
#Pls append
/bin/cat access.log.3 >> accessmonthly.log
/bin/cat access.log.2 >> accessmonthly.log
/bin/cat access.log.1 >> accessmonthly.log
/bin/cat access.log >> accessmonthly.log
#Now, It's time to remove below files.
/bin/rm -f access.log.5 access.log.4 access.log.3 access.log.2
access.log.1 access.log
#Pls change back
cd
#Here I execute to generate reports
/usr/bin/sarg -z -x -f /etc/sarg/sargmonthly.conf
#Finally remove , accessmonthly.log  as follows
/bin/rm -f /var/log/squid/squidmonthly/accessmonthly.log



I have changed bleow 3 lines of  /etc/sarg/sarg.conf files


access_log /var/log/squid/access.log
output_dir /var/www/sarg/web-reports
report_type topusers topsites sites_users users_sites date_time
site_user_time_date downloads

I created /etc/sarg/sargdaily.conf (copy of sarg.conf) and changed bleow 3 lines

access_log /var/log/squid/access.log
output_dir /var/www/sarg/daily
report_type topusers topsites sites_users users_sites date_time
site_user_time_date downloads


I created /etc/sarg/sargweekly.conf (copy of sarg.conf) and changed
bleow 3 lines


access_log /var/log/squid/squidweekly/accessweekly.log
output_dir /var/www/sarg/weekly
report_type topusers topsites sites_users users_sites date_time
site_user_time_date downloads


I created /etc/sarg/sargmonthly.conf (copy of sarg.conf) and changed
bleow 3 lines


access_log /var/log/squid/squidmonthly/accessmonthly.log
output_dir /var/www/sarg/monthly
report_type topusers topsites sites_users users_sites date_time
site_user_time_date downloads

Now, create 2 directries under /var/log/squid where accessweekly.log
and accessmonthly.log will be kept


mkdir /var/log/squid/squidweekly
mkdir /var/log/squid/squidmonthly


Now, execute all scripts one after another as below.


# /etc/cron.d/sarg

# /etc/cron.daily/sarg

# /etc/cron.weekly/sarg

# /etc/cron.monthly/sarg



N-JOY!!!!!!

That's it



-- 
Thank you
Indunil Jayasooriya
_______________________________________________
users mailing list
users@lists.rpmforge.net
http://lists.rpmforge.net/mailman/listinfo/users

Reply via email to