Initial commit

This commit is contained in:
2026-02-21 16:54:18 +01:00
commit 0cf33cd95b
80 changed files with 8042 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
version: '3.8'
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
ports:
- "9090:9090"
restart: unless-stopped
grafana:
image: grafana/grafana:latest
container_name: grafana
volumes:
- grafana_data:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
ports:
- "3000:3000"
restart: unless-stopped
volumes:
prometheus_data:
grafana_data:

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python3
"""WireGuard Lab Exporter for Prometheus"""
import subprocess
import time
from prometheus_client import start_http_server
from prometheus_client.core import GaugeMetricFamily, CounterMetricFamily, REGISTRY
import json
class WireGuardLabCollector:
def __init__(self):
try:
with open('/etc/wg-lab-exporter/config.json') as f:
self.config = json.load(f)
except:
self.config = {'labs': {}}
def collect(self):
wg_up = GaugeMetricFamily('wireguard_tunnel_up', 'Tunnel status', labels=['lab', 'peer'])
for lab_name in self.config.get('labs', {}):
try:
result = subprocess.run(['wg', 'show', f'wg-{lab_name}'],
capture_output=True, text=True, timeout=5)
if result.returncode == 0:
wg_up.add_metric([lab_name, 'all'], 1)
else:
wg_up.add_metric([lab_name, 'all'], 0)
except:
wg_up.add_metric([lab_name, 'all'], 0)
yield wg_up
if __name__ == '__main__':
REGISTRY.register(WireGuardLabCollector())
start_http_server(9586)
print("Exporter started on port 9586")
while True:
time.sleep(60)

View File

@@ -0,0 +1,8 @@
global:
scrape_interval: 30s
evaluation_interval: 30s
scrape_configs:
- job_name: 'wireguard-linux'
static_configs:
- targets: ['192.168.1.11:9586', '192.168.1.13:9586']