コード例 #1
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);
            }
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
ファイル: Installer.cs プロジェクト: tvrjcf/Demo
        /// <summary>
        /// 初始化 <see cref="System.Data.MySqlClient.CustomInstaller"/> 的新实例。
        /// </summary>
        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 = System.Data.MySqlClient.Properties.Resources.PerfMonCategoryName;
                p.CategoryHelp = System.Data.MySqlClient.Properties.Resources.PerfMonCategoryHelp;
                p.CategoryType = PerformanceCounterCategoryType.SingleInstance;

                CounterCreationData ccd1 = new CounterCreationData(
                    System.Data.MySqlClient.Properties.Resources.PerfMonHardProcName,
                    System.Data.MySqlClient.Properties.Resources.PerfMonHardProcHelp,
                    PerformanceCounterType.NumberOfItems32);

                CounterCreationData ccd2 = new CounterCreationData(
                    System.Data.MySqlClient.Properties.Resources.PerfMonSoftProcName,
                    System.Data.MySqlClient.Properties.Resources.PerfMonSoftProcHelp,
                    PerformanceCounterType.RateOfCountsPerSecond32);

                p.Counters.Add(ccd1);
                p.Counters.Add(ccd2);
                perfMonIndex = Installers.Add(p);
            }
        }
コード例 #4
0
        public void IntersectingCountersForDifferentCategoriesInDifferentTypesCreatesMultipleInstallers()
        {
            Installer parentInstaller = new Installer();
            PerformanceCounterInstallerBuilder builder
                = new PerformanceCounterInstallerBuilder(
                      new Type[]
            {
                typeof(MultipleCounterTypeForCategoryA),
                typeof(MultipleCounterTypeForCategoryB)
            });

            builder.Fill(parentInstaller);

            Assert.AreEqual(2, parentInstaller.Installers.Count);
            Assert.AreSame(typeof(PerformanceCounterInstaller), parentInstaller.Installers[0].GetType());
            Assert.AreSame(typeof(PerformanceCounterInstaller), parentInstaller.Installers[1].GetType());

            PerformanceCounterInstaller installer1 = (PerformanceCounterInstaller)parentInstaller.Installers[0];

            Assert.AreEqual(PerformanceCounterCategoryType.MultiInstance, installer1.CategoryType);
            Assert.AreEqual("CategoryName", installer1.CategoryName);
            Assert.AreEqual("This is the help", installer1.CategoryHelp);
            Assert.AreEqual(2, installer1.Counters.Count);
            Assert.IsFalse(ReferenceEquals(installer1.Counters[0], installer1.Counters[1]));
            Assert.IsFalse(installer1.Counters[0].Equals(installer1.Counters[1]));

            PerformanceCounterInstaller installer2 = (PerformanceCounterInstaller)parentInstaller.Installers[1];

            Assert.AreEqual(PerformanceCounterCategoryType.MultiInstance, installer2.CategoryType);
            Assert.AreEqual("CategoryNameB", installer2.CategoryName);
            Assert.AreEqual("This is the help", installer2.CategoryHelp);
            Assert.AreEqual(2, installer2.Counters.Count);
            Assert.IsFalse(ReferenceEquals(installer2.Counters[0], installer2.Counters[1]));
            Assert.IsFalse(installer2.Counters[0].Equals(installer2.Counters[1]));
        }
コード例 #5
0
        public static PerformanceCounterInstaller GetInstallerFor <T>() where T : IPerformanceCounterSet
        {
            var category = Helper.GetCategoryAttribute(typeof(T));

            if (category == null)
            {
                var message = string.Format("Type '{0}' should be marked with PerformanceCounterCategoryAttribute", typeof(T));
                throw new ArgumentException(message);
            }

            var installer = new PerformanceCounterInstaller
            {
                CategoryName = category.CategoryName,
                CategoryHelp = category.CategoryHelp,
                CategoryType = category.CategoryType
            };

            foreach (var propertyInfo in typeof(T).GetProperties())
            {
                var counterCreationData = Helper.GetCounterCreationData(propertyInfo);
                if (counterCreationData == null)
                {
                    continue;
                }

                installer.Counters.Add(counterCreationData);
            }

            return(installer);
        }
コード例 #6
0
 void PopulateCounterCategoryData(PerformanceCountersDefinitionAttribute attribute,
                                  Assembly originalAssembly,
                                  PerformanceCounterInstaller installer)
 {
     installer.CategoryName = attribute.CategoryName;
     installer.CategoryHelp = GetCategoryHelp(attribute, originalAssembly);
     installer.CategoryType = attribute.CategoryType;
 }
コード例 #7
0
        public void NoExceptionThrownIfNoInstrumentedTypesInList()
        {
            PerformanceCounterInstaller        installer = new PerformanceCounterInstaller();
            PerformanceCounterInstallerBuilder builder   =
                new PerformanceCounterInstallerBuilder(new Type[] { typeof(NonInstrumentedClass) });

            builder.Fill(installer);
        }
コード例 #8
0
        private static void UninstallPerformanceCounters()
        {
            var installer = new PerformanceCounterInstaller();

            installer.UninstallCounters();

            Console.WriteLine("Performance counters uninstalled!");
            Console.WriteLine();
        }
コード例 #9
0
        public void PerformanceCountersFromNonInstrumentedClassesAreNotAdded()
        {
            PerformanceCounterInstaller        parentInstaller = new PerformanceCounterInstaller();
            PerformanceCounterInstallerBuilder builder
                = new PerformanceCounterInstallerBuilder(new Type[] { typeof(NonInstrumentedClass) });

            builder.Fill(parentInstaller);

            Assert.AreEqual(0, parentInstaller.Installers.Count);
        }
コード例 #10
0
        protected override ICollection <Installer> CreateInstallers(ICollection <Type> instrumentedTypes)
        {
            List <Installer> installers = new List <Installer>();

            foreach (Type instrumentedType in instrumentedTypes)
            {
                PerformanceCounterInstaller installer = GetOrCreateInstaller(instrumentedType, installers);
                CollectPerformanceCounters(instrumentedType, installer);
            }
            return(installers);
        }
コード例 #11
0
 private CounterCreationData GetExistingCounter(PerformanceCounterInstaller installer, string counterName)
 {
     foreach (CounterCreationData counter in installer.Counters)
     {
         if (counter.CounterName.Equals(counterName, StringComparison.CurrentCulture))
         {
             return(counter);
         }
     }
     return(null);
 }
コード例 #12
0
        private void InitCountersFromInstaller(PerformanceCounterInstaller installer, string instanceName)
        {
            installer.NullCheck("installer");

            PerformanceCounterInitData initData = new PerformanceCounterInitData(installer.CategoryName, string.Empty, instanceName);

            foreach (CounterCreationData counter in installer.Counters)
            {
                initData.CounterName = counter.CounterName;
                this.counters[initData.CounterName] = new PerformanceCounterWrapper(initData);
            }
        }
コード例 #13
0
        public static void Uninstall(Type type)
        {
            ChoGuard.ArgumentNotNull(type, "type");

            ChoPerformanceCounterInstallerBuilder builder   = new ChoPerformanceCounterInstallerBuilder(type);
            PerformanceCounterInstaller           installer = builder.CreateInstaller();

            if (PerformanceCounterCategory.Exists(installer.CategoryName))
            {
                PerformanceCounterCategory.Delete(installer.CategoryName);
            }
        }
コード例 #14
0
        public Installer GetInstaller()
        {
            var installer = new PerformanceCounterInstaller
            {
                CategoryName = _categoryName,
                CategoryHelp = _categoryHelp,
            };

            installer.Counters.AddRange(_counterDefinitions);

            return(installer);
        }
コード例 #15
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);
        }
コード例 #16
0
        PerformanceCounterInstaller GetOrCreateInstaller(Type instrumentedType,
                                                         ICollection <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);
        }
コード例 #17
0
        /// <summary>
        /// Adds performance counter installers for each counter represented in this set
        /// to the installer passed.
        /// </summary>
        /// <param name="installer">The target installer.</param>
        public void AddInstallers(System.Configuration.Install.Installer installer)
        {
            PerformanceCounterInstaller ctrInstaller;

            ctrInstaller = new PerformanceCounterInstaller();
            ctrInstaller.CategoryName = this.categoryName;
            ctrInstaller.CategoryHelp = this.categoryHelp;

            foreach (var counter in counters.Values)
            {
                ctrInstaller.Counters.Add(new CounterCreationData(counter.Name, counter.Help, counter.Type));
            }

            installer.Installers.Add(ctrInstaller);
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: iamnilay3/SignalR
        private static void InstallPerformanceCounters()
        {
            Console.WriteLine("  Installing performance counters...");

            var installer = new PerformanceCounterInstaller();
            var counters = installer.InstallCounters();

            foreach (var counter in counters)
            {
                Console.WriteLine("\t" + counter);
            }

            Console.WriteLine();
            Console.WriteLine("  Performance counters installed!");
            Console.WriteLine();
        }
コード例 #19
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);
            }
        }
コード例 #20
0
        private static void InstallPerformanceCounters()
        {
            Console.WriteLine("Installing performance counters...");

            var installer = new PerformanceCounterInstaller();
            var counters  = installer.InstallCounters();

            foreach (var counter in counters)
            {
                Console.WriteLine("\t" + counter);
            }

            Console.WriteLine();
            Console.WriteLine("Performance counters installed!");
            Console.WriteLine();
        }
コード例 #21
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);
            }
        }
コード例 #22
0
        public PerformanceCounterInstallProvider()
        {
            InitializeComponent();

            PerformanceCounterInstaller performanceCounters = new PerformanceCounterInstaller();

            performanceCounters.CategoryName = "SharpOpen.Net";
            performanceCounters.CategoryHelp = "Performance counters for SharpOpen.Net";
            performanceCounters.CategoryType = PerformanceCounterCategoryType.SingleInstance;

            performanceCounters.Counters.Add(new CounterCreationData("Connections Accepted", "The number of connections accepted", PerformanceCounterType.RateOfCountsPerSecond32));
            performanceCounters.Counters.Add(new CounterCreationData("Bytes Sent", "Bytes sent to the remote end points", PerformanceCounterType.RateOfCountsPerSecond32));
            performanceCounters.Counters.Add(new CounterCreationData("Bytes Received", "Bytes received from remote end points", PerformanceCounterType.RateOfCountsPerSecond32));

            Installers.Add(performanceCounters);
        }
コード例 #23
0
        public AzureInstrumentationInstaller()
        {
            InitializeComponent();

            // Receiver performance counters
            {
                var installer = new PerformanceCounterInstaller {
                    CategoryName = Constants.ReceiversPerformanceCountersCategory, CategoryType = PerformanceCounterCategoryType.MultiInstance
                };
                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
                };
                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));
            }
        }
コード例 #24
0
ファイル: PerfCounters.cs プロジェクト: Davlind/orleans-demo
 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);
     }
 }
コード例 #25
0
 /// <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);
     }
 }
コード例 #26
0
        public void CounterCategoryInformationIsPopulatedIntoCreatedInstaller()
        {
            Installer parentInstaller = new Installer();
            PerformanceCounterInstallerBuilder builder
                = new PerformanceCounterInstallerBuilder(new Type[] { typeof(MultipleCounterTypeForCategoryA) });

            builder.Fill(parentInstaller);

            Assert.AreEqual(1, parentInstaller.Installers.Count);
            Assert.AreSame(typeof(PerformanceCounterInstaller), parentInstaller.Installers[0].GetType());

            PerformanceCounterInstaller installer = (PerformanceCounterInstaller)parentInstaller.Installers[0];

            Assert.AreEqual(PerformanceCounterCategoryType.MultiInstance, installer.CategoryType);
            Assert.AreEqual("CategoryName", installer.CategoryName);
            Assert.AreEqual("This is the help", installer.CategoryHelp);
        }
コード例 #27
0
        public void SingleCounterIsAddedToInstaller()
        {
            Installer parentInstaller = new Installer();
            PerformanceCounterInstallerBuilder builder
                = new PerformanceCounterInstallerBuilder(new Type[] { typeof(SingleCounterType) });

            builder.Fill(parentInstaller);

            Assert.AreEqual(1, parentInstaller.Installers.Count);
            Assert.AreSame(typeof(PerformanceCounterInstaller), parentInstaller.Installers[0].GetType());

            PerformanceCounterInstaller installer = (PerformanceCounterInstaller)parentInstaller.Installers[0];

            CounterCreationData createdCounterData = installer.Counters[0];

            Assert.AreEqual("Bill", createdCounterData.CounterName);
            Assert.AreEqual("Help Bill", createdCounterData.CounterHelp);
            Assert.AreEqual(PerformanceCounterType.CounterMultiTimer, createdCounterData.CounterType);
        }
コード例 #28
0
        public void DisjointCountersForSameCategoriesInDifferentTypesCreatesSingleInstaller()
        {
            Installer parentInstaller = new Installer();
            PerformanceCounterInstallerBuilder builder
                = new PerformanceCounterInstallerBuilder(new Type[] { typeof(MultipleCounterTypeForCategoryA), typeof(AlternativeMultipleCounterTypeForCategoryA) });

            builder.Fill(parentInstaller);

            Assert.AreEqual(1, parentInstaller.Installers.Count);
            Assert.AreSame(typeof(PerformanceCounterInstaller), parentInstaller.Installers[0].GetType());

            PerformanceCounterInstaller installer = (PerformanceCounterInstaller)parentInstaller.Installers[0];

            Assert.AreEqual(PerformanceCounterCategoryType.MultiInstance, installer.CategoryType);
            Assert.AreEqual("CategoryName", installer.CategoryName);
            Assert.AreEqual("This is the help", installer.CategoryHelp);

            Assert.AreEqual(4, installer.Counters.Count);
        }
コード例 #29
0
        public void MultipleCountersInSingleTypeAreAllAddedToInstaller()
        {
            Installer parentInstaller = new Installer();
            PerformanceCounterInstallerBuilder builder
                = new PerformanceCounterInstallerBuilder(new Type[] { typeof(MultipleCounterTypeForCategoryA) });

            builder.Fill(parentInstaller);

            Assert.AreEqual(1, parentInstaller.Installers.Count);
            Assert.AreSame(typeof(PerformanceCounterInstaller), parentInstaller.Installers[0].GetType());

            PerformanceCounterInstaller installer = (PerformanceCounterInstaller)parentInstaller.Installers[0];

            Assert.AreEqual(2, installer.Counters.Count);
            CounterCreationData firstCounter  = installer.Counters[0];
            CounterCreationData secondCounter = installer.Counters[1];

            Assert.IsFalse(ReferenceEquals(firstCounter, secondCounter));
            Assert.IsFalse(firstCounter.Equals(secondCounter));
        }
コード例 #30
0
        public void CountersWithBaseCountersAreAddedToInstallerInCorrectOrder()
        {
            Installer parentInstaller = new Installer();
            PerformanceCounterInstallerBuilder builder = new PerformanceCounterInstallerBuilder(new Type[] { typeof(TypeWithComplexCounter) });

            builder.Fill(parentInstaller);

            PerformanceCounterInstaller installer = (PerformanceCounterInstaller)parentInstaller.Installers[0];

            Assert.AreEqual(2, installer.Counters.Count);

            CounterCreationData realCounter = installer.Counters[0];
            CounterCreationData baseCounter = installer.Counters[1];

            Assert.AreEqual("real name", realCounter.CounterName);
            Assert.AreEqual(PerformanceCounterType.RawFraction, realCounter.CounterType);

            Assert.AreEqual("base name", baseCounter.CounterName);
            Assert.AreEqual(PerformanceCounterType.RawBase, baseCounter.CounterType);
        }
コード例 #31
0
        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);
            }
        }
コード例 #32
0
ファイル: Program.cs プロジェクト: iamnilay3/SignalR
        private static void UninstallPerformanceCounters()
        {
            var installer = new PerformanceCounterInstaller();
            installer.UninstallCounters();

            Console.WriteLine("  Performance counters uninstalled!");
            Console.WriteLine();
        }