This commit is contained in:
DerGrumpf
2026-04-26 17:03:59 +00:00
parent 76adff71d7
commit befd9f94c7
5 changed files with 348 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
# prometheus.yml — scrape config for xonotic_exporter
#
# Blackbox-style multi-target pattern: Prometheus passes each server name
# as ?target= and the exporter queries that server on demand.
#
# The three relabel rules:
# 1. Copy __address__ (= server name) into __param_target → sent as ?target=
# 2. Copy __param_target into the `instance` label visible in Grafana
# 3. Rewrite __address__ to the exporter's actual host:port
scrape_configs:
- job_name: "xonotic"
scrape_interval: 15s
scrape_timeout: 10s
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: "127.0.0.1:9260" # exporter address
static_configs:
- targets:
- "vehicles" # matches [[servers]] name in TOML
- "resurrection"
- "insurrection"
+40
View File
@@ -0,0 +1,40 @@
[Unit]
Description=Xonotic Prometheus Exporter
Documentation=https://git.cyperpunk.de/DerGrumpf/Xonotic-Exporter
After=network.target
[Service]
Type=simple
# ── User / group ──────────────────────────────────────────────────────────────
User=monitoring
Group=monitoring
# ── Working directory & binary ────────────────────────────────────────────────
WorkingDirectory=/opt/xonotic_exporter
# Single command — the TOML file contains all server definitions.
# Adjust the path to the venv and config file as needed.
ExecStart=/opt/xonotic_exporter/venv/bin/xonotic-exporter serve \
/etc/xonotic_exporter/xonotic_exporter.toml
# Send SIGHUP to reload config without restarting the process
ExecReload=/bin/kill -HUP $MAINPID
# ── Restart policy ────────────────────────────────────────────────────────────
Restart=on-failure
RestartSec=5s
KillSignal=SIGTERM
TimeoutStopSec=10s
# ── Hardening ─────────────────────────────────────────────────────────────────
NoNewPrivileges=yes
PrivateTmp=yes
ProtectHome=yes
ProtectSystem=strict
ReadWritePaths=/var/log/xonotic_exporter
SystemCallFilter=~@debug @keyring @module @mount @reboot @swap
CapabilityBoundingSet=
[Install]
WantedBy=multi-user.target
+44
View File
@@ -0,0 +1,44 @@
# xonotic_exporter.toml
# ─────────────────────────────────────────────────────────────────────────────
# Xonotic Prometheus Exporter — configuration
# ─────────────────────────────────────────────────────────────────────────────
# ── Exporter HTTP listener ────────────────────────────────────────────────────
[exporter]
host = "0.0.0.0" # bind address for the Prometheus scrape endpoint
port = 9260 # Prometheus will scrape http://<this-host>:9260/metrics?target=<name>
# ── Servers ───────────────────────────────────────────────────────────────────
# Add one [[servers]] block per Xonotic game server.
#
# rcon_mode values:
# 0 = nonsecure (password sent in plaintext — avoid in production)
# 1 = secure-time (HMAC-MD4 signed with current timestamp)
# 2 = secure-challenge (HMAC-MD4 signed with server challenge — recommended)
#
# The rcon_mode must match what is set in server.cfg:
# rcon_restricted 0 → use mode 0 (nonsecure)
# rcon_secure 1 → use mode 1 (secure-time)
# rcon_secure 2 → use mode 2 (secure-challenge / MD4)
[[servers]]
name = "vehicles"
host = "localhost"
port = 26010
rcon_password = "CHANGEME" # fill in your rcon password
rcon_mode = 2 # secure-challenge (MD4)
[[servers]]
name = "resurrection"
host = "localhost"
port = 26015
rcon_password = "CHANGEME" # fill in your rcon password
rcon_mode = 2
[[servers]]
name = "insurrection"
host = "localhost"
port = 26016
rcon_password = "CHANGEME" # fill in your rcon password
rcon_mode = 2