private void GetComputerInfo(CancellationToken token) { ManagementObjectSearcher win32OSInfo = null; ManagementObjectCollection results = null; var sb = new StringBuilder(); var diskUsage = new DiskUsage(); string osName = string.Empty; string osVersion = string.Empty; int numProcs = 0; string lastBootTime = string.Empty; string installDate = string.Empty; int logicalProcessorCount = Environment.ProcessorCount; int logicalDriveCount = 0; int activePorts = 0; int activeEphemeralPorts = 0; int totalVirtMem = 0; string fabricAppPortRange = string.Empty; string osLang = string.Empty; double freePhysicalMem = 0; double freeVirtualMem = 0; try { win32OSInfo = new ManagementObjectSearcher("SELECT Caption,Version,Status,OSLanguage,NumberOfProcesses,FreePhysicalMemory,FreeVirtualMemory,TotalVirtualMemorySize,TotalVisibleMemorySize,InstallDate,LastBootUpTime FROM Win32_OperatingSystem"); results = win32OSInfo.Get(); foreach (var prop in results) { token.ThrowIfCancellationRequested(); foreach (var p in prop.Properties) { token.ThrowIfCancellationRequested(); string name = p.Name; string value = p.Value.ToString(); if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value)) { continue; } if (name.ToLower() == "caption") { osName = value; } else if (name.ToLower() == "numberofprocesses") { // Number of running processes _ = int.TryParse(value, out numProcs); } else if (name.ToLower() == "status") { this.osStatus = value; } else if (name.ToLower() == "oslanguage") { osLang = value; } else if (name.ToLower() == "version") { osVersion = value; } else if (name.ToLower().Contains("bootuptime")) { value = ManagementDateTimeConverter.ToDateTime(value).ToUniversalTime().ToString("o"); lastBootTime = value; } else if (name.ToLower().Contains("date")) { value = ManagementDateTimeConverter.ToDateTime(value).ToUniversalTime().ToString("o"); installDate = value; } else if (name.ToLower().Contains("memory")) { // For output. int i = int.Parse(value) / 1024 / 1024; // TotalVisible only needs to be set once. if (name.ToLower().Contains("totalvisible")) { this.totalVisibleMemoryGB = i; } else if (name.ToLower().Contains("totalvirtual")) { totalVirtMem = i; } else if (name.ToLower().Contains("freephysical")) { _ = double.TryParse(value, out freePhysicalMem); } else if (name.ToLower().Contains("freevirtual")) { _ = double.TryParse(value, out freeVirtualMem); } } } } // Active, bound ports. activePorts = NetworkUsage.GetActivePortCount(); // Active, ephemeral ports. activeEphemeralPorts = NetworkUsage.GetActiveEphemeralPortCount(); var dynamicPortRange = NetworkUsage.TupleGetDynamicPortRange(); string clusterManifestXml = null; string osEphemeralPortRange = string.Empty; fabricAppPortRange = string.Empty; if (this.IsTestRun) { clusterManifestXml = File.ReadAllText(this.TestManifestPath); } else { clusterManifestXml = this.FabricClientInstance.ClusterManager.GetClusterManifestAsync(this.AsyncClusterOperationTimeoutSeconds, this.Token).GetAwaiter().GetResult(); } var appPortRange = NetworkUsage.TupleGetFabricApplicationPortRangeForNodeType(this.FabricServiceContext.NodeContext.NodeType, clusterManifestXml); int firewalls = NetworkUsage.GetActiveFirewallRulesCount(); // OS info. sb.AppendLine("OS Information:\r\n"); sb.AppendLine($"Name: {osName}"); sb.AppendLine($"Version: {osVersion}"); sb.AppendLine($"InstallDate: {installDate}"); sb.AppendLine($"LastBootUpTime*: {lastBootTime}"); sb.AppendLine($"OSLanguage: {osLang}"); sb.AppendLine($"OSHealthStatus*: {this.osStatus}"); sb.AppendLine($"NumberOfProcesses*: {numProcs}"); if (dynamicPortRange.Item1 > -1) { osEphemeralPortRange = $"{dynamicPortRange.Item1} - {dynamicPortRange.Item2}"; sb.AppendLine($"WindowsEphemeralTCPPortRange: {osEphemeralPortRange} (Active*: {activeEphemeralPorts})"); } if (appPortRange.Item1 > -1) { fabricAppPortRange = $"{appPortRange.Item1} - {appPortRange.Item2}"; sb.AppendLine($"FabricApplicationTCPPortRange: {fabricAppPortRange}"); } if (firewalls > -1) { sb.AppendLine($"ActiveFirewallRules*: {firewalls}"); } if (activePorts > -1) { sb.AppendLine($"TotalActiveTCPPorts*: {activePorts}"); } // Hardware info. // Proc/Mem sb.AppendLine("\r\nHardware Information:\r\n"); sb.AppendLine($"LogicalProcessorCount: {logicalProcessorCount}"); sb.AppendLine($"TotalVirtualMemorySize: {totalVirtMem} GB"); sb.AppendLine($"TotalVisibleMemorySize: {this.totalVisibleMemoryGB} GB"); sb.AppendLine($"FreePhysicalMemory*: {Math.Round(freePhysicalMem / 1024 / 1024, 2)} GB"); sb.AppendLine($"FreeVirtualMemory*: {Math.Round(freeVirtualMem / 1024 / 1024, 2)} GB"); // Disk var drivesInformation = diskUsage.GetCurrentDiskSpaceTotalAndUsedPercentAllDrives(SizeUnit.Gigabytes); logicalDriveCount = drivesInformation.Count; sb.AppendLine($"LogicalDriveCount: {logicalDriveCount}"); foreach (var tuple in drivesInformation) { string systemDrv = "Data"; if (Environment.SystemDirectory.Substring(0, 1) == tuple.Item1) { systemDrv = "System"; } sb.AppendLine($"Drive {tuple.Item1} ({systemDrv}) Size: {tuple.Item2} GB"); sb.AppendLine($"Drive {tuple.Item1} ({systemDrv}) Consumed*: {tuple.Item3}%"); } string osHotFixes = GetWindowsHotFixes(token); if (!string.IsNullOrEmpty(osHotFixes)) { sb.AppendLine($"\nWindows Patches/Hot Fixes*:\n\n{osHotFixes}"); } // Dynamic info qualifier (*) sb.AppendLine($"\n* Dynamic data."); this.osReport = sb.ToString(); // ETW. if (this.IsEtwEnabled) { Logger.EtwLogger?.Write( $"FabricObserverDataEvent", new { Level = 0, // Info Node = this.NodeName, Observer = this.ObserverName, OS = osName, OSVersion = osVersion, OSInstallDate = installDate, LastBootUpTime = lastBootTime, TotalMemorySizeGB = this.totalVisibleMemoryGB, LogicalProcessorCount = logicalProcessorCount, LogicalDriveCount = logicalDriveCount, NumberOfRunningProcesses = numProcs, ActiveFirewallRules = firewalls, ActivePorts = activePorts, ActiveEphemeralPorts = activeEphemeralPorts, WindowsDynamicPortRange = osEphemeralPortRange, FabricAppPortRange = fabricAppPortRange, HotFixes = GetWindowsHotFixes(token, false).Replace("\r\n", ", ").TrimEnd(','), }); } } catch (ManagementException) { } catch (Exception e) { this.HealthReporter.ReportFabricObserverServiceHealth( this.FabricServiceContext.ServiceName.OriginalString, this.ObserverName, HealthState.Error, $"Unhandled exception processing OS information: {e.Message}: \n {e.StackTrace}"); throw; } finally { results?.Dispose(); win32OSInfo?.Dispose(); diskUsage?.Dispose(); sb.Clear(); } }
private async Task GetComputerInfoAsync(CancellationToken token) { var sb = new StringBuilder(); int logicalProcessorCount = Environment.ProcessorCount; try { OSInfo osInfo = await OperatingSystemInfoProvider.Instance.GetOSInfoAsync(token); this.osStatus = osInfo.Status; // Active, bound ports. int activePorts = OperatingSystemInfoProvider.Instance.GetActivePortCount(); // Active, ephemeral ports. int activeEphemeralPorts = OperatingSystemInfoProvider.Instance.GetActiveEphemeralPortCount(); (int lowPortOS, int highPortOS) = OperatingSystemInfoProvider.Instance.TupleGetDynamicPortRange(); string osEphemeralPortRange = string.Empty; string fabricAppPortRange = string.Empty; string clusterManifestXml = IsTestRun ? File.ReadAllText( TestManifestPath) : await FabricClientInstance.ClusterManager.GetClusterManifestAsync( AsyncClusterOperationTimeoutSeconds, Token).ConfigureAwait(false); (int lowPortApp, int highPortApp) = NetworkUsage.TupleGetFabricApplicationPortRangeForNodeType( FabricServiceContext.NodeContext.NodeType, clusterManifestXml); int firewalls = NetworkUsage.GetActiveFirewallRulesCount(); // OS info. _ = sb.AppendLine("OS Information:\r\n"); _ = sb.AppendLine($"Name: {osInfo.Name}"); _ = sb.AppendLine($"Version: {osInfo.Version}"); if (string.IsNullOrEmpty(osInfo.InstallDate)) { _ = sb.AppendLine($"InstallDate: {osInfo.InstallDate}"); } _ = sb.AppendLine($"LastBootUpTime*: {osInfo.LastBootUpTime}"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // WU AutoUpdate - Download enabled. // If the config setting EnableWindowsAutoUpdateCheck is set to false, then don't add this info to sb. if (this.isWUADSettingEnabled) { string auMessage = "WindowsUpdateAutoDownloadEnabled: "; if (this.auStateUnknown) { auMessage += "Unknown"; } else { auMessage += this.isWindowsUpdateAutoDownloadEnabled; } _ = sb.AppendLine(auMessage); } // Not supported for Linux. _ = sb.AppendLine($"OSLanguage: {osInfo.Language}"); _ = sb.AppendLine($"OSHealthStatus*: {osInfo.Status}"); } _ = sb.AppendLine($"NumberOfProcesses*: {osInfo.NumberOfProcesses}"); if (lowPortOS > -1) { osEphemeralPortRange = $"{lowPortOS} - {highPortOS}"; _ = sb.AppendLine($"OSEphemeralTCPPortRange: {osEphemeralPortRange} (Active*: {activeEphemeralPorts})"); } if (lowPortApp > -1) { fabricAppPortRange = $"{lowPortApp} - {highPortApp}"; _ = sb.AppendLine($"FabricApplicationTCPPortRange: {fabricAppPortRange}"); } if (firewalls > -1) { _ = sb.AppendLine($"ActiveFirewallRules*: {firewalls}"); } if (activePorts > -1) { _ = sb.AppendLine($"TotalActiveTCPPorts*: {activePorts}"); } // Hardware info. // Proc/Mem _ = sb.AppendLine($"{Environment.NewLine}Hardware Information:{Environment.NewLine}"); _ = sb.AppendLine($"LogicalProcessorCount: {logicalProcessorCount}"); if (osInfo.TotalVirtualMemorySizeKB > 0) { _ = sb.AppendLine($"TotalVirtualMemorySize: {osInfo.TotalVirtualMemorySizeKB / 1048576} GB"); } if (osInfo.TotalVisibleMemorySizeKB > 0) { _ = sb.AppendLine($"TotalVisibleMemorySize: {osInfo.TotalVisibleMemorySizeKB / 1048576} GB"); } _ = sb.AppendLine($"FreePhysicalMemory*: {Math.Round(osInfo.AvailableMemoryKB / 1048576.0, 2)} GB"); _ = sb.AppendLine($"FreeVirtualMemory*: {Math.Round(osInfo.FreeVirtualMemoryKB / 1048576.0, 2)} GB"); // Disk var drivesInformationTuple = DiskUsage.GetCurrentDiskSpaceTotalAndUsedPercentAllDrives(SizeUnit.Gigabytes); var logicalDriveCount = drivesInformationTuple.Count; string driveInfo = string.Empty; _ = sb.AppendLine($"LogicalDriveCount: {logicalDriveCount}"); foreach (var(driveName, diskSize, percentConsumed) in drivesInformationTuple) { string drvSize; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { string systemDrv = "Data"; if (string.Equals(Environment.SystemDirectory.Substring(0, 1), driveName.Substring(0, 1), StringComparison.OrdinalIgnoreCase)) { systemDrv = "System"; } drvSize = $"Drive {driveName} ({systemDrv}) Size: {diskSize} GB, Consumed*: {percentConsumed}%"; } else { drvSize = $"Mount point: {driveName}, Size: {diskSize} GB, Consumed*: {percentConsumed}%"; } _ = sb.AppendLine(drvSize); driveInfo += $"{drvSize}{Environment.NewLine}"; } string osHotFixes = string.Empty; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { osHotFixes = GetWindowsHotFixes(token); } if (!string.IsNullOrEmpty(osHotFixes)) { _ = sb.AppendLine($"\nWindows Patches/Hot Fixes*:\n\n{osHotFixes}"); } // Dynamic info qualifier (*) _ = sb.AppendLine($"\n* Dynamic data."); this.osReport = sb.ToString(); string hotFixes = string.Empty; // ETW. if (IsEtwEnabled) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { hotFixes = GetWindowsHotFixes(token, generateUrl: false).Replace("\r\n", ", ").TrimEnd(','); } Logger.EtwLogger?.Write( ObserverConstants.FabricObserverETWEventName, new { HealthState = "Ok", Node = NodeName, Observer = ObserverName, OS = osInfo.Name, OSVersion = osInfo.Version, OSInstallDate = osInfo.InstallDate, AutoUpdateEnabled = this.auStateUnknown ? "Unknown" : this.isWindowsUpdateAutoDownloadEnabled.ToString(), osInfo.LastBootUpTime, WindowsAutoUpdateEnabled = this.isWindowsUpdateAutoDownloadEnabled, TotalMemorySizeGB = (int)(osInfo.TotalVisibleMemorySizeKB / 1048576), AvailablePhysicalMemoryGB = Math.Round(osInfo.FreePhysicalMemoryKB / 1048576.0, 2), AvailableVirtualMemoryGB = Math.Round(osInfo.FreeVirtualMemoryKB / 1048576.0, 2), LogicalProcessorCount = logicalProcessorCount, LogicalDriveCount = logicalDriveCount, DriveInfo = driveInfo, NumberOfRunningProcesses = osInfo.NumberOfProcesses, ActiveFirewallRules = firewalls, ActivePorts = activePorts, ActiveEphemeralPorts = activeEphemeralPorts, WindowsDynamicPortRange = osEphemeralPortRange, FabricAppPortRange = fabricAppPortRange, HotFixes = hotFixes, }); } // Telemetry if (IsTelemetryProviderEnabled && IsObserverTelemetryEnabled) { if (string.IsNullOrEmpty(hotFixes) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { hotFixes = GetWindowsHotFixes(token, generateUrl: false).Replace("\r\n", ", ").TrimEnd(','); } TelemetryClient?.ReportMetricAsync( new MachineTelemetryData { HealthState = "Ok", Node = NodeName, Observer = ObserverName, OS = osInfo.Name, OSVersion = osInfo.Version, OSInstallDate = osInfo.InstallDate, LastBootUpTime = osInfo.LastBootUpTime, WindowsUpdateAutoDownloadEnabled = this.isWindowsUpdateAutoDownloadEnabled, TotalMemorySizeGB = (int)osInfo.TotalVisibleMemorySizeKB / 1048576, AvailablePhysicalMemoryGB = Math.Round(osInfo.FreePhysicalMemoryKB / 1048576.0, 2), AvailableVirtualMemoryGB = Math.Round(osInfo.FreeVirtualMemoryKB / 1048576.0, 2), LogicalProcessorCount = logicalProcessorCount, LogicalDriveCount = logicalDriveCount, DriveInfo = driveInfo, NumberOfRunningProcesses = osInfo.NumberOfProcesses, ActiveFirewallRules = firewalls, ActivePorts = activePorts, ActiveEphemeralPorts = activeEphemeralPorts, WindowsDynamicPortRange = osEphemeralPortRange, FabricAppPortRange = fabricAppPortRange, HotFixes = hotFixes, }, Token); } } catch (Exception e) when(e is FabricException || e is OperationCanceledException || e is TaskCanceledException || e is InvalidComObjectException) { HealthReporter.ReportFabricObserverServiceHealth( FabricServiceContext.ServiceName.OriginalString, ObserverName, HealthState.Warning, $"Handled Exception processing OS information:{Environment.NewLine}{e}"); } catch (Exception e) { HealthReporter.ReportFabricObserverServiceHealth( FabricServiceContext.ServiceName.OriginalString, ObserverName, HealthState.Error, $"Unhandled Exception processing OS information:{Environment.NewLine}{e}"); throw; } }
private async Task GetComputerInfoAsync(CancellationToken token) { ManagementObjectSearcher win32OsInfo = null; ManagementObjectCollection results = null; var sb = new StringBuilder(); var diskUsage = new DiskUsage(); string osName = string.Empty; string osVersion = string.Empty; int numProcs = 0; string lastBootTime = string.Empty; string installDate = string.Empty; int logicalProcessorCount = Environment.ProcessorCount; int totalVirtualMem = 0; string osLang = string.Empty; double freePhysicalMem = 0; double freeVirtualMem = 0; try { win32OsInfo = new ManagementObjectSearcher("SELECT Caption,Version,Status,OSLanguage,NumberOfProcesses,FreePhysicalMemory,FreeVirtualMemory,TotalVirtualMemorySize,TotalVisibleMemorySize,InstallDate,LastBootUpTime FROM Win32_OperatingSystem"); results = win32OsInfo.Get(); foreach (var prop in results) { token.ThrowIfCancellationRequested(); foreach (var p in prop.Properties) { token.ThrowIfCancellationRequested(); string name = p.Name; string value = p.Value.ToString(); if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value)) { continue; } switch (name.ToLower()) { case "caption": osName = value; break; case "numberofprocesses": _ = int.TryParse(value, out numProcs); break; case "status": this.osStatus = value; break; case "oslanguage": osLang = value; break; case "version": osVersion = value; break; default: { if (name.ToLower().Contains("bootuptime")) { value = ManagementDateTimeConverter.ToDateTime(value).ToUniversalTime().ToString("o"); lastBootTime = value; } else if (name.ToLower().Contains("date")) { value = ManagementDateTimeConverter.ToDateTime(value).ToUniversalTime().ToString("o"); installDate = value; } else if (name.ToLower().Contains("memory")) { // For output. int i = int.Parse(value) / 1024 / 1024; // TotalVisible only needs to be set once. if (name.ToLower().Contains("totalvisible")) { this.totalVisibleMemoryGb = i; } else if (name.ToLower().Contains("totalvirtual")) { totalVirtualMem = i; } else if (name.ToLower().Contains("freephysical")) { _ = double.TryParse(value, out freePhysicalMem); } else if (name.ToLower().Contains("freevirtual")) { _ = double.TryParse(value, out freeVirtualMem); } } break; } } } } // Active, bound ports. var activePorts = NetworkUsage.GetActivePortCount(); // Active, ephemeral ports. var activeEphemeralPorts = NetworkUsage.GetActiveEphemeralPortCount(); var(lowPortOs, highPortOs) = NetworkUsage.TupleGetDynamicPortRange(); string osEphemeralPortRange = string.Empty; var fabricAppPortRange = string.Empty; var clusterManifestXml = this.IsTestRun ? File.ReadAllText( this.TestManifestPath) : await this.FabricClientInstance.ClusterManager.GetClusterManifestAsync( this.AsyncClusterOperationTimeoutSeconds, this.Token).ConfigureAwait(false); var(lowPortApp, highPortApp) = NetworkUsage.TupleGetFabricApplicationPortRangeForNodeType( this.FabricServiceContext.NodeContext.NodeType, clusterManifestXml); int firewalls = NetworkUsage.GetActiveFirewallRulesCount(); // WU AutoUpdate string auMessage = "WindowsUpdateAutoDownloadEnabled: "; if (this.auStateUnknown) { auMessage += "Unknown"; } else { auMessage += this.isWindowsUpdateAutoDownloadEnabled; } // OS info. _ = sb.AppendLine("OS Information:\r\n"); _ = sb.AppendLine($"Name: {osName}"); _ = sb.AppendLine($"Version: {osVersion}"); _ = sb.AppendLine($"InstallDate: {installDate}"); _ = sb.AppendLine($"LastBootUpTime*: {lastBootTime}"); _ = sb.AppendLine(auMessage); _ = sb.AppendLine($"OSLanguage: {osLang}"); _ = sb.AppendLine($"OSHealthStatus*: {this.osStatus}"); _ = sb.AppendLine($"NumberOfProcesses*: {numProcs}"); if (lowPortOs > -1) { osEphemeralPortRange = $"{lowPortOs} - {highPortOs}"; _ = sb.AppendLine($"WindowsEphemeralTCPPortRange: {osEphemeralPortRange} (Active*: {activeEphemeralPorts})"); } if (lowPortApp > -1) { fabricAppPortRange = $"{lowPortApp} - {highPortApp}"; _ = sb.AppendLine($"FabricApplicationTCPPortRange: {fabricAppPortRange}"); } if (firewalls > -1) { _ = sb.AppendLine($"ActiveFirewallRules*: {firewalls}"); } if (activePorts > -1) { _ = sb.AppendLine($"TotalActiveTCPPorts*: {activePorts}"); } // Hardware info. // Proc/Mem _ = sb.AppendLine($"{Environment.NewLine}Hardware Information:{Environment.NewLine}"); _ = sb.AppendLine($"LogicalProcessorCount: {logicalProcessorCount}"); _ = sb.AppendLine($"TotalVirtualMemorySize: {totalVirtualMem} GB"); _ = sb.AppendLine($"TotalVisibleMemorySize: {this.totalVisibleMemoryGb} GB"); _ = sb.AppendLine($"FreePhysicalMemory*: {Math.Round(freePhysicalMem / 1024 / 1024, 2)} GB"); _ = sb.AppendLine($"FreeVirtualMemory*: {Math.Round(freeVirtualMem / 1024 / 1024, 2)} GB"); // Disk var drivesInformationTuple = diskUsage.GetCurrentDiskSpaceTotalAndUsedPercentAllDrives(SizeUnit.Gigabytes); var logicalDriveCount = drivesInformationTuple.Count; string driveInfo = string.Empty; _ = sb.AppendLine($"LogicalDriveCount: {logicalDriveCount}"); foreach (var(driveName, diskSize, percentConsumed) in drivesInformationTuple) { string systemDrv = "Data"; if (Environment.SystemDirectory.Substring(0, 1) == driveName) { systemDrv = "System"; } string drvSize = $"Drive {driveName} ({systemDrv}) Size: {diskSize} GB"; string drvConsumed = $"Drive {driveName} ({systemDrv}) Consumed*: {percentConsumed}%"; _ = sb.AppendLine(drvSize); _ = sb.AppendLine(drvConsumed); driveInfo += $"{drvSize}{Environment.NewLine}{drvConsumed}{Environment.NewLine}"; } string osHotFixes = GetWindowsHotFixes(token); if (!string.IsNullOrEmpty(osHotFixes)) { _ = sb.AppendLine($"\nWindows Patches/Hot Fixes*:\n\n{osHotFixes}"); } // Dynamic info qualifier (*) _ = sb.AppendLine($"\n* Dynamic data."); this.osReport = sb.ToString(); // ETW. if (this.IsEtwEnabled) { Logger.EtwLogger?.Write( ObserverConstants.FabricObserverETWEventName, new { HealthState = "Ok", Node = this.NodeName, Observer = this.ObserverName, OS = osName, OSVersion = osVersion, OSInstallDate = installDate, AutoUpdateEnabled = this.auStateUnknown ? "Unknown" : this.isWindowsUpdateAutoDownloadEnabled.ToString(), LastBootUpTime = lastBootTime, WindowsAutoUpdateEnabled = this.isWindowsUpdateAutoDownloadEnabled, TotalMemorySizeGB = this.totalVisibleMemoryGb, AvailablePhysicalMemoryGB = Math.Round(freePhysicalMem / 1024 / 1024, 2), AvailableVirtualMemoryGB = Math.Round(freeVirtualMem / 1024 / 1024, 2), LogicalProcessorCount = logicalProcessorCount, LogicalDriveCount = logicalDriveCount, DriveInfo = driveInfo, NumberOfRunningProcesses = numProcs, ActiveFirewallRules = firewalls, ActivePorts = activePorts, ActiveEphemeralPorts = activeEphemeralPorts, WindowsDynamicPortRange = osEphemeralPortRange, FabricAppPortRange = fabricAppPortRange, HotFixes = GetWindowsHotFixes(token, false).Replace("\r\n", ", ").TrimEnd(','), }); } // Telemetry if (this.IsTelemetryProviderEnabled && this.IsObserverTelemetryEnabled) { this.TelemetryClient?.ReportMetricAsync( new MachineTelemetryData { HealthState = "Ok", Node = this.NodeName, Observer = this.ObserverName, OS = osName, OSVersion = osVersion, OSInstallDate = installDate, LastBootUpTime = lastBootTime, WindowsUpdateAutoDownloadEnabled = this.isWindowsUpdateAutoDownloadEnabled, TotalMemorySizeGB = this.totalVisibleMemoryGb, AvailablePhysicalMemoryGB = Math.Round(freePhysicalMem / 1024 / 1024, 2), AvailableVirtualMemoryGB = Math.Round(freeVirtualMem / 1024 / 1024, 2), LogicalProcessorCount = logicalProcessorCount, LogicalDriveCount = logicalDriveCount, DriveInfo = driveInfo, NumberOfRunningProcesses = numProcs, ActiveFirewallRules = firewalls, ActivePorts = activePorts, ActiveEphemeralPorts = activeEphemeralPorts, WindowsDynamicPortRange = osEphemeralPortRange, FabricAppPortRange = fabricAppPortRange, HotFixes = GetWindowsHotFixes(token, false).Replace("\r\n", ", ").TrimEnd(','), }, this.Token); } } catch (ManagementException) { } catch (Exception e) { this.HealthReporter.ReportFabricObserverServiceHealth( this.FabricServiceContext.ServiceName.OriginalString, this.ObserverName, HealthState.Error, $"Unhandled exception processing OS information:{Environment.NewLine}{e}"); throw; } finally { results?.Dispose(); win32OsInfo?.Dispose(); diskUsage?.Dispose(); _ = sb.Clear(); } }