Continuous Monitoring of Multiple Web Projects for QA

Max Kombarov
5 min readFeb 18, 2024

In today’s digital-first environment, businesses and developers often manage an array of web projects, including production sites, staging environments, and demos. The complexity and dynamism of handling multiple web resources demand an efficient, automated approach to monitoring. Continuous monitoring ensures operational stability, optimal performance, and a superior user experience across all digital assets. This article delves into the importance of such practices and presents a practical approach using a simple, yet powerful, shell script integrated into a CI/CD pipeline, specifically Jenkins.

The Imperative for Continuous Monitoring

As organizations scale, the task of manually monitoring each web project becomes impractical. Continuous monitoring automates the oversight of these resources, enabling immediate detection and response to downtime, performance issues, or unexpected behavior. This proactive approach is critical for:

Ensuring High Availability: Downtime can significantly impact customer satisfaction, brand reputation, and revenue. Continuous monitoring helps in maintaining the high availability of services.
Rapid Issue Resolution: Quick identification of issues allows for faster troubleshooting and resolution, minimizing the impact on end-users.
Performance Optimization: Regular monitoring helps in spotting and addressing performance bottlenecks before they affect user experience.

A Practical Approach to Monitoring with Shell Scripting

For organizations looking to implement continuous monitoring without substantial investment in specialized tools, shell scripting offers a powerful, flexible solution. Consider the following script, designed for monitoring multiple web projects:

# Define an array of web project URLs to monitor
urls=(
"https://production.example.com"
"https://staging.example.com"
"https://demo.example.com"
)
# Loop through each URL to check its status
for url in "${urls[@]}"; do
response=$(curl -s -o /dev/null -w "%{http_code}" "$url")
if [ "$response" -eq 200 ]; then
echo "$url is up and running (HTTP $response)"
else
echo "Alert: $url is experiencing issues (HTTP $response)"
# Potential integration with notification systems here
fi
done

This script is a cornerstone for continuous monitoring, checking the availability of each web project and providing immediate feedback on their status. It can be easily integrated into Jenkins, a popular CI/CD tool, to automate and schedule checks.

Integration with Jenkins for Automated Monitoring

Jenkins, with its versatile plugin ecosystem and robust automation capabilities, can be used to schedule and execute the monitoring script at regular intervals or in response to specific triggers. Here’s how to set it up:

Create a New Jenkins Job: Write down the job name and choose “Freestyle project”. which will be dedicated to running the monitoring script. Later this job can be configured to execute periodically, ensuring continuous oversight of all listed web resources.

Creating a job

Configure Script Execution: The shell script can be added directly to the job’s build steps or managed as part of a source code repository that Jenkins checks out before execution.

Setup connection to repository in Source code management Configure section:

Source Code Manager for job

Setup build triggers by filling the schedule in cron sytax. The value H/30**** has been chosen, which means the job will be triggered every half an hour. At this step it is possible to setup other triggers for job execution as well.

Build Triggers for job

In the Build Envieronment of the Configure section you can mark to delete workspace before every build and fill in job run commands in the Build Steps. For exemple, we will make the script executable and simply running it:

echo "Running monitor.sh"
chmod +x monitor.sh
/monitor.sh
Build Environment for Jenkins job

Alerts and Notifications: Jenkins can be also configured to send notifications (via email, Slack, etc.) if the script detects any issues, enabling rapid response to potential problems in Post-build Actions.

Running the Job: After the saving the configuration of the job you can run it right away from the Dashboard or check if it will be executed within the scheduled period. If job passed web resources are up and running with the 200 status code. If something will be wrong, for example 401 or 403 job will fail and you'll get error. You can check Console Output in the Last Build or setup the alerts as was mentioned above.

Jenkins job builds status

Enhancing Monitoring Strategy

While the outlined approach provides a solid foundation, organizations should consider additional enhancements to further improve monitoring effectiveness:

  • Integrating Advanced Monitoring Tools: Tools like Prometheus and Grafana can be used in conjunction with simple scripts for in-depth monitoring and visualization.
  • Incorporating Health Checks: Extend scripts to perform more than just availability checks, including performance metrics and response time analysis.
  • Automating Response Actions: Beyond notifications, integrate automated response mechanisms such as restarting services or rolling back recent changes.

For organizations juggling multiple web projects, continuous monitoring is not just a best practice — it’s a necessity. The combination of shell scripting and CI/CD integration offers a straightforward, cost-effective approach to achieving this objective. By adopting and adapting the strategies discussed, teams can ensure their web projects remain reliable, performant, and ready to serve their intended audiences.

This article offers a comprehensive overview, practical guidance, and actionable steps for implementing continuous monitoring across multiple web projects. It’s tailored to appeal to both technical and managerial audiences, emphasizing the importance of such practices in modern digital operations.

--

--