Closed mattelacchiato closed 4 years ago
Thanks a lot for this hint!
I had a problem with non-integer values. You can use sed -E 's/ ([A-Za-z]+)/ "\1"/'
to surround value with double quotes. For instance:
/bin/bash /tmp/fritzBoxShell.sh IGDIP STATE | egrep "NewConnectionStatus|NewUptime" | sed -E 's/ ([A-Za-z]+)/ "\1"/' | tr '\n' ',' | tr ' ' '=' | sed "s/,$//" | echo "fritz $(cat -)"
Hey.
Thanks a lot. Your comments drove me to create some Wiki pages. Still at the beginning but maybe can help others too. I copied your examples also there: https://github.com/jhubig/FritzBoxShell/wiki/Example-use-cases:-Telegraf. Hope that's okay. If not, just tell me.
Of course! Thank you for your work!
This mentioned regular expression sed -E 's/ ([A-Za-z]+)/ "\1"/'
is not catching all cases it should...e.g. resulting in
...
NewLastConnectionError "ERROR"_NONE
...
an improved one looks like this: awk '{ if ($2 ~ "^[0-9]+$") print $1 " " $2; else print $1 " \"" $2 "\""; }'
quoting all values which is not a decimal number.
-> https://github.com/jhubig/FritzBoxShell/wiki/Example-use-cases:-Telegraf should be adjusted also.
Instead of pushing single values to telegraf, you can push all desired values:
This creates a valid influx string (documented here)
In my setup, I also added a grep in the first place to filter only relevant lines.
I've put this into a shell file to circumvent the escape backslashes. My
[[inputs.exec]]
looks like this:And the to_influx.sh looks like this:
Feel free to adopt your documentation, if you want. Maybe it helps others to integrate your script in influxdb without calling the script multiple times for multiple values.
P.S.: Nice work! Thank you so much :kissing: