public void PollFullTables(ITableauRepoConn connection, ICollection <RepoTable> tables)
        {
            if (connection == null)
            {
                Log.Error("Missing Tableau Repo connection while polling full tables!");
                return;
            }

            Log.Info("Polling Tableau repository tables.");
            tables.Where(t => t.Full)
            .Select(t => t.Name)
            .ToList()
            .ForEach(t =>
            {
                try
                {
                    DataTable table = connection.GetTable(t);
                    OutputSerializer.Write(table, true);
                }
                catch (InvalidOperationException ioe)
                {
                    if (ioe.Message.Contains("Connection property has not been initialized"))
                    {
                        // This might also mean that the connection to Tableau is down
                        Log.Warn(ioe, "Temporarily unable to poll full table: '{0}'! Exception: ", t);
                    }
                    else
                    {
                        Log.Error(ioe, "Invalid operation exception while polling full table: '{0}'! Exception: ", t);
                    }
                }
            });
        }
示例#2
0
        public void poll(IDictionary <string, ProcessData> processData, bool allProcesses)
        {
            var  threadInfoTable      = ThreadTables.makeThreadInfoTable();
            long threadInfoTableCount = 0;
            ICollection <Process> processList;

            if (allProcesses)
            {
                processList = Process.GetProcesses();
            }
            else
            {
                processList = new List <Process>();
                foreach (string processName in processData.Keys)
                {
                    processList.AddRange(Process.GetProcessesByName(processName));
                }
            }
            pollProcessList(processList, processData, threadInfoTable, ref threadInfoTableCount);


            if (threadInfoTableCount > 0)
            {
                OutputSerializer.Write(threadInfoTable, false);
            }
        }
 /// <summary>
 /// Polls the sampler's counters and writes the results to the writer object.
 /// </summary>
 /// <param name="stateInfo"></param>
 private void PollCounters(object stateInfo)
 {
     tryStartIndividualPoll(CounterSampler.InProgressLock, PollWaitTimeout, () =>
     {
         var sampleResults = sampler.SampleAll();
         OutputSerializer.Write(sampleResults, false);
     });
 }
示例#4
0
        /// <summary>
        /// Helper that writes a serverlogs table to disk as a CSV
        /// </summary>
        /// <param name="serverLogsTable"></param>
        private static void WriteOutServerlogRows(System.Data.DataTable serverLogsTable)
        {
            var serverLogsTableCount = serverLogsTable.Rows.Count;

            if (serverLogsTableCount == 0)
            {
                // There is nothing collected.
                return;
            }

            var statusLine = String.Format("{0} server log {1}",
                                           serverLogsTableCount, "row".Pluralize(serverLogsTableCount));

            Log.Info("Sending off " + statusLine);

            if (serverLogsTableCount > 0)
            {
                OutputSerializer.Write(serverLogsTable, false);
            }

            Log.Info("Sent off {0}", statusLine);
        }
示例#5
0
        private void SerializeOutputFromPresenters(string path)
        {
            OutputSerializer os = new OutputSerializer();

            os.SaveByRegion(DisplayedImage, ViewModelID, RegionWidth, RegionHeight, RegionLocation, path, Scale);
        }
示例#6
0
        private void SerializeOutputFromList(Object obj)
        {
            OutputSerializer serializer = new OutputSerializer();

            serializer.SerializeList(_imageList, RegionWidth, RegionHeight, RegionLocation, Scale);
        }
        /// <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);
            }
        }
        public void PollStreamingTables(ITableauRepoConn connection, ICollection <RepoTable> tables, IOutput output)
        {
            if (connection == null)
            {
                Log.Error("Missing Tableau Repo connection while polling streaming tables!");
                return;
            }

            Log.Info("Polling Tableau Streaming tables.");
            tables.Where(table => !table.Full)
            .ToList()
            .ForEach((table) =>
            {
                var tableName = table.Name;

                try
                {
                    // If we have a pending request for this table, then just skip this iteration
                    if (output.IsInProgress(tableName))
                    {
                        return;
                    }

                    // Get maxid from remote server
                    var maxId = this.GetMaxId(tableName);

                    // Get data from that max id
                    string newMax;
                    DataTable dataTable = connection.GetStreamingTable(tableName, table, maxId, out newMax);
                    Log.Info("Polled records of streaming table {0} from {1} to {2}", tableName, maxId, newMax);
                    if (dataTable != null)
                    {
                        RepoPollAgent.localMaxId[tableName] = newMax;
                        OutputSerializer.Write(dataTable, false, newMax);
                    }
                }
                catch (AggregateException ae)
                {
                    ae.Handle((x) =>
                    {
                        if (x is HttpRequestException || x is TaskCanceledException || x is TemporaryException)
                        {
                            // HttpRequestException is expected on network errors. TaskCanceledException is thrown if the async task (HTTP request) timed out.
                            Log.Warn(x, "Polling streaming table: '{0}' timed out! Exception: ", tableName);
                            return(true);
                        }

                        Log.Error(x, "Async exception caught while polling streaming table: {0}! Exception: ", tableName);
                        return(true);
                    });
                }
                catch (TemporaryException tex)
                {
                    Log.Warn("Temporarily unable to poll streaming table: {0}! Exception: {1}", tableName, tex);
                }
                catch (TaskCanceledException tce)
                {
                    // This should be only a temporary condition, it is only a problem if it occurs many times in a row.
                    Log.Warn("Polling streaming table: '{0}' timed out! Exception: {1}", tableName, tce);
                }
                catch (HttpRequestException hre)
                {
                    Log.Warn("HTTP request exception while polling streaming table: '{0}'! Exception: {1}", tableName, hre);
                }
                catch (Exception e)
                {
                    if (e is InvalidOperationException && e.Message.Contains("Connection property has not been initialized"))
                    {
                        // This might also mean that the connection to Tableau is down
                        Log.Warn(e, "Temporarily unable to poll streaming table: '{0}'! Exception: ", tableName);
                        return;
                    }
                    Log.Error(e, "Error while polling streaming table: '{0}'! Exception: ", tableName);
                }
            });
        }