private MonitorServerComponentState CalculatedConsolidatedServerComponentState(HealthReportHelper.ServerComponentStateStatistics stats) { MonitorServerComponentState result = MonitorServerComponentState.Unknown; if (stats.TotalCount == stats.UnknownCount) { result = MonitorServerComponentState.Unknown; } else if (stats.TotalCount == stats.NotApplicableCount + stats.UnknownCount) { result = MonitorServerComponentState.NotApplicable; } else if (stats.TotalCount == stats.OnlineCount) { result = MonitorServerComponentState.Online; } else if (stats.TotalCount == stats.PartiallyOnlineCount) { result = MonitorServerComponentState.PartiallyOnline; } else if (stats.TotalCount == stats.OfflineCount) { result = MonitorServerComponentState.Offline; } else if (stats.TotalCount == stats.FunctionalCount) { result = MonitorServerComponentState.Functional; } else if (stats.TotalCount == stats.SidelinedCount) { result = MonitorServerComponentState.Sidelined; } else if (stats.OnlineCount > 0 || stats.OfflineCount > 0 || stats.PartiallyOnlineCount > 0) { int totalCount = stats.TotalCount; if (this.GroupSize > 0) { totalCount = this.GroupSize; } int num = totalCount * this.MinimumOnlinePercent / 100; if (num < 1) { num = 1; } if (stats.OnlineCount + stats.PartiallyOnlineCount >= num) { result = MonitorServerComponentState.PartiallyOnline; } else { result = MonitorServerComponentState.Offline; } } return(result); }
internal void ProcessHealth(Action <ConsolidatedHealth> action) { int num = 0; foreach (KeyValuePair <string, Dictionary <string, List <MonitorHealthEntry> > > keyValuePair in this.serverHealthMap) { Dictionary <string, List <MonitorHealthEntry> > value = keyValuePair.Value; if (value != null) { num += value.Count; } } foreach (KeyValuePair <string, Dictionary <string, List <MonitorHealthEntry> > > keyValuePair2 in this.serverHealthMap) { string key = keyValuePair2.Key; Dictionary <string, List <MonitorHealthEntry> > value2 = keyValuePair2.Value; foreach (KeyValuePair <string, List <MonitorHealthEntry> > keyValuePair3 in value2) { string key2 = keyValuePair3.Key; List <MonitorHealthEntry> value3 = keyValuePair3.Value; string healthGroup = null; MonitorServerComponentState state = MonitorServerComponentState.Unknown; if (value3 != null && value3.Count > 0) { MonitorHealthEntry monitorHealthEntry = value3.First <MonitorHealthEntry>(); if (monitorHealthEntry != null) { healthGroup = monitorHealthEntry.HealthGroupName; state = monitorHealthEntry.CurrentHealthSetState; } } int monitorCount = 0; int haImpactingMonitorCount = 0; if (value3 != null) { monitorCount = value3.Count <MonitorHealthEntry>(); haImpactingMonitorCount = value3.Count((MonitorHealthEntry che) => che.IsHaImpacting); } HealthReportHelper.HealthSetStatistics healthSetStats = this.GetHealthSetStats(value3); MonitorAlertState alertValue = this.CalculatedConsolidatedHealthSetAlertValue(healthSetStats); DateTime lastTransitionTime = healthSetStats.LastTransitionTime; ConsolidatedHealth obj = new ConsolidatedHealth(key, key2, healthGroup, alertValue, state, monitorCount, haImpactingMonitorCount, lastTransitionTime, value3); action(obj); } } }
internal ConsolidatedHealth ConsolidateAcrossServers(Dictionary <string, ConsolidatedHealth> serverHealthMap) { HealthReportHelper.HealthSetStatistics healthSetStatistics = new HealthReportHelper.HealthSetStatistics(); int num = 0; int num2 = 0; Dictionary <string, ConsolidatedHealth> .ValueCollection values = serverHealthMap.Values; string text = null; string healthGroup = null; List <ConsolidatedHealth> list = new List <ConsolidatedHealth>(); Dictionary <string, ConsolidatedHealth> .ValueCollection values2 = serverHealthMap.Values; int num3 = values2.Count((ConsolidatedHealth health) => health == null); if (num3 > 0) { ConsolidatedHealth consolidatedHealth = serverHealthMap.Values.First((ConsolidatedHealth health) => health != null); if (consolidatedHealth != null) { Dictionary <string, ConsolidatedHealth> dictionary = new Dictionary <string, ConsolidatedHealth>(); foreach (KeyValuePair <string, ConsolidatedHealth> keyValuePair in serverHealthMap) { string key = keyValuePair.Key; if (keyValuePair.Value == null) { ConsolidatedHealth value = new ConsolidatedHealth(key, consolidatedHealth.HealthSet, consolidatedHealth.HealthGroup); dictionary[key] = value; } } foreach (KeyValuePair <string, ConsolidatedHealth> keyValuePair2 in dictionary) { serverHealthMap[keyValuePair2.Key] = keyValuePair2.Value; } } } foreach (ConsolidatedHealth consolidatedHealth2 in values) { if (consolidatedHealth2 != null) { this.UpdateHealthStats(healthSetStatistics, consolidatedHealth2.AlertValue, consolidatedHealth2.LastTransitionTime); if (string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(consolidatedHealth2.HealthSet)) { text = consolidatedHealth2.HealthSet; healthGroup = consolidatedHealth2.HealthGroup; } num += consolidatedHealth2.MonitorCount; num2 += consolidatedHealth2.HaImpactingMonitorCount; list.Add(consolidatedHealth2); } else { this.UpdateHealthStats(healthSetStatistics, MonitorAlertState.Unknown, DateTime.MinValue); } } if (string.IsNullOrEmpty(text)) { text = "Unknown"; healthGroup = "Unknown"; } MonitorAlertState alertValue = this.CalculatedConsolidatedHealthSetAlertValue(healthSetStatistics); DateTime lastTransitionTime = healthSetStatistics.LastTransitionTime; int haImpactingMonitorCount = num2; HealthReportHelper.ServerComponentStateStatistics serverComponentStats = this.GetServerComponentStats(serverHealthMap.Values); MonitorServerComponentState state = this.CalculatedConsolidatedServerComponentState(serverComponentStats); return(new ConsolidatedHealth(text, healthGroup, alertValue, state, num, haImpactingMonitorCount, lastTransitionTime, list)); }