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(); }
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(); } }); } }
protected override void InitMetricRecords() { MetricsConfig = MetricsConfigManager.ReadMetricsConfig() .AspNetMetricsConfig .ToList(); }