| name | health-check |
| description | Check service health via HTTP endpoints with response time, status code, and body validation. Trigger: when checking service health, verifying HTTP endpoints, readiness/liveness probes, uptime monitoring |
| version | 1 |
| argument-hint | [url] |
| allowed-tools | ["bash","read","grep"] |
Health Check
You are now operating in service health check mode.
Basic HTTP Health Check
curl -s -o /dev/null -w "%{http_code} %{time_total}s" http://localhost:8080/health
curl -s -w "\nStatus: %{http_code}\nTime: %{time_total}s\n" http://localhost:8080/health
curl -s -f http://localhost:8080/health || echo "UNHEALTHY"
curl -s -L -o /dev/null -w "%{http_code}" http://localhost:8080/
Parse JSON Health Response
curl -s http://localhost:8080/health | jq .
curl -s http://localhost:8080/health | jq -r '.status'
STATUS=$(curl -s http://localhost:8080/health | jq -r '.status')
[ "$STATUS" = "ok" ] && echo "PASS" || echo "FAIL: status=$STATUS"
Response Time Thresholds
TIME=$(curl -s -o /dev/null -w "%{time_total}" http://localhost:8080/health)
echo "Response time: ${TIME}s"
if (( $(echo "$TIME > 1.0" | bc -l) )); then
echo "WARNING: slow response (${TIME}s > 1.0s threshold)"
fi
if (( $(echo "$TIME > 5.0" | bc -l) )); then
echo "CRITICAL: very slow response (${TIME}s)"
fi
Check Multiple Endpoints
for url in \
"http://localhost:8080/health" \
"http://localhost:8080/ready" \
"http://localhost:8080/metrics"; do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$url")
echo "$url → $STATUS"
done
Kubernetes Readiness / Liveness Probe Pattern
livenessProbe:
httpGet:
path: /health/live
port: 8080
initialDelaySeconds: 10
periodSeconds: 30
failureThreshold: 3
readinessProbe:
httpGet:
path: /health/ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
curl -s -f http://localhost:8080/health/live && echo "LIVE" || echo "NOT LIVE"
curl -s -f http://localhost:8080/health/ready && echo "READY" || echo "NOT READY"
Go Health Endpoint Implementation Pattern
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, `{"status":"ok"}`)
})
http.HandleFunc("/health/ready", func(w http.ResponseWriter, r *http.Request) {
if err := db.PingContext(r.Context()); err != nil {
w.WriteHeader(http.StatusServiceUnavailable)
fmt.Fprintf(w, `{"status":"not ready","error":%q}`, err.Error())
return
}
w.Header().Set("Content-Type", "application/json")
fmt.Fprintln(w, `{"status":"ready"}`)
})
SSL Certificate Check
curl -s -o /dev/null -w "%{ssl_verify_result}" https://example.com
echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates
EXPIRY=$(echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -enddate | cut -d= -f2)
EXPIRY_EPOCH=$(date -d "$EXPIRY" +%s 2>/dev/null || date -j -f "%b %d %T %Y %Z" "$EXPIRY" +%s)
DAYS=$(( (EXPIRY_EPOCH - $(date +%s)) / 86400 ))
echo "Certificate expires in $DAYS days"
Interpreting Results
| HTTP Status | Meaning | Action |
|---|
| 200 | Healthy | None |
| 503 | Service Unavailable | Check logs, dependencies |
| 404 | Endpoint missing | Verify route configuration |
| 000 | Connection refused | Service may be down |
| 504 | Gateway timeout | Check upstream services |