287 lines
8.2 KiB
C#
287 lines
8.2 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
|
|||
|
|
namespace JiShe.CollectBus.PluginFileWatcher
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 文件监控程序的配置类
|
|||
|
|
/// </summary>
|
|||
|
|
public class FileMonitorConfig
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 基本配置
|
|||
|
|
/// </summary>
|
|||
|
|
public GeneralConfig General { get; set; } = new GeneralConfig();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 文件过滤配置
|
|||
|
|
/// </summary>
|
|||
|
|
public FileFiltersConfig FileFilters { get; set; } = new FileFiltersConfig();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 性能相关配置
|
|||
|
|
/// </summary>
|
|||
|
|
public PerformanceConfig Performance { get; set; } = new PerformanceConfig();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 健壮性相关配置
|
|||
|
|
/// </summary>
|
|||
|
|
public RobustnessConfig Robustness { get; set; } = new RobustnessConfig();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 事件存储和回放配置
|
|||
|
|
/// </summary>
|
|||
|
|
public EventStorageConfig EventStorage { get; set; } = new EventStorageConfig();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 文件系统通知过滤器配置
|
|||
|
|
/// </summary>
|
|||
|
|
public List<string> NotifyFilters { get; set; } = new List<string>();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 日志配置
|
|||
|
|
/// </summary>
|
|||
|
|
public LoggingConfig Logging { get; set; } = new LoggingConfig();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 常规配置
|
|||
|
|
/// </summary>
|
|||
|
|
public class GeneralConfig
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 是否启用文件过滤
|
|||
|
|
/// </summary>
|
|||
|
|
public bool EnableFileFiltering { get; set; } = true;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 内存监控间隔(分钟)
|
|||
|
|
/// </summary>
|
|||
|
|
public int MemoryMonitorIntervalMinutes { get; set; } = 1;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 默认监控路径
|
|||
|
|
/// </summary>
|
|||
|
|
public string DefaultMonitorPath { get; set; } = string.Empty;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 文件过滤配置
|
|||
|
|
/// </summary>
|
|||
|
|
public class FileFiltersConfig
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 允许监控的文件扩展名
|
|||
|
|
/// </summary>
|
|||
|
|
public string[] AllowedExtensions { get; set; } = new[] { ".dll" };
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 排除的目录
|
|||
|
|
/// </summary>
|
|||
|
|
public string[] ExcludedDirectories { get; set; } = new[] { "bin", "obj", "node_modules" };
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 是否包含子目录
|
|||
|
|
/// </summary>
|
|||
|
|
public bool IncludeSubdirectories { get; set; } = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 性能相关配置
|
|||
|
|
/// </summary>
|
|||
|
|
public class PerformanceConfig
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 内存清理阈值(事件数)
|
|||
|
|
/// </summary>
|
|||
|
|
public int MemoryCleanupThreshold { get; set; } = 5000;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 通道容量
|
|||
|
|
/// </summary>
|
|||
|
|
public int ChannelCapacity { get; set; } = 1000;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 事件去抖时间(秒)
|
|||
|
|
/// </summary>
|
|||
|
|
public int EventDebounceTimeSeconds { get; set; } = 3;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 最大字典大小
|
|||
|
|
/// </summary>
|
|||
|
|
public int MaxDictionarySize { get; set; } = 10000;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 清理间隔(秒)
|
|||
|
|
/// </summary>
|
|||
|
|
public int CleanupIntervalSeconds { get; set; } = 5;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 处理延迟(毫秒)
|
|||
|
|
/// </summary>
|
|||
|
|
public int ProcessingDelayMs { get; set; } = 5;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 健壮性相关配置
|
|||
|
|
/// </summary>
|
|||
|
|
public class RobustnessConfig
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 是否启用自动恢复机制
|
|||
|
|
/// </summary>
|
|||
|
|
public bool EnableAutoRecovery { get; set; } = true;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 监控器健康检查间隔(秒)
|
|||
|
|
/// </summary>
|
|||
|
|
public int WatcherHealthCheckIntervalSeconds { get; set; } = 30;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 监控器无响应超时时间(秒)
|
|||
|
|
/// </summary>
|
|||
|
|
public int WatcherTimeoutSeconds { get; set; } = 60;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 监控器重启尝试最大次数
|
|||
|
|
/// </summary>
|
|||
|
|
public int MaxRestartAttempts { get; set; } = 3;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 重启尝试之间的延迟(秒)
|
|||
|
|
/// </summary>
|
|||
|
|
public int RestartDelaySeconds { get; set; } = 5;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 是否启用文件锁检测
|
|||
|
|
/// </summary>
|
|||
|
|
public bool EnableFileLockDetection { get; set; } = true;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 对锁定文件的处理策略: Skip(跳过), Retry(重试), Log(仅记录)
|
|||
|
|
/// </summary>
|
|||
|
|
public string LockedFileStrategy { get; set; } = "Retry";
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 文件锁定重试次数
|
|||
|
|
/// </summary>
|
|||
|
|
public int FileLockRetryCount { get; set; } = 3;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 文件锁定重试间隔(毫秒)
|
|||
|
|
/// </summary>
|
|||
|
|
public int FileLockRetryDelayMs { get; set; } = 500;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 事件存储和回放配置
|
|||
|
|
/// </summary>
|
|||
|
|
public class EventStorageConfig
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 是否启用事件存储
|
|||
|
|
/// </summary>
|
|||
|
|
public bool EnableEventStorage { get; set; } = true;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 存储类型:SQLite 或 File
|
|||
|
|
/// </summary>
|
|||
|
|
public string StorageType { get; set; } = "SQLite";
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 事件存储目录
|
|||
|
|
/// </summary>
|
|||
|
|
public string StorageDirectory { get; set; } = "D:/EventLogs";
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// SQLite数据库文件路径
|
|||
|
|
/// </summary>
|
|||
|
|
public string DatabasePath { get; set; } = "D:/EventLogs/events.db";
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// SQLite连接字符串
|
|||
|
|
/// </summary>
|
|||
|
|
public string ConnectionString { get; set; } = "Data Source=D:/EventLogs/events.db";
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 数据库命令超时(秒)
|
|||
|
|
/// </summary>
|
|||
|
|
public int CommandTimeout { get; set; } = 30;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 事件日志文件名格式 (使用DateTime.ToString格式)
|
|||
|
|
/// </summary>
|
|||
|
|
public string LogFileNameFormat { get; set; } = "FileEvents_{0:yyyy-MM-dd}.json";
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 存储间隔(秒),多久将缓存的事件写入一次存储
|
|||
|
|
/// </summary>
|
|||
|
|
public int StorageIntervalSeconds { get; set; } = 60;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 事件批量写入大小,达到此数量时立即写入存储
|
|||
|
|
/// </summary>
|
|||
|
|
public int BatchSize { get; set; } = 100;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 最大保留事件记录条数
|
|||
|
|
/// </summary>
|
|||
|
|
public int MaxEventRecords { get; set; } = 100000;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 数据保留天数
|
|||
|
|
/// </summary>
|
|||
|
|
public int DataRetentionDays { get; set; } = 30;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 最大保留日志文件数
|
|||
|
|
/// </summary>
|
|||
|
|
public int MaxLogFiles { get; set; } = 30;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 是否压缩存储的事件日志
|
|||
|
|
/// </summary>
|
|||
|
|
public bool CompressLogFiles { get; set; } = true;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 是否可以回放事件
|
|||
|
|
/// </summary>
|
|||
|
|
public bool EnableEventReplay { get; set; } = true;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 回放时间间隔(毫秒)
|
|||
|
|
/// </summary>
|
|||
|
|
public int ReplayIntervalMs { get; set; } = 100;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 回放速度倍率,大于1加速,小于1减速
|
|||
|
|
/// </summary>
|
|||
|
|
public double ReplaySpeedFactor { get; set; } = 1.0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 日志相关配置
|
|||
|
|
/// </summary>
|
|||
|
|
public class LoggingConfig
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 日志级别:Verbose、Debug、Information、Warning、Error、Fatal
|
|||
|
|
/// </summary>
|
|||
|
|
public string LogLevel { get; set; } = "Information";
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 是否记录文件事件处理详情
|
|||
|
|
/// </summary>
|
|||
|
|
public bool LogFileEventDetails { get; set; } = false;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 日志文件保留天数
|
|||
|
|
/// </summary>
|
|||
|
|
public int RetainedLogDays { get; set; } = 30;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 日志文件目录
|
|||
|
|
/// </summary>
|
|||
|
|
public string LogDirectory { get; set; } = "Logs";
|
|||
|
|
}
|
|||
|
|
}
|