Add strongswan IPsec extend script#622
Open
lirone wants to merge 1 commit into
Open
Conversation
Companion agent script for the LibreNMS 'strongswan' application. Emits the JSON SNMP extend payload (per-connection IPsec state, in/out traffic, child SAs, re-establishments + global rekey/error counters) by parsing 'swanctl --list-sas' and 'swanctl --counters'. Per-SA counters reset on rekey, so it keeps a small state file and emits monotonic cumulative counters for clean DERIVE rates. Works on OPNsense (legacy con<N> and new UUID 'Connections' model) and plain Linux strongSwan. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
strongswanIPsec extend scriptCompanion agent script for the new strongSwan / IPsec application proposed in
librenms/librenms#19858.
It outputs the LibreNMS JSON SNMP extend
payload describing every IPsec connection on a strongSwan host:
re-establishment count
invalid/invalid SPIerrors)It works by parsing
swanctl --list-sasandswanctl --counters. The raw per-SA byte/packetcounters reset on every rekey, so the script keeps a small state file
(
/var/lib/librenms-strongswan-state.json) and emits monotonic cumulative counters, givingLibreNMS clean DERIVE rates instead of spikes at each rekey.
Connection labels come from the OPNsense
config.xmlwhen present (covers both the legacy"Tunnel Settings"
con<N>model and the new "Connections" UUID model); on plain Linux strongSwanthe raw connection name is used.
Install
Tested on OPNsense 21.1 / 22.7 / 23.7 and Linux strongSwan, polled by LibreNMS 26.5.
swanctlis auto-detected viaPATHand the usual locations. Python 3, stdlib only.