Example #1
0
        public CustomInstaller()
        {
            string loadPerf = Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\loadperf.dll";
            if (File.Exists(loadPerf))
            {
                // add in a perf mon installer
                PerformanceCounterInstaller p = new PerformanceCounterInstaller();
                p.CategoryName = Resources.PerfMonCategoryName;
                p.CategoryHelp = Resources.PerfMonCategoryHelp;
                p.CategoryType = PerformanceCounterCategoryType.SingleInstance;

                CounterCreationData ccd1 = new CounterCreationData(
                    Resources.PerfMonHardProcName,
                    Resources.PerfMonHardProcHelp,
                    PerformanceCounterType.NumberOfItems32);

                CounterCreationData ccd2 = new CounterCreationData(
                 Resources.PerfMonSoftProcName,
                 Resources.PerfMonSoftProcHelp,
                 PerformanceCounterType.RateOfCountsPerSecond32);

                p.Counters.Add(ccd1);
                p.Counters.Add(ccd2);
                perfMonIndex = Installers.Add(p);
            }
        }
		private void PopulateCounterCategoryData(PerformanceCountersDefinitionAttribute attribute, Assembly originalAssembly, PerformanceCounterInstaller installer)
		{
			installer.CategoryName = attribute.CategoryName;
			installer.CategoryHelp = GetCategoryHelp(attribute, originalAssembly);

			installer.CategoryType = attribute.CategoryType;
		}
Example #3
0
        public WebsiteInstaller()
        {
            InstallerInfo info = InstallerInfo.GetInstallerInfo();

            // Add a default one that we can always fall back to
            EventLogInstaller myEventLogInstaller = new EventLogInstaller();
            myEventLogInstaller.Source = InstallerInfo.DefaultEventLogSource;
            Installers.Add(myEventLogInstaller);

            foreach (EventLogInfo source in info.EventLogInfos)
            {
                myEventLogInstaller = new EventLogInstaller();
                myEventLogInstaller.Source = source.Source;
                Installers.Add(myEventLogInstaller);
            }

            foreach (PerformanceCounterCategoryInfo performanceCounter in info.PerformanceCounterCategoryInfos)
            {
                PerformanceCounterInstaller myCounterInstaller = new PerformanceCounterInstaller();
                myCounterInstaller.CategoryHelp = performanceCounter.CategoryHelp;
                myCounterInstaller.CategoryName = performanceCounter.CategoryName;
                ArrayList counters = new ArrayList();
                foreach (CounterCreationDataInfo creationDataInfo in performanceCounter.CounterCreationDataInfos)
                    counters.Add(new CounterCreationData(creationDataInfo.CounterName, creationDataInfo.CounterHelp,
                                                         creationDataInfo.CounterType));

                myCounterInstaller.Counters.AddRange(
                    (CounterCreationData[]) counters.ToArray(typeof (CounterCreationData)));
                Installers.Add(myCounterInstaller);
            }
        }
        public void PerformanceCountersFromNonInstrumentedClassesAreNotAdded()
        {
            PerformanceCounterInstaller parentInstaller = new PerformanceCounterInstaller();
            PerformanceCounterInstallerBuilder builder
                = new PerformanceCounterInstallerBuilder(new Type[] { typeof(NonInstrumentedClass) });
            builder.Fill(parentInstaller);

            Assert.AreEqual(0, parentInstaller.Installers.Count);
        }
        public Installer GetInstaller()
        {
            var installer = new PerformanceCounterInstaller
            {
                CategoryName = _categoryName,
                CategoryHelp = _categoryHelp,
            };
            installer.Counters.AddRange(_counterDefinitions);

            return installer;
        }
        public PerformanceCounterInstaller CreateInstaller()
        {
            PerformanceCounterInstaller performanceCounterInstaller = new System.Diagnostics.PerformanceCounterInstaller();

            performanceCounterInstaller.CategoryName = _performanceCounterCategoryAttribute.CategoryName;
            performanceCounterInstaller.CategoryType = _performanceCounterCategoryAttribute.CategoryType;
            performanceCounterInstaller.CategoryHelp = _performanceCounterCategoryAttribute.CaregoryHelp;
            performanceCounterInstaller.Counters.AddRange(_counterCreationData.Values.ToArray());

            return(performanceCounterInstaller);
        }
 private CounterCreationData GetExistingCounter(PerformanceCounterInstaller installer, string counterName)
 {
     foreach (CounterCreationData data in installer.Counters)
     {
         if (data.CounterName.Equals(counterName, StringComparison.CurrentCulture))
         {
             return data;
         }
     }
     return null;
 }
        public CacheInstaller()
        {
            var installer = new PerformanceCounterInstaller
            {
                CategoryName = "Example User Cache",
                CategoryHelp = "An example cache of users.",
                CategoryType = PerformanceCounterCategoryType.SingleInstance,
                UninstallAction = UninstallAction.Remove
            };
            installer.Counters.AddRange(CacheMonitor.CreateCounterData("UserCache"));

            Installers.Add(installer);
        }
Example #9
0
        private void InstallPerformanceCounters()
        {
            PerformanceCounterInstaller installer = new PerformanceCounterInstaller();
            installer.CategoryName = EnterpriseLibraryPerformanceCounterFixture.counterCategoryName;
            installer.CategoryHelp = "J Random Text";
            installer.CategoryType = PerformanceCounterCategoryType.MultiInstance;

            CounterCreationData firstCounterData = new CounterCreationData(EnterpriseLibraryPerformanceCounterFixture.counterName, "Test Counter", PerformanceCounterType.NumberOfItems32);
            CounterCreationData secondCounterData = new CounterCreationData("SecondTestCounter", "Second Test Counter", PerformanceCounterType.NumberOfItems32);

            installer.Counters.Add(firstCounterData);
            installer.Counters.Add(secondCounterData);

            Installers.Add(installer);
        }
		private PerformanceCounterInstaller GetOrCreateInstaller(Type instrumentedType,	IList<Installer> installers)
		{
			PerformanceCountersDefinitionAttribute attribute
				= (PerformanceCountersDefinitionAttribute)instrumentedType.GetCustomAttributes(typeof(PerformanceCountersDefinitionAttribute), false)[0];

			PerformanceCounterInstaller installer = GetExistingInstaller(attribute.CategoryName, installers);
			if (installer == null)
			{
				installer = new PerformanceCounterInstaller();
				PopulateCounterCategoryData(attribute, instrumentedType.Assembly, installer);
				installers.Add(installer);
			}

			return installer;
		}
Example #11
0
        private void AddPerformanceCountersToInstaller()
        {
            // The categoryInstaller is for one performance category only.
            // We have only one category per assembly
            PerformanceCounterInstaller categoryInstaller = new PerformanceCounterInstaller();
            categoryInstaller.CategoryName = ExceptionHandledEvent.InstrumentationCounterCategory;
            categoryInstaller.CategoryHelp = SR.InstrumentationCounterCategoryHelp;
            Installers.Add(categoryInstaller);

            // adding all the counters in the category.
            foreach (CounterCreationData counterCreation in ExceptionHandlingEvent.counters)
            {
                categoryInstaller.Counters.Add(counterCreation);
            }
        }
 /// <summary>
 /// Constructors -- Registers Orleans system performance counters, 
 /// plus any grain-specific activation conters that can be detected when this installer is run.
 /// </summary>
 public OrleansPerformanceCounterInstaller()
 {
     try
     {
         using (var myPerformanceCounterInstaller = new PerformanceCounterInstaller())
         {
             myPerformanceCounterInstaller.CategoryName = OrleansPerfCounterManager.CATEGORY_NAME;
             myPerformanceCounterInstaller.CategoryType = PerformanceCounterCategoryType.MultiInstance;
             myPerformanceCounterInstaller.Counters.AddRange(OrleansPerfCounterManager.GetCounterCreationData());
             Installers.Add(myPerformanceCounterInstaller);
         }
     }
     catch (Exception exc)
     {
         Context.LogMessage("Failed to install performance counters: " + exc.Message);
     }
 }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            const string PRODUCT = "Alachisoft";
            components = new System.ComponentModel.Container();                       

            ContentOptimizationCountersInstaller = new System.Diagnostics.PerformanceCounterInstaller();
            ContentOptimizationCountersInstaller.CategoryName = PRODUCT + ":" + "ContentOptimization";
            ContentOptimizationCountersInstaller.Counters.AddRange(new System.Diagnostics.CounterCreationData[]{
                new CounterCreationData("Viewstate size", "Size of viewstate in bytes.", PerformanceCounterType.AverageCount64),
                new CounterCreationData("Viewstate size base", "Base counter for viewstate size.", PerformanceCounterType.AverageBase),
                new CounterCreationData("Viewstate hits/sec", "Number of times viewstate is successfully served from cache.", PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData("Viewstate misses/sec", "Number of times viewstate is not successfully served from cache.", PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData("Viewstate additions/sec", "Number of viewstate add operations per second.", PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData("Viewstate requests/sec", "Number of viewstate read requests per second.", PerformanceCounterType.RateOfCountsPerSecond32),
            });            

            this.Installers.AddRange(new System.Configuration.Install.Installer[] {ContentOptimizationCountersInstaller});
        }
Example #14
0
        protected void SetupCounters()
        {
            var performanceCounterInstaller =
                new PerformanceCounterInstaller
                    {
                        CategoryName = ServiceName
                    };

            Installers.Add(performanceCounterInstaller);

            #region Processing - item processing time

            var turnoverTimeCounterCreation = new CounterCreationData
                                                {
                                                    CounterName = "Item turnover time, ms",
                                                    CounterHelp = "Time, in milliseconds, to process the single item.",
                                                    CounterType = PerformanceCounterType.AverageTimer32
                                                };
            performanceCounterInstaller.Counters.Add(turnoverTimeCounterCreation);

            CounterCreationData familyTimeAverageCounterCreation = new CounterCreationData();
            familyTimeAverageCounterCreation.CounterName = "Item turnover time base, ms";
            familyTimeAverageCounterCreation.CounterHelp = "Time, in milliseconds, to process single item.";
            familyTimeAverageCounterCreation.CounterType = PerformanceCounterType.AverageBase;
            performanceCounterInstaller.Counters.Add(familyTimeAverageCounterCreation);

            // Add a counter to collection of  performanceCounterInstaller.

            #endregion Processing - item processing time

            #region Processing - Rate of items production per second

            var queueCounterCreation = new CounterCreationData
                                           {
                                               CounterName = "Produced items/sec",
                                               CounterType = PerformanceCounterType.RateOfCountsPerSecond32,
                                               CounterHelp =
                                                   "Rate of items production per second."
                                           };
            // Add a counter to collection of  performanceCounterInstaller.
            performanceCounterInstaller.Counters.Add(queueCounterCreation);

            #endregion Processing - Rate of items production per second
        }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            const string PRODUCT = "Alachisoft";

            components = new System.ComponentModel.Container();

            ContentOptimizationCountersInstaller = new System.Diagnostics.PerformanceCounterInstaller();
            ContentOptimizationCountersInstaller.CategoryName = PRODUCT + ":" + "ContentOptimization";
            ContentOptimizationCountersInstaller.Counters.AddRange(new System.Diagnostics.CounterCreationData[] {
                new CounterCreationData("Viewstate size", "Size of viewstate in bytes.", PerformanceCounterType.AverageCount64),
                new CounterCreationData("Viewstate size base", "Base counter for viewstate size.", PerformanceCounterType.AverageBase),
                new CounterCreationData("Viewstate hits/sec", "Number of times viewstate is successfully served from cache.", PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData("Viewstate misses/sec", "Number of times viewstate is not successfully served from cache.", PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData("Viewstate additions/sec", "Number of viewstate add operations per second.", PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData("Viewstate requests/sec", "Number of viewstate read requests per second.", PerformanceCounterType.RateOfCountsPerSecond32),
            });

            this.Installers.AddRange(new System.Configuration.Install.Installer[] { ContentOptimizationCountersInstaller });
        }
        public CounterInstaller()
        {
            using (var counterInstaller = new PerformanceCounterInstaller())
            {
                counterInstaller.CategoryHelp = "Category help";
                counterInstaller.CategoryType = PerformanceCounterCategoryType.MultiInstance;
                counterInstaller.CategoryName = "Category name";

                CounterCreationData numbersProcessed = new CounterCreationData
                {
                    CounterType = PerformanceCounterType.NumberOfItems32,
                    CounterName = "Items processed/sec",
                    CounterHelp = "Number of items processed"
                };

                counterInstaller.Counters.Add(numbersProcessed);

                base.Installers.Add(counterInstaller);
            }
        }
        public AzureInstrumentationInstaller()
        {
            InitializeComponent();

            // Receiver performance counters
            {
                var installer = new PerformanceCounterInstaller { CategoryName = Constants.ReceiversPerformanceCountersCategory, CategoryType = PerformanceCounterCategoryType.MultiInstance };
                this.Installers.Add(installer);

                installer.Counters.Add(new CounterCreationData(SessionSubscriptionReceiverInstrumentation.TotalSessionsCounterName, string.Empty, PerformanceCounterType.NumberOfItems32));
                installer.Counters.Add(new CounterCreationData(SessionSubscriptionReceiverInstrumentation.CurrentSessionsCounterName, string.Empty, PerformanceCounterType.NumberOfItems32));

                installer.Counters.Add(new CounterCreationData(SubscriptionReceiverInstrumentation.CurrentMessagesInProcessCounterName, string.Empty, PerformanceCounterType.NumberOfItems32));
                installer.Counters.Add(new CounterCreationData(SubscriptionReceiverInstrumentation.TotalMessagesCounterName, string.Empty, PerformanceCounterType.NumberOfItems32));
                installer.Counters.Add(new CounterCreationData(SubscriptionReceiverInstrumentation.TotalMessagesSuccessfullyProcessedCounterName, string.Empty, PerformanceCounterType.NumberOfItems32));
                installer.Counters.Add(new CounterCreationData(SubscriptionReceiverInstrumentation.TotalMessagesUnsuccessfullyProcessedCounterName, string.Empty, PerformanceCounterType.NumberOfItems32));
                installer.Counters.Add(new CounterCreationData(SubscriptionReceiverInstrumentation.TotalMessagesCompletedCounterName, string.Empty, PerformanceCounterType.NumberOfItems32));
                installer.Counters.Add(new CounterCreationData(SubscriptionReceiverInstrumentation.TotalMessagesNotCompletedCounterName, string.Empty, PerformanceCounterType.NumberOfItems32));

                installer.Counters.Add(new CounterCreationData(SubscriptionReceiverInstrumentation.AverageMessageProcessingTimeCounterName, string.Empty, PerformanceCounterType.RawFraction));
                installer.Counters.Add(new CounterCreationData(SubscriptionReceiverInstrumentation.AverageMessageProcessingTimeBaseCounterName, string.Empty, PerformanceCounterType.RawBase));

                installer.Counters.Add(new CounterCreationData(SubscriptionReceiverInstrumentation.MessagesReceivedPerSecondCounterName, string.Empty, PerformanceCounterType.RateOfCountsPerSecond32));
            }

            // Event store publisher counters
            {
                var installer = new PerformanceCounterInstaller { CategoryName = Constants.EventPublishersPerformanceCountersCategory, CategoryType = PerformanceCounterCategoryType.MultiInstance };
                this.Installers.Add(installer);


                installer.Counters.Add(new CounterCreationData(EventStoreBusPublisherInstrumentation.TotalEventsPublishingRequestsCounterName, string.Empty, PerformanceCounterType.NumberOfItems32));
                installer.Counters.Add(new CounterCreationData(EventStoreBusPublisherInstrumentation.EventPublishingRequestsPerSecondCounterName, string.Empty, PerformanceCounterType.RateOfCountsPerSecond32));

                installer.Counters.Add(new CounterCreationData(EventStoreBusPublisherInstrumentation.TotalEventsPublishedCounterName, string.Empty, PerformanceCounterType.NumberOfItems32));
                installer.Counters.Add(new CounterCreationData(EventStoreBusPublisherInstrumentation.EventsPublishedPerSecondCounterName, string.Empty, PerformanceCounterType.RateOfCountsPerSecond32));

                installer.Counters.Add(new CounterCreationData(EventStoreBusPublisherInstrumentation.CurrentEventPublishersCounterName, string.Empty, PerformanceCounterType.NumberOfItems32));
            }
        }
        void CollectPerformanceCounters(Type instrumentedType,
                                        PerformanceCounterInstaller installer)
        {
            foreach (FieldInfo field in instrumentedType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
            {
                object[] attributes = field.GetCustomAttributes(typeof(PerformanceCounterAttribute), false);
                if (attributes.Length == 1)
                {
                    PerformanceCounterAttribute attribute = (PerformanceCounterAttribute)attributes[0];

                    CounterCreationData counter = GetExistingCounter(installer, attribute.CounterName);
                    if (counter == null)
                    {
                        installer.Counters.Add(
                            new CounterCreationData(attribute.CounterName, GetCounterHelp(attribute.CounterHelp, instrumentedType.Assembly), attribute.CounterType));
                        if (attribute.HasBaseCounter())
                        {
                            installer.Counters.Add(
                                new CounterCreationData(attribute.BaseCounterName, GetCounterHelp(attribute.BaseCounterHelp, instrumentedType.Assembly), attribute.BaseCounterType));
                        }
                    }
                    else
                    {
                        if (counter.CounterType != attribute.CounterType || !counter.CounterHelp.Equals(GetCounterHelp(attribute.CounterHelp, instrumentedType.Assembly)))
                        {
                            throw new InvalidOperationException(
                                string.Format(
                                    CultureInfo.CurrentCulture,
                                    Resources.ExceptionPerformanceCounterRedefined,
                                    counter.CounterName,
                                    installer.CategoryName,
                                    instrumentedType.FullName));
                        }

                        // ignore new definition if equal
                    }
                }
            }
        }
Example #19
0
		/// <summary>
		/// Instantiates the custom installer class
		/// </summary>
		public PerfCounterInstaller()
		{
			System.Diagnostics.Debug.WriteLine( "PerfCounterInstaller: done" );
			// This call is required by the Designer.
			InitializeComponent();

			try
			{
				// Create an instance of 'PerformanceCounterInstaller'.
				PerformanceCounterInstaller performanceCounterInstaller =
					new PerformanceCounterInstaller();
				
				// Set the 'CategoryName' for performance counter.
				performanceCounterInstaller.CategoryName = PerfCounterManager.CATEGORY;

				CounterCreationData cacheHitCounterCreation = new CounterCreationData();
				cacheHitCounterCreation.CounterName = PerfCounterManager.SERIALIZER_HITS_NAME;
				cacheHitCounterCreation.CounterHelp = PerfCounterManager.SERIALIZER_HITS_DESCRIPTION;
				cacheHitCounterCreation.CounterType = PerformanceCounterType.NumberOfItems64;

				CounterCreationData cachedInstancesCounterCreation = new CounterCreationData();
				cachedInstancesCounterCreation.CounterName = PerfCounterManager.CACHED_INSTANCES_NAME;
				cachedInstancesCounterCreation.CounterHelp = PerfCounterManager.CACHED_INSTANCES_DESCRIPTION;
				cachedInstancesCounterCreation.CounterType = PerformanceCounterType.NumberOfItems64;

				// Add a counter to collection of  performanceCounterInstaller.
				performanceCounterInstaller.Counters.Add(cacheHitCounterCreation);
				performanceCounterInstaller.Counters.Add(cachedInstancesCounterCreation);
				Installers.Add(performanceCounterInstaller);
				System.Diagnostics.Debug.WriteLine( "PerfCounterInstaller: Added counters and category" );
			}
			catch(Exception e)
			{
				System.Diagnostics.Debug.WriteLine("PerfCounterInstaller Error occured :"+e.Message);
			}
			System.Diagnostics.Debug.WriteLine( "PerfCounterInstaller done" );

		}
 private void CollectPerformanceCounters(Type instrumentedType, PerformanceCounterInstaller installer)
 {
     foreach (FieldInfo info in instrumentedType.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance))
     {
         object[] customAttributes = info.GetCustomAttributes(typeof(PerformanceCounterAttribute), false);
         if (customAttributes.Length == 1)
         {
             PerformanceCounterAttribute attribute = (PerformanceCounterAttribute) customAttributes[0];
             CounterCreationData existingCounter = this.GetExistingCounter(installer, attribute.CounterName);
             if (existingCounter == null)
             {
                 installer.Counters.Add(new CounterCreationData(attribute.CounterName, GetCounterHelp(attribute.CounterHelp, instrumentedType.Assembly), attribute.CounterType));
                 if (attribute.HasBaseCounter())
                 {
                     installer.Counters.Add(new CounterCreationData(attribute.BaseCounterName, GetCounterHelp(attribute.BaseCounterHelp, instrumentedType.Assembly), attribute.BaseCounterType));
                 }
             }
             else if ((existingCounter.CounterType != attribute.CounterType) || !existingCounter.CounterHelp.Equals(GetCounterHelp(attribute.CounterHelp, instrumentedType.Assembly)))
             {
                 throw new InvalidOperationException(string.Format(Resources.Culture, Resources.ExceptionPerformanceCounterRedefined, new object[] { existingCounter.CounterName, installer.CategoryName, instrumentedType.FullName }));
             }
         }
     }
 }
Example #21
0
        protected void SetupCounters()
        {
            //TODO: (SD) All of that will be setup with Spring.net
            var performanceCounterInstaller =
                new PerformanceCounterInstaller
                    {
                        CategoryName = ServiceName
                    };

            Installers.Add(performanceCounterInstaller);

            #region Processing - item processing times

            var turnoverTimeCounterCreation = new CounterCreationData
                                                {
                                                    CounterName = "Command Avg Execution time, ms",
                                                    CounterHelp = "Time, in milliseconds, to process the single command.",
                                                    CounterType = PerformanceCounterType.AverageTimer32
                                                };
            performanceCounterInstaller.Counters.Add(turnoverTimeCounterCreation);

            var turnoverTimeAverageCounterCreation = new CounterCreationData
                                                                       {
                                                                           CounterName = "Command Avg Execution time base, ms",
                                                                           CounterHelp =
                                                                               "Average time, in milliseconds, to process single command.",
                                                                           CounterType =
                                                                               PerformanceCounterType.AverageBase
                                                                       };
            performanceCounterInstaller.Counters.Add(turnoverTimeAverageCounterCreation);

            // Add a counter to collection of  performanceCounterInstaller.

            #endregion Processing - item processing time

            #region Processing - Statistics - commands

            var commandsTotalCounterCreation = new CounterCreationData {
                CounterName = "New Commands",
                CounterType = PerformanceCounterType.NumberOfItems32,
                CounterHelp = "Commands that came within specified period"
                };

            performanceCounterInstaller.Counters.Add(commandsTotalCounterCreation);

            var commandsUnprocessedCounterCreation = new CounterCreationData {
                CounterName = "Commands in process",
                CounterType = PerformanceCounterType.NumberOfItems32,
                CounterHelp = "Total of commands that are being currently processed"
                };
            performanceCounterInstaller.Counters.Add(commandsUnprocessedCounterCreation);

            var commandsProcessedCounterCreation = new CounterCreationData {
                CounterName = "Completed commands",
                CounterType = PerformanceCounterType.NumberOfItems32,
                CounterHelp = "Total of commands that have been processed within the defined period"
                };

            performanceCounterInstaller.Counters.Add(commandsProcessedCounterCreation);


            var commandsFailedCounterCreation = new CounterCreationData
            {
                CounterName = "Failed commands",
                CounterType = PerformanceCounterType.NumberOfItems32,
                CounterHelp = "Total of commands that failed within the defined period"
            };

            performanceCounterInstaller.Counters.Add(commandsFailedCounterCreation);

            #endregion

        }
Example #22
0
 public OrleansPerformanceCounterInstaller()
 {
     try
     {
         using (PerformanceCounterInstaller myPerformanceCounterInstaller = new PerformanceCounterInstaller())
         {
             myPerformanceCounterInstaller.CategoryName = ChirperPerformanceCounters.CategoryName;
             myPerformanceCounterInstaller.CategoryType = PerformanceCounterCategoryType.MultiInstance;
             myPerformanceCounterInstaller.Counters.Add(new CounterCreationData(ChirperPerformanceCounters.ChirpsPerSecondName, "Number of grains", PerformanceCounterType.NumberOfItems32));
             Installers.Add(myPerformanceCounterInstaller);
         }
     }
     catch (Exception exc)
     {
         this.Context.LogMessage("Failed to install performance counters: " + exc.Message);
     }
 }
        private void CreateInstallers()
        {
            Installers.Clear();
            foreach(string categoryName in categoryNames)
            {
                PerformanceCounterInstaller installer = new PerformanceCounterInstaller();
                installer.CategoryName = categoryName;
                installer.CategoryHelp = Resources.PerformanceCounterCategoryHelp;
                installer.CategoryType = PerformanceCounterCategoryType.MultiInstance;

                installer.Counters.Add(GetNumberOfCallsCreationData());
                installer.Counters.Add(GetCallsPerSecondCreationData());
                installer.Counters.Add(GetNumberOfExceptionsCreationData());
                installer.Counters.Add(GetExceptionsPerSecondCreationData());
                installer.Counters.Add(GetAverageCallDurationCreationData());
                installer.Counters.Add(GetAverageCallDurationBaseCreationData());

                Installers.Add(installer);
            }
        }
 public void NoExceptionThrownIfNoInstrumentedTypesInList()
 {
     PerformanceCounterInstaller installer = new PerformanceCounterInstaller();
     PerformanceCounterInstallerBuilder builder =
         new PerformanceCounterInstallerBuilder(new Type[] { typeof(NonInstrumentedClass) });
     builder.Fill(installer);
 }
 static CounterCreationData GetExistingCounter(PerformanceCounterInstaller installer,
                                        string counterName)
 {
     foreach (CounterCreationData counter in installer.Counters)
     {
         if (counter.CounterName.Equals(counterName, StringComparison.CurrentCulture))
             return counter;
     }
     return null;
 }
Example #26
0
        private void AddPerformanceCountersToInstaller()
        {
            // The categoryInstaller is for one performance category only.
            // We have only one category per assembly
            PerformanceCounterInstaller categoryInstaller = new PerformanceCounterInstaller();
            categoryInstaller.CategoryName = this.counterCategory;
            categoryInstaller.CategoryHelp = this.counterCategoryHelp;
            Installers.Add(categoryInstaller);

            // adding all the counters in the category.
            foreach (CounterCreationData counterCreation in this.counterData)
            {
                categoryInstaller.Counters.Add(counterCreation);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskManagerInstaller"/> class.
        /// </summary>
        public TaskManagerInstaller()
        {
            this.InitializeComponent();

            this._serviceInstaller = new ServiceInstaller();
            this._serviceProcessInstaller = new ServiceProcessInstaller();
            this._eventLogInstaller = new EventLogInstaller();

            this._serviceInstaller.ServiceName = SERVICE_NAME;
            this._serviceInstaller.StartType = ServiceStartMode.Automatic;
            this._serviceInstaller.Description = SERVICE_DESCRIPTION;

            this._serviceProcessInstaller.Account = ServiceAccount.NetworkService;

            this._eventLogInstaller.Log = TaskManagerService.LogName;
            this._eventLogInstaller.Source = TaskManagerService.LogSource;

            this.Installers.Add(this._serviceInstaller);
            this.Installers.Add(this._serviceProcessInstaller);
            this.Installers.Add(this._eventLogInstaller);

            this._perfCounterInstaller = new PerformanceCounterInstaller();
            this._perfCounterInstaller.CategoryName = PERFORMANCE_COUNTER_CATEGORY;
            this._perfCounterInstaller.CategoryHelp = PERFORMANCE_COUNTER_DESCRIPTION;
            this._perfCounterInstaller.CategoryType = PerformanceCounterCategoryType.SingleInstance;

            this._perfCounterInstaller.Counters.AddRange(COUNTERS);

            this.Installers.Add(this._perfCounterInstaller);
        }