Add Telegram bot integration for real-time alert notifications
- Implemented ITelegramNotificationService and TelegramNotificationService for sending alerts via Telegram. - Updated MonitoringSettings to include Telegram configuration options. - Enhanced AlertService to send alerts and resolutions through Telegram. - Added API endpoints for checking Telegram status and sending test alerts. - Updated README and TELEGRAM_SETUP.md with setup instructions and features. - Included example configuration in appsettings.telegram.example.json.
This commit is contained in:
@@ -22,6 +22,7 @@ A comprehensive system monitoring service specifically designed for Windows VMs
|
||||
- **Game Detection**: Multi-platform game detection with fullscreen monitoring and configurable root folders
|
||||
- **Process Management**: View top processes with CPU/memory percentages, terminate processes via API
|
||||
- **Smart Alerting**: Duration-based alerting to prevent false positives
|
||||
- **Telegram Bot Integration**: Real-time alerts via Telegram bot with customizable notifications
|
||||
- **System Control**: Remote shutdown/restart capabilities
|
||||
- **Health Monitoring**: Comprehensive health checks and uptime tracking
|
||||
- **Real-time Metrics**: CPU usage calculation and memory percentage tracking for processes
|
||||
@@ -57,6 +58,10 @@ The service runs on `http://localhost:5000` by default and provides the followin
|
||||
- `POST /api/alerts/{alertId}/resolve` - Manually resolve an alert
|
||||
- `GET /api/alerts/enabled` - Check if alerting is enabled
|
||||
|
||||
### Telegram Bot Integration
|
||||
- `GET /api/telegram/status` - Check Telegram bot status and connection
|
||||
- `POST /api/telegram/test` - Send a test alert to verify bot configuration
|
||||
|
||||
### System Control
|
||||
- `POST /api/process/kill` - Terminate a process (requires process ID and optional force flag)
|
||||
- `POST /api/system/shutdown` - Shutdown, restart, or cancel system operations
|
||||
@@ -180,6 +185,40 @@ D:\Games\The Witcher 3\witcher3.exe
|
||||
- Use absolute paths (e.g., `C:\Games`, not `Games`)
|
||||
- Root folders are checked in order, so prioritize most common locations first
|
||||
|
||||
### Telegram Bot Alerts
|
||||
|
||||
The service supports real-time alert notifications via Telegram bot. To set up Telegram alerts:
|
||||
|
||||
1. **Create a Telegram Bot** - Contact `@BotFather` on Telegram and create a new bot
|
||||
2. **Get Chat ID** - Send a message to your bot, then visit `https://api.telegram.org/bot<TOKEN>/getUpdates`
|
||||
3. **Configure Settings** - Add Telegram configuration to your `appsettings.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"MonitoringSettings": {
|
||||
"Telegram": {
|
||||
"IsEnabled": true,
|
||||
"BotToken": "123456789:ABCdefGHIjklMNOpqrSTUvwxyz",
|
||||
"ChatIds": [123456789, -987654321],
|
||||
"SendWarningAlerts": true,
|
||||
"SendCriticalAlerts": true,
|
||||
"SendResolutionNotifications": true,
|
||||
"MessageTemplate": "🚨 *{Level} Alert*\n\n📊 *{Component}*\n💬 {Message}\n⏰ {Timestamp}",
|
||||
"ResolutionTemplate": "✅ *Alert Resolved*\n\n📊 *{Component}*\n💬 {Message}\n⏰ Resolved at {ResolvedAt}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- **Multiple Chats**: Send alerts to multiple users/groups by adding chat IDs
|
||||
- **Customizable Templates**: Modify message format with placeholders for alert data
|
||||
- **Alert Filtering**: Choose which alert levels to send (Warning/Critical)
|
||||
- **Silent Notifications**: Warning alerts are sent silently, critical alerts with sound
|
||||
- **Resolution Notifications**: Optional notifications when alerts are resolved
|
||||
|
||||
📋 For detailed setup instructions, see [TELEGRAM_SETUP.md](TELEGRAM_SETUP.md)
|
||||
|
||||
## 📊 Example API Responses
|
||||
|
||||
### Health Check
|
||||
|
||||
Reference in New Issue
Block a user