Skip to content

Instantly share code, notes, and snippets.

@rskuipers
Created February 8, 2022 15:17
Show Gist options
  • Save rskuipers/9357c16e5517bc60833ec729d89e4777 to your computer and use it in GitHub Desktop.
Save rskuipers/9357c16e5517bc60833ec729d89e4777 to your computer and use it in GitHub Desktop.
#!/bin/bash
UPTIMEROBOT_TOKEN="uptimerobot-token-here"
OHDEAR_TOKEN="ohdear-token-here"
OHDEAR_TEAM_ID=123456789
OFFSET=0
LIMIT=50
TOTAL=1000000
while [[ "$OFFSET" -lt "$TOTAL" ]]; do
RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" https://api.uptimerobot.com/v2/getMonitors?api_key=${UPTIMEROBOT_TOKEN} -d 'limit='${LIMIT}'&offset='${OFFSET})
OFFSET=$(($OFFSET + $(echo "${RESPONSE}" | jq -r '.pagination.limit')))
TOTAL=$(echo "${RESPONSE}" | jq -r '.pagination.total')
for row in $(echo "${RESPONSE}" | jq -r '.monitors[] | @base64'); do
_jq() {
echo "${row}" | base64 --decode | jq -r "${1}"
}
URL=$(_jq '.url')
echo -n "Migrating ${URL} ... "
curl -s -X POST https://ohdear.app/api/sites \
-H "Authorization: Bearer ${OHDEAR_TOKEN}" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"url":"'"${URL}"'", "team_id":"'"${OHDEAR_TEAM_ID}"'", "checks": ["uptime", "performance", "broken_links", "mixed_content", "certificate_health", "dns"]}' > /dev/null
echo "done"
done
done
echo "Migrated ${TOTAL} sites"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment