public void TestLoadConfigFile() { PaletteInsightConfiguration config = Loader.LoadConfigFile("config/Config.yml"); Assert.AreEqual(true, config.UseRepoPolling); Assert.AreEqual("http://localhost:9000", config.Webservice.Endpoint); }
/// <summary> /// Adds the log folders from either the config (if no tableau server is installed), /// or from the registry /// </summary> /// <param name="config"></param> /// <param name="options"></param> /// <param name="tableauRoot"></param> private static void AddLogFoldersToOptions(PaletteInsightConfiguration config, PaletteInsightAgentOptions options, string tableauRoot) { // check and load the log folder paths from the config file, so // the folders listed in there will be definitely watched if (config.Logs != null) { foreach (LogFolder logFolder in config.Logs) { AddFolderToWatched(options.LogFolders, PaletteInsightAgentOptions.LogFolderInfo.Create(logFolder.Directory, logFolder.Filter, logFolder.Format)); } } if (tableauRoot != null) { // otherwise try to add the log folders from the registry setup foreach (var logFolder in LoadDefaultLogFolders()) { var fullPath = Path.GetFullPath(Path.Combine(tableauRoot, logFolder.Directory)); // we check here so we won't add non-existent folders if (!Directory.Exists(fullPath)) { Log.Error("Log folder not found: {0}", fullPath); continue; } AddFolderToWatched(options.LogFolders, PaletteInsightAgentOptions.LogFolderInfo.Create(fullPath, logFolder.Filter, logFolder.Format)); } } }
private static void LoadRepositoryFromConfig(PaletteInsightConfiguration config, PaletteInsightAgentOptions options) { if (!options.UseRepoPolling && !options.UseStreamingTables) { return; } // load the tableau repo properties var repoProps = config.TableauRepo; if (repoProps == null) { // Repository credentials are not filled in Config.yml return; } try { options.RepositoryDatabase = new DbConnectionInfo { Server = repoProps.Host, Port = Convert.ToInt32(repoProps.Port), Username = repoProps.User, Password = repoProps.Password, DatabaseName = repoProps.Database }; Log.Info("Found Tableau repo credentials in Config.yml."); } catch (Exception e) { Log.Error(e, "Failed to parse Tableau repository configs! Error:"); } }
/// <summary> /// Add the tableau repo database details to the options. /// </summary> /// <param name="config"></param> /// <param name="options"></param> /// <param name="tableauRoot"></param> public static bool AddRepoFromWorkgroupYaml(PaletteInsightConfiguration config, string tableauRoot, PaletteInsightAgentOptions options) { var workgroupYmlPath = GetWorkgroupYmlPath(tableauRoot); Workgroup repo = GetRepoFromWorkgroupYaml(workgroupYmlPath, options.PreferPassiveRepository); if (repo == null) { return(false); } try { if (IsEncrypted(repo.Password)) { Log.Info("Encrypted readonly password found in workgroup.yml."); // if (Tableau.getVersionNumber() >= TABLEAU_VERSION_2018_2) // { // Log.Warn("Palette Insight cannot decrypt readonly user's password on Tableau Server 2018.2+! Credentials must be provided in Config.yml!"); // return false; // } Log.Info("Getting readonly password with tabadmin command."); repo.Password = Tableau.tabadminRun("get pgsql.readonly_password"); } options.RepositoryDatabase = new DbConnectionInfo { Server = repo.Connection.Host, Port = repo.Connection.Port, Username = repo.Username, Password = repo.Password, DatabaseName = repo.Connection.DatabaseName }; if (config.TableauRepo != null) { Log.Warn("Ignoring Tableau repo settings from config.yml."); } return(true); } catch (Exception e) { Log.Error(e, "Failed to acquire Tableau repo connection details! Exception: "); } return(false); }
/// <summary> /// Do the conversion of config types /// </summary> /// <param name="conf"></param> /// <param name="outConfig">the PaletteInsightAgentOptions instance to update, since its a singleton, we cannot /// call its constructor, hence we cannot return it.</param> public static void LoadConfigTo(PaletteInsightConfiguration config, string tableauRoot, PaletteInsightAgentOptions options) { options.PollInterval = config.PollInterval; options.LogPollInterval = config.LogPollInterval; options.UploadInterval = config.UploadInterval; options.RepoTablesPollInterval = config.RepoTablesPollInterval; options.StreamingTablesPollInterval = config.StreamingTablesPollInterval; options.ThreadInfoPollInterval = config.ThreadInfoPollInterval; options.ProcessedFilestTTL = config.ProcessedFilesTTL; options.StorageLimit = config.StorageLimit; options.AllProcesses = config.AllProcesses; options.PreferPassiveRepository = config.PreferPassiveRepository; options.AuthToken = config.InsightAuthToken; if (config.Webservice != null) { // Do not add the username or password here, as they come from the license options.WebserviceConfig = new WebserviceConfiguration { Endpoint = config.Webservice.Endpoint, UseProxy = config.Webservice.UseProxy, ProxyAddress = config.Webservice.ProxyAddress, ProxyUsername = config.Webservice.ProxyUsername, ProxyPassword = config.Webservice.ProxyPassword }; } else { // make sure the webservice config is null, so we wont write // to the webservice if its not configured options.WebserviceConfig = null; } // Load thread monitoring configuration options.Processes = new Dictionary <string, ProcessData>(); foreach (var process in LoadProcessData()) { options.Processes.Add(process.Name, process); } options.RepositoryTables = LoadRepositoryTables(); // Add the log folders based on the Tableau Data path from the registry AddLogFoldersToOptions(config, options, tableauRoot); // setup the polling options options.UseCounterSamples = config.UseCounterSamples; options.UseLogPolling = config.UseLogPolling; options.UseThreadInfo = config.UseThreadInfo; // Polling of Tableau repo and streaming tables needs to be executed only on primary nodes. // [...] for the legacy case UseRepoPolling is true by default and RepoTablesPollInterval is 0 to // disable repo polling so this would mean different behaviour with the same config file. options.UseRepoPolling = config.UseRepoPolling && config.RepoTablesPollInterval > 0; // and streaming tables is very similar and related to repo polling options.UseStreamingTables = config.UseRepoPolling && config.StreamingTablesPollInterval > 0; LoadRepositoryFromConfig(config, options); // set the maximum log lines options.LogLinesPerBatch = config.LogLinesPerBatch; options.StreamingTablesPollLimit = config.StreamingTablesPollLimit; }