Skip to content

A comprehensive system for monitoring and optimizing network traffic

Notifications You must be signed in to change notification settings

manish3173/TrafficGuard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 

Repository files navigation

TrafficGuard : A comprehensive system for monitoring and optimizing network traffic

This project provides a comprehensive system for monitoring and optimizing network traffic. It includes tools for capturing network traffic, analyzing it, and optimizing traffic flow using HAProxy. Performance is monitored with Prometheus and Grafana.

Installation on Ubuntu

Step-by-Step Installation

  1. Clone the Repository
    git clone https://github.com/manish3173/TrafficGuard.git
    cd TrafficGuard
  2. Install Monitoring Tools
    sudo apt update
    sudo apt install tcpdump -y
  3. Install Analysis Tools
    sudo apt install python3-pip -y
    pip3 install scapy prometheus-client psutil
  4. Install Optimization Tools
    sudo apt install haproxy -y
    cp config/haproxy.cfg /etc/haproxy/haproxy.cfg
    sudo systemctl restart haproxy
  5. Install Reporting Tools
    # Install Prometheus
    wget https://github.com/prometheus/prometheus/releases/download/v2.43.0/prometheus-2.43.0.linux-amd64.tar.gz
    tar xvf prometheus-2.43.0.linux-amd64.tar.gz
    mv prometheus-2.43.0.linux-amd64 /opt/prometheus
    
    # Install Grafana
    sudo apt update
    sudo apt install -y software-properties-common
    sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
    sudo apt update
    sudo apt install grafana -y
    sudo systemctl start grafana-server

Usage

  • Capture Traffic
    sudo python3 src/capture_traffic.py --interface enp0s3 --duration 300 --output pcaps/capture_manual.pcap --filter "not port 22"
  • Analyze Captured Traffic
    sudo python3 src/analyze_traffic.py pcaps/capture_manual.pcap
  • Start Metrics Server
    sudo python3 src/metrics_server.py --port 8000 --destinations 8.8.8.8,1.1.1.1
  • Start Prometheus
    sudo prometheus --config.file=config/prometheus.yml --storage.tsdb.path=prometheus_data
  • Access Monitoring Interfaces

Configuration

HAProxy Configuration

Edit config/haproxy.cfg to:

  • Add backend servers if needed
  • Modify load balancing algorithms as required
  • Configure health checks
  • Set security parameters

Prometheus Configuration

Modify config/prometheus.yml to:

  • Add additional monitoring targets if you want more servers
  • Configure alerting rules
  • Adjust scraping intervals

Connecting Grafana to Prometheus

  1. Log in to Grafana at http://localhost:3000.
  2. Go to the Configuration (gear icon) > Data Sources > Add data source.
  3. Search for Prometheus, select it, and configure:
  4. Click Save & Test to verify the connection.

Creating a Dashboard in Grafana

  1. Click the "+" icon in the sidebar and select Dashboard.
  2. Click Add new panel.
  3. In the Metrics tab, click Add query.
  4. Select the Prometheus data source and enter a PromQL query to visualize your metrics.

Contributing

Feel free to submit issues and pull requests. Contributions are welcome!

Contact

For questions or support, please contact:

License

This project is licensed under the MIT License.

About

A comprehensive system for monitoring and optimizing network traffic

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages