public string NormalizeAndValidateMetadata(string metadataValue, string metadataField, string vendorName) { if (metadataValue == null) { return(null); } var normalizedValue = NormalizeString(metadataValue); if (normalizedValue.IsEmpty()) { return(null); } if (!IsValidMetadata(normalizedValue)) { Log.InfoFormat("Unable to validate {0} metadata for the {1} field.", vendorName, metadataField); switch (vendorName) { case AwsName: _agentHealthReporter.ReportAwsUtilizationError(); break; case AzureName: _agentHealthReporter.ReportAzureUtilizationError(); break; case GcpName: _agentHealthReporter.ReportGcpUtilizationError(); break; case PcfName: _agentHealthReporter.ReportPcfUtilizationError(); break; case DockerName: _agentHealthReporter.ReportBootIdError(); break; case KubernetesName: _agentHealthReporter.ReportKubernetesUtilizationError(); break; } return(null); } return(normalizedValue); }
public UtilizationSettingsModel GetUtilizationSettings() { var totalMemory = _systemInfo.GetTotalPhysicalMemoryBytes(); var logicalProcessors = _systemInfo.GetTotalLogicalProcessors(); var hostname = _configuration.UtilizationHostName; var fullHostName = _configuration.UtilizationFullHostName; var ipAddress = _dnsStatic.GetIpAddresses(); var vendors = GetVendorSettings(); var bootIdResult = _systemInfo.GetBootId(); if (!bootIdResult.IsValid) { Log.Warn("boot_id is not in expected format."); _agentHealthReporter.ReportBootIdError(); } //if bootId is longer than 128 characters, truncate it to 128 characters. var bootId = Truncate(bootIdResult.BootId, MaxBootIdLength); return(new UtilizationSettingsModel(logicalProcessors, totalMemory, hostname, fullHostName, ipAddress, bootId, vendors, GetUtilitizationConfig())); }