fix: make comma optional when parsing ipsec trafficstatus (#10190)
\{0,1\} is used instead of ? because standard sed doesn't support "?" https://stackoverflow.com/questions/6156259/sed-expression-doesnt-allow-optional-grouped-string
Ashley Wulber committed
Nov 4, 2020 at 08:26 UTC
3f70299e3521ac4708bd6f47abbf46f70e8692e8
1 file changed
+1
-1
collectors/charts.d.plugin/libreswan/libreswan.chart.sh
+1
-1
@@ -78,7 +78,7 @@ libreswan_get() {
78
libreswan_ipsec whack --trafficstatus
79
} | sed -n \
80
-e "s|[0-9]\+ #\([0-9]\+\): \"\(.*\)\".*IPsec SA established.*newest IPSEC.*|libreswan_connected_tunnels[\"\1\"]=\"\2\"|p" \
81
- -e "s|[0-9]\+ #\([0-9]\+\): \"\(.*\)\",.* add_time=\([0-9]\+\),.* inBytes=\([0-9]\+\),.* outBytes=\([0-9]\+\).*|libreswan_traffic_in[\"\1\"]=\"\4\"; libreswan_traffic_out[\"\1\"]=\"\5\"; libreswan_established_add_time[\"\1\"]=\"\3\";|p"
81
+ -e "s|[0-9]\+ #\([0-9]\+\): \"\(.*\)\",\{0,1\}.* add_time=\([0-9]\+\),.* inBytes=\([0-9]\+\),.* outBytes=\([0-9]\+\).*|libreswan_traffic_in[\"\1\"]=\"\4\"; libreswan_traffic_out[\"\1\"]=\"\5\"; libreswan_established_add_time[\"\1\"]=\"\3\";|p"
82
) || return 1
83
84
# check we got some data