initial #1
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 scriptos
|
||||
Copyright (c) 2026 Patrick Asmus (scriptos)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
112
README.md
112
README.md
@@ -1,15 +1,121 @@
|
||||
# template_repository
|
||||
# Dockernet Inspector
|
||||
|
||||
Ein Bash-Script zur Analyse und Anzeige von Details zu Docker-Netzwerken.
|
||||
|
||||
## 📋 Beschreibung
|
||||
|
||||
Wichtig: Link für Lizenz anpassen.
|
||||
**Dockernet Inspector** ist ein praktisches Bash-Script, das detaillierte Informationen über Docker-Netzwerke anzeigt. Es ermöglicht Administratoren und Entwicklern einen schnellen Überblick über die Konfiguration und den Status eines Docker-Netzwerks zu erhalten.
|
||||
|
||||
Das Script zeigt folgende Informationen an:
|
||||
- **Netzwerk-Driver** (bridge, overlay, host, etc.)
|
||||
- **Bridge-Interface-Name** auf dem Host-System
|
||||
- **Subnet und Gateway** des Netzwerks
|
||||
- **Interface-Status** (operstate: up, down, unknown)
|
||||
- **Netzwerk-Statistiken** (RX/TX Bytes und Pakete)
|
||||
|
||||
## 🚀 Installation
|
||||
|
||||
1. Repository klonen:
|
||||
```bash
|
||||
git clone https://git.techniverse.net/scriptos/dockernet-inspector.git
|
||||
cd dockernet-inspector
|
||||
```
|
||||
|
||||
2. Script ausführbar machen:
|
||||
```bash
|
||||
chmod +x dockernet-inspector.v1.sh
|
||||
```
|
||||
|
||||
## 💡 Verwendung
|
||||
|
||||
### Grundlegende Syntax
|
||||
|
||||
```bash
|
||||
bash ./dockernet-inspector.v1.sh <docker-network-name>
|
||||
```
|
||||
|
||||
### Beispiele
|
||||
|
||||
**Beispiel 1: Standard Bridge-Netzwerk analysieren**
|
||||
```bash
|
||||
bash ./dockernet-inspector.v1.sh bridge
|
||||
```
|
||||
|
||||
**Beispiel 2: Benutzerdefiniertes Netzwerk analysieren**
|
||||
```bash
|
||||
bash ./dockernet-inspector.v1.sh my-custom-network
|
||||
```
|
||||
|
||||
### Beispiel-Ausgabe
|
||||
|
||||
```
|
||||
Docker-Netzwerk : my-network
|
||||
Driver : bridge
|
||||
Bridge-Interface : br-1234567890ab
|
||||
Subnet/Gateway : 172.18.0.0/16 / 172.18.0.1
|
||||
OperState : up
|
||||
RX bytes/packets : 123456 / 789
|
||||
TX bytes/packets : 654321 / 456
|
||||
```
|
||||
|
||||
## 📊 Ausgabe-Details
|
||||
|
||||
| Feld | Beschreibung |
|
||||
|------|-------------|
|
||||
| **Docker-Netzwerk** | Name des analysierten Docker-Netzwerks |
|
||||
| **Driver** | Verwendeter Netzwerk-Treiber (bridge, overlay, host, etc.) |
|
||||
| **Bridge-Interface** | Name des Bridge-Interfaces auf dem Host (z.B. `br-xxxxxxxxxxxx`) |
|
||||
| **Subnet/Gateway** | IP-Bereich und Gateway-Adresse des Netzwerks |
|
||||
| **OperState** | Betriebszustand des Interfaces (up, down, unknown) |
|
||||
| **RX bytes/packets** | Empfangene Bytes/Pakete |
|
||||
| **TX bytes/packets** | Gesendete Bytes/Pakete |
|
||||
|
||||
## ⚠️ Voraussetzungen
|
||||
|
||||
- **Docker** muss installiert und laufend sein
|
||||
- **Bash** (Version 4.0 oder höher empfohlen)
|
||||
- **Root/Sudo-Rechte** können für den Zugriff auf System-Interfaces erforderlich sein
|
||||
- Linux-Betriebssystem (das Script nutzt `/sys/class/net/` für Interface-Statistiken)
|
||||
|
||||
## 🔧 Fehlerbehandlung
|
||||
|
||||
Das Script gibt folgende Fehlermeldungen aus:
|
||||
|
||||
- **Keine Netzwerk-Angabe:** `Usage: ./dockernet-inspector.v1.sh <docker-network-name>`
|
||||
- **Netzwerk nicht gefunden:** `Fehler: Netzwerk '<name>' nicht gefunden.`
|
||||
- **Interface existiert nicht:** `WARN: Interface <name> existiert (noch) nicht auf dem Host.`
|
||||
|
||||
## 🛠️ Technische Details
|
||||
|
||||
Das Script nutzt:
|
||||
- `docker network inspect` zur Abfrage von Netzwerk-Informationen
|
||||
- `/sys/class/net/` Interface für Netzwerk-Statistiken
|
||||
- `set -euo pipefail` für sichere Script-Ausführung
|
||||
|
||||
## 📝 Lizenz
|
||||
|
||||
Siehe [LICENSE](./LICENSE) Datei für Details.
|
||||
|
||||
## 👤 Autor
|
||||
|
||||
**Patrick Asmus**
|
||||
- Website: [https://www.cleveradmin.de](https://www.cleveradmin.de)
|
||||
- Git: [https://git.techniverse.net/scriptos/dockernet-inspector.git](https://git.techniverse.net/scriptos/dockernet-inspector.git)
|
||||
|
||||
## 🤝 Beitragen
|
||||
|
||||
Beiträge, Issues und Feature-Anfragen sind willkommen!
|
||||
|
||||
## 📅 Version
|
||||
|
||||
- **Version:** 1.0.0
|
||||
- **Datum:** 17.02.2026
|
||||
- **Modifikation:** Initial Release
|
||||
|
||||
<p align="center">
|
||||
<img src="https://assets.techniverse.net/f1/git/graphics/gray0-catonline.svg" alt="">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://assets.techniverse.net/f1/logos/small/license.png" alt="License" width="15" height="15"> <a href="./template_repository/src/branch/main/LICENSE">License</a> | <img src="https://assets.techniverse.net/f1/logos/small/matrix2.svg" alt="Matrix" width="15" height="15"> <a href="https://matrix.to/#/#community:techniverse.net">Matrix</a> | <img src="https://assets.techniverse.net/f1/logos/small/mastodon2.svg" alt="Matrix" width="15" height="15"> <a href="https://social.techniverse.net/@donnerwolke">Mastodon</a>
|
||||
<img src="https://assets.techniverse.net/f1/logos/small/license.png" alt="License" width="15" height="15"> <a href="./LICENSE">License</a> | <img src="https://assets.techniverse.net/f1/logos/small/matrix2.svg" alt="Matrix" width="15" height="15"> <a href="https://matrix.to/#/#community:techniverse.net">Matrix</a> | <img src="https://assets.techniverse.net/f1/logos/small/mastodon2.svg" alt="Matrix" width="15" height="15"> <a href="https://social.techniverse.net/@donnerwolke">Mastodon</a>
|
||||
</p>
|
||||
56
dockernet-inspector.v1.sh
Normal file
56
dockernet-inspector.v1.sh
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Script Name: dockernet-inspector.v1.sh
|
||||
# Beschreibung: Dockernet Inspector - Zeigt Details zu einem Docker-Netzwerk an (Netzwerktyp, Bridge-Interface, Subnet/Gateway, Interface-Status & Stats)
|
||||
# Verwendung: bash ./dockernet-inspector.v1.sh <docker-network-name>
|
||||
# Autor: Patrick Asmus
|
||||
# Web: https://www.cleveradmin.de
|
||||
# Git-Reposit.: https://git.techniverse.net/scriptos/dockernet-inspector.git
|
||||
# Version: 1.0.0
|
||||
# Datum: 17.02.2026
|
||||
# Modifikation: Initial
|
||||
#####################################################
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
NET="${1:-}"
|
||||
[[ -z "$NET" ]] && { echo "Usage: $0 <docker-network-name>"; exit 1; }
|
||||
|
||||
# 1) Netzwerk-ID und Bridge-Name separat holen (jeweils eigenes inspect)
|
||||
ID="$(docker network inspect "$NET" --format '{{.Id}}' 2>/dev/null || true)"
|
||||
[[ -z "$ID" ]] && { echo "Fehler: Netzwerk '$NET' nicht gefunden."; exit 2; }
|
||||
|
||||
BR_RAW="$(docker network inspect "$NET" --format '{{index .Options "com.docker.network.bridge.name"}}' 2>/dev/null || true)"
|
||||
|
||||
# 2) Falls kein eigener Bridge-Name: Standardname br-<ID[:12]>
|
||||
if [[ -z "$BR_RAW" || "$BR_RAW" == "<no value>" ]]; then
|
||||
IF="br-${ID:0:12}"
|
||||
else
|
||||
IF="$BR_RAW"
|
||||
fi
|
||||
|
||||
# 3) Subnet/Gateway
|
||||
SUBNET="$(docker network inspect "$NET" --format '{{(index .IPAM.Config 0).Subnet}}' 2>/dev/null || true)"
|
||||
GATEWAY="$(docker network inspect "$NET" --format '{{(index .IPAM.Config 0).Gateway}}' 2>/dev/null || true)"
|
||||
|
||||
# 4) Interface-Status & Stats
|
||||
state="unknown"; rxb=0; txb=0; rxp=0; txp=0
|
||||
if ip link show "$IF" &>/dev/null; then
|
||||
state="$(cat /sys/class/net/"$IF"/operstate 2>/dev/null || echo unknown)"
|
||||
rxb="$(cat /sys/class/net/"$IF"/statistics/rx_bytes 2>/dev/null || echo 0)"
|
||||
txb="$(cat /sys/class/net/"$IF"/statistics/tx_bytes 2>/dev/null || echo 0)"
|
||||
rxp="$(cat /sys/class/net/"$IF"/statistics/rx_packets 2>/dev/null || echo 0)"
|
||||
txp="$(cat /sys/class/net/"$IF"/statistics/tx_packets 2>/dev/null || echo 0)"
|
||||
else
|
||||
echo "WARN: Interface $IF existiert (noch) nicht auf dem Host."
|
||||
fi
|
||||
|
||||
cat <<OUT
|
||||
Docker-Netzwerk : $NET
|
||||
Driver : $(docker network inspect "$NET" --format '{{.Driver}}')
|
||||
Bridge-Interface : $IF
|
||||
Subnet/Gateway : ${SUBNET:--} / ${GATEWAY:--}
|
||||
OperState : $state
|
||||
RX bytes/packets : $rxb / $rxp
|
||||
TX bytes/packets : $txb / $txp
|
||||
OUT
|
||||
Reference in New Issue
Block a user