SqStat: Difference between revisions

From Alpine Linux
(replace /etc/init.d with rc-service)
 
(4 intermediate revisions by 4 users not shown)
Line 7: Line 7:
This document will be a quick c/p guide to setup SqStat acive squid log viewer on Alpine linux. What we will install is the following:
This document will be a quick c/p guide to setup SqStat acive squid log viewer on Alpine linux. What we will install is the following:


*Lighttpd  
* Lighttpd  
*PHP
* PHP


== Installing Lighthttpd and PHP ==
== Installing Lighthttpd and PHP ==
 
{{:Setting Up Lighttpd With FastCGI}}
'''Installing Lighthttpd'''
 
apk add php lighttpd
 
 
== Configuring Lighttpd ==
 
'''Edit lighttpd.conf'''
 
nano +46 /etc/lighttpd/lighttpd.conf
 
* Uncomment line:
 
include "mod_fastcgi.conf"
 
'''Start http server and add to boot'''
 
/etc/init.d/lighttpd start && rc-update add lighttpd default
 


== Installing SqStat ==
== Installing SqStat ==
Line 36: Line 17:
'''Download SqStat '''
'''Download SqStat '''


cd /tmp
{{Cmd|cd /tmp
wget http://samm.kiev.ua/sqstat/sqstat-1.20.tar.gz
wget http://samm.kiev.ua/sqstat/sqstat-1.20.tar.gz}}
== Configuring SqStat ==
== Configuring SqStat ==
Line 44: Line 24:
'''Unpack and move SqStat'''
'''Unpack and move SqStat'''


gunzip sqstat-1.20.tar.gz
{{Cmd|gunzip sqstat-1.20.tar.gz
tar xvf sqstat-1.20.tar -C /var/www/localhost/htdocs/
tar xvf sqstat-1.20.tar -C /var/www/localhost/htdocs/
mv /var/www/localhost/htdocs/sqstat-1.20 /var/www/localhost/htdocs/sqstat
mv /var/www/localhost/htdocs/sqstat-1.20 /var/www/localhost/htdocs/sqstat}}
'''Copy and edit the sqstats config file '''
'''Copy and edit the sqstats config file '''


cp /var/www/localhost/htdocs/sqstat/config.inc.php.defaults /var/www/localhost/htdocs/sqstat/config.inc.php
{{Cmd|cp /var/www/localhost/htdocs/sqstat/config.inc.php.defaults /var/www/localhost/htdocs/sqstat/config.inc.php
nano /var/www/localhost/htdocs/sqstat/config.inc.php
nano /var/www/localhost/htdocs/sqstat/config.inc.php}}
* Modify this lines with your proxy ip addres and port
* Modify this lines with your proxy ip addres and port
Line 59: Line 39:
  /* Squid proxy server port */
  /* Squid proxy server port */
  $squidport[0]=3128;
  $squidport[0]=3128;


== Configuring your squid server ==
== Configuring your squid server ==
Line 66: Line 45:


'''Edit squid.conf'''
'''Edit squid.conf'''
nano /etc/squid/squid.conf
{{Cmd|nano /etc/squid/squid.conf}}
   
   
* Add this lines and replace the ip addres with your webserver IP
* Add this lines and replace the ip addres with your webserver IP
Line 78: Line 57:
'''Restart squid'''
'''Restart squid'''


/etc/init.d/squid restart
{{Cmd|rc-service squid restart}}
* Browse and see
* Browse and see


  http://SQSTAT_IP_NUMBER/sqstat/sqstat.php
  <nowiki>http://SQSTAT_IP_NUMBER/sqstat/sqstat.php</nowiki>
 
 
Note: License
 
SqStat is distributed under the following ISC-style license:
 
Copyright © 2006 Alex Samorukov <samm@os2.kiev.ua>
 
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
 
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
EOF

Latest revision as of 09:54, 17 November 2023

What is SqStat

SqStat is a script which allows to look through active squid users connections. It use cachemgr protocol to get information from squid proxy server.

Set up SqStat on Alpine Linux

This document will be a quick c/p guide to setup SqStat acive squid log viewer on Alpine linux. What we will install is the following:

  • Lighttpd
  • PHP

Installing Lighthttpd and PHP

Basic Installation

For installing the additional packages first activate community packages and update the package index

Install the required packages:

# apk add lighttpd php82 fcgi php82-cgi

Configure Lighttpd

Edit lighttpd.conf (/etc/lighttpd/lighttpd.conf) and uncomment the line:

Contents of /etc/lighttpd/lighttpd.conf

... include "mod_fastcgi.conf" ...

Edit mod_fastcgi.conf (/etc/lighttpd/mod_fastcgi.conf), find and change /usr/bin/php-cgi to /usr/bin/php-cgi82.

Contents of /etc/lighttpd/mod_fastcgi.conf

... "bin-path" => "/usr/bin/php-cgi82" # php-cgi ...

Start lighttpd service and add it to default runlevel

# rc-service lighttpd start # rc-update add lighttpd default

Installing SqStat

Download SqStat

cd /tmp wget http://samm.kiev.ua/sqstat/sqstat-1.20.tar.gz

Configuring SqStat

Unpack and move SqStat

gunzip sqstat-1.20.tar.gz tar xvf sqstat-1.20.tar -C /var/www/localhost/htdocs/ mv /var/www/localhost/htdocs/sqstat-1.20 /var/www/localhost/htdocs/sqstat

Copy and edit the sqstats config file

cp /var/www/localhost/htdocs/sqstat/config.inc.php.defaults /var/www/localhost/htdocs/sqstat/config.inc.php nano /var/www/localhost/htdocs/sqstat/config.inc.php

  • Modify this lines with your proxy ip addres and port
/* Squid proxy server ip address or host name */
$squidhost[0]="127.0.0.1";
/* Squid proxy server port */
$squidport[0]=3128;

Configuring your squid server

Note: You need edit your squid.conf to allow cachemgr protocol

Edit squid.conf

nano /etc/squid/squid.conf

  • Add this lines and replace the ip addres with your webserver IP
acl manager proto cache_object
# replace 10.0.0.1 with your webserver IP
acl webserver src 10.0.0.1/255.255.255.255
http_access allow manager webserver
http_access deny manager

Restart squid

rc-service squid restart

  • Browse and see
http://SQSTAT_IP_NUMBER/sqstat/sqstat.php