Table of contents
A modern tool for parsing and analyzing Squid logs, providing a sleek and user-friendly dashboard to visualize real-time connection data. This project helps network administrators monitor and manage Squid proxy connections effectively.
You can view the example here.
- Real-time Log Parsing: Parses active Squid connections and displays detailed information.
- User Monitoring: Identifies connections by username, URI, and log type.
- Metrics Overview:
- Total read and written data for each connection.
- Number of requests per connection.
- Delay pool usage.
- Interactive Dashboard: Clean interface for easy data interpretation.
- Squid Cache Statistics:
- Stored entries.
- Used and free capacity
- Maximum and current cache size
- Disk space and inode usage
- Age of cached objects
- Logs Users:
- User activity monitoring ๐ฅ
- Beautiful visualizations ๐
- Advanced filtering & search ๐
- Paginated results ๐
- Top Graphs:
- Top 20 Users Activity
- Top 20 Users Data Usage
- Total Users
- Total Transmitted Data
- Total Request
- And More...
- And More
The entire installation process in more detail can be found here.
- Python 3.10+
- Squid proxy server
squidclient
installed on the server
apt install git python3 python3-pip python3-venv python3-pymysql libmariadb-dev curl
โ ๏ธ !!Importantโ ๏ธ For compatibility with user logs, use this format in /etc/squid/squid.conf:
logformat detailed \
"%ts.%03tu %>a %ui %un [%tl] \"%rm %ru HTTP/%rv\" %>Hs %<st %rm %ru %>a %mt %<a %<rm %Ss/%Sh %<st
access_log /var/log/squid/access.log detailed
- Get Script With curl o wget:
wget https://github.com/kaelthasmanu/SquidStats/releases/download/0.2/install.sh
- Add permission execution:
sudo chmod +x install.sh
- Execute the script:
sudo ./install.sh
The installer now supports multiple modes:
# Full installation (interactive)
sudo ./install.sh
# Update existing installation
sudo ./install.sh --update
# Configure blacklist only
sudo ./install.sh --configure-blacklist
# Show help
./install.sh --help
During installation, you can configure which domains notify like block:
- Option 1: Use default blacklist (facebook.com, twitter.com, instagram.com, etc.)
- Option 2: Configure custom domains
- Option 3: Skip blacklist configuration
Example custom configuration:
# When prompted, enter domains separated by commas:
facebook.com,twitter.com,youtube.com,netflix.com,tiktok.com
- Clone the repository:
mkdir -p /opt/squidstats git clone https://github.com/kaelthasmanu/SquidStats.git /opt/squidstats
- Creating a virtual environment (venv):
cd /opt/squidstats/
python3 -m venv "/opt/squidstats/venv"
source venv/bin/activate
pip install --upgrade pip
- Install requeriments python with pip or pip3:
pip install -r /opt/squidstats/requirements.txt
- Create a .env file in the project root and add the following content:
Note: for use MARIADB need your own database runningB15D li>VERSION=2 SQUID_HOST="127.0.0.1" SQUID_PORT=3128 FLASK_DEBUG="True" DATABASE_TYPE="SQLITE" SQUID_LOG="/var/log/squid/access.log" DATABASE_STRING_CONNECTION="/opt/squidstats/" REFRESH_INTERVAL=60 BLACKLIST_DOMAINS="facebook.com,twitter.com,instagram.com,tiktok.com,youtube.com,netflix.com"
- Run App with python or python3 ๐:
python3 app.py
- With your preferred browser, visit the installation URL:
http://ip/hostname:5000
Warning: ๐จ The first execution may cause high CPU usage.
- Get Script With curl o wget:
wget https://github.com/kaelthasmanu/SquidStats/releases/download/0.2/install.sh
- Add permission execution:
sudo chmod +x install.sh
- Execute the script with parameters update:
sudo ./install.sh --update
๐ Run on System Startup To ensure the application starts automatically when the system boots, add the following cron job:
- Open with a editor the file crontab
nano /etc/crontab
- Add the following line to the crontab file(change path_app for your path):
@reboot root nohup python3 path_app/app.py &
- Save
Or can use service(daemon):
- Copy file service:
cp ./utils/squidstats.service /etc/systemd/system/squidstats.service
- Restart daemons:
systemctl daemon-reload
- Enable service:
systemctl enable squidstats.service
- Start service:
systemctl start squidstats.service
This software has been thoroughly tested and is compatible with Squid version 6.12 in Ubuntu 24.04 and Debian12. Please ensure your Squid installation matches this version or newer for optimal performance.
Make blah blah.
- Fork the repository:
2.Create a new branch for your feature or fix:
git checkout -b feature-name
git checkout -b feature-name
3.Commit your changes and push the branch:
git push origin feature-name
4.Open a pull request.
Contributors
Kaelthas | Alexminator |
---|---|
|
The SquidStats project is released under the MIT license.
Need help? Feel free to contact me ๐จ manuelalberto.gorrin@gmail.com
Project Link: (SquidStats)
Backend: Python, Flask Frontend: HTML, CSS
- To the Cuban Sysadmins community.
- To everyone who gave me his help when I had doubts.