This project is a system monitoring tool that allows you to collect, display, and analyze system metrics in real-time and over time. It consists of three main components:
- Backend API Server: A Node.js server connected to MongoDB for storing and providing data via RESTful API.
- Frontend Web Application: A Next.js React application that displays real-time and historical system metrics, rendering graphs using libraries like Chart.js or D3.js.
- Python Upload Script: A script that collects system statistics (e.g., CPU usage, memory usage, GPU stats via
nvidia-smi) and uploads them to the backend server at regular intervals.
- Real-time Monitoring: View live system metrics such as CPU usage, memory consumption, disk I/O, and GPU statistics.
- Historical Data: Analyze system performance over time with aggregated data and interactive visualizations.
- Customizable Metrics: Configure which metrics to collect and display using RESTful APIs, allowing flexibility based on user needs.
- User Authentication: Secure access to the application with admin and user roles.
- Responsive Design: Accessible on various devices, including desktops, tablets, and smartphones.
Before you begin, ensure you have the following installed on your system:
- Operating System: Linux (tested on Ubuntu, but should work on other distributions)
- Node.js: backend and frontend
- npm: package manager
- Python: Version 3.x
- MongoDB: A running MongoDB instance for data storage
- Git: For cloning the repository
Open a terminal and clone the repository to your local machine:
# Clone the repository
git clone https://github.com/yourusername/system-monitor.git
cd system-monitor
# Install backend dependencies
cd backend
npm install
# Install frontend dependencies
cd ../system-monitor-frontend
npm installSeveral configuration files contain placeholders marked with "TODO" that need to be updated with your specific settings. Locate and replace these placeholders to ensure the application runs correctly.
./upload_log.sh:4:BASE_URL='https://localhost:"TODO"/api'
./upload_log.sh:7:USERNAME='"TODO"'
./upload_log.sh:8:PASSWORD='"TODO"'
./system-monitor-backend.service:7:User="TODO"
./system-monitor-backend.service:8:WorkingDirectory="TODO"
./system-monitor-backend.service:12:Environment=PORT="TODO"
./upload_stat_loop.py:31:BASE_URL = 'https://localhost:"TODO"/api'
./upload_stat_loop.py:34:USERNAME = '"TODO"'
./upload_stat_loop.py:35:PASSWORD = '"TODO"'
./backend/config/config.yaml:2: port: "TODO"
./backend/config/config.yaml:22: - "TODO"
./backend/scripts/setupAdmin.js:27: const username = '"TODO"';
./backend/scripts/setupAdmin.js:28: const password = '"TODO"'; // Replace with a strong password
./system-monitor-upload.service:9:User="TODO"
./system-monitor-upload.service:10:WorkingDirectory="TODO"
with open('"TODO"/temp1_input', 'r') as f:
./system-monitor-frontend.service:7:User="TODO"
./system-monitor-frontend.service:8:WorkingDirectory="TODO"
./system-monitor-frontend.service:12:Environment=PORT="TODO"
./system-monitor-frontend/server.js:20: console.log('> Server listening on https://0.0.0.0:"TODO"');
./system-monitor-frontend/.env.local:1:NEXT_PUBLIC_API_BASE_URL=https://"TODO":"TODO"/api
To run the application components as system services that start on boot, you can set up systemd service files.
Warning: Setting up system services requires administrative privileges and should be done carefully.
To set up admin you can change the script of ./backend/scripts/setupAdmin.js to create admin user. Admin user should not be created from api.
Both server run in https and the cert should place in follow
./system-monitor-frontend/server.cert
./system-monitor-frontend/server.key
./backend/server.cert
./backend/server.key
generate by
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
