Skip to content

Commit ffe3f2c

Browse files
rlahnemannweyrick
authored andcommitted
run-pktvisor.sh IFS fix for args with spaces (#111)
* run-pktvisor.sh IFS fix for args with spaces * Add check for presence of semi colon for conditional IFS * Update README.md for pktvisor-prom-write with semi colon example
1 parent 27f548b commit ffe3f2c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

centralized_collection/prometheus/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ PKTVISORD_ARGS="--prom-instance <INSTANCE> --geo-city /geo/GeoIP2-City.mmdb --ge
3131
--env REMOTE_URL="https://<REMOTEHOST>/api/prom/push" --env USERNAME="<USERNAME>" --env PASSWORD="<PASSWORD>" ns1labs/pktvisor-prom-write
3232
```
3333

34+
**PKTVISORD_ARGS optionally allows a semicolon delimited list of arguments to handle arguments such as bpf filters that may contain whitespace*
35+
36+
Example with Geo enabled and bpf filter (assuming files are located in `/usr/local/geo`):
37+
38+
```shell
39+
docker pull ns1labs/pktvisor-prom-write
40+
docker run -d --mount type=bind,source=/usr/local/geo,target=/geo --net=host --env \
41+
PKTVISORD_ARGS="-b; port 53; --prom-instance; <INSTANCE>; --geo-city; /geo/GeoIP2-City.mmdb; --geo-asn; /geo/GeoIP2-ISP.mmdb; <INTERFACE>" \
42+
--env REMOTE_URL="https://<REMOTEHOST>/api/prom/push" --env USERNAME="<USERNAME>" --env PASSWORD="<PASSWORD>" ns1labs/pktvisor-prom-write
43+
```
44+
3445
There are a several pieces of information you need to substitute above:
3546

3647
* `<INSTANCE>`: The prometheus "instance" label for all metrics, e.g. "myhost"

centralized_collection/prometheus/docker-grafana-agent/files/run-pktvisord.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22

33
[[ "$PKTVISORD_ARGS" == "" ]] && PKTVISORD_ARGS="eth0"
44

5+
if [[ "$PKTVISORD_ARGS" == *';'* ]]; then
6+
# allow for space after semi ('; ') for better readability and strip leading spaces in args
7+
PKTVISORD_ARGS="${PKTVISORD_ARGS//; /;}"
8+
IFS=$';'
9+
fi
10+
511
exec pktvisord --prometheus $PKTVISORD_ARGS

0 commit comments

Comments
 (0)