#!/bin/sh TITLE="Recycled Cloud Status" LOCATIONS="swdn.ch" EXTERNAL_PROMETHEUS_ADDR=http://localhost:9090 query () { endpoint="$1/api/v1/query" query=$2 curl "$endpoint" --data-urlencode "query=$query" | jq --raw-output .data.result[].value[1] } get_state () { case "$1" in 0) echo "down" ;; 1) echo "up" ;; *) echo "unknown" ;; esac } get_canary_state () { location=$1 inet=$2 instance="canary.$location.recycled.cloud" job="blackbox-external-v$inet" result=$(query $EXTERNAL_PROMETHEUS_ADDR \ "probe_success{instance=\"$instance\", job=\"$job\"}") get_state "$result" } get_edge_state () { location=$1 edge=$2 instance="edge$edge.$location.recycled.cloud" job="blackbox-external-icmpv6" result=$(query $EXTERNAL_PROMETHEUS_ADDR \ "probe_success{instance=\"$instance\", job=\"$job\"}") get_state "$result" } cat << EOF
This page reports the status of the Recycled Cloud infrastructure, regenerated every minute.
States: up down unknown
Last refresh on $(date).