krsyer-server-monitor-pro
v1.0.34
Published
API to get server details like IP address, health, applications running, etc.
Maintainers
Readme
Server Monitor Pro (SaaS)
A secure, SaaS-based server monitoring tool with Cashfree payment integration and obfuscated code for production.
Features
- 🌐 SaaS Ready: Remote subscription verification.
- 💳 Cashfree Integration: Professional payment gateway for subscriptions.
- 🔒 Code Obfuscation: Securely packaged for NPM distribution.
- 📊 Comprehensive Monitoring: CPU, Memory, PM2, Docker, and more.
- ⌨️ Integrated Terminal: Direct access from your browser.
Installation
As a global CLI tool
npm install -g server-monitor-apiAs a project dependency
npm install server-monitor-apiSetup
- Create a
.envfile in your project root:
PORT=3014
LICENSE_KEY=DEMO-123 # Get your key after payment
CASHFREE_APP_ID=your_app_id
CASHFREE_SECRET_KEY=your_secret_key
APP_URL=http://localhost:3014Usage
Using CLI
server-monitor start --port 3014In your Node.js app
const app = require('server-monitor-api');
// The app is an express instance
app.listen(3014);API Endpoints
1. Get Comprehensive Server Information
Endpoint: GET /api/server/info
Returns complete server details including:
- Public and local IP addresses
- System information (hostname, OS, architecture)
- CPU information (cores, speed, load average)
- Memory usage statistics
- Node.js version and process info
- List of running PM2 applications
Response Example:
{
"status": "success",
"timestamp": "2025-12-27T13:44:35.000Z",
"server": {
"hostname": "server-name",
"platform": "win32",
"architecture": "x64",
"type": "Windows_NT",
"release": "10.0.22631",
"uptime": {
"raw": 86400,
"formatted": "1d 0h 0m 0s"
}
},
"network": {
"publicIP": "203.0.113.1",
"localIPs": [
{
"interface": "Ethernet",
"address": "192.168.1.100",
"netmask": "255.255.255.0",
"mac": "00:00:00:00:00:00"
}
]
},
"cpu": {
"model": "Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz",
"cores": 8,
"speed": "3600 MHz",
"loadAverage": {
"1min": "0.50",
"5min": "0.45",
"15min": "0.42"
}
},
"memory": {
"total": "16.00 GB",
"free": "8.50 GB",
"used": "7.50 GB",
"usagePercentage": "46.88%"
},
"node": {
"version": "v18.17.0",
"processUptime": {
"raw": 3600,
"formatted": "1h 0m"
},
"pid": 12345
},
"applications": [
{
"name": "my-app",
"pid": 54321,
"status": "online",
"uptime": 1703689475000,
"restarts": 2,
"memory": "150.25 MB",
"cpu": "2.5%",
"mode": "cluster",
"instances": 4
}
]
}2. Get Server Health Status
Endpoint: GET /api/server/health
Returns current health status with warnings based on resource usage.
Response Example:
{
"status": "healthy",
"timestamp": "2025-12-27T13:44:35.000Z",
"uptime": "1d 0h 0m 0s",
"checks": {
"memory": {
"status": "ok",
"usage": "46.88%"
},
"cpu": {
"status": "ok",
"loadAverage": "0.50",
"cores": 8
}
},
"warnings": null
}Health Status Values:
healthy- All systems normalwarning- Some metrics are elevatedcritical- Action required (memory > 90% or CPU overloaded)
3. Get Running Applications
Endpoint: GET /api/server/applications
Returns list of applications managed by PM2.
Response Example:
{
"status": "success",
"timestamp": "2025-12-27T13:44:35.000Z",
"count": 2,
"applications": [
{
"name": "my-app",
"pid": 54321,
"status": "online",
"uptime": 1703689475000,
"restarts": 2,
"memory": "150.25 MB",
"cpu": "2.5%",
"mode": "cluster",
"instances": 4
},
{
"name": "worker-app",
"pid": 54322,
"status": "online",
"uptime": 1703689475000,
"restarts": 0,
"memory": "85.50 MB",
"cpu": "1.2%",
"mode": "fork",
"instances": 1
}
]
}Usage Examples
Using cURL
# Get full server information
curl http://localhost:3014/api/server/info
# Check health status
curl http://localhost:3014/api/server/health
# List running applications
curl http://localhost:3014/api/server/applicationsUsing JavaScript/Fetch
// Get server information
const response = await fetch('http://localhost:3014/api/server/info');
const data = await response.json();
console.log('Server IP:', data.network.publicIP);
console.log('Memory Usage:', data.memory.usagePercentage);Project Structure
getIPApi/
├── controllers/
│ └── serverController.js # Controller logic for all endpoints
├── routes/
│ └── serverRoutes.js # Route definitions
├── .env # Environment variables
├── .gitignore # Git ignore file
├── package.json # Project dependencies
├── README.md # This file
└── server.js # Main application entry pointDependencies
- express - Web framework
- cors - Enable CORS
- dotenv - Environment variables
- axios - HTTP client for external API calls
- pm2 - Process manager (optional, for listing applications)
Notes
- The API uses
https://api.ipify.orgto fetch the public IP address - PM2 must be installed and running for the applications endpoint to return data
- On Windows, some Unix-specific features (like load average) may not be available
- The health endpoint uses the following thresholds:
- Memory: Warning at 75%, Critical at 90%
- CPU: Warning when load average > (cores × 2)
License
ISC
