A comprehensive AWS EC2 server monitoring application with authentication, real-time metrics tracking, and visual alerts for CPU, RAM, and disk usage.
- π Secure Authentication - JWT-based authentication with bcrypt password hashing
- π₯οΈ AWS EC2 Integration - Monitor EC2 instances via CloudWatch and SSH
- π³ Docker Monitoring - Monitor Docker containers on the host
- π Real-time Metrics - Track CPU, RAM, and disk usage with auto-refresh
- π Background Monitoring - Continuous monitoring even when logged out
- π Public Status Page - Share server status without authentication
- π§ Email Alerts - Automatic notifications for critical issues (NEW!)
- π¨ Smart Status System - 5-state system that's backup-aware
- π¨ Beautiful UI - Modern, responsive dashboard with dark theme
- π³ Docker Ready - Fully containerized with automated CI/CD
- π Auto-deployment - GitHub Actions workflow for GHCR
- Node.js 18+ or Docker
- AWS Account with EC2 access (optional)
- SSH access to your servers
- Clone and install dependencies:
git clone https://github.com/HiveMindNet/Server-Monitor.git
cd Server-Monitor
npm install- Create environment file:
cp .env.example .env- Configure environment variables:
Edit
.envand set:
ADMIN_USERNAMEandADMIN_PASSWORD(for initial login)- AWS credentials (if monitoring EC2 instances)
- Other configuration as needed
- Start the server:
npm start- Access the dashboard: Open http://localhost:3000 and login with your admin credentials
docker pull ghcr.io/hivemindnet/Server-Monitor:latest
docker run -d \
-p 3000:3000 \
-v $(pwd)/data:/app/data \
-e ADMIN_USERNAME=admin \
-e ADMIN_PASSWORD=your-secure-password \
-e AWS_ACCESS_KEY_ID=your-key \
-e AWS_SECRET_ACCESS_KEY=your-secret \
-e AWS_REGION=us-east-1 \
ghcr.io/hivemindnet/Server-Monitor:latest| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3000 |
NODE_ENV |
Environment | production |
ADMIN_USERNAME |
Initial admin username | admin |
ADMIN_PASSWORD |
Initial admin password | admin123 |
JWT_SECRET |
JWT signing secret | random |
SESSION_SECRET |
Session encryption key | random |
MONITOR_INTERVAL |
Auto-refresh interval (ms) | 30000 |
| Variable | Description | Default |
|---|---|---|
AWS_REGION |
AWS region | us-east-1 |
AWS_ACCESS_KEY_ID |
AWS access key | - |
AWS_SECRET_ACCESS_KEY |
AWS secret key | - |
Note: AWS credentials are optional. You can use IAM Instance Profiles instead (recommended for EC2).
| Variable | Description | Example |
|---|---|---|
SMTP_HOST |
SMTP server hostname | smtp.gmail.com |
SMTP_PORT |
SMTP server port | 587 |
SMTP_SECURE |
Use SSL/TLS | false |
SMTP_USER |
SMTP username | your-email@gmail.com |
SMTP_PASS |
SMTP password/app password | your-app-password |
SMTP_FROM |
From address | Server Monitor alerts@example.com |
ALERT_EMAIL_TO |
Alert recipient(s) - comma-separated for multiple | admin@example.com,ops@example.com |
| Variable | Description | Default |
|---|---|---|
CPU_THRESHOLD |
CPU warning threshold (%) | 80 |
RAM_THRESHOLD |
RAM warning threshold (%) | 80 |
DISK_THRESHOLD |
Disk warning threshold (%) | 90 |
- Normal (Green): Below warning threshold
- Warning (Yellow): 80-90% utilization
- Critical (Red): Above 90-95% utilization
-
Click "Add Server" in the dashboard
-
Fill in the server details:
- Server Name: Friendly name for identification
- EC2 Instance ID: Optional, for AWS integration
- Host/IP: Server hostname or IP address
- SSH Username: Username for SSH access (e.g., ec2-user)
- SSH Private Key: Your private SSH key for authentication
-
Click "Add Server" to start monitoring
Provides detailed metrics for CPU, RAM, and disk usage by connecting directly to the server via SSH.
Requirements:
- SSH access to the server
- Private key authentication
Metrics provided:
- CPU utilization percentage
- RAM utilization percentage
- Disk usage percentage for /
- Disk space details (total, used, free)
Monitors Docker containers running on the same host as the monitoring application.
Requirements:
- Docker socket mounted to container:
-v /var/run/docker.sock:/var/run/docker.sock
Metrics provided:
- Container state (running, exited, restarting, etc.)
- CPU utilization percentage
- Memory utilization percentage
- Memory usage (used/total)
- Container image and name
Uses AWS CloudWatch for basic EC2 metrics when SSH is not available.
Requirements:
- AWS credentials configured
- EC2 Instance ID provided
- CloudWatch monitoring enabled
Metrics provided:
- CPU utilization (from CloudWatch)
- Instance state and metadata
Server Monitor can automatically send email notifications when critical issues are detected. This ensures you're always aware of problems even when you're not actively monitoring the dashboard.
Email alerts are sent only for the following severity levels:
- π¨ Down - Server or container is offline/unreachable
- π₯ Critical - Disk β₯90%, RAM β₯95%, or CPU 100% with RAM β₯90%
Not sent via email:
β οΈ Warning - Still visible in dashboard, but no email alert- π Heavily Loaded - High CPU only (normal during backups)
This focuses alerts on truly urgent issues that require immediate attention.
- Smart Deduplication - Won't spam you with duplicate alerts for the same issue within 1 hour
- Automatic Resolution - Tracks when issues are resolved
- Beautiful HTML Emails - Professional-looking emails with color-coded alerts
- Multiple Recipients - Send alerts to multiple email addresses
- Actionable Information - Includes specific metrics and recommended actions
- Test Button - Send a test email to verify your configuration
- Add SMTP settings to your
.envfile:
# SMTP Server Settings
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
# Email Addresses
SMTP_FROM=Server Monitor <your-email@gmail.com>
ALERT_EMAIL_TO=admin@example.com
# Multiple recipients (comma-separated)
# ALERT_EMAIL_TO=admin@example.com,ops@example.com,alerts@example.com- Restart the container:
docker compose restart server-monitor- Test the configuration:
- Login to the admin dashboard
- Click "π§ Email Alerts" in the header
- Click "Send Test Email"
- Check your inbox!
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-16-char-app-passwordNote: Must use an App Password, not your regular Gmail password.
SMTP_HOST=smtp.office365.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=your-email@outlook.com
SMTP_PASS=your-passwordSMTP_HOST=smtp.sendgrid.net
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=apikey
SMTP_PASS=your-sendgrid-api-keySMTP_HOST=smtp.mailgun.org
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=postmaster@your-domain.mailgun.org
SMTP_PASS=your-mailgun-password"Email not configured" error:
- Verify all SMTP_* variables are set in your
.envfile - Check that
ALERT_EMAIL_TOis set - Restart the container after making changes
Test email not arriving:
- Check your spam folder
- Verify SMTP credentials are correct
- For Gmail, ensure you're using an App Password, not your regular password
- Check container logs for error messages:
docker compose logs server-monitor
Authentication errors:
- Gmail: Use an App Password (Settings β Security β 2-Step Verification β App passwords)
- Outlook: May need to enable "SMTP AUTH" in your account settings
- Check if your email provider requires SSL/TLS (set
SMTP_SECURE=trueand try port 465)
GET /status- Public status pageGET /api/status/public- Public API for status data
POST /api/auth/login- Login with username/passwordPOST /api/auth/logout- Logout current userGET /api/auth/me- Get current user info
GET /api/servers- List all serversPOST /api/servers- Add new serverPUT /api/servers/:id- Update serverDELETE /api/servers/:id- Delete server
GET /api/monitor/all- Get cached metrics for all servers and Docker containersGET /api/monitor/:id- Get cached metrics for specific server
GET /api/email/status- Check if email is configuredPOST /api/email/test- Send a test email
All API endpoints (except login and public status) require authentication via JWT token.
Server data is stored in JSON files:
data/users.json- User accountsdata/servers.json- Server configurations
Important: When running in Docker, mount a volume to /app/data to persist data:
-v /path/to/data:/app/data- Passwords are hashed using bcrypt
- SSH private keys are stored server-side only
- JWT tokens expire after 24 hours
- Use HTTPS in production
- Regularly rotate AWS credentials
- Use strong admin passwords
- Consider using AWS Secrets Manager for credentials in production
This project includes GitHub Actions for automatic Docker builds:
- Trigger: Push to main branch
- Registry: GitHub Container Registry (GHCR)
- Image:
ghcr.io/hivemindnet/Server-Monitor:latest
# Install dependencies
npm install
# Run in development mode with auto-reload
npm run dev
# Run in production mode
npm start- Verify the private key is correct
- Ensure SSH access is allowed from your server
- Check firewall rules and security groups
- Verify the username is correct for your OS
- Verify AWS credentials are configured
- Ensure EC2 Instance ID is correct
- Check IAM permissions for EC2 and CloudWatch
- Verify the region is correct
- Check
data/users.jsonexists - Verify environment variables are set
- Try deleting
data/users.jsonto recreate admin user
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions, please open an issue on GitHub.