SQUIDSTAT logo
The definitive analysis for your proxy

[![GitHub repo size](https://img.shields.io/github/repo-size/kaelthasmanu/SquidStats?logo=github&style=plastic)](https://github.com/kaelthasmanu/SquidStats/) [![GitHub License](https://img.shields.io/github/license/kaelthasmanu/SquidStats.svg?logo=github&style=plastic&colorB=68B7EB)](https://github.com/kaelthasmanu/SquidStats/blob/master/LICENSE) [![GitHub stars](https://img.shields.io/github/stars/kaelthasmanu/SquidStats.svg?style=plastic&logo=github&color=yellow)](https://github.com/kaelthasmanu/SquidStats/stargazers) [![GitHub forks](https://img.shields.io/github/forks/kaelthasmanu/SquidStats.svg?logo=github&color=teal&style=plastic)](https://github.com/kaelthasmanu/SquidStats/members) [![GitHub top language](https://img.shields.io/github/languages/top/kaelthasmanu/SquidStats?logo=github&style=plastic&color=blueviolet)](https://github.com/kaelthasmanu/SquidStats/) [![GitHub contributors](https://img.shields.io/github/contributors/kaelthasmanu/SquidStats?logo=github&style=plastic)](https://github.com/kaelthasmanu/SquidStats/) [![Watchers](https://img.shields.io/github/watchers/kaelthasmanu/SquidStats?logo=github&color=teal&style=plastic)](https://github.com/kaelthasmanu/SquidStats/watchers)

:star: Give me one star — it will motivate me to keep improving it!!

Table of contents
  1. About the Project
  2. Getting Started
  3. To do
  4. Contributing
  5. License
  6. Contact
  7. Technologies Used
  8. Special thanks
## About the Project _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](https://github.com/kaelthasmanu/SquidStats/tree/main/assets "Examples").**
fig1
fig2
fig3
### Goals of this project : - **_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_** ## ## Getting Started [![SquidStat](https://img.shields.io/badge/Web-Project-teal.svg?colorA=teal&colorB=red&style=for-the-badge)](https://github.com/kaelthasmanu/SquidStats/) **The entire installation process in more detail can be found [here](https://www.sysadminsdecuba.com/2025/04/squidstat-analizador-de-logs-de-squid-diferente-y-100-cubano/).** ### Prerequisites - Python 3.10+ - Squid proxy server - `squidclient` installed on the server ```bash 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: ```bash logformat detailed \ "%ts.%03tu %>a %ui %un [%tl] \"%rm %ru HTTP/%rv\" %>Hs %a %mt % ### Installation Manual 1. Clone the repository: ```bash mkdir -p /opt/squidstats git clone https://github.com/kaelthasmanu/SquidStats.git /opt/squidstats ``` 2. Creating a virtual environment (venv): ```bash cd /opt/squidstats/ python3 -m venv "/opt/squidstats/venv" source venv/bin/activate pip install --upgrade pip ``` 3. Install requeriments python with pip or pip3: ```bash pip install -r /opt/squidstats/requirements.txt ``` 4. Create a .env file in the project root and add the following content:\ Note: for use MARIADB need your own database running ```bash 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" HTTP_PROXY="" ``` 5. Run App with python or python3 🚀: ```bash python3 app.py ``` 6. With your preferred browser, visit the installation URL: ```bash http://ip/hostname:5000 ``` ### ⚠️ First Execution Alert ⚠️ Warning: 🚨 The first execution may cause high CPU usage. ### Update project(web) with Script 1. Get Script With curl o wget: ```bash wget https://github.com/kaelthasmanu/SquidStats/releases/download/1.0/install.sh ``` 2. Add permission execution: ```bash sudo chmod +x install.sh ``` 3. Execute the script with parameters update: ```bash sudo ./install.sh --update ``` 🕒 Run on System Startup To ensure the application starts automatically when the system boots, add the following cron job: 1. Open with a editor the file crontab ```bash nano /etc/crontab ``` 2. Add the following line to the crontab file(change path_app for your path): ```bash @reboot root nohup python3 path_app/app.py & ``` 3. Save Or can use service(daemon): 1. Copy file service: ```bash cp ./utils/squidstats.service /etc/systemd/system/squidstats.service ``` 2. Restart daemons: ```bash systemctl daemon-reload ``` 3. Enable service: ```bash systemctl enable squidstats.service ``` 3. Start service: ```bash systemctl start squidstats.service ``` ## ## Testing Information 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. ## Uninstall SquidStats The installation script now includes a complete uninstall option that cleans all system components: ### Using the Uninstall Script 1. Get the installation script (if you don't have it): ```bash wget https://github.com/kaelthasmanu/SquidStats/releases/download/1.0/install.sh chmod +x install.sh ``` 2. Run the uninstallation: ```bash sudo ./install.sh --uninstall ``` ### What Does the Uninstall Do? The **COMPLETE** uninstallation performs the following actions: - **🛑 Stops and disables** the systemd service `squidstats.service` - **🗑️ Removes files** from the `/opt/squidstats` directory - **⚠️ Requires confirmation** from user before proceeding ### Manual Uninstallation If you prefer to uninstall manually: ```bash # Stop and disable service sudo systemctl stop squidstats.service sudo systemctl disable squidstats.service sudo rm -f /etc/systemd/system/squidstats.service sudo systemctl daemon-reload # Remove project files sudo rm -rf /opt/squidstats ``` ### ⚠️ Important Note about Uninstallation - Uninstallation will **permanently delete** all SquidStats data and configurations - It's recommended to **backup** any custom configurations before uninstalling - Squid configuration will be restored from the automatic backup created during installation ## To do _Future functionalities and planned improvements._ ### Upcoming Features - **Advanced Audit Center** 🔍 - Keyword search in URLs - Activity analysis by specific IP - HTTP response code filters - Social media monitoring - Daily activity reports per user - **Interface Improvements** 🎨 - Customizable dashboards - Dark/light themes - Report export (PDF, Excel) - Real-time notifications - **Security Features** 🔒 - User authentication - Roles and permissions - System audit logs - Automated alerts - **Optimization and Performance** ⚡ - Enhanced data caching - Historical log compression - Complete RESTful API - Multi-proxy support ## Contributing 1. Fork the repository: ```bash git checkout -b feature-name ``` 2.Create a new branch for your feature or fix: ```bash git checkout -b feature-name ``` 3.Commit your changes and push the branch: ```bash git push origin feature-name ``` 4.Open a pull request. **Contributors**
Kaelthas Alexminator
kaelthasmanu alexminator
## License _The SquidStats project is released under the MIT license._ ## Contact > **_Need help?_** > **_Feel free to contact me 📨 [manuelalberto.gorrin@gmail.com](mailto:manuelalberto.gorrin@gmail.com?Subject=SquidStats_issues)_** Related project: ([CuCuota](https://github.com/kaelthasmanu/cucuota)) ## Technologies Used Backend: Python, Flask Frontend: HTML, CSS, JavaScript ## Special thanks - _To the Cuban Sysadmins community._ - _To everyone who gave me his help when I had doubts._ ##