How I Built an Automated Website Uptime Monitoring System with Bash and GitHub Actions
As part of my ongoing DevOps learning journey, I decided to build a simple automated website uptime monitoring project using Bash scripting, cURL, and GitHub Actions.
The idea was straightforward: instead of manually opening my websites to confirm whether they were accessible, I wanted to create a script that could check their availability automatically and report the results through GitHub Actions.
However, building this project involved more than writing a Bash script. I encountered scripting errors, unexpected HTTP 429 responses, and situations where I needed to distinguish between an actual website failure and intentional downtime.
In this article, I will share how I approached the project, the challenges I encountered, the improvements I made, and the successful result.
1. Project Overview
I built this project to monitor three websites associated with my personal projects and learning activities.
- sirvickcloud9.online: My portfolio website.
- blog.sirvickcloud9.online: My DevOps learning blog.
- clinic.sirvickcloud9.online: A clinic website from an earlier project.
There was one important consideration: I had terminated the EC2 instance hosting the clinic website to avoid continuing AWS costs. Therefore, I expected that website to be unavailable during monitoring.
I divided the websites into two categories:
- Required websites: Websites expected to remain accessible.
- Expected downtime: Websites intentionally taken offline.
This distinction was important because I did not want the monitoring workflow to report a failure simply because I had deliberately taken a server offline.
2. Technologies Used
- Bash: Writing the monitoring script and handling the monitoring logic.
- cURL: Sending HTTP requests and retrieving response codes.
- GitHub Actions: Automating the monitoring process.
- Ubuntu: The environment used by the GitHub-hosted runner.
- GitHub: Storing and managing the project source code.
3. How the Monitoring Process Works
The monitoring process follows a simple sequence:
- GitHub Actions starts the workflow.
- An Ubuntu runner prepares the environment.
- The workflow checks that cURL is available.
- The Bash monitoring script is executed.
- The script sends HTTP requests to the configured websites.
- It collects and classifies the HTTP response codes.
- The results are displayed in the GitHub Actions logs.
- The script returns an exit code to determine whether the workflow succeeds or fails.
This project also builds on some of my earlier practical work with website availability and cloud infrastructure. In a previous project, I explored how multiple EC2 instances, an Application Load Balancer, Auto Scaling, and Amazon EFS can work together to support a highly available website. You can read about that experience in my article: How I Built a Highly Available Website on AWS Using EC2, NGINX, ALB, Auto Scaling and EFS.
4. Building the Bash Monitoring Script
I placed the main monitoring script inside the scripts directory and named it monitor.sh.
One important decision was to separate the websites into two Bash arrays:
REQUIRED_WEBSITESEXPECTED_DOWN_WEBSITES
This allowed the script to apply different rules depending on the website being checked.
I also configured cURL to follow redirects, use connection and overall request timeouts, and return the HTTP response code for classification.
The monitoring logic handles responses as follows:
- HTTP 2xx and 3xx: Classified as available.
- HTTP 000: Indicates a connection failure or timeout.
- HTTP 429: Indicates that the request was rate limited.
- Other HTTP responses: Classified as HTTP errors.
This classification helped the script make more meaningful decisions instead of treating every unsuccessful request in exactly the same way.
5. Automating the Checks with GitHub Actions
After developing the Bash script, I integrated it into a GitHub Actions workflow.
The workflow is stored in:
.github/workflows/uptime-monitor.yml
It uses an Ubuntu-hosted runner, checks out the repository, verifies that cURL is available, and executes the monitoring script with:
bash scripts/monitor.sh
I configured the workflow to run automatically every five minutes and also included manual execution through workflow_dispatch.
This gave me two ways to test the monitoring process: allow the scheduled workflow to run or trigger it manually from the GitHub Actions interface.
6. Troubleshooting: Bash Script Formatting Errors
During development, I encountered errors caused by accidentally copying Markdown code-fence characters into the Bash script.
This resulted in command-not-found and syntax errors when the workflow attempted to execute the file.
After investigating the logs, I corrected the script by separating the actual Bash commands from the Markdown formatting used to display code in documentation.
This was a useful lesson: code formatting in documentation is not part of the executable script. When copying commands into a file, it is important to include only the actual code.
7. Troubleshooting: HTTP 429 Rate Limiting
One of the more interesting challenges appeared after the basic monitoring process started working.
During a GitHub Actions run, my blog initially returned HTTP 429. What made this interesting was that the blog opened normally when I accessed it through my regular browser.
I could not establish the exact reason for the difference, but I knew the monitoring script needed to handle the response more intelligently.
Rather than immediately treating the first HTTP 429 response as a confirmed website failure, I improved the script with a retry mechanism.
The updated logic included:
- A maximum of three attempts.
- A 10-second wait before retrying an HTTP 429 response.
- A custom User-Agent identifying the monitoring request.
- Separate reporting when rate limiting continues after all attempts.
This meant that a temporary rate-limiting response would not automatically cause the monitoring job to fail if a subsequent attempt succeeded.
It also meant that persistent rate limiting would not be incorrectly reported as a confirmed successful availability check.
8. Handling Intentional Website Downtime
Another important part of the project was handling the clinic website.
Its EC2 instance had been terminated to avoid ongoing AWS costs. Therefore, the website was expected to be unavailable during monitoring.
I configured the script to recognize this expected downtime separately.
When the script received an HTTP 000 response for that website, it reported:
STATUS: EXPECTED DOWN (Intentional downtime)
This did not cause the workflow to fail.
However, if the clinic website became reachable again, the script would report that it was unexpectedly UP. This made the classification useful in both situations.
9. Understanding Exit Codes in GitHub Actions
I also learned more about how Bash exit codes communicate results to GitHub Actions.
The script uses the following exit codes:
- 0: All required websites passed their availability checks.
- 1: A required website returned an unexpected failure or an inconclusive result.
- 2: Not all configured websites were checked.
- 127: cURL is unavailable.
This helped me understand why some earlier workflow runs failed even though the script had displayed monitoring results. GitHub Actions uses the process exit code to determine whether a job succeeds or fails.
10. Testing the Script Locally
Before relying on the automated workflow, I also executed the Bash script locally in my Ubuntu environment through WSL.
During this earlier test, the portfolio and blog returned HTTP 200, while the clinic website returned HTTP 000 because its EC2 instance had already been terminated.
At that stage, the initial version of the script treated the clinic website as a failure. This helped me identify why separating required websites from intentionally unavailable websites was necessary.
Figure 1: Initial local execution of the Bash website monitoring script, showing successful responses from two websites and an unexpected failure classification for the intentionally offline clinic website.
The local test was an important part of the troubleshooting process because it showed me how the script behaved before the later improvements were introduced.
11. Successful GitHub Actions Monitoring Test – November 6, 2026
After making the improvements, I triggered another GitHub Actions workflow run to test the updated monitoring logic.
The results were successful.
| Website | Response | Final Result |
|---|---|---|
| sirvickcloud9.online | HTTP 200 | UP |
| blog.sirvickcloud9.online | HTTP 429, then HTTP 200 | UP after retry |
| clinic.sirvickcloud9.online | HTTP 000 | EXPECTED DOWN |
The most important part of this test was the blog website.
It initially returned HTTP 429. The script waited for 10 seconds, retried the request, and received HTTP 200 on the second attempt.
The clinic website was correctly classified as intentionally offline, while the portfolio and blog passed their availability checks.
The final monitoring output was:
RESULT: All required websites passed availability checks.
Figure 2: Successful GitHub Actions monitoring run showing HTTP 429 retry recovery, website availability checks, and correct handling of intentional downtime.
The GitHub Actions job completed successfully in 21 seconds.
View the successful workflow run:
Website Uptime Monitoring – Successful Run #17
12. What I Learned from This Project
This project helped me improve my understanding of several practical DevOps concepts:
- Writing and troubleshooting Bash scripts.
- Using cURL to check website availability.
- Understanding HTTP response codes.
- Handling temporary rate-limiting responses with retry logic.
- Automating recurring tasks with GitHub Actions.
- Using exit codes to communicate script results to automation workflows.
- Distinguishing between unexpected downtime and intentional downtime.
- Reading workflow logs and using them to troubleshoot problems.
One important lesson was that monitoring is not simply about checking whether a website responds. It is also about interpreting the response correctly and deciding what action the monitoring system should take.
13. Current Limitations and Future Improvements
The project currently performs automated HTTP availability checks and reports the results through GitHub Actions.
It does not yet include:
- A historical uptime dashboard.
- Email or SMS notifications.
- Response-time trend analysis.
- SSL certificate expiry alerts.
- Persistent storage of monitoring results.
These are possible improvements I may explore as I continue developing the project.
Conclusion
Building this automated website monitoring project was a practical learning experience. I started with a simple Bash script and gradually improved it by troubleshooting real issues encountered during GitHub Actions executions.
The HTTP 429 challenge was particularly useful because it showed me why a monitoring script should not always treat the first unsuccessful response as a final result. Adding retry handling made the checks more reliable in the tested scenario.
I also learned the importance of classifying expected downtime correctly and using exit codes to communicate meaningful results to GitHub Actions.
This is still a simple learning project, and there is more I would like to add. However, getting the monitoring workflow to complete successfully after troubleshooting these issues was a satisfying milestone in my DevOps journey.
Project Source Code
The complete project, including the Bash monitoring script, GitHub Actions workflow, and documentation, is available on GitHub:
Automated Website Uptime Monitoring – GitHub Repository
Thank you for following my learning journey. I will continue sharing the practical projects, challenges, and lessons I encounter as I develop my cloud and DevOps skills.


Comments
Post a Comment