{"id":204,"date":"2017-08-12T17:00:30","date_gmt":"2017-08-12T17:00:30","guid":{"rendered":"http:\/\/info.ffteixeira.net\/2017\/08\/12\/sarg-squid-analysis-report-generator-installation-configuration\/"},"modified":"2017-08-12T17:00:30","modified_gmt":"2017-08-12T17:00:30","slug":"sarg-squid-analysis-report-generator-installation-configuration","status":"publish","type":"post","link":"https:\/\/blog.ffteixeira.net\/?p=204","title":{"rendered":"SARG ( Squid Analysis Report Generator ) Installation &amp; Configuration"},"content":{"rendered":"<p>It is an Open-Source tool, which helps us analyze Squid Proxy logs &amp; generates reports in HTML format with all the information from logs presented in nice &amp; easy to understand format.<br \/>&amp; It gives information about User&rsquo;s IP addresses , total &amp; individually used bandwidth etc with access to Daily, Weekly &amp; Monthly reports.<\/p>\n<p><strong>Installation<\/strong><br \/>The process for installing sarg on Centos\/Redhat is a bit complicated, as it needs to be compiled from source. To do that, firstly we need to install required packages to download &amp; compile the package<\/p>\n<p>$ sudo apt-get install -y gcc lighttpd sarg<\/p>\n<p>Now that&rsquo;s the installation is complete, we will configure it as per our needs by making changes in configuration file<\/p>\n<p>$ sudo nano \/etc\/sarg\/sarg.conf<\/p>\n<p>Firstly, uncomment the line starting with access_log &amp; add path for squid access log. Next, provide output directory for reports next to line starting with output_dir &amp; also select your desired time format, change&nbsp; line with date_format<\/p>\n<p><em><em>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-sarg.conf&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/em><br \/># TAG: access_log file<br \/># Where is the access.log file<br \/>#<br \/>#<br \/>access_log \/var\/log\/squid\/access.log<br \/>Add output directory<br \/># TAG: output_dir<br \/># The reports will be saved in that directory<br \/>#<br \/>#<br \/>output_dir \/var\/www\/html\/squid-reports<br \/>Set the correct date format<br \/># TAG: date_format<br \/># Date format in reports: e (European=dd\/mm\/yy), u (American=mm\/dd\/yy), w (Weekly=yy.ww)<br \/>#<br \/>date_format e<br \/><em>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/em><\/em><\/p>\n<p>&amp; lastly , set overwrite report to yes<\/p>\n<p><em>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;sarg.conf&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/em><\/p>\n<p><em># # TAG: overwrite_report yes|no<br \/># yes &ndash; if report date already exist then will be overwritten.<br \/># no &ndash; if report date already exist then will be renamed to filename.n, filename.n+1<br \/>#<br \/>overwrite_report yes<br \/>#<em>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/em><\/em><\/p>\n<p>$ sudo mkdir \/var\/www\/html\/squid-reports<\/p>\n<p><strong>Generating report<\/strong><br \/>To create squid analysis report, we have to enter following command<\/p>\n<p>$ sudo sarg -x<\/p>\n<p>Note: It may take a while depending on number of users accessing squid proxy.<\/p>\n<p><strong>Accessing report<\/strong><\/p>\n<p>To access the report, enter below mentioned URL in web-browser<br \/><em>http:\/\/IP-Address of server\/squid-reports<\/em><\/p>\n<p>Now, we have all the squid analyzed logs in nice, sorted &amp;easy to understand format<\/p>\n<p>Note: you can also create a cron&ndash;job to schedule a report being generated automatically at the time of your choosing.<\/p>\n<p>$ sudo crontab -e<\/p>\n<p>Add for example this line at the end<\/p>\n<p>&nbsp;* *\/4 * * * \/usr\/bin\/sarg -x<\/p>\n<p>This will generate a report every 4th hour.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/linuxtechlab.com\/sarg-installation-configuration\/\" target=\"_blank\" rel=\"noopener noreferrer\">Credits<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is an Open-Source tool, which helps us analyze Squid Proxy logs &amp; generates reports in HTML format with all the information from logs presented in nice &amp; easy to understand format.&amp; It gives information about User&rsquo;s IP addresses , &hellip; <a href=\"https:\/\/blog.ffteixeira.net\/?p=204\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-204","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts\/204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=204"}],"version-history":[{"count":0,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts\/204\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}