예제 #1
0
 protected override void InitMetricRecords()
 {
     //todo: for the memory - var memSize = (double)Convert.ToInt32(memoryCounter.NextValue()) / 1024;
     //todo: for the cpu - var cpu = cpuCounter.NextValue() / Environment.ProcessorCount;
     MetricsConfig = MetricsConfigManager.ReadMetricsConfig()
                     .ProccessMetricsConfig
                     .ToList();
 }
예제 #2
0
        private void SaveMetrics()
        {
            InstanceName = GetW3pInstanceName();
            var counters = MetricsConfigManager.ReadMetricsConfig()
                           .ProccessMetricsConfig
                           .Select(c => new MeasurementData
            {
                Measurement = c.Measurement,
                Counter     = new PerformanceCounter
                {
                    CategoryName = c.CategoryName,
                    CounterName  = c.CounterName,
                    InstanceName = InstanceName
                }
            })
                           .ToList();

            try
            {
                while (true)
                {
                    PauseOrStartEvent.WaitOne();
                    if (ReloadConfigIndicator.GetAndResetProcessCollectorFlag())
                    {
                        throw new Exception("Перезугрузка конфигурации ProcessCOllector'a.");
                    }
                    counters.ForEach(WriteRecord);
                    Thread.Sleep(Settings.ReadingInterval);
                }
            }
            finally
            {
                counters.ForEach(c =>
                {
                    if (c.Counter != null)
                    {
                        c.Counter.Dispose();
                    }
                });
            }
        }
예제 #3
0
 protected override void InitMetricRecords()
 {
     MetricsConfig = MetricsConfigManager.ReadMetricsConfig()
                     .AspNetMetricsConfig
                     .ToList();
 }