Skip to content

Commit

Permalink
run-pktvisor.sh IFS fix for args with spaces (#111)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rlahnemann authored Jul 15, 2021
1 parent 46bc07d commit 4ec5025
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions centralized_collection/prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ PKTVISORD_ARGS="--prom-instance <INSTANCE> --geo-city /geo/GeoIP2-City.mmdb --ge
--env REMOTE_URL="https://<REMOTEHOST>/api/prom/push" --env USERNAME="<USERNAME>" --env PASSWORD="<PASSWORD>" ns1labs/pktvisor-prom-write
```

**PKTVISORD_ARGS optionally allows a semicolon delimited list of arguments to handle arguments such as bpf filters that may contain whitespace*

Example with Geo enabled and bpf filter (assuming files are located in `/usr/local/geo`):

```shell
docker pull ns1labs/pktvisor-prom-write
docker run -d --mount type=bind,source=/usr/local/geo,target=/geo --net=host --env \
PKTVISORD_ARGS="-b; port 53; --prom-instance; <INSTANCE>; --geo-city; /geo/GeoIP2-City.mmdb; --geo-asn; /geo/GeoIP2-ISP.mmdb; <INTERFACE>" \
--env REMOTE_URL="https://<REMOTEHOST>/api/prom/push" --env USERNAME="<USERNAME>" --env PASSWORD="<PASSWORD>" ns1labs/pktvisor-prom-write
```

There are a several pieces of information you need to substitute above:

* `<INSTANCE>`: The prometheus "instance" label for all metrics, e.g. "myhost"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

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

if [[ "$PKTVISORD_ARGS" == *';'* ]]; then
# allow for space after semi ('; ') for better readability and strip leading spaces in args
PKTVISORD_ARGS="${PKTVISORD_ARGS//; /;}"
IFS=$';'
fi

exec pktvisord --prometheus $PKTVISORD_ARGS

0 comments on commit 4ec5025

Please sign in to comment.