Files
2026-09-06 12:08:05 -04:00

23 lines
578 B
Bash
Executable File

#!/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