Skip to content

Instantly share code, notes, and snippets.

@mdjnewman
Last active July 12, 2023 22:10
Show Gist options
  • Save mdjnewman/e471f6349ea5d09fb1838355395ad161 to your computer and use it in GitHub Desktop.
Save mdjnewman/e471f6349ea5d09fb1838355395ad161 to your computer and use it in GitHub Desktop.
Dump some info from uptime.is to CSV
#!/usr/bin/env bash
# 11 hours = 9 AM ET to 5 PM PT
curl 'https://get.uptime.is/api?sla=99&dur=11&dur=11&dur=11&dur=11&dur=11&dur=0&dur=0' > out.json
curl 'https://get.uptime.is/api?sla=99.5&dur=11&dur=11&dur=11&dur=11&dur=11&dur=0&dur=0' >> out.json
curl 'https://get.uptime.is/api?sla=99.9&dur=11&dur=11&dur=11&dur=11&dur=11&dur=0&dur=0' >> out.json
curl 'https://get.uptime.is/api?sla=99.95&dur=11&dur=11&dur=11&dur=11&dur=11&dur=0&dur=0' >> out.json
curl 'https://get.uptime.is/api?sla=99.99&dur=11&dur=11&dur=11&dur=11&dur=11&dur=0&dur=0' >> out.json
curl 'https://get.uptime.is/api?sla=99.995&dur=11&dur=11&dur=11&dur=11&dur=11&dur=0&dur=0' >> out.json
curl 'https://get.uptime.is/api?sla=99.999&dur=11&dur=11&dur=11&dur=11&dur=11&dur=0&dur=0' >> out.json
curl 'https://get.uptime.is/api?sla=99&dur=24' >> out.json
curl 'https://get.uptime.is/api?sla=99.5&dur=24' >> out.json
curl 'https://get.uptime.is/api?sla=99.9&dur=24' >> out.json
curl 'https://get.uptime.is/api?sla=99.95&dur=24' >> out.json
curl 'https://get.uptime.is/api?sla=99.99&dur=24' >> out.json
curl 'https://get.uptime.is/api?sla=99.995&dur=24' >> out.json
curl 'https://get.uptime.is/api?sla=99.999&dur=24' >> out.json
cat out.json | jq -s | jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' > out.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment