%define sarg_ver 2.1 %define sysconfdir /etc/sarg %define bindir /usr/bin %define mandir /usr/share/man/man1 %define htmloutputdir %{_localstatedir}/www/sarg %define debug_package %{nil} Summary: Squid usage report generator per user/ip/name Name: sarg Version: %{sarg_ver} Release: 1 License: GPL Group: Applications/Network URL: http://sarg.sf.net/sarg.php Source0: http://dl.sf.net/sarg/sarg-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release} Patch0: %{name}-%{version}-lastlog.patch BuildRequires: perl, gd-devel Requires: bash, coreutils, squid, httpd, gzip, gd >= 1.8 Obsoletes: sqrmgrlog %description Squid Analysis Report Generator is a tool that allows you to view "where" your users are going to on the Internet. Sarg generate reports in html showing users, IP Addresses, bytes, sites and times. %prep %setup -q -n %{name}-%{sarg_ver} %patch0 -p0 -b .lastlog # Fix dir permissions chmod 755 sarg-php/locale %{__perl} -pi.orig -e ' s|^#(access_log) (.+)$|#$1 $2\n$1 %{_localstatedir}/log/squid/access.log|; s|^#(output_dir) (.+)$|#$1 $2\n$1 %{htmloutputdir}/ONE-SHOT|; s|^#(resolve_ip) (.+)$|#$1 $2\n$1 yes|; s|^#(show_successful_message) (.+)$|#$1 $2\n$1 no|; s|^#(mail_utility) (.+)$|#$1 $2\n$1 mail|; s|^#(external_css_file) (.+)$|#$1 $2\n$1 %{htmloutputdir}/sarg.css|; ' sarg.conf %{__cat} <<'EOF' >sarg.daily #!/bin/bash exec %{_bindir}/sarg \ -o %{htmloutputdir}/daily \ -d "$(date --date "1 day ago" +%d/%m/%Y)" > /dev/null 2>&1 exit 0 EOF %{__cat} <<'EOF' >sarg.weekly #!/bin/bash LOG_FILES= if [[ -s %{_localstatedir}/log/squid/access.log.1.gz ]]; then LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.1.gz" fi if [[ -s %{_localstatedir}/log/squid/access.log ]]; then LOG_FILES="$LOG_FILES -l %{_localstatedir}/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 %{_bindir}/sarg \ $LOG_FILES \ -o %{htmloutputdir}/weekly \ -d $WEEKAGO-$YESTERDAY > /dev/null 2>&1 exit 0 EOF %{__cat} <<'EOF' >sarg.monthly #!/bin/bash LOG_FILES= if [[ -s %{_localstatedir}/log/squid/access.log.4.gz ]]; then LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.4.gz" fi if [[ -s %{_localstatedir}/log/squid/access.log.3.gz ]]; then LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.3.gz" fi if [[ -s %{_localstatedir}/log/squid/access.log.2.gz ]]; then LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.2.gz" fi if [[ -s %{_localstatedir}/log/squid/access.log.1.gz ]]; then LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.1.gz" fi if [[ -s %{_localstatedir}/log/squid/access.log ]]; then LOG_FILES="$LOG_FILES -l %{_localstatedir}/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 %{_bindir}/sarg \ $LOG_FILES \ -o %{htmloutputdir}/monthly \ -d $MONTHAGO-$YESTERDAY > /dev/null 2>&1 exit 0 EOF %{__cat} <sarg-index.html Squid User's Access Report

Squid User's Access Report

DIRECTORY DESCRIPTION
ONE-SHOT One shot reports
daily Daily reports
weekly Weekly reports
monthly Monthly reports
EOF %{__cat} <sarg-http.conf Alias /sarg %{htmloutputdir} DirectoryIndex index.html Order deny,allow Deny from all Allow from 127.0.0.1 Allow from ::1 # Allow from your-workstation.com EOF %build %configure \ --enable-bindir=%{bindir} \ --enable-sysconfdir=%{sysconfdir} \ --enable-mandir=%{mandir} \ --enable-htmldir=%{htmloutputdir} %{__make} %{?_smp_mflags} %install %{__rm} -rf %{buildroot} %{__install} -d -m0755 %{buildroot}%{sysconfdir} \ %{buildroot}%{bindir} \ %{buildroot}%{mandir} \ %{buildroot}%{htmloutputdir} %{__install} -d -m0755 %{buildroot}/%{htmloutputdir}/{ONE-SHOT,daily,weekly,monthly}/ %{__install} -D -m0644 sarg-http.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/sarg.conf %{__install} -D -m0755 sarg.daily %{buildroot}%{_sysconfdir}/cron.daily/sarg %{__install} -D -m0755 sarg.weekly %{buildroot}%{_sysconfdir}/cron.weekly/sarg %{__install} -D -m0755 sarg.monthly %{buildroot}%{_sysconfdir}/cron.monthly/sarg %{__install} -D -m0644 sarg-index.html %{buildroot}/%{htmloutputdir}/index.html %{__install} -D -m0644 css.tpl %{buildroot}/%{htmloutputdir}/sarg.css %{__install} -m0755 -d %{buildroot}/%{htmloutputdir} %{__install} -m0755 -d %{buildroot}%{bindir} %{__install} -m0755 sarg %{buildroot}%{bindir} %{__install} -m0755 -d %{buildroot}%{sysconfdir} %{__install} -m0644 sarg.conf %{buildroot}%{sysconfdir}/sarg.conf %{__install} -m0644 exclude_codes %{buildroot}%{sysconfdir}/exclude_codes %{__install} -m0644 sarg.1 %{buildroot}%{mandir} cp -r ./images %{buildroot}%{sysconfdir}/images cp -r ./languages %{buildroot}%{sysconfdir}/languages cp -r ./fonts %{buildroot}%{sysconfdir}/fonts rm -rf %{buildroot}%{sysconfdir}/languages/.new %clean %{__rm} -rf %{buildroot} %files %defattr(-, root, root, 0755) %doc ChangeLog CONTRIBUTORS COPYING README DONATIONS %config(noreplace) %{_sysconfdir}/sarg/sarg.conf %config(noreplace) %{_sysconfdir}/httpd/conf.d/sarg.conf %config %{_sysconfdir}/sarg/exclude_codes %config %{_sysconfdir}/cron.*/sarg %dir %{htmloutputdir} %dir %{sysconfdir} %dir %{sysconfdir}/fonts %dir %{sysconfdir}/images %dir %{sysconfdir}/languages %dir %{htmloutputdir}/ONE-SHOT %dir %{htmloutputdir}/daily %dir %{htmloutputdir}/weekly %dir %{htmloutputdir}/monthly %dir %{bindir} %doc %{mandir}/* %{bindir}/* %{sysconfdir}/fonts/* %{sysconfdir}/images/* %{sysconfdir}/languages/* %{htmloutputdir}/index.html %{htmloutputdir}/sarg.css %changelog * Sun Apr 16 2006 Petr Krištof 2.1-1 - Rebuild on FC-5 - Update to 2.1 * Tue Jun 21 2005 Petr Krištof 2.0.8-1 - Update to 2.0.8 - Rebuild on FC-4 * Mon Apr 04 2005 Neculai Macarie - Misc fixes (cron scripts, sort and manpage patches) from Bronislav Bronsky - Applied latest patches * Mon Mar 28 2005 Neculai Macarie - Fixed weekly and monthly scripts - Make the index.html file standards compliant * Tue Mar 22 2005 Neculai Macarie - Rebuilt for 2.0.5 * Mon Mar 14 2005 lonely wolf (wolfy@pcnet.ro) - merged spec file from dag (http://dag.wieers.com/packages/sarg/sarg.spec) and mack (http://mack.ro/linux/sarg/) * Tue Mar 10 2005 lonely wolf (wolfy@pcnet.ro) - Compile for Centos 3.4 * Tue Mar 01 2005 Neculai Macarie - Added patch for segmentation fault * Thu Feb 24 2005 Neculai Macarie - Rebuilt for 2.0.4 * Thu Nov 4 2004 Neculai Macarie - Initial package for sarg 2, with ideas from Dag Wiers