This project is a modern Windows application that monitors system metrics such as CPU usage, RAM, storage, and Hyper-V virtual machine information. It features a dynamic dashboard that refreshes every 5 seconds.
- Real-time monitoring of:
- CPU Usage
- RAM Usage
- Storage Usage
- Integration with Hyper-V to display virtual machine details:
- VM Name
- State (Running, Off, etc.)
- CPU Usage
- Memory Assigned
- Uptime
- Dynamic dashboard built with Flask, JavaScript, and Bootstrap.
system-monitor
├── src
│ ├── app.py # Entry point of the application
│ ├── monitors # Package containing monitoring classes
│ │ ├── __init__.py
│ │ ├── cpu_monitor.py # Class for CPU monitoring
│ │ ├── memory_monitor.py # Class for RAM monitoring
│ │ └── storage_monitor.py # Class for storage monitoring
│ ├── static # Static files for the dashboard
│ │ ├── css
│ │ │ └── styles.css # CSS styles for the dashboard
│ │ └── js
│ │ └── dashboard.js # JavaScript for dynamic updates
│ └── templates # HTML templates for the dashboard
│ ├── base.html # Base template
│ └── index.html # Dashboard view
├── requirements.txt # Project dependencies
└── README.md # Project documentation
- Python 3.8+ installed on your system.
- Windows OS with Hyper-V enabled and configured.
- Administrative privileges to run the application.
-
Clone the repository:
git clone <repository-url> cd system-monitor
-
Install the required dependencies:
pip install -r requirements.txt
-
Run the application:
python src/app.py
-
Access the dashboard: Open your web browser and navigate to:
http://localhost:5000
- System Metrics:
- Displays real-time CPU, RAM, and storage usage.
- Automatically refreshes every 5 seconds.
- Hyper-V Virtual Machines:
- Lists all virtual machines on the host.
- Displays VM name, state, CPU usage, memory assigned, and uptime.
The application uses PowerShell cmdlets to fetch Hyper-V virtual machine information. The following PowerShell command is executed internally:
Get-VM | Select-Object Name, State, @{Name='CPUUsage';Expression={(Get-VMProcessor -VMName $_.Name).LoadPercentage}},
@{Name='MemoryAssigned';Expression={$_.MemoryAssigned / 1GB}}, Uptime | ConvertTo-Json -Depth 2The dashboard displays the following system metrics:
- CPU Usage: Percentage of CPU utilization.
- RAM Usage: Total, used, and percentage of memory usage.
- Storage Usage: Total, used, and percentage of disk usage.
The /hyperv endpoint returns JSON data like this:
[
{
"Name": "VM1",
"State": "Running",
"CPUUsage": 10,
"MemoryAssigned": 4.0,
"Uptime": "1:23:45"
},
{
"Name": "VM2",
"State": "Off",
"CPUUsage": 0,
"MemoryAssigned": 0.0,
"Uptime": null
}
]The dashboard displays this data in a table format.
-
PowerShell Errors:
- Ensure that PowerShell is installed and accessible.
- Verify that the execution policy allows running scripts:
If needed, set the execution policy to
Get-ExecutionPolicyRemoteSigned:Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
-
Administrative Privileges:
- The application requires administrative privileges to access Hyper-V data. Run the Flask app as an administrator:
python src/app.py
- The application requires administrative privileges to access Hyper-V data. Run the Flask app as an administrator:
-
Hyper-V Not Enabled:
- Ensure that Hyper-V is enabled on your Windows machine. You can enable it via the "Turn Windows features on or off" menu.
-
Empty Hyper-V Data:
- If the
/hypervendpoint returns an empty response, ensure that there are virtual machines configured in Hyper-V Manager.
- If the
The project uses the following Python libraries:
- Flask: Web framework for building the dashboard.
- Flask-Cors: Enables Cross-Origin Resource Sharing (CORS) for API endpoints.
- psutil: Fetches system metrics like CPU, memory, and disk usage.
- pywin32: Provides access to Windows APIs, including WMI for Hyper-V integration.
Install all dependencies using:
pip install -r requirements.txtContributions are welcome! Feel free to submit issues or pull requests to improve the project.