Пример #1
0
        /// <summary>
        /// Starts up the agent.
        /// </summary>
        public void Start()
        {
            Log.Info("Initializing TabMon..");

            // Assert that runtime options are valid.
            if (!TabMonOptions.Instance.Valid())
            {
                Log.Fatal("Invalid TabMon options specified!\nAborting..");
                return;
            }

            // Read Counters.config & create counters.
            Log.Info(String.Format(@"Loading performance counters from {0}\{1}..", Directory.GetCurrentDirectory(), PathToCountersConfig));
            ICollection <ICounter> counters;

            try
            {
                counters = CounterConfigLoader.Load(PathToCountersConfig, options.Hosts);
            }
            catch (ConfigurationErrorsException ex)
            {
                Log.Error(String.Format("Failed to correctly load '{0}': {1}\nAborting..", PathToCountersConfig, ex.Message));
                return;
            }
            Log.Debug(String.Format("Successfully loaded {0} {1} from configuration file.", counters.Count, "counter".Pluralize(counters.Count)));

            // Spin up counter sampler.
            sampler = new CounterSampler(counters, options.TableName);

            // Kick off the polling timer.
            Log.Info("TabMon initialized!  Starting performance counter polling..");
            timer = new Timer(callback: Poll, state: null, dueTime: 0, period: options.PollInterval * 1000);
        }
Пример #2
0
        /// <summary>
        /// Polls all known counters and maps the results to the dynamic data model.
        /// </summary>
        /// <returns>DataTable of all samples mapped to dynamic data model.</returns>
        public DataTable SampleAll()
        {
            Log.Info("Polling..");
            var pollTimestamp = DateTime.UtcNow;

            // Load any "ephemeral" counters which may have been instantiated between polling cycles.
            var ephemeralCounters = CounterConfigLoader.Load(hostsToSample, CounterLifecycleType.Ephemeral);
            var allCounters       = persistentCounters.Concat(ephemeralCounters).ToList();

            // Sample all persistent counters.
            DataTable dataTable = SampleCounters(allCounters, pollTimestamp);

            return(dataTable);
        }
        /// <summary>
        /// Starts up the agent.
        /// </summary>
        public void Start()
        {
            Log.Info("Initializing PaletteInsightAgent..");

            // Assert that runtime options are valid.
            if (!PaletteInsightAgentOptions.Instance.Valid())
            {
                Log.Fatal("Invalid PaletteInsightAgent options specified!\nAborting..");
                return;
            }

            // NOTE: License check disabled as this project became open-source
            //// Check the license every day
            //var oneDayInMs = 24 * 60 * 60 * 1000;
            //licenseCheckTimer = new Timer(callback: licenseGuard.PollLicense, state: options.LicenseKey, dueTime: oneDayInMs, period: oneDayInMs);

            // only start the JMX if we want to
            if (USE_COUNTERSAMPLES)
            {
                ICollection <ICounter> counters;
                try
                {
                    counters = CounterConfigLoader.Load(PathToCountersYaml);
                }
                catch (ConfigurationErrorsException ex)
                {
                    Log.Error("Failed to correctly load '{0}': {1}\nAborting..", PathToCountersYaml, ex.Message);
                    return;
                }

                // Spin up counter sampler.
                sampler = new CounterSampler(counters);

                // Kick off the polling timer.
                Log.Info("PaletteInsightAgent initialized!  Starting performance counter polling..");
                counterSampleTimer = new Timer(callback: PollCounters, state: null, dueTime: 0, period: options.PollInterval * 1000);
            }


            if (USE_LOGPOLLER)
            {
                // Start the log poller agent
                logPollerAgent.start();
                logPollTimer = new Timer(callback: PollLogs, state: null, dueTime: 0, period: options.LogPollInterval * 1000);
            }

            if (USE_THREADINFO)
            {
                // Kick off the thread polling timer
                int dueTime = CalculateDueTime(options.ThreadInfoPollInterval);
                Log.Debug("Due time until the next best timing for thread info poll start: {0} msec", dueTime);
                threadInfoTimer = new Timer(callback: PollThreadInfo, state: null, dueTime: dueTime, period: options.ThreadInfoPollInterval * 1000);
            }

            // send the metadata if there is a tableau repo behind us
            if (IsConnectionToTableauRepoRequired())
            {
                // On start get the schema of the repository tables
                var table = tableauRepo.GetSchemaTable();

                // Add the metadata of the agent table to the schema table
                DataTableUtils.AddAgentMetadata(table);

                // Serialize schema table so that it gets uploaded with all other tables
                OutputSerializer.Write(table, true);

                // Do the same for index data
                table = tableauRepo.GetIndices();
                OutputSerializer.Write(table, true);
            }

            output          = WebserviceOutput.MakeWebservice(options.WebserviceConfig);
            webserviceTimer = new Timer(callback: UploadData, state: output, dueTime: 0, period: options.UploadInterval * 1000);

            if (USE_TABLEAU_REPO)
            {
                // Poll Tableau repository data as well
                repoTablesPollTimer = new Timer(callback: PollFullTables, state: output, dueTime: 0, period: options.RepoTablesPollInterval * 1000);
            }

            if (USE_STREAMING_TABLES)
            {
                streamingTablesPollTimer = new Timer(callback: PollStreamingTables, state: output, dueTime: 0, period: options.StreamingTablesPollInterval * 1000);
            }
        }
Пример #4
0
 public CounterSampler(ICollection <Host> hostsToSample, string tableName)
 {
     this.hostsToSample = hostsToSample;
     this.tableName     = tableName;
     persistentCounters = CounterConfigLoader.Load(hostsToSample, CounterLifecycleType.Persistent);
 }