private List <MaxPerformanceCounterDataViewModel> GetLastCounterValueViolatesThreshold(string counter , Func <MaxPerformanceCounterData, bool> validator, DateTime dateTimeAfter) { var monitoringRepository = new PerformanceDataProvider(); var result = monitoringRepository.GetMaxCounterValues(counter, dateTimeAfter) .Where(validator) .ToList() .Select(Mapper.Map <MaxPerformanceCounterDataViewModel>) .ToList(); return(result); }
private ServiceOverviewViewModel GetSummary(string displayName, string service, string instance, string throughputCounter, string totalCounter) { var lookBackTime = LookBackTime(); var performanceDataProvider = new PerformanceDataProvider(); var thoughputValues = performanceDataProvider.GetCounterValues(instance, throughputCounter, service, lookBackTime); var thoughputValuesPerServer = thoughputValues.GroupBy(t => new { t.MachineName }, (key, group) => new { key.MachineName, CounterValue = group.Max(g => g.CounterValue), TimeStamp = group.Max(g => g.Timestamp) }).ToList(); var totalRequests = performanceDataProvider.GetCounterValues(instance, totalCounter, service, lookBackTime); var totalRequestsPerServer = totalRequests.GroupBy(t => new { t.MachineName }, (key, group) => new { key.MachineName, CounterValue = group.Max(g => g.CounterValue), TimeStamp = group.Max(g => g.Timestamp) }).ToList(); var maxValue = thoughputValuesPerServer.Any() ? thoughputValues.Max(l => l.CounterValue).ToString("N2") : "NO DATA"; var avgValue = thoughputValuesPerServer.Any() ? thoughputValues.Average(l => l.CounterValue).ToString("N2") : "NO DATA"; var sumTotalRequestsPerServer = totalRequestsPerServer.Any() ? totalRequestsPerServer.Sum(t => t.CounterValue).ToString("N2") : "NO DATA"; var lastNonZeroCounterValues = performanceDataProvider.GetCounterValues(instance, throughputCounter, service, 0.0m); var lastTimeItRan = lastNonZeroCounterValues.Any() ? lastNonZeroCounterValues.First().Timestamp.ToString(DataTimeFormatString) : "NO DATA"; return(new ServiceOverviewViewModel { Category = displayName, LastTimeItRan = lastTimeItRan, ThroughputMax = maxValue, ThroughputAverage = avgValue, Total = sumTotalRequestsPerServer }); }