#!/bin/bash # check_iss.sh API="http://api.open-notify.org/iss-now.json" # Query the public ISS live API DATA=$(curl --connect-timeout 5 --max-time 15 -s "$API") if [ "$?" -gt 0 ]; then echo "UNKNOWN - $API returned no data or serious error: $DATA" exit 3 fi if [ $(echo "$DATA" | jq -r '.message') != "success" ]; then echo "UNKNOWN - $API timed out" exit 3 fi # Extract coordinates echo $DATA | jq -r '.iss_position | .latitude + " " + .longitude' | \ (read LAT LON; \ echo "OK - ISS Location: Lat $LAT, Lon $LON | ISS_lat=$LAT;;;; ISS_lon=$LON;;;;") exit 0