public static PerfmonStatsCollector GetInstance(string cacheId, string counterName = null, string category = null, string processInstance = null, string machine = null)
 {
     if (!Instances.ContainsKey(processInstance + counterName + category))
     {
         PerfmonStatsCollector perfmonStatsCollector = CreatePerformanceCounterInstance(counterName, category, processInstance, ref machine);
         Instances.Add(processInstance + counterName + category, perfmonStatsCollector);
     }
     return(Instances[processInstance + counterName + category]);
 }
        private static PerfmonStatsCollector CreatePerformanceCounterInstance(string counterName, string category, string processInstance, ref string machine)
        {
            PerfmonStatsCollector perfmonStatsCollector;

            try
            {
                perfmonStatsCollector = new PerfmonStatsCollector(category, counterName, processInstance, machine);
            }
            catch (Exception e)
            {
                machine = DnsCache.ResolveAddress(machine);
                perfmonStatsCollector = new PerfmonStatsCollector(category, counterName, processInstance, machine);
            }

            return(perfmonStatsCollector);
        }