Monitoring bash Beginner

Uptime Monitor Script

Check HTTP endpoints and alert if they return non-200 or exceed response threshold.

bash
#!/bin/bash
URLs=(https://example.com https://api.example.com/health)
for url in "${URLs[@]}"; do
  code=$(curl -s -o /dev/null -w "%{http_code}" $url)
  if [ $code != 200 ]; then
    echo ALERT: $url returned $code
  fi
  echo $url $code
done

Prerequisites

  • curl

Pro Tips

  • → Run every 5 minutes via cron for basic uptime monitoring.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
bash
Level
Beginner
Read time
2 min
Published
Apr 2025
License
Commercial License

Newsletter

New modules every week, directly to your inbox.