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); } }
/// <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); }
/// <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); } }
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])); }
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); }
void PopulateCounterCategoryData(PerformanceCountersDefinitionAttribute attribute, Assembly originalAssembly, PerformanceCounterInstaller installer) { installer.CategoryName = attribute.CategoryName; installer.CategoryHelp = GetCategoryHelp(attribute, originalAssembly); installer.CategoryType = attribute.CategoryType; }
public void NoExceptionThrownIfNoInstrumentedTypesInList() { PerformanceCounterInstaller installer = new PerformanceCounterInstaller(); PerformanceCounterInstallerBuilder builder = new PerformanceCounterInstallerBuilder(new Type[] { typeof(NonInstrumentedClass) }); builder.Fill(installer); }
private static void UninstallPerformanceCounters() { var installer = new PerformanceCounterInstaller(); installer.UninstallCounters(); Console.WriteLine("Performance counters uninstalled!"); Console.WriteLine(); }
public void PerformanceCountersFromNonInstrumentedClassesAreNotAdded() { PerformanceCounterInstaller parentInstaller = new PerformanceCounterInstaller(); PerformanceCounterInstallerBuilder builder = new PerformanceCounterInstallerBuilder(new Type[] { typeof(NonInstrumentedClass) }); builder.Fill(parentInstaller); Assert.AreEqual(0, parentInstaller.Installers.Count); }
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); }
private CounterCreationData GetExistingCounter(PerformanceCounterInstaller installer, string counterName) { foreach (CounterCreationData counter in installer.Counters) { if (counter.CounterName.Equals(counterName, StringComparison.CurrentCulture)) { return(counter); } } return(null); }
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); } }
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); } }
public Installer GetInstaller() { var installer = new PerformanceCounterInstaller { CategoryName = _categoryName, CategoryHelp = _categoryHelp, }; installer.Counters.AddRange(_counterDefinitions); return(installer); }
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); }
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); }
/// <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); }
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(); }
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); } }
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(); }
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); } }
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); }
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)); } }
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); } }
/// <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); } }
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); }
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); }
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); }
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)); }
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); }
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); } }
private static void UninstallPerformanceCounters() { var installer = new PerformanceCounterInstaller(); installer.UninstallCounters(); Console.WriteLine(" Performance counters uninstalled!"); Console.WriteLine(); }