collection.dockerfile/alpine/cloudflare-cli/monitoring.sh
2022-01-17 15:56:05 +08:00

10 lines
802 B
Bash

cfcli zones -f json | jq -cr '.[] | .name,.id' | paste - - | awk '{print $1,$2}' | while read d k; do
cfcli ls -d $d -f json | jq -cr '.[] | select(.type == "A") | .name' | while read s; do
echo curl -X POST \"https://api.cloudflare.com/client/v4/zones/$k/healthchecks\" \
-H \"X-Auth-Email: ken.fong@rackspace.com\" \
-H \"X-Auth-Key: xxx\" \
-H \"Content-Type: application/json\" \
--data \'\{\"name\":\"site-monitor\",\"description\":\"Health check\",\"check_regions\":[\"SEAS\"],\"type\":\"HTTPS\",\"consecutive_successes\":1,\"consecutive_fails\":2,\"http_config\":\{\"method\":\"GET\",\"port\":443,\"path\":\"/\",\"expected_codes\":[\"200\"],\"follow_redirects\":true,\"allow_insecure\":false,\"timeout\":5,\"retries\":2,\"interval\":60,\"address\":\"$s\"\}\'
done
done