Add tailscale-api.py: HTTP-API für Homepage
- Python-HTTP-Server stellt Tailscale-Traffic als JSON bereit - Pro Gerät: Upload/Download in Mbit/s, Online-Status - Gesamtwerte und Peer-Statistik - systemd-Service-Datei inklusive - Homepage Widget Beispiel-Konfiguration - Läuft direkt auf dem Exit-Node (kein Docker nötig) Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
67
README.md
67
README.md
@ -2,6 +2,73 @@
|
||||
|
||||
Scripts für Tailscale Exit-Node Monitoring und mehr.
|
||||
|
||||
## tailscale-api.py – HTTP-API für Homepage
|
||||
|
||||
Stellt Tailscale-Traffic-Daten als JSON über HTTP bereit. Ideal für [Homepage](https://github.com/gethomepage/homepage) oder andere Dashboards.
|
||||
|
||||
### JSON-Ausgabe
|
||||
|
||||
```json
|
||||
{
|
||||
"devices": [
|
||||
{"name": "PC7-77", "upload_mbit": 1.23, "download_mbit": 4.56, "online": true, "type": "self"},
|
||||
{"name": "S22 von Alf", "upload_mbit": 0.12, "download_mbit": 0.34, "online": true, "type": "peer"}
|
||||
],
|
||||
"total": {"upload_mbit": 1.35, "download_mbit": 4.90},
|
||||
"peers_online": 15,
|
||||
"peers_total": 28,
|
||||
"self_name": "heimathafen"
|
||||
}
|
||||
```
|
||||
|
||||
### Installation auf dem Exit-Node
|
||||
|
||||
```bash
|
||||
# 1. Script installieren
|
||||
sudo cp tailscale-api.py /usr/local/bin/
|
||||
sudo chmod +x /usr/local/bin/tailscale-api.py
|
||||
|
||||
# 2. systemd-Service einrichten
|
||||
sudo cp tailscale-api.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now tailscale-api
|
||||
|
||||
# 3. Testen
|
||||
curl http://localhost:8080/tailscale
|
||||
```
|
||||
|
||||
### Homepage Widget
|
||||
|
||||
Siehe `homepage-widget.yaml` für Beispiel-Konfiguration.
|
||||
|
||||
```yaml
|
||||
- Tailscale Exit-Node:
|
||||
icon: tailscale.png
|
||||
widget:
|
||||
type: customapi
|
||||
url: http://100.87.87.105:8080/tailscale
|
||||
refreshInterval: 10000
|
||||
mappings:
|
||||
- label: Upload gesamt
|
||||
field: total.upload_mbit
|
||||
suffix: Mbit/s
|
||||
- label: Download gesamt
|
||||
field: total.download_mbit
|
||||
suffix: Mbit/s
|
||||
```
|
||||
|
||||
### Konfiguration
|
||||
|
||||
Im Script anpassbar:
|
||||
|
||||
```python
|
||||
PORT = 8080 # HTTP-Port
|
||||
MEASURE_INTERVAL = 1 # Sekunden zwischen Messungen (für Rate)
|
||||
MAX_DEVICES = 10 # Max. Geräte in der Ausgabe
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## exitnode-bw.sh
|
||||
|
||||
Zeigt die Up-/Download-Bandbreite ausgewählter Geräte an, die über einen Tailscale Exit-Node verbunden sind.
|
||||
|
||||
Reference in New Issue
Block a user