private List <Task> GetTasksForWindows() { var taskList = new List <Task>(); if (ServiceVariables.AllowWindowsLogs) { taskList.Add(Task.Run(() => { _notify("Collecting Windows event log files.", MessageLevels.Animate, "WindowsEventLogs"); try { var ba = new WindowsEventLogs(_logger); ba.ReadEvents(ServiceVariables.StartDateForLogs, ServiceVariables.StopDateForLogs, new CollectorHelper(ServiceVariables, _logger)); //_collectorHelper.WriteContentToFile(c, "WindowsEvents"); _notify("Collected Windows event log files.", MessageLevels.Ok, "WindowsEventLogs"); } catch (Exception e) { _logger.Add("Failed collecting Windows event log files", e); _notify("Failed collecting Windows event log files.", MessageLevels.Error, "WindowsEventLogs"); } })); } if (ServiceVariables.AllowMachineInfo) { taskList.Add(Task.Run(async() => { try { _notify("Collecting machine information", MessageLevels.Animate, "MachineInfo"); var wmi = new WmiCollector(); await RunCmdLineAgents().ConfigureAwait(false); _collectorHelper.WriteContentToFile(wmi.GetValuesFromWin32Os(), "WmiWin32"); _collectorHelper.WriteContentToFile(wmi.GetHotFixes(), "HotFixes"); _collectorHelper.WriteContentToFile(wmi.GetStandardInfo(), "StdInfo"); _collectorHelper.WriteContentToFile(wmi.GetValuesFromWmiPagefile(), "PageFile"); _collectorHelper.WriteContentToFile(wmi.GetValuesFromWindowsServicesInfo(), "Services"); _collectorHelper.WriteContentToFile(wmi.GetValuesFromWindowsServicesInfo(), "WindowsServiceInfovi"); _notify("Collected machine information", MessageLevels.Ok, "MachineInfo"); } catch (Exception e) { _logger.Add("Failed collecting machine information", e); _notify("Failed collecting machine information", MessageLevels.Error, "MachineInfo"); } })); } return(taskList); }
public void CollectFromApi() { try { var collectionStatus = MessageLevels.Ok; _notify("Starting Collecting from API", MessageLevels.Animate, "ApiCollector"); using (var qmsApiService = new QMS_API.AgentsQmsApiService(_settings.QvSettings.QmsAddress)) { if (!qmsApiService.TestConnection()) { _logger.Add("Could not connect to QMS API (" + _settings.QvSettings.QmsAddress + ")!"); _notify("Failed Collecting from API", MessageLevels.Error, "ApiCollector"); return; } var services = qmsApiService.GetServices(); List <Guid> serviceIDs = services.Select(t => t.ID).ToList(); //List<ServiceInfo> qvsServices = qmsApiService.GetServices(ServiceTypes.QlikViewServer); _collectorHelper.WriteContentToFile(qmsApiService.GetServiceStatuses(serviceIDs), "QvServiceStatuses"); _collectorHelper.WriteContentToFile(services, "QvServices"); var qvServers = services.Where(p => p.Type == ServiceTypes.QlikViewServer | p.Type == ServiceTypes.QlikViewDistributionService).ToList(); _notify("Collecting Service info from API", MessageLevels.Animate, "ApiCollector"); qvServers.ForEach(p => { if (p.Type == ServiceTypes.QlikViewServer) { QVSSettings settings = null; try { settings = qmsApiService.GetQvsSettings(p.ID, QVSSettingsScope.All); _collectorHelper.WriteContentToFile(settings, $"QvsSettings_{p.Name}"); _collectorHelper.WriteContentToFile(qmsApiService.GetCalConfiguration(p.ID, CALConfigurationScope.All), $"QvsCals_{p.Name}"); _collectorHelper.WriteContentToFile(qmsApiService.GetUserDocuments(p.ID), $"QvsUserDocuments_{p.Name}"); _collectorHelper.WriteContentToFile(qmsApiService.GetQvsDocumentsAndUsers(p.ID, QueryTarget.Resource), $"QvsDocumentsAndUsers_{p.Name}"); } catch (Exception e) { _logger.Add($"Failed collecting API details from {p.Name ?? "UndefinedService"}", e); _notify($"Failed collecting details from {p.Name}", MessageLevels.Warning, "ApiCollector"); collectionStatus = MessageLevels.Warning; } _settings.QvSettings.QvLogLocations.Add(new QvLogLocation { Name = $"Qvs settings - {p.Name}", Type = QvLogLocationSource.QvsSetting, Path = settings?.Logging?.Folder ?? "Failed retrival" }); _settings.QvSettings.QvLogLocations.Add(new QvLogLocation { Name = $"Qvs Root Folder - {p.Name}", Type = QvLogLocationSource.QvsSetting, Path = settings?.Folders?.UserDocumentRootFolder ?? "Failed retrival" }); } if (p.Type == ServiceTypes.QlikViewDistributionService) { var docs = GetAllDocumentsAndFolders(qmsApiService, p); _collectorHelper.WriteContentToFile(docs, $"QvsDocumentsAndFolders_{p.Name}"); var qdsSettings = qmsApiService.GetQdsSettings(p.ID, QDSSettingsScope.All); qdsSettings.General.ClusterInfo.ForEach(clusterInfo => { var hostName = clusterInfo.Url.Host; _settings.QvSettings.QvLogLocations.Add(new QvLogLocation { Name = $"Programdata - QlikTech - {hostName}", Type = QvLogLocationSource.QdsClusterInfoUrl, Path = $"\\\\{hostName}\\c$\\ProgramData\\QlikTech" }); _settings.QvSettings.QvLogLocations.Add(new QvLogLocation { Name = $"ProgramFiles - QlikView - {hostName}", Type = QvLogLocationSource.QdsClusterInfoUrl, Path = $"\\\\{hostName}\\c$\\Program Files\\QlikView", LogCollectionType = QvLogCollectionType.SettingsOnly }); _settings.QvSettings.QvLogLocations.Add(new QvLogLocation { Name = $"CommonFiles - QlikTech - {hostName}", Type = QvLogLocationSource.QdsClusterInfoUrl, Path = $"\\\\{hostName}\\c$\\Program Files\\Common Files\\QlikTech", LogCollectionType = QvLogCollectionType.SettingsOnly }); }); _settings.QvSettings.QvLogLocations.Add(new QvLogLocation { Name = $"QDS Application DataFolder - {p.Name}", Type = QvLogLocationSource.QdsSettingsApplicationDataFolder, Path = qdsSettings.General.ApplicationDataFolder, IgnorePaths = IgnoreQdsApplicationDataFolder, LogCollectionType = QvLogCollectionType.SettingsOnly }); _collectorHelper.WriteContentToFile(qdsSettings, $"QdsSettings_{p.Name}"); } _collectorHelper.WriteContentToFile(qmsApiService.GetLicense(p.Type == ServiceTypes.QlikViewServer ? LicenseType.QlikViewServer : LicenseType.Publisher, p.ID), $"License_{p.Name}"); }); if (collectionStatus == MessageLevels.Ok) { _notify("Finished collectinging from API", MessageLevels.Ok, "ApiCollector"); } else { _notify("Finished collectinging from API but some errors where found.", MessageLevels.Warning, "ApiCollector"); } //Analyze(qmsApiService); } } catch (Exception e) { _logger.Add("Failed collecting from API", e); _notify("Failed collecting from API", MessageLevels.Error, "ApiCollector"); } }