metrics: json: use tr for newline/whitespace conversion

Use `tr` rather than `sed` for doing the line/whitespace conversions
on the JSON stream, if asked. Slightly more efficient, and we also drop
the wrapping ""'s, to allow the data to land in logstash without error.

Signed-off-by: Graham Whaley <graham.whaley@intel.com>
This commit is contained in:
Graham Whaley
2019-08-29 12:33:41 -06:00
committed by David Lyle
parent 18fde35232
commit be164144e4
+1 -1
View File
@@ -111,7 +111,7 @@ EOF
# If we have a JSON URL or host/socket pair set up, post the results there as well.
# Optionally compress into a single line.
if [[ $JSON_TX_ONELINE ]]; then
json="$(sed 's/[\n\t]//g' <<< ${json})"
json=$(tr -d '\t\n\r\f' <<< ${json})
fi
if [[ $JSON_HOST ]]; then