node-health-monitor
v1.0.0
Published
A zero-dependency system health monitor HTTP API using Node.js core modules only.
Maintainers
Readme
node-health-metrics
A lightweight Node.js system health monitoring server without any external dependencies.
Provides detailed system metrics, process info, disk usage, network interfaces, uptime, and API pinging — all accessible via simple HTTP endpoints.
Features
- System memory, CPU load, and uptime metrics
- List of top CPU and memory-consuming processes
- Disk usage info (total, used, free)
- Network interfaces and their IP addresses
- Uptime in human-readable format
- HTTP API ping tool with response time and status code
- No external dependencies — uses only built-in Node.js modules
- Simple HTTP server interface (no Express or frameworks)
Installation
npm install node-health-metrics
API Endpoints
All endpoints accept GET requests.
1. /metrics
Get overall system metrics: memory, CPU load, uptime.
Request: GET /metrics
Response:
{
"memory": {
"totalMB": 8192,
"freeMB": 2048,
"usedMB": 6144,
"usagePercent": 75
},
"cpuLoad": "[0.5, 0.4, 0.3]",
"uptimeSeconds": 1234562. /ping
Ping a target URL and get response time and status.
Request: GET /ping?url=<target_url>
Response:
{
"url": "https://example.com",
"responseTimeMs": 123,
"status": 200,
"success": true
}3. /processes
Get top CPU and memory-consuming processes.
Request: GET /processes?limit=
limit (optional): Number of top processes to return (default: 10)
Response:
[
{
"pid": 1234,
"command": "node",
"cpuPercent": 12.3,
"memoryMB": 150
},
...
]4. /disk
Get disk usage information for mounted drives.
Request: GET /disk
Response:
[
{
"filesystem": "/dev/sda1",
"totalMB": 512000,
"usedMB": 256000,
"freeMB": 256000,
"usagePercent": 50
},
...
]5. /uptime
Get system uptime in a human-readable format.
Request: GET /uptime
Response:
{
"uptime": "1 day, 10 hours, 5 minutes"
}6. /network
Get details of network interfaces with IP addresses.
Request: GET /network
Response:
{
"eth0": ["192.168.1.10", "fe80::1"],
"lo": ["127.0.0.1", "::1"]
}
Error Responses
400 Bad Request: For missing or invalid query parameters
404 Not Found: For unknown endpoints
500 Internal Server Error: On unexpected errors
