Commit 9fc0e78
committed
feat(strongswan-connections): add --match and --ignore filter parameters
Adds --match (include filter) and --ignore (exclude filter), both
Python regex, case-sensitive by default (use (?i) for
case-insensitive matching), both repeatable. Include-first,
exclude-second semantics match the disk-usage plugin and the
lib.args canonical --match / --ignore convention.
Typical use cases on a strongSwan VPN gateway:
- --ignore='^RA_' to hide transient remote-access clients and
keep a single Icinga service for all permanent site-to-site
peers
- --match='^S2S_SITE-XY$' to pin a dedicated Icinga service to
one specific site-to-site peer (per-site granularity, named
alerts)
The filter applies to both the "configured" and the "active"
connection lists before the "configured but not active"
comparison, so an ignored connection that happens to be down
does not trigger the warning.
Along the way the test mode was fixed: format_sas_data() and
format_child_data() now accept both VICI bytes and JSON strings,
which uncovered that the existing unit tests were passing only
because the pre-existing fixture-load path triggered a swallowed
exception and left state at STATE_OK, asserting only the trivial
"Everything is ok." fallback. With the fix, fixtures actually
drive the plugin through format_sas_data / format_child_data and
the assertions can check real rendered output.
Other polish in the same commit: dedupe
get_possible_connection_keys / get_active_connection_keys via a
_collect_keys helper, fix a socket leak (try/finally + close),
narrow a bare except Exception on socket.connect to OSError with
a descriptive error message, replace an O(n*m) sas[key] probe
loop with items() + set lookup, move import json to module
scope, drop an unused import lib.shell, delete a vestigial
1173-char OrderedDict-repr comment, delete the vestigial "do not
call the command" comment on the --test else branch.
Closes #7381 parent 12d0e16 commit 9fc0e78
File tree
8 files changed
+464
-47
lines changed- check-plugins/strongswan-connections
- icingaweb2-module-director
- unit-test
- stdout
8 files changed
+464
-47
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
49 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
50 | 72 | | |
51 | 73 | | |
52 | 74 | | |
| |||
Lines changed: 44 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
11 | 19 | | |
12 | 20 | | |
13 | 21 | | |
| |||
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
32 | 50 | | |
33 | 51 | | |
34 | 52 | | |
| |||
72 | 90 | | |
73 | 91 | | |
74 | 92 | | |
75 | | - | |
| 93 | + | |
76 | 94 | | |
77 | 95 | | |
78 | 96 | | |
| |||
84 | 102 | | |
85 | 103 | | |
86 | 104 | | |
| 105 | + | |
87 | 106 | | |
| 107 | + | |
88 | 108 | | |
89 | 109 | | |
90 | 110 | | |
| |||
103 | 123 | | |
104 | 124 | | |
105 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
106 | 137 | | |
107 | 138 | | |
108 | 139 | | |
| |||
111 | 142 | | |
112 | 143 | | |
113 | 144 | | |
114 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
115 | 157 | | |
116 | 158 | | |
117 | 159 | | |
| |||
0 commit comments