Без опису

Manuel fcbb673f0b update readme 1 рік тому
.idea c17311899e separate code python from sh 1 рік тому
assets fb0487ae2e move files to static 1 рік тому
database 7de7e620f9 Revert "ReportesOK" 1 рік тому
parsers 7fe9c55474 refactor create tables 1 рік тому
services 7de7e620f9 Revert "ReportesOK" 1 рік тому
static 96aac78407 feat: Enhance installation script with improved error handling and user prompts 1 рік тому
templates 96aac78407 feat: Enhance installation script with improved error handling and user prompts 1 рік тому
tests 5c8f5ec2fb add test for create tables 1 рік тому
utils c17311899e separate code python from sh 1 рік тому
.gitignore 6c51a019a0 fix bug cache page 1 рік тому
CHANGELOG.md fcbb673f0b update readme 1 рік тому
IMPROVEMENTS_SUMMARY.md fcbb673f0b update readme 1 рік тому
LICENSE 7242ab717e Create LICENSE 1 рік тому
README.md 8639667299 chore: Remove details about blacklist management features from README 1 рік тому
README_es.md b98a805685 fix name 1 рік тому
app.py 96aac78407 feat: Enhance installation script with improved error handling and user prompts 1 рік тому
install.sh fcbb673f0b update readme 1 рік тому
requirements.txt b6d6cc96ea add mariaDB support and some changes 1 рік тому

README.md

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.
  • 🛡️ Blacklist Management: Configure and manage blocked domains dynamically via web interface.
  • 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.
  • 🎨 Modern UI: Professional design with responsive layout and intuitive navigation.
  • 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...
  • ⚙️ Easy Configuration: Environment-based settings with automated installer.
  • And More

Configuration

Edit the .env file to configure blocked domains:

BLACKLIST_DOMAINS="facebook.com,twitter.com,instagram.com,tiktok.com,youtube.com,netflix.com"

Management Commands

# Reconfigure blacklist interactively
sudo ./install.sh --configure-blacklist

# Restart service after manual changes
sudo systemctl restart squidstats.service

# View current configuration
grep BLACKLIST_DOMAINS /opt/squidstats/.env

Getting Started

SquidStat

The entire installation process in more detail can be found here.

Prerequisites

  • 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
    

Installation Script

🎉 New in v2.1.0: Enhanced installer with blacklist configuration and multiple options!

Quick Installation

  1. Get Script with curl or wget:

    wget https://github.com/kaelthasmanu/SquidStats/releases/download/v2.1.0/install.sh
    # or
    curl -O https://raw.githubusercontent.com/kaelthasmanu/SquidStats/main/install.sh
    
  2. Add execution permission:

    sudo chmod +x install.sh
    
  3. Execute the script:

    sudo ./install.sh
    

Installation Options

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

🛡️ Blacklist Configuration

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

Installation Manual

  1. Clone the repository:

    mkdir -p /opt/squidstats
    git clone https://github.com/kaelthasmanu/SquidStats.git /opt/squidstats
    
  2. Creating a virtual environment (venv):

    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:

    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

    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"
    
  5. Run App with python or python3 🚀:

    python3 app.py
    
  6. With your preferred browser, visit the installation URL:

    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:

    wget https://github.com/kaelthasmanu/SquidStats/releases/download/0.2/install.sh
    
  2. Add permission execution:

    sudo chmod +x install.sh
    
  3. 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:

  1. Open with a editor the file crontab

    nano /etc/crontab
    
  2. Add the following line to the crontab file(change path_app for your path):

    @reboot root nohup python3 path_app/app.py &
    
  3. Save

Or can use service(daemon):

  1. Copy file service:

    cp ./utils/squidstats.service /etc/systemd/system/squidstats.service
    
  2. Restart daemons:

    systemctl daemon-reload
    
  3. Enable service:

    systemctl enable squidstats.service
    
  4. Start service:

    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.

To do

Make blah blah.

Contributing

  1. Fork the repository:

    git checkout -b feature-name
    

    2.Create a new branch for your feature or fix:

    git checkout -b feature-name
    

    3.Commit your changes and push the branch:

    git push origin feature-name
    

    4.Open a pull request.

Contributors

<th><b>Kaelthas</b></th>
<th><b>Alexminator</b></th>

<td align="center"><a href="https://github.com/kaelthasmanu"><img src="https://avatars.githubusercontent.com/u/39976595?v=4" width=150px height=150px alt="kaelthasmanu"/></a></td>
<td align="center"><a href="https://github.com/alexminator"><img src="https://avatars.githubusercontent.com/u/9116486?s=400&v=4" width=150px height=150px alt="alexminator"/></a></td>

<td align="center"></a> <a href="https://www.linkedin.com/in/manuel-gorrin-095242238/"><img src="assets/linkedin-48.png" width="32px" height="32px"></a><a href="https://t.me/king_0f_deathhh"><img src="assets/telegram-app-48.png" width="32px" height="32px"></a></td>
<td align="center"><a href="https://twitter.com/alexminator99"><img src="assets/x_48.png" width="32px" height="32px"></a> <a href="https://www.linkedin.com/in/alexander-rivas-73532037/"><img src="assets/linkedin-48.png" width="32px" height="32px"></a><a href="https://t.me/Alexminator"><img src="assets/telegram-app-48.png" width="32px" height="32px"></a></td>

License

The SquidStats project is released under the MIT license.

Contact

Need help? _Feel free to contact me 📨 manuelalberto.gorrin@gmail.com_

Project Link: (SquidStats)

Technologies Used

Backend: Python, Flask Frontend: HTML, CSS

Special thanks

  • To the Cuban Sysadmins community.
  • To everyone who gave me his help when I had doubts.