Skip to content

Instantly share code, notes, and snippets.

@nna774
Created September 23, 2020 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nna774/e4bb2879f42eeae38a72cbadc7bcfbe9 to your computer and use it in GitHub Desktop.
Save nna774/e4bb2879f42eeae38a72cbadc7bcfbe9 to your computer and use it in GitHub Desktop.
HOST_ID='xxx'
API_KEY='xxx'
OUTS=`sudo get-co2`
CO2=`echo ${OUTS} | jq ".co2"`
TEMP=`echo ${OUTS} | jq ".temperature"`
TT=`echo ${OUTS} | jq ".TT"`
TIME=`date +%s`
JSON=$(cat << EOS
[
{
"hostId":"${HOST_ID}",
"name":"custom.co2.ppm",
"time":${TIME},
"value":${CO2}
},
{
"hostId":"${HOST_ID}",
"name":"custom.co2.temp",
"time":${TIME},
"value":${TEMP}
},
{
"hostId":"${HOST_ID}",
"name":"custom.co2.tt",
"time":${TIME},
"value":${TT}
}
]
EOS
)
curl -s https://mackerel.io/api/v0/tsdb \
-H "X-Api-Key: ${API_KEY}" \
-H "Content-Type: application/json" \
-X POST \
-d "${JSON}"
#! /bin/bash
python -m mh_z19 --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment