feat: add /api/health endpoint for monitoring
- Returns status, version, uptime, scanner_id - Component status: database, peer_sync, auto_scanner - Returns 200 for healthy, 503 for unhealthy - Tracks app start time for uptime calculation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
59
docs/API.md
59
docs/API.md
@@ -6,6 +6,65 @@ REST API documentation for RF Mapper web interface.
|
||||
|
||||
---
|
||||
|
||||
## System
|
||||
|
||||
### Health Check
|
||||
|
||||
Returns health status for monitoring and load balancers.
|
||||
|
||||
```
|
||||
GET /api/health
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "healthy",
|
||||
"version": "1.0.0",
|
||||
"uptime_seconds": 3600,
|
||||
"uptime_human": "1h 0m",
|
||||
"scanner_id": "rpios",
|
||||
"components": {
|
||||
"database": {
|
||||
"status": "ok",
|
||||
"device_count": 100
|
||||
},
|
||||
"peer_sync": {
|
||||
"status": "ok",
|
||||
"peer_count": 2
|
||||
},
|
||||
"auto_scanner": {
|
||||
"status": "stopped"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Status Codes:**
|
||||
- `200` - Healthy
|
||||
- `503` - Unhealthy (component error)
|
||||
|
||||
**Component Status Values:**
|
||||
- `ok` - Component working normally
|
||||
- `disabled` - Component not enabled in config
|
||||
- `error` - Component has errors
|
||||
- `running` / `stopped` - For auto_scanner
|
||||
|
||||
**Example:**
|
||||
|
||||
```bash
|
||||
# Simple health check
|
||||
curl -s http://localhost:5000/api/health | jq '.status'
|
||||
|
||||
# Use in monitoring scripts
|
||||
if curl -sf http://localhost:5000/api/health > /dev/null; then
|
||||
echo "RF Mapper is healthy"
|
||||
fi
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Scanning
|
||||
|
||||
### Trigger Scan
|
||||
|
||||
Reference in New Issue
Block a user