public static async Task LogThresholdReached(CpuUsageServer cpuUsageServer, IBaseServerEventLogger serverEventLogger) { var server = cpuUsageServer.Server; var usageInPercentage = cpuUsageServer.AverageCpuUsagePastMinute.ToString("#.#"); await serverEventLogger.LogEvent( $@"CPU threshold reached for {server.Name} server", $@"{server.Name} server reached CPU usage threshold. Current CPU usage is {usageInPercentage}%", EventType.CPUUsageThresholdReached, server ); }
private async Task CPUEventLoggerChecker(CpuUsageServer cpuUsage) { var notificationThreshold = await _unitOfWork.NotificationThresholds.Get( q => q.ServerId == cpuUsage.ServerId ); if (notificationThreshold == null) { return; } if (notificationThreshold.CpuUsageThresholdInPercentage <= cpuUsage.AverageCpuUsagePastMinute) { await CPUServerEventLogger.LogThresholdReached(cpuUsage, _baseServerEventLogger); } }