[users] Sarg ...

Clinton Lee Taylor clintonlee.taylor at gmail.com
Sat Mar 29 13:19:27 CET 2008


Greetings ...

 Just about to start playing with sarg in CentOS ...

 Found that with the change in Fedora 8, the normal sarg cron scripts
just don't work ...

[root at zeus cron.daily]# cat sarg
#!/bin/bash
LOG_FILES=

LOG_FILES=$(find /var/log/squid -iname 'access*' -mtime -2 -print0 \
    | sort | xargs -0 -i{} echo -n " -l {}")

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

exec /usr/bin/sarg \
        $LOG_FILES \
        -o /var/www/sarg/daily \
        -d $YESTERDAY $* &>/dev/null
exit 0

[root at zeus cron.weekly]# cat sarg
#!/bin/bash
LOG_FILES=

LOG_FILES=$(find /var/log/squid -iname 'access*' -mtime -14 -print0 \
    | sort | xargs -0 -i{} echo -n " -l {}")

#if [ -s /var/log/squid/access.log.1.gz ]; then
#       LOG_FILES="$LOG_FILES -l /var/log/squid/access.log.1.gz"
#fi
#if [ -s /var/log/squid/access.log ]; then
#       LOG_FILES="$LOG_FILES -l /var/log/squid/access.log"
#fi

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

# Get one week ago date
WEEKAGO=$(date --date "7 days ago" +%d/%m/%Y)

exec /usr/bin/sarg \
        $LOG_FILES \
        -o /var/www/sarg/weekly \
        -d $WEEKAGO-$YESTERDAY $* &>/dev/null
exit 0

[root at zeus cron.monthly]# cat sarg
#!/bin/bash
LOG_FILES=

LOG_FILES=$(find /var/log/squid -iname 'access*' -mtime -60 -print0 \
    | sort | xargs -0 -i{} echo -n " -l {}")

#if [ -s /var/log/squid/access.log.4.gz ]; then
#       LOG_FILES="$LOG_FILES -l /var/log/squid/access.log.4.gz"
#fi
#if [ -s /var/log/squid/access.log.3.gz ]; then
#       LOG_FILES="$LOG_FILES -l /var/log/squid/access.log.3.gz"
#fi
#if [ -s /var/log/squid/access.log.2.gz ]; then
#       LOG_FILES="$LOG_FILES -l /var/log/squid/access.log.2.gz"
#fi
#if [ -s /var/log/squid/access.log.1.gz ]; then
#       LOG_FILES="$LOG_FILES -l /var/log/squid/access.log.1.gz"
#fi
#if [ -s /var/log/squid/access.log ]; then
#       LOG_FILES="$LOG_FILES -l /var/log/squid/access.log"
#fi

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

# Get 1 month ago date
MONTHAGO=$(date --date "1 month ago" +%d/%m/%Y)

exec /usr/bin/sarg \
        $LOG_FILES \
        -o /var/www/sarg/monthly \
        -d $MONTHAGO-$YESTERDAY $* &>/dev/null
exit 0

 Hope this all makes sense ... There might be better ways to do this,
but this is the best I could do ...

Thanks
Mailed
LeeT



More information about the users mailing list