Skip to content

evsybut/service-health-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🩺 Service Health Checker

A beginner-friendly Python tool that checks whether a list of services/URLs are up, logs the results, and saves a JSON report.

Built as a learning project covering Python scripting, HTTP requests, logging, file I/O, and GitHub Actions CI.


Features

  • Checks HTTP status and response time for each target
  • Logs results to terminal and to logs/checker.log
  • Saves a timestamped JSON report to reports/
  • GitHub Actions workflow runs checks on every push and on a schedule

Project Structure

health-checker/
├── checker.py           # Main script
├── requirements.txt     # Python dependencies
├── .gitignore
├── .github/
│   └── workflows/
│       └── health-check.yml   # CI/CD pipeline
├── logs/                # Created at runtime
└── reports/             # Created at runtime

Getting Started

1. Clone the repo

git clone https://github.com/YOUR_USERNAME/YOUR_REPO.git
cd YOUR_REPO

2. Install dependencies

pip install -r requirements.txt

3. Run the checker

python checker.py

Configuration

Edit the TARGETS list in checker.py to check your own URLs:

TARGETS = [
    {"name": "My App",  "url": "https://myapp.example.com"},
    {"name": "My API",  "url": "https://api.example.com/health"},
]

You can also adjust:

  • TIMEOUT_SECONDS — how long to wait before marking a service as down
  • The cron schedule in .github/workflows/health-check.yml

Example Output

2024-01-15 10:30:01  INFO      Starting health checks...
2024-01-15 10:30:01  INFO      [UP]   Google — 142ms  (HTTP 200)
2024-01-15 10:30:02  INFO      [UP]   GitHub — 310ms  (HTTP 200)
2024-01-15 10:30:02  WARNING   [DOWN] Fake Service — Connection error: ...

==================================================
  HEALTH CHECK SUMMARY
==================================================
  ✅  UP:    2
  ❌  DOWN:  1

  Services down:
    - Fake Service  (Connection error: ...)
==================================================

What I Learned

  • Python scripting and project structure
  • HTTP requests with the requests library
  • Logging to files and stdout
  • Writing JSON reports
  • GitHub Actions for CI/CD automation

Next Steps

  • Add email/Slack alerts when a service goes down
  • Add a retry mechanism before marking a service as DOWN
  • Store results in a database (SQLite to start)
  • Build a simple dashboard to visualise uptime history

About

Python service health checker with GitHub Actions CI

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages