Inheritance: Natol.PerformanceCounter2CloudWatch.Framework.CounterDescriptor
        private static CounterDescriptor CreateAllMethodRequestsDescriptor()
        {
            var pc = new PerformanceCounter("Web Service", "Total Method Requests/sec", "_Total", true);
            pc.NextValue();

            var pcd = new PerformanceCounterDescriptor
            {
                Name = "Total",
                SystemCounter = pc,
                Unit = "Count/Second",
                MetricName = "Method Requests"
            };

            pcd.Dimensions.Add("SiteName", "Total");

            return pcd;
        }
コード例 #2
0
        public IList<CounterDescriptor> UpdateCounterItems(IList<CounterDescriptor> counterItems)
        {
            //no need to update, since we're hardcoded (& eventually configuration-vased)
            if (counterItems.Count == 0)
            {
                //create reference to PerformanceCounter object
                var pc = new PerformanceCounter("Processor", "% Processor Time", "_Total", true);
                //read value to start counter
                pc.NextValue();

                //setup descriptor object for central framework
                var result = new PerformanceCounterDescriptor
                {
                    Name = "CPUUtilization",
                    SystemCounter = pc,
                    Unit = "Percent",
                    MetricName = "CPUUtilization"
                };
                counterItems.Add(result);
            }

            return counterItems;
        }