private async Task <IEnumerable <IPerfCounter> > GetCounters(ApplicationPool pool)
        {
            var poolCounters = new List <IPerfCounter>();
            var wps          = pool.GetWorkerProcesses();

            foreach (WorkerProcess wp in wps)
            {
                if (!_processCounterInstances.ContainsKey(wp.ProcessId))
                {
                    _processCounterInstances = await ProcessUtil.GetProcessCounterMap(_counterProvider, "W3WP");

                    //
                    // Counter instance doesn't exist
                    if (!_processCounterInstances.ContainsKey(wp.ProcessId))
                    {
                        continue;
                    }
                }

                poolCounters.AddRange(await _counterProvider.GetCounters(ProcessCounterNames.Category, _processCounterInstances[wp.ProcessId], ProcessCounterNames.CounterNames));
            }

            foreach (WorkerProcess wp in wps)
            {
                poolCounters.AddRange(await _counterProvider.GetCounters(
                                          WorkerProcessCounterNames.Category,
                                          WorkerProcessCounterNames.GetInstanceName(wp.ProcessId, pool.Name),
                                          WorkerProcessCounterNames.CounterNames));
            }

            poolCounters.AddRange(await _counterProvider.GetSingletonCounters(MemoryCounterNames.Category, MemoryCounterNames.CounterNames));

            return(poolCounters);
        }
        private async Task <IEnumerable <IPerfCounter> > GetCounters(Site site)
        {
            var counters = new List <IPerfCounter>();

            counters.AddRange(await _counterProvider.GetCounters(WebSiteCounterNames.Category, site.Name, WebSiteCounterNames.CounterNames));

            Application rootApp = site.Applications["/"];

            ApplicationPool pool = rootApp != null?AppPools.AppPoolHelper.GetAppPool(rootApp.ApplicationPoolName) : null;

            if (pool != null)
            {
                var wps = pool.GetWorkerProcesses();
                _siteProcessCounts[site.Name] = wps.Count();

                foreach (WorkerProcess wp in wps)
                {
                    if (!_processCounterInstances.ContainsKey(wp.ProcessId))
                    {
                        _processCounterInstances = await ProcessUtil.GetProcessCounterMap(_counterProvider, "W3WP");

                        //
                        // Counter instance doesn't exist
                        if (!_processCounterInstances.ContainsKey(wp.ProcessId))
                        {
                            continue;
                        }
                    }

                    counters.AddRange(await _counterProvider.GetCounters(ProcessCounterNames.Category, _processCounterInstances[wp.ProcessId], ProcessCounterNames.CounterNames));
                }

                foreach (WorkerProcess wp in wps)
                {
                    counters.AddRange(await _counterProvider.GetCounters(
                                          WorkerProcessCounterNames.Category,
                                          WorkerProcessCounterNames.GetInstanceName(wp.ProcessId, pool.Name),
                                          WorkerProcessCounterNames.CounterNames));
                }
            }

            counters.AddRange(await _counterProvider.GetSingletonCounters(MemoryCounterNames.Category, MemoryCounterNames.CounterNames));

            return(counters);
        }