Menu

Build on Linux

Frederic Marchal Evgeniy Yakushev

This page describes how to build Sarg and install it.

Where to build Sarg

First you must decide where to build Sarg.

Sarg reads the log files produced by your proxy server or appliance. If those logs are stored on a NAS, then Sarg can run on any computer with read access to the NAS.

If the logs are stored locally on the server, it is best to run Sarg on the same server and avoid to move potentially several GB of data across the network. Moreover, by installing Sarg on the same server, the logs stay safely locked on the server without worrying about someone eavesdropping on your network accesses.

Now, if Sarg is to be installed on a server, you must not build it on that server. You don't want to have a complete fully functional development environment installed on a web connected server processing HTTP requests, possibly analyzing them and scanning them for viruses. Hackers would love that, not you!

The procedure described on this page assumes you are building Sarg on a computer running the same operating system as the server. It makes it easier to build sarg and move the executable to the server.

The build server may be a virtual machine cloned from the real server or it may be a different computer provided that the processor model is the same (32 or 64-bit) and the operating system version is the same.

Get the sources

Download the latest sources and uncompress the gz file into a directory of your choice. That would mean to execute the commands:

cd $HOME/path/to/build/sarg
tar zxf sarg-2.3.10.tar.gz

This will result in a directory named sarg-2.3.10 where all the sources are.

If you are brave, you can also get the bleeding edge version from git:

git clone git://git.code.sf.net/p/sarg/code sarg-code

I do my best to only commit fully working code but there is no way I, alone, can test all the possible environments and configurations.

Should you prefer to build the 2.3 branch, checkout that branch before continuing:

git checkout -b v2.3 origin/v2.3

Once you have fetched the sources, you may have to generate the configuration script in sarg-code directory with this command:

autoreconf -fi

You must do this if you fetched the sources from git.

The above autoreconf command is provided by the autoconf package and needs the automake package.

Configuration

Change to the directory where you stored the sources fetched in the previous section.

Read the configuration options:

./configure --help

Then run the configure script with the options you need. For instance:

./configure --prefix=/ --sysconfdir=/etc/sarg --enable-extraprotection

The --enable-extraprotection option compiles Sarg with additional GCC flags to ensure the compiled code is safe. Any warning will abort the compilation instead of producing a potentially unsafe executable. Possible buffer overruns and similar hazardous constructs are flagged by the compiler. GCC also includes some run-time protections against stack smashing attacks. If Sarg doesn't compile with that option, you may want to configure it without it.

The configure script reports everything it finds or doesn't find. It doesn't have to find
everything it searches for (i.e. some lines will end with "no" because they are for other operating systems). The last few lines report what features are disabled due to missing dependencies. For instance, if you want to have graphs, install the gd-devel package (the exact name depends on your distribution).

Required dependencies

The configure script looks on the computer for libraries and header files required to build sarg. If it can't find the files it needs, it stops with an error.

Sarg is written in C. You need a C compiler installed on your computer. Sarg is developed and compiled with gcc. It is the recommended choice.

Make is also the preferred method to build sarg. Some attempts were made to use cmake but I never managed to compile sarg with national language support using cmake. The cmake script is not kept up to date at this time (July 2015).

National language support requires gettext from the packages gettext-runtime and gettext-tools version 0.18 and newer.

In case your system have older versions of gettext, you can remove national language support. Before running autoreconf -fi run these two commands:

sed -i configure.ac -e '/Build with iconv/,/Build with pcre/d' -e '/AM_GNU_GETTEXT/d
sed -i Makefile.in -e 's/@LIBINTL@//g' -e 's/all install-po/all/g'

Optional dependencies

Sarg can be built without some features. If a library is not available for a feature, then the feature is disabled. It is perfectly valid to use sarg without some features but in case you need it, the configure script output a short message for every feature that is disabled.

Packages needed for clean OpenSUSE:

To produce graphs in the report, you need to install the gd library and its development package gd-devel.

Regular expressions are compiled in if pcre-devel is installed.

LDAP support requires openldap2-devel.

To uncompress bzip2 files, you need to install libbz2-devel.

To uncompress xz files, you need to install xz-devel.

Gzip compressed files are decompressed by zlib from zlib-devel.

Packages needed for clean minimal CentOS:

autoconf automake gd-devel pcre-devel bzip2-devel openldap-devel gettext-devel xz xz-devel

Packages needed on Debian:

zlib1g-dev is needed for Gzip compressed files.

libgd-dev add graphs support.

Bzip2 files are processed if libbz2-dev is installed.

Xz files are processed if liblzma-dev is available.

libldap2-dev allows sarg to connect to a LDAP server.

In short, install these packages and their dependencies.

apt-get install libgd-dev libbz2-dev libldap2-dev zlib1g-dev liblzma-dev

Compile

Sarg is compiled with a simple

make

Install

Remember I asked to compile Sarg on a computer that's not the server on which Sarg will be executed. Installing it means to move the proper files to their final place on the server. It can be accomplished simply by mounting the root directory of the server through a fuser mount point like this:

sshfs root@squid:/ /mnt/squid

Then install Sarg with the command

make DESTDIR=/mnt/squid install

There is no need to run that step as root because the mount point is mounted as root on the server.

Finally, unmount the fuser mount point with

fusermount -u /mnt/squid

Upgrading an existing install

If sarg has previously been installed by the package manager of your distribution and you want to upgrade to the latest version you build yourself, the installation step is, in fact, much simpler!

It is sufficient to copy the sarg executable file (found in the build directory) to the directory where it was installed by the package manager. It usually is /usr/bin. Every other file should have been installed by the native package and still be valid.

Make sure you compiled sarg on a computer with the same processor family (32 or 64-bit) and the same OS version as the one running on the server.


Related

Bugs: #158
Discussion: How to analyze w3c-logs (extended log format) with sarg?
Discussion: No records found and xz support
Discussion: does anyone have manual for sarg 2.3.10
Discussion: Old logs not deleted
Discussion: site_user_time_date
Wiki: Home
Wiki: Table of content
Wiki: Usage

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.