protected override void ProcessRecord()
 {
     if (ShouldProcess(Environment.MachineName))
     {
         PerformanceCounterSetup.SetupCounters();
     }
 }
 void ForceCreate()
 {
     var setup = new PerformanceCounterSetup(Host);
     try
     {
        setup.DeleteCategory();
     }
     catch (Exception exception)
     {
         var errorRecord = new ErrorRecord(exception, "FailedToDeleteCategory", ErrorCategory.NotSpecified, null);
         ThrowTerminatingError(errorRecord);
     }
     setup.SetupCounters();
 }
        void ForceCreate()
        {
            var setup = new PerformanceCounterSetup(Host);

            try
            {
                setup.DeleteCategory();
            }
            catch (Exception exception)
            {
                var errorRecord = new ErrorRecord(exception, "FailedToDeleteCategory", ErrorCategory.NotSpecified, null);
                ThrowTerminatingError(errorRecord);
            }
            setup.SetupCounters();
        }
Exemplo n.º 4
0
 void ForceCreate()
 {
     try
     {
         Host.UI.WriteLine("Deleting counters");
         PerformanceCounterSetup.DeleteCategory();
     }
     catch (Exception exception)
     {
         var errorRecord = new ErrorRecord(exception, "FailedToDeleteCategory", ErrorCategory.NotSpecified, null);
         ThrowTerminatingError(errorRecord);
     }
     Host.UI.WriteLine("Creating counters");
     PerformanceCounterSetup.SetupCounters();
 }
        void Create()
        {
            var setup = new PerformanceCounterSetup(Host);
            var allCountersExist = setup.CheckCounters();
            if (allCountersExist)
            {
                return;
            }

            if (setup.DoesCategoryExist())
            {
                var exception = new Exception("Existing category is not configured correctly. Use the -Force option to delete and re-create");
                var errorRecord = new ErrorRecord(exception, "FailedToCreateCategory", ErrorCategory.NotSpecified, null);
                ThrowTerminatingError(errorRecord);
            }
            setup.SetupCounters();
        }
        void Create()
        {
            var setup            = new PerformanceCounterSetup(Host);
            var allCountersExist = setup.CheckCounters();

            if (allCountersExist)
            {
                return;
            }

            if (setup.DoesCategoryExist())
            {
                var exception   = new Exception("Existing category is not configured correctly. Use the -Force option to delete and re-create");
                var errorRecord = new ErrorRecord(exception, "FailedToCreateCategory", ErrorCategory.NotSpecified, null);
                ThrowTerminatingError(errorRecord);
            }
            setup.SetupCounters();
        }
Exemplo n.º 7
0
        void Create()
        {
            var allCountersExist = PerformanceCounterSetup.CheckCounters();

            if (allCountersExist)
            {
                Host.UI.WriteLine("Did not create counters since they already exist");
                return;
            }

            if (PerformanceCounterSetup.DoesCategoryExist())
            {
                var exception   = new Exception("Existing category is not configured correctly. Use the -Force option to delete and re-create");
                var errorRecord = new ErrorRecord(exception, "FailedToCreateCategory", ErrorCategory.NotSpecified, null);
                ThrowTerminatingError(errorRecord);
            }

            Host.UI.WriteLine("Creating counters");
            PerformanceCounterSetup.SetupCounters();
        }
Exemplo n.º 8
0
        protected override void Process()
        {
            bool coutersIsGood;

            if (!ShouldProcess(Environment.MachineName))
            {
                coutersIsGood = PerformanceCounterSetup.SetupCounters();

                Host.UI.WriteLine(coutersIsGood
                                          ? "Performance Counters is setup and ready for use with NServiceBus"
                                          : "Performance Counters is not properly configured");

                WriteObject(coutersIsGood);
                return;
            }

            coutersIsGood = PerformanceCounterSetup.SetupCounters(true);

            WriteObject(coutersIsGood);
        }