private void LoadTestStarting(object sender, EventArgs e)
        {
            // Delete the category if already exists
            if (PerformanceCounterCategory.Exists("AMSStressCounterSet"))
            {

                PerformanceCounterCategory.Delete("AMSStressCounterSet");
            }

            CounterCreationDataCollection counters = new CounterCreationDataCollection();

                // 1. counter for counting totals: PerformanceCounterType.NumberOfItems32
                CounterCreationData totalOps = new CounterCreationData();
                totalOps.CounterName = "# operations executed";
                totalOps.CounterHelp = "Total number of operations executed";
                totalOps.CounterType = PerformanceCounterType.NumberOfItems32;
                counters.Add(totalOps);

                // 2. counter for counting operations per second:
                //        PerformanceCounterType.RateOfCountsPerSecond32
                CounterCreationData opsPerSecond = new CounterCreationData();
                opsPerSecond.CounterName = "# operations / sec";
                opsPerSecond.CounterHelp = "Number of operations executed per second";
                opsPerSecond.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
                counters.Add(opsPerSecond);

                // create new category with the counters above
                PerformanceCounterCategory.Create("AMSStressCounterSet", "KeyDelivery Stress Counters", PerformanceCounterCategoryType.SingleInstance, counters);
        }
        private static void InitializeCounters()
        {
            try
            {
                var counterDatas =
                    new CounterCreationDataCollection();

                // Create the counters and set their properties.
                var cdCounter1 =
                    new CounterCreationData();
                var cdCounter2 =
                    new CounterCreationData();

                cdCounter1.CounterName = "Total Requests Handled";
                cdCounter1.CounterHelp = "Total number of requests handled";
                cdCounter1.CounterType = PerformanceCounterType.NumberOfItems64;
                cdCounter2.CounterName = "Requests Per Secpmd";
                cdCounter2.CounterHelp = "Average number of requests per second.";
                cdCounter2.CounterType = PerformanceCounterType.RateOfCountsPerSecond64;

                // Add both counters to the collection.
                counterDatas.Add(cdCounter1);
                counterDatas.Add(cdCounter2);

                // Create the category and pass the collection to it.
                PerformanceCounterCategory.Create(
                    "Socket Service Data Stats", "Stats for the socket service.",
                    PerformanceCounterCategoryType.MultiInstance, counterDatas);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.ToString());
            }
        }
Beispiel #3
0
        private static void SetupCategory()
        {
            if (PerformanceCounterCategory.Exists(CategoryName))
            {
                PerformanceCounterCategory.Delete(CategoryName);
            }
            if (!PerformanceCounterCategory.Exists(CategoryName))
            {
                CounterCreationDataCollection creationDataCollection =
                    new CounterCreationDataCollection();

                CounterCreationData ctrCreationData = new CounterCreationData();
                ctrCreationData.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
                ctrCreationData.CounterName = SpeedCounterName;
                creationDataCollection.Add(ctrCreationData);

                CounterCreationData ctrCreationData2 = new CounterCreationData();
                ctrCreationData2.CounterType = PerformanceCounterType.RateOfCountsPerSecond64;
                ctrCreationData2.CounterName = SpeedBytesCounterName;
                creationDataCollection.Add(ctrCreationData2);

                PerformanceCounterCategory.Create(CategoryName,
                    "Sample TransVault category",
                    PerformanceCounterCategoryType.MultiInstance,
                    creationDataCollection);
            }
        }
Beispiel #4
0
		static void Main(string[] args)
		{

			if (PerformanceCounterCategory.Exists("DontStayIn"))
				PerformanceCounterCategory.Delete("DontStayIn");
				
			// Create the collection container
			CounterCreationDataCollection counters = new CounterCreationDataCollection();

			// Create counter #1 and add it to the collection
			CounterCreationData dsiPages = new CounterCreationData();
			dsiPages.CounterName = "DsiPages per sec";
			dsiPages.CounterHelp = "Total number of dsi pages per second.";
			dsiPages.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
			counters.Add(dsiPages);

			// Create counter #3 and add it to the collection
			CounterCreationData genTime = new CounterCreationData();
			genTime.CounterName = "DsiPage generation time";
			genTime.CounterHelp = "Average time to generate a page.";
			genTime.CounterType = PerformanceCounterType.AverageTimer32;
			counters.Add(genTime);

			CounterCreationData genTimeBase = new CounterCreationData();
			genTimeBase.CounterName = "DsiPage generation time base";
			genTimeBase.CounterHelp = "Average time to generate a page base.";
			genTimeBase.CounterType = PerformanceCounterType.AverageBase;
			counters.Add(genTimeBase);

			// Create the category and all of the counters.
			PerformanceCounterCategory.Create("DontStayIn", "Performance counters for DontStayIn.", PerformanceCounterCategoryType.SingleInstance, counters);
			Console.WriteLine("Done!");
			Console.ReadLine();

		}
Beispiel #5
0
        internal static void Create()
        {
            if (PerformanceCounterCategory.Exists(engineCategory))
            {
                PerformanceCounterCategory.Delete(engineCategory);
            }

            var counterList = new CounterCreationDataCollection();

            counterList.Add(new CounterCreationData(
                dirtyNodeEventCount,
                "Describes the number of dirty node messages on the engine's event queue.",
                PerformanceCounterType.NumberOfItems32));

            counterList.Add(new CounterCreationData(
                calculatedNodeCount,
                "Describes the number of items scheduled for calculation by an engine task.",
                PerformanceCounterType.NumberOfItems32));

            counterList.Add(new CounterCreationData(
                taskExecutionTime,
                @"Describes the time in milliseconds to process an engine task.",
                PerformanceCounterType.NumberOfItems32));

            PerformanceCounterCategory.Create(
                engineCategory,
                "Engine counters",
                PerformanceCounterCategoryType.SingleInstance,
                counterList);
        }
        private void InitializeClicked(object sender, RoutedEventArgs e)
        {
            if (PerformanceCounterCategory.Exists(CategoryName))
            {
                PerformanceCounterCategory.Delete(CategoryName);
            }
            if (!PerformanceCounterCategory.Exists(CategoryName))
            {
                CounterCreationDataCollection creationDataCollection =
                    new CounterCreationDataCollection();

                CounterCreationData ctrCreationData = new CounterCreationData();
                ctrCreationData.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
                ctrCreationData.CounterName = SpeedCounterName;
                creationDataCollection.Add(ctrCreationData);

                CounterCreationData ctrCreationData2 = new CounterCreationData();
                ctrCreationData2.CounterType = PerformanceCounterType.RateOfCountsPerSecond64;
                ctrCreationData2.CounterName = SpeedBytesCounterName;
                creationDataCollection.Add(ctrCreationData2);

                PerformanceCounterCategory.Create(CategoryName,
                    "Sample Custom category",
                    PerformanceCounterCategoryType.MultiInstance,
                    creationDataCollection);
            }
            currentContainer = new CountersContainer()
            {
                BytesPerSecCounter = SetupCounter(CategoryName, SpeedCounterName, "Task " + currentTask),
                ItemsPerSecCounter = SetupCounter(CategoryName, SpeedBytesCounterName, "Task " + currentTask)
            };
        }
		private void InstallPerformanceCounters()
		{
			if (!PerformanceCounterCategory.Exists("nHydrate"))
			{
				var counters = new CounterCreationDataCollection();

				// 1. counter for counting totals: PerformanceCounterType.NumberOfItems32
				var totalAppointments = new CounterCreationData();
				totalAppointments.CounterName = "# appointments processed";
				totalAppointments.CounterHelp = "Total number of appointments processed.";
				totalAppointments.CounterType = PerformanceCounterType.NumberOfItems32;
				counters.Add(totalAppointments);

				// 2. counter for counting operations per second:
				//        PerformanceCounterType.RateOfCountsPerSecond32
				var appointmentsPerSecond = new CounterCreationData();
				appointmentsPerSecond.CounterName = "# appointments / sec";
				appointmentsPerSecond.CounterHelp = "Number of operations executed per second";
				appointmentsPerSecond.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
				counters.Add(appointmentsPerSecond);

				// create new category with the counters above
				PerformanceCounterCategory.Create("nHydrate", "nHydrate Category", counters);
			}

		}
        public void CreatePerformanceCategory()
        {
            const string category = "MikePerfSpike";

            if (!PerformanceCounterCategory.Exists(category))
            {
                var counters = new CounterCreationDataCollection();

                // 1. counter for counting values
                var totalOps = new CounterCreationData
                {
                    CounterName = "# of operations executed",
                    CounterHelp = "Total number of operations that have been executed",
                    CounterType = PerformanceCounterType.NumberOfItems32
                };
                counters.Add(totalOps);

                // 2. counter for counting operations per second
                var opsPerSecond = new CounterCreationData
                {
                    CounterName = "# of operations/second",
                    CounterHelp = "Number of operations per second",
                    CounterType = PerformanceCounterType.RateOfCountsPerSecond32
                };
                counters.Add(opsPerSecond);

                PerformanceCounterCategory.Create(
                    category,
                    "An experiment",
                    PerformanceCounterCategoryType.MultiInstance,
                    counters);
            }
        }
        private static void CreateCounters(string groupName)
        {
            if (PerformanceCounterCategory.Exists(groupName))
            {
                PerformanceCounterCategory.Delete(groupName);
            }

            var counters = new CounterCreationDataCollection();

            var totalOps = new CounterCreationData
                               {
                                   CounterName = "Messages Read",
                                   CounterHelp = "Total number of messages read",
                                   CounterType = PerformanceCounterType.NumberOfItems32
                               };
            counters.Add(totalOps);

            var opsPerSecond = new CounterCreationData
                                   {
                                       CounterName = "Messages Read / Sec",
                                       CounterHelp = "Messages read per second",
                                       CounterType = PerformanceCounterType.RateOfCountsPerSecond32
                                   };
            counters.Add(opsPerSecond);

            PerformanceCounterCategory.Create(groupName, "PVC", PerformanceCounterCategoryType.SingleInstance, counters);
        }
Beispiel #10
0
        void CreateCategories()
        {
            try
            {
                if (System.Diagnostics.PerformanceCounterCategory.Exists(counterCategory))
                {
                    return;
                }

                // Create a collection of type CounterCreationDataCollection.
                System.Diagnostics.CounterCreationDataCollection CounterDatas = new System.Diagnostics.CounterCreationDataCollection();
                // Create the counters and set their properties.

                System.Diagnostics.CounterCreationData cdCounter1 = new System.Diagnostics.CounterCreationData()
                {
                    CounterName = "In Call",
                    CounterHelp = "Number of simultaneous messages submitted from the BizTalk Benchmark Wizard application",
                    CounterType = System.Diagnostics.PerformanceCounterType.NumberOfItems64
                };
                System.Diagnostics.CounterCreationData cdCounter2 = new System.Diagnostics.CounterCreationData()
                {
                    CounterName = "Call Time",
                    CounterHelp = "Elasped time for call (msecs)",
                    CounterType = System.Diagnostics.PerformanceCounterType.NumberOfItems64
                };
                System.Diagnostics.CounterCreationData cdCounter3 = new System.Diagnostics.CounterCreationData()
                {
                    CounterName = "Total Calls",
                    CounterHelp = "Total number of messages submitted from the BizTalk Benchmark Wizard application",
                    CounterType = System.Diagnostics.PerformanceCounterType.NumberOfItems64
                };
                System.Diagnostics.CounterCreationData cdCounter4 = new System.Diagnostics.CounterCreationData()
                {
                    CounterName = "Calls/sec",
                    CounterHelp = "Number of messages submitted from the BizTalk Benchmark Wizard application",
                    CounterType = System.Diagnostics.PerformanceCounterType.RateOfCountsPerSecond32
                };

                // Add both counters to the collection.
                CounterDatas.Add(cdCounter1);
                CounterDatas.Add(cdCounter2);
                CounterDatas.Add(cdCounter3);
                CounterDatas.Add(cdCounter4);

                // Create the category and pass the collection to it.
                //if (System.Diagnostics.PerformanceCounterCategory.Exists(counterCategory))
                //    System.Diagnostics.PerformanceCounterCategory.Delete(counterCategory);

                PerformanceCounterCategory cat = System.Diagnostics.PerformanceCounterCategory.Create(
                    counterCategory,
                    counterCategory,
                    PerformanceCounterCategoryType.MultiInstance,
                    CounterDatas);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool CreatePerformanceCounters()
        {
            string categoryName = "WebSocketListener_Test";

            if (!PerformanceCounterCategory.Exists(categoryName))
            {
                var ccdc = new CounterCreationDataCollection();

                ccdc.Add(new CounterCreationData
                {
                    CounterType = PerformanceCounterType.RateOfCountsPerSecond64,
                    CounterName = pflabel_msgIn
                });

                ccdc.Add(new CounterCreationData
                {
                    CounterType = PerformanceCounterType.RateOfCountsPerSecond64,
                    CounterName = pflabel_msgOut
                });

                ccdc.Add(new CounterCreationData
                {
                    CounterType = PerformanceCounterType.NumberOfItems64,
                    CounterName = pflabel_connected
                });

                ccdc.Add(new CounterCreationData
                {
                    CounterType = PerformanceCounterType.AverageTimer32,
                    CounterName = pflabel_delay
                });

                ccdc.Add(new CounterCreationData
                {
                    CounterType = PerformanceCounterType.AverageBase,
                    CounterName = pflabel_delay + " base"
                });

                PerformanceCounterCategory.Create(categoryName, "", PerformanceCounterCategoryType.SingleInstance, ccdc);

                Console.WriteLine("Performance counters have been created, please re-run the app");
                return true;
            }
            else
            {
                //PerformanceCounterCategory.Delete(categoryName);
                //Console.WriteLine("Delete");
                //return true;

                MessagesIn = new PerformanceCounter(categoryName, pflabel_msgIn, false);
                MessagesOut = new PerformanceCounter(categoryName, pflabel_msgOut, false);
                Connected = new PerformanceCounter(categoryName, pflabel_connected, false);
                Delay = new PerformanceCounter(categoryName, pflabel_delay, false);
                DelayBase = new PerformanceCounter(categoryName, pflabel_delay + " base", false);
                Connected.RawValue = 0;

                return false;
            }
        }
Beispiel #12
0
        public SaveMetrics()
        {
            if ( !PerformanceCounterCategory.Exists( PerformanceCategoryName ) ) {
                CounterCreationDataCollection counters = new CounterCreationDataCollection();

                counters.Add( new CounterCreationData(
                        "Save - Count",
                        "Number of world saves.",
                        PerformanceCounterType.NumberOfItems32
                    )
                );

                counters.Add( new CounterCreationData(
                        "Save - Items/sec",
                        "Number of items saved per second.",
                        PerformanceCounterType.RateOfCountsPerSecond32
                    )
                );

                counters.Add( new CounterCreationData(
                        "Save - Mobiles/sec",
                        "Number of mobiles saved per second.",
                        PerformanceCounterType.RateOfCountsPerSecond32
                    )
                );

                counters.Add( new CounterCreationData(
                        "Save - Serialized bytes/sec",
                        "Amount of world-save bytes serialized per second.",
                        PerformanceCounterType.RateOfCountsPerSecond32
                    )
                );

                counters.Add( new CounterCreationData(
                        "Save - Written bytes/sec",
                        "Amount of world-save bytes written to disk per second.",
                        PerformanceCounterType.RateOfCountsPerSecond32
                    )
                );

            #if !MONO
                PerformanceCounterCategory.Create( PerformanceCategoryName, PerformanceCategoryDesc, PerformanceCounterCategoryType.SingleInstance, counters );
            #endif
            }

            numberOfWorldSaves = new PerformanceCounter( PerformanceCategoryName, "Save - Count", false );

            itemsPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Items/sec", false );
            mobilesPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Mobiles/sec", false );

            serializedBytesPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Serialized bytes/sec", false );
            writtenBytesPerSecond = new PerformanceCounter( PerformanceCategoryName, "Save - Written bytes/sec", false );

            // increment number of world saves
            numberOfWorldSaves.Increment();
        }
Beispiel #13
0
		private void CheckAndCreateCategory()
		{
			if (!System.Diagnostics.PerformanceCounterCategory.Exists(CATEGORY))
			{
				CounterCreationDataCollection counters =
					new CounterCreationDataCollection();
				counters.Add(GetCacheHitCounterData());
				counters.Add(GetCachedInstancesCounterData());
				PerformanceCounterCategory.Create(
				   CATEGORY, CATEGORY_DESCRIPTION, counters);
			}
		}
Beispiel #14
0
        public static void Create()
        {
            if (PerformanceCounterCategory.Exists(CategoryName))
                PerformanceCounterCategory.Delete(CategoryName);

            CounterCreationDataCollection ccdc = new CounterCreationDataCollection();
            ccdc.Add(
                new CounterCreationData()
                {
                    CounterType = PerformanceCounterType.NumberOfItems32,
                    CounterName = "Open Connections",
                    CounterHelp = string.Empty
                });
            ccdc.Add(
                new CounterCreationData()
                {
                    CounterType = PerformanceCounterType.NumberOfItems32,
                    CounterName = "Writes Outstanding",
                    CounterHelp = string.Empty
                });
            ccdc.Add(
                new CounterCreationData()
                {
                    CounterType = PerformanceCounterType.NumberOfItems32,
                    CounterName = "Writes Total",
                    CounterHelp = string.Empty
                });
            ccdc.Add(
                new CounterCreationData()
                {
                    CounterType = PerformanceCounterType.NumberOfItems32,
                    CounterName = "Writes Posted Total",
                    CounterHelp = string.Empty
                });
            ccdc.Add(
                new CounterCreationData()
                {
                    CounterType = PerformanceCounterType.NumberOfItems32,
                    CounterName = "Writes Posted Failures",
                    CounterHelp = string.Empty
                });
            ccdc.Add(
                new CounterCreationData()
                {
                    CounterType = PerformanceCounterType.NumberOfItems32,
                    CounterName = "Sql Transient Errors",
                    CounterHelp = string.Empty
                });

            // Create the category.
            PerformanceCounterCategory.Create(CategoryName, string.Empty, PerformanceCounterCategoryType.SingleInstance, ccdc);
        }
        /// <summary>
        /// 
        /// </summary>
        public static void SetupCategory()
        {
            RemoveCategory();
            //if (!PerformanceCounterCategory.Exists(CATEGORY_NAME)) {

            CounterCreationDataCollection CCDC = new CounterCreationDataCollection();

            CounterCreationData a = new CounterCreationData();
            a.CounterType = PerformanceCounterType.NumberOfItems32;
            a.CounterName = "Connected";
            CCDC.Add(a);

            //CounterCreationData b = new CounterCreationData();
            //b.CounterType = PerformanceCounterType.NumberOfItems64;
            //b.CounterName = "Disconneted";
            //CCDC.Add(b);

            CounterCreationData c = new CounterCreationData();
            c.CounterType = PerformanceCounterType.NumberOfItems64;
            c.CounterName = "Fault Count";
            CCDC.Add(c);

            CounterCreationData d1 = new CounterCreationData();
            d1.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
            d1.CounterName = "Produce/sec";
            CCDC.Add(d1);

            CounterCreationData d2 = new CounterCreationData();
            d2.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
            d2.CounterName = "Process/sec";
            CCDC.Add(d2);

            CounterCreationData d3 = new CounterCreationData();
            d3.CounterType = PerformanceCounterType.NumberOfItems64;
            d3.CounterName = "Login Failed";
            CCDC.Add(d3);

            CounterCreationData d4 = new CounterCreationData();
            d4.CounterType = PerformanceCounterType.NumberOfItems64;
            d4.CounterName = "Unregisted";
            CCDC.Add(d4);

            CounterCreationData d5 = new CounterCreationData();
            d5.CounterType = PerformanceCounterType.NumberOfItems32;
            d5.CounterName = "Queue length";
            CCDC.Add(d5);

            PerformanceCounterCategory.Create(CATEGORY_NAME, NAME,
                PerformanceCounterCategoryType.MultiInstance, CCDC);

            //}
        }
Beispiel #16
0
        public static void SetupCounters()
        {
            var counterList = new CounterCreationDataCollection();

            var sentPacketCounter = new CounterCreationData
                                        {
                                            CounterName = "Packets Sent/sec",
                                            CounterType = PerformanceCounterType.RateOfCountsPerSecond64,
                                            CounterHelp = "Number of packets sent per second."
                                        };

            var recvPacketCounter = new CounterCreationData
                                        {
                                            CounterName = "Packets Received/sec",
                                            CounterType = PerformanceCounterType.RateOfCountsPerSecond64,
                                            CounterHelp = "Number of packets received per second."
                                        };

            var bytesSentCounter = new CounterCreationData
                                       {
                                           CounterName = "Bytes Sent",
                                           CounterType = PerformanceCounterType.NumberOfItems64,
                                           CounterHelp = "Total number of bytes sent."
                                       };

            var bytesRecvCounter = new CounterCreationData
                                       {
                                           CounterName = "Bytes Received",
                                           CounterType = PerformanceCounterType.NumberOfItems64,
                                           CounterHelp = "Total number of bytes received."
                                       };

            var authQueueCounter = new CounterCreationData
                                       {
                                           CounterName = "Auth Queue Size",
                                           CounterType = PerformanceCounterType.CountPerTimeInterval32,
                                           CounterHelp = "Number of clients waiting in the auth queue."
                                       };

            counterList.Add(sentPacketCounter);
            counterList.Add(recvPacketCounter);
            counterList.Add(bytesSentCounter);
            counterList.Add(bytesRecvCounter);
            counterList.Add(authQueueCounter);

            if (!PerformanceCounterCategory.Exists(CategoryName))
            {
                PerformanceCounterCategory.Create(CategoryName, CategoryHelp,
                                                  PerformanceCounterCategoryType.SingleInstance,
                                                  counterList);
            }
        }
        private static void CreateCounters()
        {
            // If this crashes with a "Cannot load Counter Name data because an invalid index '' was read from the registry."
            // exception then open cmd as an administrator and run the following
            // lodctr /r
            // This refreshes the counter cache in the registry
            // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009 \ Counter+Help

            if (PerformanceCounterCategory.Exists(CounterCategory))
            {
                //PerformanceCounterCategory.Delete(CounterCategory);
                return;
            }

            var counters = new CounterCreationDataCollection();

            var totalOps = new CounterCreationData
            {
                CounterName = "# operations executed",
                CounterHelp = "Total number of operations executed",
                CounterType = PerformanceCounterType.NumberOfItems32
            };
            counters.Add(totalOps);

            var opsPerSecond = new CounterCreationData
            {
                CounterName = "# operations /sec",
                CounterHelp = "Number of operations executed per second",
                CounterType = PerformanceCounterType.RateOfCountsPerSecond32
            };
            counters.Add(opsPerSecond);

            var avgDuration = new CounterCreationData
            {
                CounterName = "average time per operation",
                CounterHelp = "Average duration per operation execution",
                CounterType = PerformanceCounterType.AverageTimer32
            };
            counters.Add(avgDuration);

            var avgDurationBase = new CounterCreationData
            {
                CounterName = "average time per operation base",
                CounterHelp = "Average duration per operation execution base",
                CounterType = PerformanceCounterType.AverageBase
            };
            counters.Add(avgDurationBase);

            PerformanceCounterCategory.Create(CounterCategory, "MBSI category", PerformanceCounterCategoryType.Unknown, counters);
        }
        private void EnsureCounters()
        {
            if (!PerformanceCounterCategory.Exists(CategoryName))
            {
                CounterCreationDataCollection counters = new CounterCreationDataCollection();

                counters.Add(CreateCountingCounterCreationData(CounterNameNumberOfJobsScheduled, "Total number of jobs that have been scheduled"));
                counters.Add(CreateCountingCounterCreationData(CounterNameJobsExecuting, "Total number of jobs that have started executing"));
                counters.Add(CreateCountingCounterCreationData(CounterNameJobsCompleted, "Total number of jobs that have completed"));

                // create new category with counters
                PerformanceCounterCategory.Create(CategoryName, "Quartz.NET Performance Counters", PerformanceCounterCategoryType.MultiInstance, counters);
            }
        }
		public static bool InstallCounters()
		{
			string message = String.Empty;
			try
			{
				if(RelayNode.log.IsInfoEnabled)
                    RelayNode.log.InfoFormat("Creating performance counter category {0}", RelayNodeCounters.PerformanceCategoryName);
				Console.WriteLine("Creating performance counter category " + RelayNodeCounters.PerformanceCategoryName);
				CounterCreationDataCollection counterDataCollection = new CounterCreationDataCollection();

				for (int i = 0; i < RelayNodeCounters.PerformanceCounterNames.Length; i++)
				{
					counterDataCollection.Add(new CounterCreationData(RelayNodeCounters.PerformanceCounterNames[i], RelayNodeCounters.PerformanceCounterHelp[i], RelayNodeCounters.PerformanceCounterTypes[i]));
					message = "Creating perfomance counter " + RelayNodeCounters.PerformanceCounterNames[i];
					Console.WriteLine(message);
					if(RelayNode.log.IsInfoEnabled)
                        RelayNode.log.Info(message);
				}

				PerformanceCounterCategory.Create(RelayNodeCounters.PerformanceCategoryName, "Counters for the MySpace Data Relay", PerformanceCounterCategoryType.MultiInstance, counterDataCollection);
				return true;
			}
			catch (Exception ex)
			{
				message = "Error creating Perfomance Counter Category " + RelayNodeCounters.PerformanceCategoryName + ": " + ex.ToString() + ". Counter category will not be used.";
				Console.WriteLine(message);
                if (RelayNode.log.IsErrorEnabled)
                    RelayNode.log.Error(message);
				return false;
			}




		}
        public override void RegisterIn(CounterCreationDataCollection collection)
        {
            var averageTimer = new CounterCreationData
            {
                CounterType = PerformanceCounterType.AverageTimer32,
                CounterName = Name,
            };

            var averageTimerBase = new CounterCreationData
            {
                CounterType = PerformanceCounterType.AverageBase,
                CounterName = Name + "Base",
            };
            collection.Add(averageTimer);
            collection.Add(averageTimerBase);
        }
        public override void RegisterIn(CounterCreationDataCollection collection)
        {
            var numberOfItems = new CounterCreationData
            {
                CounterType = PerformanceCounterType.NumberOfItems64,
                CounterName = Name,
            };

            var rates = new CounterCreationData
            {
                CounterType = PerformanceCounterType.RateOfCountsPerSecond64,
                CounterName = RatePerformanceCounterName(Name),
            };
            collection.Add(numberOfItems);
            collection.Add(rates);
        }
Beispiel #22
0
        static void Main(string[] args)
        {
            CounterCreationDataCollection counters = new CounterCreationDataCollection();
            counters.Add(new CounterCreationData("Sales", "Number of total sales", PerformanceCounterType.NumberOfItems64));
            counters.Add(new CounterCreationData("Active Users", "Number of active users", PerformanceCounterType.NumberOfItems64));
            counters.Add(new CounterCreationData("Sales value", "Total value of all sales", PerformanceCounterType.NumberOfItems64));
            PerformanceCounterCategory.Create("MyApp Counters", "Counters describing the performance of MyApp",
                PerformanceCounterCategoryType.SingleInstance, counters);

            PerformanceCounter pc = new PerformanceCounter("MyApp Counters", "Sales", false);

            pc.RawValue = 7;
            pc.Decrement();
            pc.Increment();
            pc.IncrementBy(3);
        }
        /// <summary>
        /// install thge perfmon counters
        /// </summary>
        public static void InstallCounters()
        {
            if (!PerformanceCounterCategory.Exists(BabaluCounterDescriptions.CounterCategory))
            {
                //Create the collection that will hold
                // the data for the counters we are
                // creating.
                CounterCreationDataCollection counterData = new CounterCreationDataCollection();

                //Create the CreationData object.
                foreach (string counter in BabaluCounterDescriptions.BabaluCounters)
                {
                    CounterCreationData BabaluCounter = new CounterCreationData();

                    // Set the counter's type to NumberOfItems32
                    BabaluCounter.CounterType = PerformanceCounterType.NumberOfItems32;

                    //Set the counter's name
                    BabaluCounter.CounterName = counter;

                    //Add the CreationData object to our
                    //collection
                    counterData.Add(BabaluCounter);
                }

                //Create the counter in the system using the collection.
                PerformanceCounterCategory.Create(BabaluCounterDescriptions.CounterCategory, BabaluCounterDescriptions.CategoryDescription,
                                    PerformanceCounterCategoryType.SingleInstance, counterData);
            }
        }
        private bool SetupCategory()
        {
            // PerformanceCounterCategory.Delete("DCC2012");

            if (!PerformanceCounterCategory.Exists(this.categoryName))
            {
                CounterCreationDataCollection counterDataCollection = new CounterCreationDataCollection();

                // Add the counter.
                CounterCreationData averageCount64 = new CounterCreationData();
                averageCount64.CounterType = PerformanceCounterType.NumberOfItems32;
                averageCount64.CounterName = "GetData Call Count";
                counterDataCollection.Add(averageCount64);

                CounterCreationData averageCount641 = new CounterCreationData();
                averageCount641.CounterType = PerformanceCounterType.CounterTimer;
                averageCount641.CounterName = "GetData Execution Time";
                counterDataCollection.Add(averageCount641);

                // Create the category.
                PerformanceCounterCategory.Create("DCC2012", "Desert Code Camp.",
                    PerformanceCounterCategoryType.SingleInstance, counterDataCollection);

                return (true);
            }
            else
            {
                Console.WriteLine("Category exists - AverageCounter64SampleCategory");
                return (false);
            }
        }
Beispiel #25
0
        public static void CreateCounter()
        {
            CounterCreationDataCollection col = new CounterCreationDataCollection();

            // Create two custom counter objects.
            CounterCreationData addCounter = new CounterCreationData();
            addCounter.CounterName = "AddCounter";
            addCounter.CounterHelp = "Custom Add counter ";
            addCounter.CounterType = PerformanceCounterType.NumberOfItemsHEX32;

            // Add custom counter objects to CounterCreationDataCollection.
            col.Add(addCounter);

            // Bind the counters to a PerformanceCounterCategory
            // Check if the category already exists or not.
            if (!PerformanceCounterCategory.Exists("MyCategory"))
            {
                PerformanceCounterCategory category =
                PerformanceCounterCategory.Create("MyCategory", "My Perf Category Description ", PerformanceCounterCategoryType.Unknown, col);
            }
            else
            {
                Console.WriteLine("Counter already exists");
            }
        }
        static PerformanceCounters()
        {
            try
            {
                if (PerformanceCounterCategory.Exists(category))
                    PerformanceCounterCategory.Delete(category);

                // order to be sure that *Base follows counter
                var props = typeof(PerformanceCounters).GetProperties().OrderBy(p => p.Name).ToList();

                var counterCollection = new CounterCreationDataCollection();

                foreach (var p in props)
                {
                    var attr = (PerformanceCounterTypeAttribute)p.GetCustomAttributes(typeof(PerformanceCounterTypeAttribute), true).First();
                    counterCollection.Add(new CounterCreationData() { CounterName = p.Name, CounterHelp = string.Empty, CounterType = attr.Type });
                }

                PerformanceCounterCategory.Create(category, "Online Trainer Perf Counters", PerformanceCounterCategoryType.MultiInstance, counterCollection);
            }
            catch (Exception e)
            {
                new TelemetryClient().TrackException(e);
            }
        }
        /// <summary>
        /// Starts the install
        /// </summary>
        public static void InstallCounters()
        {
            Logger.Debug("Starting installation of PerformanceCounters ");

            var categoryName = "NServiceBus";
            var counterName = "Critical Time";

            if (PerformanceCounterCategory.Exists(categoryName))
            {
                Logger.Warn("Category " + categoryName + " already exist, going to delete first");
                PerformanceCounterCategory.Delete(categoryName);
            }
                

            var data = new CounterCreationDataCollection();

            var c1 = new CounterCreationData(counterName, "Age of the oldest message in the queue",
                                             PerformanceCounterType.NumberOfItems32);
            data.Add(c1);

            PerformanceCounterCategory.Create(categoryName, "NServiceBus statistics",
                                              PerformanceCounterCategoryType.MultiInstance, data);

            Logger.Debug("Installation of PerformanceCounters successful.");
        }
    private void EnsurePerfCategoryExist()
    {
      var ccdc = new CounterCreationDataCollection();
      var ccd = new CounterCreationData();
      ccd.CounterType = PerformanceCounterType.NumberOfItems32;
      ccd.CounterName = "HardProcedureQueries";
      ccdc.Add(ccd);

      ccd = new CounterCreationData();
      ccd.CounterType = PerformanceCounterType.NumberOfItems32;
      ccd.CounterName = "SoftProcedureQueries";
      ccdc.Add(ccd);

      if (!PerformanceCounterCategory.Exists(Resources.PerfMonCategoryName))
        PerformanceCounterCategory.Create(Resources.PerfMonCategoryName, null, ccdc);
    }
        static void CreateGroup(CounterCreationDataCollection counters, string operation, string persecName, string successName, string totalName)
        {
            counters.Add(new CounterCreationData(
                        persecName,
                        String.Format("The total number of [{0}] operations per sec.", operation),
                        PerformanceCounterType.RateOfCountsPerSecond64));

            counters.Add(new CounterCreationData(
                        totalName,
                        String.Format("The total number of [{0}] operations.", operation),
                        PerformanceCounterType.NumberOfItems64));

            counters.Add(new CounterCreationData(
                        successName,
                        String.Format("The total number of successful [{0}] operations.", operation),
                        PerformanceCounterType.NumberOfItems64));
        }
        public void AddCounterToCollection(CounterCreationDataCollection counterData)
        {
            CounterCreationData counterCreationData = new CounterCreationData(
                _counterName, 
                _counterHelp, 
                _pcType);

            counterData.Add(counterCreationData);
        }
		public void AddCounterToCollection(CounterCreationDataCollection counterData)
		{
			var counterCreationData = new CounterCreationData(
				_name,
				_help,
				_counterType);

			counterData.Add(counterCreationData);
		}
        /// <summary>
        /// Installs the specified performance <paramref name="counters" />.
        /// </summary>
        /// <param name="counters">A list of counters to install.</param>
        /// <exception cref="ArgumentNullException"><paramref name="counters" /> is <c>null</c>.</exception>
        public static void Install(this IEnumerable <PerformanceCounterSettings> counters)
        {
            if (counters == null)
            {
                throw new ArgumentNullException(nameof(counters));
            }

            // Group counters by category
            var countersByCategories =
                (
                    from
                    counter in counters
                    group
                    counter by counter.Category
                    into
                    countersByCategory
                    select
                    countersByCategory
                ).ToDictionary(c => c.Key);

            // For each counters by category
            foreach (var countersByCategory in countersByCategories)
            {
                // Get group category
                var category = countersByCategory.Key;

                // Check if category exists
                if (PerformanceCounterCategory.Exists(category))
                {
                    // Check if all counters exists within the category
                    if (countersByCategory.Value.All(counter => PerformanceCounterCategory.CounterExists(counter.Name, counter.Category)))
                    {
                        continue;
                    }

                    // Some or all counters does not exists within the category
                    // Delete category
                    PerformanceCounterCategory.Delete(category);
                }

                // Create new counters collection
                var counterData = new CounterCreationDataCollection();

                foreach (var counterCreationData in countersByCategory.Value.Select(counterConfig => new CounterCreationData(counterConfig.Name, String.Empty, counterConfig.CounterType)))
                {
                    counterData.Add(counterCreationData);
                }

                // Create category with counters
                PerformanceCounterCategory.Create(category, String.Empty, PerformanceCounterCategoryType.SingleInstance, counterData);
            }
        }
        private static void createCounterIfNotExist(string categoryName, string counterName, string counterHelp, System.Diagnostics.PerformanceCounterType type, System.Diagnostics.CounterCreationDataCollection counterDatas)
        {
            if (!System.Diagnostics.PerformanceCounterCategory.Exists(categoryName) ||
                !System.Diagnostics.PerformanceCounterCategory.CounterExists(counterName, categoryName))
            {
                System.Diagnostics.CounterCreationData counter =
                    new System.Diagnostics.CounterCreationData();
                counter.CounterName = counterName;
                counter.CounterHelp = counterHelp;
                counter.CounterType = type;

                counterDatas.Add(counter);
            }
        }
        public static void installPerformanceCounter()
        {
            CounterCreationDataCollection CounterDatas = new System.Diagnostics.CounterCreationDataCollection();
            CounterCreationData           cdCounter1   = new System.Diagnostics.CounterCreationData();

            try {
                cdCounter1.CounterName = "Messages Per Second";
                cdCounter1.CounterType = PerformanceCounterType.RateOfCountsPerSecond64;
                CounterDatas.Add(cdCounter1);
                if (!((PerformanceCounterCategory.Exists("netSmtpMail"))))
                {
                    PerformanceCounterCategory.Create("netSmtpMail", "", CounterDatas);
                }
            } catch (Exception e) {
                throw (e);
            }
        }