Update README and installation scripts for Resource Monitor Service v2.1, enhancing web dashboard features and adjusting firewall configurations.
This commit is contained in:
@@ -1,9 +1,33 @@
|
||||
# Resource Monitor Service for Unraid VM
|
||||
# Resource Monitor Service
|
||||
|
||||
A comprehensive system monitoring service specifically designed for Windows VMs running on Unraid servers. This service provides real-time monitoring of CPU, memory, GPU, disk, network, and system resources through a RESTful API.
|
||||
A comprehensive system monitoring service with a modern web dashboard for real-time resource monitoring. Originally designed for Windows VMs running on Unraid servers, now featuring a responsive web interface for easy monitoring and management.
|
||||
|
||||
## 🌟 New: Web Dashboard
|
||||
|
||||
Access the interactive web dashboard at `http://localhost:5000` featuring:
|
||||
|
||||
- **Real-time Monitoring**: Live updates every 15 seconds via SignalR
|
||||
- **Responsive Design**: Mobile-friendly interface built with Tailwind CSS
|
||||
- **Interactive Controls**: Toggle auto-refresh, show/hide sections, manual refresh
|
||||
- **Game Detection**: Prominent game monitoring with process termination
|
||||
- **Process Management**: View and terminate top processes
|
||||
- **System Details**: Comprehensive system information and disk usage
|
||||
- **Performance Charts**: Historical CPU and memory usage graphs
|
||||
- **API Documentation**: Built-in Swagger/OpenAPI interface at `/swagger`
|
||||
|
||||
## 🚀 Features
|
||||
|
||||
### Web Dashboard
|
||||
- **Modern Interface**: Clean, responsive design with dark/light themes
|
||||
- **Real-time Updates**: SignalR-powered live data updates
|
||||
- **Auto-refresh Control**: Toggle between automatic and manual refresh modes
|
||||
- **Game Detection Section**: Monitor running games with termination capability
|
||||
- **Process Management**: View top processes with one-click termination
|
||||
- **System Information**: Detailed hardware and software information
|
||||
- **Disk Usage Visualization**: Visual disk space utilization
|
||||
- **Performance Charts**: Historical data visualization with Chart.js
|
||||
- **Mobile Responsive**: Works seamlessly on phones, tablets, and desktop
|
||||
|
||||
### Core Monitoring
|
||||
- **CPU Monitoring**: Per-core usage, frequency, temperature, and throttling detection
|
||||
- **Memory Monitoring**: RAM usage, available memory, committed memory, and paging
|
||||
@@ -29,23 +53,30 @@ A comprehensive system monitoring service specifically designed for Windows VMs
|
||||
|
||||
## 📡 API Endpoints
|
||||
|
||||
The service runs on `http://localhost:5000` by default and provides the following endpoints:
|
||||
The service runs a web server on `http://localhost:5000` providing:
|
||||
|
||||
### Web Interface
|
||||
- `GET /` - **Main Dashboard** - Interactive web interface for monitoring
|
||||
- `GET /swagger` - **API Documentation** - Interactive API explorer and documentation
|
||||
|
||||
### REST API
|
||||
All API endpoints are available at `http://localhost:5000/api/[endpoint]`:
|
||||
|
||||
### System Information
|
||||
- `GET /api/system-info` - Complete system information including VM details
|
||||
- `GET /api/vm/info` - VM-specific information (hypervisor, uptime, etc.)
|
||||
- `GET /api/health` - Service health status and monitoring capabilities
|
||||
- `GET /api/metrics` - Service metrics and performance overview
|
||||
- `GET /api/config` - Current configuration settings
|
||||
- `GET /api/resource/usage` - **Complete resource overview** - All monitoring data in one call
|
||||
- `GET /api/resource/system-info` - Complete system information including VM details
|
||||
- `GET /api/resource/cpu` - Detailed CPU metrics with per-core data
|
||||
- `GET /api/resource/memory` - Memory utilization and statistics
|
||||
- `GET /api/resource/gpu` - NVIDIA GPU usage, memory, temperature, fan speed, and power consumption
|
||||
- `GET /api/resource/disks` - Disk I/O and space usage for all drives
|
||||
- `GET /api/resource/network` - Network interface statistics
|
||||
- `GET /api/resource/processes?count=10` - Top processes by CPU/memory usage with percentage data
|
||||
|
||||
### Resource Monitoring
|
||||
- `GET /api/resource-usage` - Complete resource usage overview
|
||||
- `GET /api/cpu-usage` - Detailed CPU metrics with per-core data
|
||||
- `GET /api/memory-usage` - Memory utilization and statistics
|
||||
- `GET /api/gpu-usage` - NVIDIA GPU usage, memory, temperature, fan speed, and power consumption
|
||||
- `GET /api/disk-usage` - Disk I/O and space usage for all drives
|
||||
- `GET /api/network-usage` - Network interface statistics
|
||||
- `GET /api/top-processes?count=10` - Top processes by CPU/memory usage with percentage data
|
||||
### Process Management
|
||||
- `POST /api/resource/kill-process/{processId}` - **Terminate Process** - End any process by ID
|
||||
|
||||
### Real-time Updates
|
||||
- **SignalR Hub**: `/resourceHub` - Real-time data updates every 15 seconds
|
||||
|
||||
### Game Detection
|
||||
- `GET /api/current-game` - Currently running game information
|
||||
@@ -76,25 +107,97 @@ The service runs on `http://localhost:5000` by default and provides the followin
|
||||
|
||||
## 🛠️ Installation & Usage
|
||||
|
||||
### Option 1: Console Application (Development/Testing)
|
||||
### Option 1: Web Dashboard (Recommended)
|
||||
```powershell
|
||||
cd C:\Work\DEV\ResourceUsageAPI
|
||||
dotnet run --configuration Release
|
||||
```
|
||||
Then open your browser to `http://localhost:5000` for the interactive dashboard.
|
||||
|
||||
### Option 2: Windows Service (Production)
|
||||
```powershell
|
||||
# Run as Administrator
|
||||
cd C:\Work\DEV\ResourceUsageAPI\publish
|
||||
.\install-service.bat
|
||||
cd C:\Work\DEV\ResourceUsageAPI
|
||||
.\install-service.ps1
|
||||
```
|
||||
|
||||
### Option 3: Standalone Executable
|
||||
### Option 3: Linux Service (if running on Linux)
|
||||
```bash
|
||||
cd /path/to/ResourceUsageAPI
|
||||
chmod +x install-service.sh
|
||||
sudo ./install-service.sh
|
||||
```
|
||||
|
||||
### Option 4: Standalone Executable
|
||||
```powershell
|
||||
cd C:\Work\DEV\ResourceUsageAPI\publish
|
||||
cd C:\Work\DEV\ResourceUsageAPI
|
||||
dotnet build --configuration Release
|
||||
dotnet publish --configuration Release
|
||||
cd bin\Release\net9.0-windows\publish
|
||||
.\ResourceMonitorService.exe
|
||||
```
|
||||
|
||||
## 🎮 Web Dashboard Features
|
||||
|
||||
### Dashboard Overview
|
||||
- **Resource Cards**: CPU, Memory, GPU, and Network usage with visual progress bars
|
||||
- **Game Detection**: Prominent section showing currently running games
|
||||
- **Auto-refresh Toggle**: Control automatic updates (15-second intervals)
|
||||
- **Manual Refresh**: Force immediate data updates
|
||||
- **Responsive Design**: Works on desktop, tablet, and mobile devices
|
||||
|
||||
### Interactive Sections
|
||||
- **Processes**: View and terminate top CPU/memory consuming processes
|
||||
- **Details**: System information, disk usage, and performance charts
|
||||
- **Game Management**: Monitor and terminate running games
|
||||
- **Real-time Charts**: Historical CPU and memory usage visualization
|
||||
|
||||
### Controls
|
||||
- **Auto: ON/OFF** - Toggle automatic data updates
|
||||
- **Processes** - Show/hide process management table
|
||||
- **Details** - Show/hide system information and charts
|
||||
- **Refresh** - Manually update all data immediately
|
||||
|
||||
## 📊 Service Management
|
||||
|
||||
### Starting and Stopping the Service
|
||||
|
||||
```powershell
|
||||
# Start the service
|
||||
Start-Service "ResourceMonitorService"
|
||||
|
||||
# Stop the service
|
||||
Stop-Service "ResourceMonitorService"
|
||||
|
||||
# Get service status
|
||||
Get-Service "ResourceMonitorService"
|
||||
|
||||
# Restart the service
|
||||
Restart-Service "ResourceMonitorService"
|
||||
```
|
||||
|
||||
### Development Mode
|
||||
|
||||
For development and testing:
|
||||
|
||||
```powershell
|
||||
# Run in development mode with hot reload
|
||||
dotnet run --environment Development
|
||||
|
||||
# Access the dashboard at http://localhost:5000
|
||||
# Access Swagger API documentation at http://localhost:5000/swagger
|
||||
```
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
- **Service won't start**: Check the logs in the `logs/` directory
|
||||
- **No GPU data**: Make sure you have an NVIDIA GPU and drivers installed
|
||||
- **High CPU usage**: Adjust monitoring intervals in `appsettings.json`
|
||||
- **Web dashboard not accessible**: Verify firewall settings and ensure port 5000 is available
|
||||
- **Game detection issues**: Check if games are running from standard installation directories
|
||||
- **API errors**: Verify endpoints using Swagger documentation at `/swagger`
|
||||
- **Performance issues**: Consider increasing `UpdateIntervalMs` in configuration
|
||||
|
||||
## ⚙️ Configuration
|
||||
|
||||
Configuration is managed through `appsettings.json`:
|
||||
@@ -102,7 +205,7 @@ Configuration is managed through `appsettings.json`:
|
||||
```json
|
||||
{
|
||||
"MonitoringSettings": {
|
||||
"UpdateIntervalMs": 5000,
|
||||
"UpdateIntervalMs": 15000,
|
||||
"EnableGpuMonitoring": true,
|
||||
"EnableDiskMonitoring": true,
|
||||
"EnableNetworkMonitoring": true,
|
||||
@@ -123,18 +226,15 @@ Configuration is managed through `appsettings.json`:
|
||||
"E:\\Games"
|
||||
]
|
||||
},
|
||||
"AlertThresholds": {
|
||||
"CpuUsageThreshold": 80.0,
|
||||
"MemoryUsageThreshold": 85.0,
|
||||
"GpuUsageThreshold": 90.0,
|
||||
"DiskUsageThreshold": 90.0,
|
||||
"TemperatureThreshold": 80.0,
|
||||
"AlertDurationSeconds": 30
|
||||
},
|
||||
"ApiSettings": {
|
||||
"RequireApiKey": false,
|
||||
"AllowedOrigins": ["http://localhost:4200", "http://unraid:4200"],
|
||||
"BasePath": "/api"
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"Http": {
|
||||
"Url": "http://localhost:5000"
|
||||
},
|
||||
"Https": {
|
||||
"Url": "https://localhost:5001"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -331,68 +431,40 @@ The service supports real-time alert notifications via Telegram bot. To set up T
|
||||
## 🔧 PowerShell Usage Examples
|
||||
|
||||
```powershell
|
||||
# Get system health
|
||||
$health = Invoke-RestMethod -Uri "http://localhost:5000/api/health"
|
||||
Write-Host "System Status: $($health.status)"
|
||||
# Access the web dashboard
|
||||
Start-Process "http://localhost:5000"
|
||||
|
||||
# Get CPU usage
|
||||
$cpu = Invoke-RestMethod -Uri "http://localhost:5000/api/cpu-usage"
|
||||
Write-Host "CPU Usage: $($cpu.usage)%"
|
||||
# Get complete resource overview
|
||||
$resources = Invoke-RestMethod -Uri "http://localhost:5000/api/resource/usage"
|
||||
Write-Host "CPU: $($resources.cpu.usage.ToString('F1'))%"
|
||||
Write-Host "Memory: $($resources.memory.usagePercentage.ToString('F1'))%"
|
||||
Write-Host "GPU: $($resources.gpu.usage)%"
|
||||
|
||||
# Get GPU usage
|
||||
$gpu = Invoke-RestMethod -Uri "http://localhost:5000/api/gpu-usage"
|
||||
if ($gpu.isAvailable) {
|
||||
Write-Host "GPU: $($gpu.name)"
|
||||
Write-Host "GPU Usage: $($gpu.usage)%"
|
||||
Write-Host "GPU Memory: $([math]::Round($gpu.memoryUsed / 1GB, 2))GB / $([math]::Round($gpu.memoryTotal / 1GB, 2))GB ($($gpu.memoryUsage)%)"
|
||||
Write-Host "GPU Temperature: $($gpu.temperature)°C"
|
||||
} else {
|
||||
Write-Host "GPU not available: $($gpu.error)"
|
||||
# Get system information
|
||||
$systemInfo = Invoke-RestMethod -Uri "http://localhost:5000/api/resource/system-info"
|
||||
Write-Host "Machine: $($systemInfo.machineName)"
|
||||
Write-Host "OS: $($systemInfo.osVersion)"
|
||||
Write-Host "CPU: $($systemInfo.cpuName)"
|
||||
|
||||
# Get disk usage
|
||||
$disks = Invoke-RestMethod -Uri "http://localhost:5000/api/resource/disks"
|
||||
foreach ($disk in $disks) {
|
||||
$freeGB = [math]::Round($disk.freeSpace / 1GB, 1)
|
||||
$totalGB = [math]::Round($disk.totalSize / 1GB, 1)
|
||||
Write-Host "$($disk.driveLetter): $freeGB GB free of $totalGB GB"
|
||||
}
|
||||
|
||||
# Get current game (enhanced with root folder detection)
|
||||
$game = Invoke-RestMethod -Uri "http://localhost:5000/api/current-game"
|
||||
if ($game) {
|
||||
Write-Host "Currently playing: $($game.gameName)"
|
||||
Write-Host "Platform: $($game.platform)"
|
||||
Write-Host "Executable: $($game.executableName)"
|
||||
if ($game.isFullscreen) {
|
||||
Write-Host "Running in fullscreen mode"
|
||||
}
|
||||
} else {
|
||||
Write-Host "No game currently detected"
|
||||
}
|
||||
|
||||
# Get all detected games
|
||||
$allGames = Invoke-RestMethod -Uri "http://localhost:5000/api/all-games"
|
||||
Write-Host "Detected games on system:"
|
||||
foreach ($gameItem in $allGames) {
|
||||
Write-Host " $($gameItem.gameName) ($($gameItem.platform)) - Memory: $([math]::Round($gameItem.memoryUsage / 1MB, 0))MB"
|
||||
}
|
||||
|
||||
# Get top processes by CPU usage
|
||||
$processes = Invoke-RestMethod -Uri "http://localhost:5000/api/top-processes?count=5"
|
||||
# Get top processes
|
||||
$processes = Invoke-RestMethod -Uri "http://localhost:5000/api/resource/processes?count=5"
|
||||
Write-Host "Top 5 processes by CPU usage:"
|
||||
foreach ($proc in $processes.value) {
|
||||
Write-Host " $($proc.name): $($proc.cpuUsage.ToString('F2'))% CPU, $($proc.memoryUsagePercentage.ToString('F2'))% Memory"
|
||||
foreach ($proc in $processes) {
|
||||
if ($proc.cpuUsage) {
|
||||
Write-Host " $($proc.name): $($proc.cpuUsage.ToString('F1'))% CPU"
|
||||
}
|
||||
}
|
||||
|
||||
# Terminate a process (example - be careful!)
|
||||
$killRequest = @{
|
||||
ProcessId = 1234
|
||||
Force = $false
|
||||
} | ConvertTo-Json
|
||||
|
||||
# Invoke-RestMethod -Uri "http://localhost:5000/api/process/kill" -Method Post -Body $killRequest -ContentType "application/json"
|
||||
|
||||
# Shutdown system with 60-second delay
|
||||
$shutdownRequest = @{
|
||||
Action = "shutdown"
|
||||
DelaySeconds = 60
|
||||
Message = "Scheduled maintenance shutdown"
|
||||
} | ConvertTo-Json
|
||||
|
||||
Invoke-RestMethod -Uri "http://localhost:5000/api/system/shutdown" -Method Post -Body $shutdownRequest -ContentType "application/json"
|
||||
# Invoke-RestMethod -Uri "http://localhost:5000/api/resource/kill-process/1234" -Method Post
|
||||
```
|
||||
|
||||
## 🚨 Known Warnings (Non-Critical)
|
||||
@@ -435,7 +507,7 @@ The service uses Serilog for structured logging:
|
||||
|
||||
## 📈 Performance
|
||||
|
||||
- Lightweight background monitoring (5-second intervals by default)
|
||||
- Lightweight background monitoring (15-second intervals by default)
|
||||
- Efficient memory usage with smart caching and cleanup of old process data
|
||||
- Non-blocking async operations
|
||||
- Real-time CPU usage calculation for individual processes
|
||||
|
||||
Reference in New Issue
Block a user