Skip to content

Instantly share code, notes, and snippets.

@ArrEssJay
Last active August 7, 2022 13:47
Show Gist options
  • Save ArrEssJay/36165c134000ff7639429ec84bc6cc9d to your computer and use it in GitHub Desktop.
Save ArrEssJay/36165c134000ff7639429ec84bc6cc9d to your computer and use it in GitHub Desktop.
Parse gpsd JSON messges with telegraf
#!/bin/bash
gpspipe -w | jq -c -M '. | select( (.class == "SKY" and has("satellites") == true) or .class == "TPV")' | while IFS= read obj
do
echo $obj
done
[[inputs.execd]]
command = ["gpsd.sh"]
data_format = "json_v2"
name_suffix = "_gpsd"
signal = "none"
[[inputs.execd.json_v2]]
measurement_name_path = "class"
timestamp_path = "time"
timestamp_format = "rfc3339"
#per sky message data
[[inputs.execd.json_v2.object]]
path = "@this"
included_keys = ["gdop","hdop","pdop","tdop","xdop","ydop","vdop","nSat","uSat"]
#per-sv data
[[inputs.execd.json_v2.object]]
path = "satellites"
tags = ["PRN","svid","gnssid","sigid"]
optional = true
#tpv
[[inputs.execd.json_v2.object]]
path = "@this"
included_keys = ["status","mode","leapseconds","ept","lat","lon","altHAE","altMSL","alt","epx","epy","epv","track","magtrack","magvar","speed","climb","eps","epc","ecefx","ecefy","ecefz","ecefvx","ecefvy","ecefvz","ecefpAcc","ecefvAcc","velN","velE","velD","geoidSep","eph","sep"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment