νκ΅μ΄ | English
A Go-based health checker that periodically monitors website availability and sends notifications via Slack or Discord when issues are detected.
- Periodic website health checks
- HTTP status code and response time monitoring
- Slack Webhook notification support
- Discord Webhook notification support
- Support for using both Slack and Discord simultaneously
- Test mode support (sends notifications even when status is healthy)
go install github.com/your-username/health-checker@latestOr build from source:
git clone https://github.com/your-username/health-checker.git
cd health-checker
go buildFor deploying to external servers, see the Deployment Guide.
- Deploy using Docker
- Deploy directly to Linux servers
- Run as a systemd service
# Windows PowerShell
.\health-checker.exe run --url https://example.com
# Linux/Mac
./health-checker run --url https://example.com--url,-u: URL to check (required)--url https://example.com
-
--interval,-i: Check interval (default:60s)--interval 30s # Check every 30 seconds --interval 5m # Check every 5 minutes
-
--timeout,-t: Request timeout (default:5s)--timeout 10s # 10 second timeout -
--slack-webhook,-s: Slack Webhook URL--slack-webhook https://hooks.slack.com/services/YOUR/WEBHOOK/URL
-
--discord-webhook,-d: Discord Webhook URL--discord-webhook https://discord.com/api/webhooks/YOUR/WEBHOOK/URL
-
--latency-threshold: Response latency threshold (if specified, responses exceeding this are considered failures)--latency-threshold 3s # Alert if response takes 3 seconds or more --latency-threshold 500ms # Alert if response takes 500ms or more
-
--test: Test mode (sends notifications even when status is healthy)--test
All duration-related options (--interval, --timeout, --latency-threshold and related environment variables) follow Go's time.ParseDuration format and support the following units:
ns(nanoseconds),us/Β΅s(microseconds),ms(milliseconds)s(seconds),m(minutes),h(hours)
Examples: 500ms, 2s, 1.5s, 3m, 1h30m
You can use environment variables instead of flags:
SLACK_WEBHOOK_URL: Slack Webhook URLDISCORD_WEBHOOK_URL: Discord Webhook URLLATENCY_THRESHOLD: Response latency threshold (e.g.,3s,500ms)
# Windows PowerShell
$env:SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
$env:DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/YOUR/WEBHOOK/URL"
$env:LATENCY_THRESHOLD="3s"
.\health-checker.exe run --url https://example.com
# Linux/Mac
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
export DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/YOUR/WEBHOOK/URL"
export LATENCY_THRESHOLD="3s"
./health-checker run --url https://example.com.\health-checker.exe run --url https://example.com --interval 60s.\health-checker.exe run \
--url https://example.com \
--interval 30s \
--slack-webhook https://hooks.slack.com/services/YOUR/WEBHOOK/URL.\health-checker.exe run \
--url https://example.com \
--interval 30s \
--discord-webhook https://discord.com/api/webhooks/YOUR/WEBHOOK/URL.\health-checker.exe run \
--url https://example.com \
--interval 60s \
--slack-webhook https://hooks.slack.com/services/YOUR/WEBHOOK/URL \
--discord-webhook https://discord.com/api/webhooks/YOUR/WEBHOOK/URL.\health-checker.exe run \
--url https://example.com \
--discord-webhook https://discord.com/api/webhooks/YOUR/WEBHOOK/URL \
--test.\health-checker.exe run \
--url https://example.com \
--interval 10s \
--timeout 3s \
--latency-threshold 2s \
--discord-webhook https://discord.com/api/webhooks/YOUR/WEBHOOK/URLNotifications are sent in the following cases:
- HTTP request failure (connection errors, timeouts, etc.)
- HTTP status code is not 200 (500, 404, 503, etc.)
- (Optional) When
--latency-thresholdorLATENCY_THRESHOLDis set, if response time exceeds the threshold
Notifications are sent in all states:
- On error: Failure notification
- Non-200 status code: Failure notification
- 200 OK: Healthy notification (only in test mode)
π¨ Site Failure Detected: https://example.com
Status Code: 500
Response Time: 2.5s
Or
π¨ Site Failure Detected: https://example.com
Error: connection timeout
Response Time: 5s
β
Site Healthy: https://example.com
Status Code: 200
Response Time: 150ms
- Create a new app at Slack API
- Enable Incoming Webhooks
- Copy the Webhook URL
- Set it in the
--slack-webhookflag orSLACK_WEBHOOK_URLenvironment variable
- Discord channel settings β Integrations β Webhooks
- Create a new webhook
- Copy the webhook URL
- Set it in the
--discord-webhookflag orDISCORD_WEBHOOK_URLenvironment variable
Press Ctrl+C to stop the program.
Press Ctrl+C to stop
^C
Shutting down...
health-checker/
βββ cmd/
β βββ root.go # Root command
β βββ run.go # Run subcommand
βββ internal/
β βββ checker/ # Health check logic
β β βββ checker.go
β βββ notifier/ # Notification logic
β βββ slack.go
β βββ discord.go
β βββ notifier.go
βββ main.go
βββ go.mod
βββ README.md
- Language: Go
- CLI Framework: Cobra
- HTTP Client: net/http (standard library)
MIT License
Issues and Pull Requests are welcome!