Пример #1
0
        private void Analyze(QMS_API.AgentsQmsApiService qmsAgentsQmsApi)
        {
            List <Guid> serviceIDs = qmsAgentsQmsApi.GetServices().Select(t => t.ID).ToList();

            if (serviceIDs.Count == 0)
            {
                return;
            }
            //List<ServiceInfo> qvsServices = qmsAgentsQmsApi.GetServices(ServiceTypes.QlikViewServer);
            //var abb = qmsAgentsQmsApi.GetQdsSettings(serviceIDs[2], QDSSettingsScope.General);
            List <ServiceStatus> serviceStatuses = qmsAgentsQmsApi.GetServiceStatuses(serviceIDs);


            serviceStatuses.ForEach(svc => svc.MemberStatusDetails.ForEach(msd =>
            {
                try
                {
                    //var a = qmsAgentsQmsApi.GetQdsSettings(svc.ID, QDSSettingsScope.General);
                    //if (!a.General.ShowAlerts)
                    //    return;
                    var key = $"{svc.Name}_{msd.Host}_{msd.ID}";
                    _groupedNotifyer.AddIfMissing(key, $"{svc.Name} service down on {msd.Host}", "");
                    _groupedNotifyer.Analyze(key, (int)msd.Status);
                }
                catch (Exception ex)
                {
                    Log.To.Main.AddException("Failed QmsMonitor analyze", ex);
                }
            }));
            _groupedNotifyer.AnalyzeRoundFinished();
        }
Пример #2
0
        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");
            }
        }