Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
# Dockerfile for netprobe_lite
# https://github.com/plaintextpackets/netprobe_lite/
FROM python:3.11-slim-bookworm
FROM python:3.13-alpine

COPY requirements.txt /netprobe_lite/requirements.txt

# Install python/pip
ENV PYTHONUNBUFFERED=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=on

RUN apt-get update && apt-get install -y iputils-ping && apt-get install -y traceroute && apt-get clean \
&& pip install -r /netprobe_lite/requirements.txt --break-system-packages
# install ip utils to get a ping with jitter data in the output
RUN apk add iputils

# Install uv (https://github.com/astral-sh/uv)
COPY --from=ghcr.io/astral-sh/uv:python3.13-alpine /usr/local/bin/uv /usr/local/bin/uvx /bin/

WORKDIR /netprobe_lite

ENTRYPOINT [ "/bin/bash", "./entrypoint.sh" ]
COPY requirements.txt ./requirements.txt

# create virtualenv and install packages
RUN uv venv
RUN uv pip install -r ./requirements.txt

# copy python files into the container
COPY entrypoint.sh ./entrypoint.sh
COPY *.py ./
COPY helpers ./helpers
COPY config/__init__.py ./config/__init__.py
COPY logs ./logs

ENTRYPOINT [ "/bin/sh", "./entrypoint.sh" ]
21 changes: 16 additions & 5 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ services:
restart: always
container_name: netprobe-probe
image: "plaintextpackets/netprobe:latest"
build: .
pull_policy: always
volumes:
- .:/netprobe_lite
- ./logs:/netprobe_lite/logs
env_file:
- .env
environment:
MODULE: "NETPROBE"
networks:
Expand All @@ -37,9 +40,12 @@ services:
restart: always
container_name: netprobe-speedtest
image: "plaintextpackets/netprobe:latest"
build: .
pull_policy: always
volumes:
- .:/netprobe_lite
- ./logs:/netprobe_lite/logs
env_file:
- .env
environment:
MODULE: "SPEEDTEST"
networks:
Expand All @@ -52,11 +58,16 @@ services:
restart: always
container_name: netprobe-presentation
image: "plaintextpackets/netprobe:latest"
build: .
pull_policy: always
volumes:
- .:/netprobe_lite
- ./logs:/netprobe_lite/logs
env_file:
- .env
environment:
MODULE: "PRESENTATION"
ports:
- 5080:5000
networks:
- netprobe-net
dns:
Expand Down Expand Up @@ -97,8 +108,8 @@ services:
dns:
- 8.8.8.8
- 8.8.4.4

volumes:
prometheus_data:
grafana_data:

12 changes: 11 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
if [[ "${MODULE}" == "NETPROBE" ]]; then python3 netprobe.py; elif [[ "${MODULE}" == "COLLECTOR" ]]; then python3 collector.py; elif [[ "${MODULE}" == "PRESENTATION" ]]; then python3 presentation.py; elif [[ "${MODULE}" == "SPEEDTEST" ]]; then python3 netprobe_speedtest.py; else /bin/bash; fi
if [[ "${MODULE}" == "NETPROBE" ]]; then
uv run netprobe.py;
elif [[ "${MODULE}" == "COLLECTOR" ]]; then
uv run collector.py;
elif [[ "${MODULE}" == "PRESENTATION" ]]; then
uv run presentation.py;
elif [[ "${MODULE}" == "SPEEDTEST" ]]; then
uv run netprobe_speedtest.py;
else
/bin/sh;
fi
2 changes: 1 addition & 1 deletion helpers/network_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self,sites,count,dns_test_site,nameservers_external):

def pingtest(self,count,site):

ping = subprocess.getoutput(f"ping -n -i 0.1 -c {count} {site} | grep 'rtt\|loss'")
ping = subprocess.getoutput(f"ping -n -i 0.1 -c {count} {site} | grep 'rtt\\|loss'")

try:
loss = ping.split(' ')[5].strip('%')
Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prometheus_client==0.18.0
requests==2.31.0
redis==5.0.1
python-dotenv==1.0.0
dnspython==2.4.2
speedtest-cli==2.1.3
prometheus_client==0.21.1
requests==2.32.3
redis==5.2.1
python-dotenv==1.0.1
dnspython==2.7.0
speedtest-cli==2.1.3