From ad34bf7f1d37a7c72bfab7b3e95c4ac01d69502f Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 5 Jul 2019 02:16:45 -0700 Subject: [PATCH] add comments --- core/unifi/examples/convert.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/unifi/examples/convert.sh b/core/unifi/examples/convert.sh index 91de843d..de5b2975 100755 --- a/core/unifi/examples/convert.sh +++ b/core/unifi/examples/convert.sh @@ -5,15 +5,21 @@ # It converts the go struct to an influx thing, like you see in uap_influx.go. # [prefix] is optional. I used it to do all the stat_ uap metrics. # Very crude, just helps skip a lot of copy/paste. +# path=$1 pre=$2 + +# Reads in the file one line at a time. while IFS='' read -r line; do + # Split each piece of the file out. name=$(echo "${line}" | awk '{print $1}') type=$(echo "${line}" | awk '{print $2}') json=$(echo "${line}" | awk '{print $3}') json=$(echo "${json}" | cut -d\" -f2) - if [ "$json" != "" ] && [ "$name" != "" ]; then + # Don't print junk lines. (it still prints some junk lines) + if [ "$json" != "" ]; then + # Add a .Val suffix if this is a FlexInt or FlexBool. [[ "$type" = Flex* ]] && suf=.Val echo "\"${pre}${json}\": u.Stat.${name}${suf}," fi