private PerformanceCounter GetPerformanceCounter(CounterConfig counterConfig)
 {
     if (!performanceCounters.ContainsKey(counterConfig.ToString()))
     {
         var counter = new PerformanceCounter(counterConfig.Category, counterConfig.CounterName, counterConfig.InstanceName, counterConfig.Server);
         performanceCounters.Add(counterConfig.ToString(), counter);
         return counter;
     }
     return performanceCounters[counterConfig.ToString()];
 }
        private CounterResult CheckAndRecordData(CounterConfig counterConfig)
        {
            var counter = GetPerformanceCounter(counterConfig);
            var value = (counterConfig.ValueType == ValueType.Raw)
                ? counter.RawValue
                : (long) Math.Round(counter.NextValue());

            var counterResult = new CounterResult
            {
                DateTime = DateTime.Now,
                Counter = counterConfig.PrettyName,
                Instance = counterConfig.InstanceName,
                Machine = counterConfig.Server,
                Value = value,
                CounterConfig = counterConfig
            };
            return counterResult;
        }