Files
Phoenix d6efa9163b 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.
2025-08-07 17:30:02 +08:00

91 lines
3.8 KiB
C#

namespace ResourceMonitorService.Configuration
{
public class MonitoringSettings
{
public int UpdateIntervalMs { get; set; } = 5000; // 5 seconds
public int DataRetentionDays { get; set; } = 7;
public bool EnableGpuMonitoring { get; set; } = true;
public bool EnableDiskMonitoring { get; set; } = true;
public bool EnableNetworkMonitoring { get; set; } = true;
public bool EnableTemperatureMonitoring { get; set; } = true;
public bool EnableProcessMonitoring { get; set; } = true;
public bool EnableGameDetection { get; set; } = true;
public bool EnableAlerts { get; set; } = true;
public int MaxProcessesToTrack { get; set; } = 10;
public int MaxHistoryPoints { get; set; } = 1000;
public List<string> GamePlatformPaths { get; set; } = new()
{
@"\steamapps\common\",
@"\Epic Games\",
@"\GOG Galaxy\Games\",
@"\Origin Games\",
@"\Ubisoft Game Launcher\games\"
};
public List<string> GameRootFolders { get; set; } = new()
{
@"C:\Games",
@"D:\Games",
@"E:\Games"
};
public List<AlertThresholdConfig> AlertThresholds { get; set; } = new()
{
new() { Component = "CPU", WarningThreshold = 80, CriticalThreshold = 95, DurationSeconds = 30 },
new() { Component = "Memory", WarningThreshold = 85, CriticalThreshold = 95, DurationSeconds = 30 },
new() { Component = "GPU", WarningThreshold = 85, CriticalThreshold = 95, DurationSeconds = 30 },
new() { Component = "CPUTemp", WarningThreshold = 75, CriticalThreshold = 85, DurationSeconds = 60 },
new() { Component = "GPUTemp", WarningThreshold = 80, CriticalThreshold = 90, DurationSeconds = 60 }
};
public TelegramSettings Telegram { get; set; } = new();
}
public class AlertThresholdConfig
{
public string Component { get; set; } = string.Empty;
public float WarningThreshold { get; set; }
public float CriticalThreshold { get; set; }
public int DurationSeconds { get; set; } = 30;
public bool IsEnabled { get; set; } = true;
}
public class ApiSettings
{
public string ApiKey { get; set; } = string.Empty;
public bool RequireApiKey { get; set; } = false;
public List<string> AllowedOrigins { get; set; } = new()
{
"http://localhost:4200",
"http://192.168.50.52:4200",
"http://vmwin11:4200"
};
public bool EnableSwagger { get; set; } = false;
public string BasePath { get; set; } = "/api";
}
public class LoggingSettings
{
public string LogLevel { get; set; } = "Information";
public string LogPath { get; set; } = "logs";
public int MaxLogFiles { get; set; } = 30;
public long MaxLogFileSizeMB { get; set; } = 10;
public bool EnableFileLogging { get; set; } = true;
public bool EnableConsoleLogging { get; set; } = true;
public bool EnablePerformanceLogging { get; set; } = false;
}
public class TelegramSettings
{
public bool IsEnabled { get; set; } = false;
public string BotToken { get; set; } = string.Empty;
public List<long> ChatIds { get; set; } = new();
public bool SendWarningAlerts { get; set; } = true;
public bool SendCriticalAlerts { get; set; } = true;
public bool SendResolutionNotifications { get; set; } = true;
public string MessageTemplate { get; set; } = "🚨 *{Level} Alert*\n\n📊 *{Component}*\n💬 {Message}\n⏰ {Timestamp:yyyy-MM-dd HH:mm:ss}";
public string ResolutionTemplate { get; set; } = "✅ *Alert Resolved*\n\n📊 *{Component}*\n💬 {Message}\n⏰ Resolved at {ResolvedAt:yyyy-MM-dd HH:mm:ss}";
}
}