Squid for the little ones. Part 3 Statistics
Everyone who raises a proxy, then wants to see who uses it, who shakes how much. And sometimes it’s very useful to watch in real time who is downloading what. The following programs will be considered in this topic:
SqStat - Real Time statistics via web
Sarg - Squid log analyzer followed by HTML generation
SquidView - Squid interactive console log monitor
I will not talk here about how to configure Apache. There are so many manuals on this topic in the internet, so forward and with the song, I will talk about those features that I introduced at home.
Yes, I will tell you on the example of Debian Etch, your paths may differ, keep in mind ...
Let's go ...
This program works in the console, and displays everything Squid does there.
Installation: Let's wait a couple of seconds if you have fast internet. That's it, now we can watch who shakes. If you did not change the location of the logs, and left most of the squid parameters default, then you only need to run it to view it, but with root privileges, because the squid logs are written to them ... I think this will be enough for you, but I will also report some very useful things , you need to press the buttons, and watch:
According to SquidView, everything seems to be if something has not been said before, write, I will add!
This is a script that allows you to watch active connections, channel load, and average channel load.
I assume you already have Apache configured.
Download the latest version, That's it, now we need to configure Squid-cgi or cachemgr.cgi, Set it: Now we need to configure access ... Add Now we need to fix /etc/squid/cachemgr.conf Instead of * you can put the network address that squid listens for ! http: //localhost/cgi-bin/cachemgr.cgi
For some reason, I could not get it at the address 127.0.0.1 and entered 192.168.0.1 and it worked. Now you need to enter the external network address in the Cache Host field. What port you have, in the login field, if you did everything according to the manual, you can not enter anything, and write secret in the password field. If everything went well, then you will see a list of available parameters ... You can look, and we will go on to configure SqStat ... In principle, the config itself is well-documented, study, there is nothing to learn there)) Now we make a subdomain, it’s much more convenient) We write for resolving / etc / hosts That's all :) almost everything
This program generates html reports, draws graphs, and so on ...
We put : Of course, no one forbids you to make fun of the display style of this whole farm - the config is provided with very detailed comments.
That's it :)) If you want, you can create a subdomain for it too! This has already been described ...
I myself use all three programs and am satisfied.
UPD To solve the problem with the 3rd version skivd, you need to make a soft link:
UPD.2. The next article will talk about delay pools
Krosspost from my blog.
SqStat - Real Time statistics via web
Sarg - Squid log analyzer followed by HTML generation
SquidView - Squid interactive console log monitor
0. Introduction
I will not talk here about how to configure Apache. There are so many manuals on this topic in the internet, so forward and with the song, I will talk about those features that I introduced at home.
Yes, I will tell you on the example of Debian Etch, your paths may differ, keep in mind ...
Let's go ...
1. SquidView
This program works in the console, and displays everything Squid does there.
Installation: Let's wait a couple of seconds if you have fast internet. That's it, now we can watch who shakes. If you did not change the location of the logs, and left most of the squid parameters default, then you only need to run it to view it, but with root privileges, because the squid logs are written to them ... I think this will be enough for you, but I will also report some very useful things , you need to press the buttons, and watch:
aptitude install squidview
sudo squidview
- h - help, here we can recognize even more;)
- l - enter - report generation, you can also configure additional settings
- T - statistics on the size of the download starts
- O - watching who downloaded users, after T
According to SquidView, everything seems to be if something has not been said before, write, I will add!
2. SqStat
This is a script that allows you to watch active connections, channel load, and average channel load.
I assume you already have Apache configured.
Download the latest version, That's it, now we need to configure Squid-cgi or cachemgr.cgi, Set it: Now we need to configure access ... Add Now we need to fix /etc/squid/cachemgr.conf Instead of * you can put the network address that squid listens for ! http: //localhost/cgi-bin/cachemgr.cgi
wget -c samm.kiev.ua/sqstat/sqstat-1.20.tar.gz
tar xvfz sqstat-1.20.tar.gz
cd ./sqstat-1.20
mkdir /var/www/squid-stat
cp -R * /var/www/squid-stat*
aptitude install squid-cgi
nano /etc/squid/squid.conf
acl manager proto cache_object
http_access allow manager localhost
http_access deny manager
#Данная строка задает пароль secret и разрешает делать все
cachemgr_passwd secret all
echo "*" >> /etc/squid/cachemgr.conf
For some reason, I could not get it at the address 127.0.0.1 and entered 192.168.0.1 and it worked. Now you need to enter the external network address in the Cache Host field. What port you have, in the login field, if you did everything according to the manual, you can not enter anything, and write secret in the password field. If everything went well, then you will see a list of available parameters ... You can look, and we will go on to configure SqStat ... In principle, the config itself is well-documented, study, there is nothing to learn there)) Now we make a subdomain, it’s much more convenient) We write for resolving / etc / hosts That's all :) almost everything
nano /var/www/squid-stat/config.inc.php
//Это адрес на котором слушает ваш сквид
$squidhost[0]="192.168.0.1";
$squidport[0]=3128;
$cachemgr_passwd[0]="secret";
//Этот параметр разрешает резолвить имена записями в ващей системе
$resolveip[0]=false;
//В этом файле содержится айпи и имена кмопьютеров, можно использовать кирилицу :)
$hosts_file[0]="hosts";
$group_by[0]="host";
nano /etc/apache2/sites-enabled/sqstat
ServerAdmin squid@gmail.com
DocumentRoot /var/www/squid-stat/
ServerName proxy.server.local
nano /etc/hosts
192.168.0.1 proxy.server.local
squid -k reconfigure
/etc/init.d/apache2 reload
3. Sarg
This program generates html reports, draws graphs, and so on ...
We put : Of course, no one forbids you to make fun of the display style of this whole farm - the config is provided with very detailed comments.
aptitude install sarg
nano /etc/squid/sarg.conf
language Russian_koi8
graphs yes
title "Squid User Access Reports"
temporary_dir /tmp
output_dir /var/www/sarg
max_elapsed 28800000
charset Koi8-r
crontab -u root -e
* 08-18/1 * * * /usr/sbin/sarg-reports today
* 00 * * * /usr/sbin/sarg-reports daily
* 01 * * 1 /usr/sbin/sarg-reports weekly
* 02 1 * * /usr/sbin/sarg-reports monthly
Epilogue
That's it :)) If you want, you can create a subdomain for it too! This has already been described ...
I myself use all three programs and am satisfied.
UPD To solve the problem with the 3rd version skivd, you need to make a soft link:
ln -s /var/log/squid3/access.log /root/.squidview/log1
UPD.2. The next article will talk about delay pools
Krosspost from my blog.