https://github.com/rasmushs/week2-http-health-checker
Week 2 of a 12 week 1 project per week plan
https://github.com/rasmushs/week2-http-health-checker
concurrency go goroutines http learning-by-doing learning-project multithreading
Last synced: about 2 months ago
JSON representation
Week 2 of a 12 week 1 project per week plan
- Host: GitHub
- URL: https://github.com/rasmushs/week2-http-health-checker
- Owner: RasmusHS
- Created: 2026-04-05T14:08:06.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2026-04-06T17:31:42.000Z (3 months ago)
- Last Synced: 2026-04-06T19:14:26.144Z (3 months ago)
- Topics: concurrency, go, goroutines, http, learning-by-doing, learning-project, multithreading
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HTTP Health Checker
This project is the 2nd in my 12 weeks 12 projects plan. [Overview](https://github.com/RasmusHS/12-Weeks-of-Coding) \
A concurrent command-line tool written in Go that continuously monitors the health of a list of URLs. It performs HTTP GET requests in parallel, reports status codes, response times, and up/down status in a formatted table, and repeats on a configurable interval.
## Features
- **Concurrent checks** — URLs are checked in parallel using goroutines, with a concurrency limit of 10 to avoid overwhelming the system.
- **Configurable interval** — Set the check interval via the `-interval` flag (default: 60 seconds).
- **Live countdown** — Displays a real-time countdown until the next check cycle.
- **Formatted output** — Results are displayed in an aligned table showing URL, status code, response time, and up/down status.
- **Graceful exit** — Press Enter at any time during the countdown to stop the program.
- **Status classification** — Differentiates between UP (2xx), REDIRECT (3xx), client errors (4xx), server errors (5xx), and connection failures.
## Project Structure
| File | Purpose |
|--------------|--------------------------------------------|
| `main.go` | Entry point, orchestration, and check loop |
| `checker.go` | HTTP checking logic (5s timeout per URL) |
| `config.go` | JSON config file loading and parsing |
| `result.go` | Result struct and table output formatting |
| `urls.json` | List of URLs to monitor |
## Getting Started
### Prerequisites
- [Go](https://go.dev/dl/) 1.26+
### Installation
```bash
git clone
cd "HTTP Health Checker"
go build -o health-checker .
```
### Configuration
Edit urls.json to specify the URLs you want to monitor:
```json
"urls": [
"https://www.example.com",
"https://www.google.com",
"https://www.github.com"
]
```
### Usage
```sh
# Run with default 60-second interval
go run .
# Run with a custom interval (e.g., 30 seconds)
go run . -interval 30
```
## Example Output
```bash
URL | Status | Response Time | Up/Down Status
https://www.google.com | 200 | 150ms | UP
https://www.example.com | 200 | 85ms | UP
https://www.badurl.invalid | --- | --- | DOWN (error: ...)
Next check in 60 seconds... Press Enter to exit.
Time remaining: 47 seconds
```