Skip to content

A cross-platform Python tool that monitors incoming network traffic and alerts via Discord when traffic exceeds defined thresholds, with optional packet capture for diagnostics and analysis.

Notifications You must be signed in to change notification settings

sam18p/network-traffic-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

🛡️ Network Traffic Monitor

A cross-platform Python tool that monitors incoming network traffic and alerts via Discord when traffic exceeds defined thresholds, with optional packet capture for diagnostics and analysis.

Screenshot Showcase

image

PPS threshold altered strictly for this example


📑 Table of Contents

  1. Features
  2. Requirements
  3. Installation
  4. How to Run
  5. How to Deploy on a Server
  6. Configuring the Discord Webhook
  7. Configuring Server Variables

⭐ Features

  • Cross-platform (Linux, Windows, macOS)
  • Real-time monitoring of incoming packets per second
  • Configurable traffic thresholds
  • Discord webhook alerts with relevant context
  • Optional packet capture for investigation and diagnostics
  • Designed to run quietly in the background

📦 Requirements

  • Python 3.8+
  • Works on:
    • Windows 10/11
    • macOS (Intel & Apple Silicon)
    • Linux distributions (Ubuntu, Debian, Fedora, Arch, etc.)

📥 Installation

git clone https://github.com/sam18p/network-traffic-monitor.git
cd network-traffic-monitor

▶️ How to Run

The script is a single Python file — running it is mostly the same on all systems.

🪟 Windows

Check Python version:

python --version

Run the tool:

python network-traffic-monitor.py

If that fails, try:

py network-traffic-monitor.py

🍎 macOS

Verify Python3:

python3 --version

Run the script:

python3 network-traffic-monitor.py

If Python isn’t installed:

brew install python

🐧 Linux

Most Linux distros come with Python preinstalled.

Run the script:

python3 network-traffic-monitor.py

If Python is missing:

Debian/Ubuntu:

sudo apt install python3

Fedora:

sudo dnf install python3

Arch:

sudo pacman -S python


🌐 How to Deploy on a Server

The script is a single Python file — running it is mostly the same on all systems.

🪟 Windows Server

Check Python version:

python --version

Option 1: Simple detached run (console hidden)

pythonw network-traffic-monitor.py

Option 2: Run in background with output logged (from Command Prompt)

start /B python network-traffic-monitor.py > monitor.log 2>&1

If that fails, try:

py network-traffic-monitor.py

🍎 macOS Server

As of April 21, 2022, Apple has discontinued macOS Server. Existing macOS Server customers can continue to download and use the app with macOS Monterey.

Read more on Apple's Website

Verify Python3:

python3 --version

nohup python3 network-traffic-monitor.py > monitor.log 2>&1 &

You can also use screen or tmux if you prefer an attachable session:

screen -dmS monitor python3 network-traffic-monitor.py

🐧 Linux Server

Most Linux distros come with Python preinstalled.

nohup python3 network-traffic-monitor.py > monitor.log 2>&1 &

To check if it's running:

ps aux | grep network-traffic-monitor.py

To stop it:

pkill -f network-traffic-monitor.py


🪝 Discord Webhook

To receive alerts, create a Discord webhook in your server channel settings (Integrations → Webhooks → New Webhook). Copy the webhook URL and replace the placeholder in the script:

DISCORD_WEBHOOK_URL = "https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN"

The script sends rich embeds with a red alert color, server name, incoming PPS, and (after capture) a note about the saved .pcap file.

Creating a Discord webhook

Have admin permissions and select settings for the desired output channel

image

Select integrations

image

Webhook

image

New Webhook

image

Copy Webhook URL and add to the script

image

🔡 Server Variables

These are the main configurable variables at the top of the script:

SERVER_NAME = "AWS, France"
PPS_THRESHOLD = 50000
CHECK_INTERVAL = 1
CAPTURE_PACKET_COUNT = 10000
CAPTURE_FILENAME_PREFIX = "traffic_capture_"

About

A cross-platform Python tool that monitors incoming network traffic and alerts via Discord when traffic exceeds defined thresholds, with optional packet capture for diagnostics and analysis.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages