-
-
Save sylr/87de3c9f3bb23e037a1aa5c9640bdda0 to your computer and use it in GitHub Desktop.
A script to check internet connectivity with the node_exporter textfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
URLS[0]="https://www.google.com" | |
URLS[1]="http://169.254.169.254/metadata/instance?api-version=2020-06-01" # azure internal endpoint | |
HEADERS[O]="" | |
HEADERS[1]="-H 'Metadata: true'" | |
OUTPUT=${OUTPUT:-/tmp/curl.prom} | |
SLEEP=${SLEEP:-10} | |
while [ true ]; do | |
{ | |
for i in $(seq 0 $((${#URLS[@]} - 1))); do | |
if curl -s -f --connect-timeout 4 -o /dev/null ${HEADERS[$i]} ${URLS[$i]}; then | |
echo "node_http_url_reached{url=\"${URLS[$i]}\"} 1" | |
else | |
echo "node_http_url_reached{url=\"${URLS[$i]}\"} 0" | |
fi | |
done | |
} > ${OUTPUT} | |
sleep ${SLEEP} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment