Commit 8144abe5 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add strongswan vici drop-in for telegraf vpn_status

check-vpn-status.sh (run as the telegraf user) calls swanctl --list-sas, which needs the root-only vici socket /run/charon.vici (770 root:root). Without access, swanctl fails and the script falls back to a flappy rx_bytes check, emitting false vpn_status connected=0 that churns ikev2.* gateways in route-health. This drop-in grants telegraf read access to the vici socket via ExecStartPost setfacl. On ALT, /bin/sudo is 4710 root:wheel (telegraf can't even exec it), so a sudoers approach is blocked; the vici ACL is the minimal contained fix and needs no script or sudoers change. Type=notify guarantees the socket exists at ExecStartPost; "|| true" so an ACL hiccup can never take the tunnel down. Deployed to ikev2.vdska (.131), ikev2.hetzner (.120), ikev2.gr (.139), ikev2.fr (.140). Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
parent 5f8a5bc3
# systemd drop-in for strongswan.service
#
# Deploy to: /etc/systemd/system/strongswan.service.d/telegraf-vici.conf
# Then: systemctl daemon-reload && systemctl restart strongswan
#
# Why: check-vpn-status.sh runs as the telegraf user and queries SA state with
# `swanctl --list-sas`. swanctl needs the strongSwan vici socket
# (/run/charon.vici, mode 770 root:root), which telegraf cannot read. With no
# access, swanctl fails and the script falls back to a flappy "ipsec0 rx_bytes
# changed in the last 10s" check -> false vpn_status connected=0 -> route-health
# churns ikev2.* gateways dead/healthy (and flushes/re-adds 100k+ routes).
#
# Why not sudo: on ALT, /bin/sudo is 4710 root:wheel, so non-wheel users
# (telegraf) cannot even execute sudo. Granting read on the vici socket directly
# is the minimal, contained fix (no setuid binary, no wheel elevation, no
# sudoers rule, no script change).
#
# strongswan.service is Type=notify, so the vici socket already exists when
# ExecStartPost runs. `|| true` so a transient ACL failure can never take the
# IPsec tunnel down (tunnel uptime matters more than the monitoring ACL).
[Service]
ExecStartPost=/bin/sh -c "setfacl -m u:telegraf:rwx /run/charon.vici || true"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment