From be164144e4c69c12cd2b2b4e835ec3cd21010839 Mon Sep 17 00:00:00 2001 From: Graham Whaley Date: Wed, 28 Aug 2019 15:26:25 +0100 Subject: [PATCH] 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 --- metrics/lib/json.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metrics/lib/json.bash b/metrics/lib/json.bash index 1641836..b45451a 100644 --- a/metrics/lib/json.bash +++ b/metrics/lib/json.bash @@ -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