internal static void EnsureCounterSet()
 {
     if (endpointCounterSet == null)
     {
         lock (syncRoot)
         {
             if (endpointCounterSet == null)
             {
                 CounterSet localCounterSet = CreateCounterSet();
                 // Add the counters to the counter set definition.
                 localCounterSet.AddCounter((int)PerfCounters.Calls, CounterType.RawData32, perfCounterNames[(int)PerfCounters.Calls]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.CallsPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsOutstanding, CounterType.RawData32, perfCounterNames[(int)PerfCounters.CallsOutstanding]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsFailed, CounterType.RawData32, perfCounterNames[(int)PerfCounters.CallsFailed]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsFailedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.CallsFailedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsFaulted, CounterType.RawData32, perfCounterNames[(int)PerfCounters.CallsFaulted]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsFaultedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.CallsFaultedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.CallDurationBase, CounterType.AverageBase, perfCounterNames[(int)PerfCounters.CallDurationBase]);
                 localCounterSet.AddCounter((int)PerfCounters.CallDuration, CounterType.AverageTimer32, perfCounterNames[(int)PerfCounters.CallDuration]);
                 localCounterSet.AddCounter((int)PerfCounters.SecurityValidationAuthenticationFailures, CounterType.RawData32, perfCounterNames[(int)PerfCounters.SecurityValidationAuthenticationFailures]);
                 localCounterSet.AddCounter((int)PerfCounters.SecurityValidationAuthenticationFailuresPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.SecurityValidationAuthenticationFailuresPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsNotAuthorized, CounterType.RawData32, perfCounterNames[(int)PerfCounters.CallsNotAuthorized]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsNotAuthorizedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.CallsNotAuthorizedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.RMSessionsFaulted, CounterType.RawData32, perfCounterNames[(int)PerfCounters.RMSessionsFaulted]);
                 localCounterSet.AddCounter((int)PerfCounters.RMSessionsFaultedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.RMSessionsFaultedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.RMMessagesDropped, CounterType.RawData32, perfCounterNames[(int)PerfCounters.RMMessagesDropped]);
                 localCounterSet.AddCounter((int)PerfCounters.RMMessagesDroppedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.RMMessagesDroppedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.TxFlowed, CounterType.RawData32, perfCounterNames[(int)PerfCounters.TxFlowed]);
                 localCounterSet.AddCounter((int)PerfCounters.TxFlowedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.TxFlowedPerSecond]);
                 endpointCounterSet = localCounterSet;
             }
         }
     }
 }
Пример #2
0
		public PerfCounters(Uri instanceName)
		{
			this.providerGuid = new Guid("{b0f9d01b-71f3-4d7d-b69e-5d1c5932b74d}");
			this.providerCounterSetGuid = new Guid("{e711142e-c6b7-41a9-ac1a-aa63c936cd55}");
			this.counterSet = new CounterSet(this.providerGuid, this.providerCounterSetGuid, CounterSetInstanceType.Multiple);
			this.counterSet.AddCounter(1, CounterType.RawData32);
			this.counterSet.AddCounter(2, CounterType.RawData32);
			this.counterSet.AddCounter(3, CounterType.RawData32);
			this.counterSet.AddCounter(4, CounterType.RateOfCountPerSecond32);
			this.counterSet.AddCounter(5, CounterType.RateOfCountPerSecond32);
			this.counterSetInstance = this.CreateInstance(instanceName);
		}
        internal CounterSetInstance(CounterSet counterSetDefined, String instanceName) {
            if (counterSetDefined == null) {
                throw new ArgumentNullException("counterSetDefined");
            }
            if (instanceName == null) {
                throw new ArgumentNullException("InstanceName");
            }
            if (instanceName.Length == 0) {
                throw new ArgumentException(SR.GetString(SR.Perflib_Argument_EmptyInstanceName), "InstanceName");
            }

            m_counterSet = counterSetDefined;
            m_instName   = instanceName;
            unsafe {
                m_nativeInst = UnsafeNativeMethods.PerfCreateInstance(
                        m_counterSet.m_provider.m_hProvider, ref m_counterSet.m_counterSet, m_instName, 0);
                int Status = (int) ((m_nativeInst != null) ? UnsafeNativeMethods.ERROR_SUCCESS : Marshal.GetLastWin32Error());
                if (m_nativeInst != null) {
                    m_counters = new CounterSetInstanceCounterDataSet(this);
                }
                else {
                    // ERROR_INVALID_PARAMETER,
                    // ERROR_NOT_FOUND (cannot find installed CounterSet),
                    // ERROR_ALREADY_EXISTS,
                    // ERROR_NOT_ENOUGH_MEMORY

                    switch (Status) {
                        case (int) UnsafeNativeMethods.ERROR_ALREADY_EXISTS:
                            throw new ArgumentException(SR.GetString(SR.Perflib_Argument_InstanceAlreadyExists, m_instName, m_counterSet.m_counterSet), "InstanceName");

                        case (int) UnsafeNativeMethods.ERROR_NOT_FOUND:
                            throw new InvalidOperationException( SR.GetString(SR.Perflib_InvalidOperation_CounterSetNotInstalled, m_counterSet.m_counterSet));

                        case (int) UnsafeNativeMethods.ERROR_INVALID_PARAMETER:
                            if (m_counterSet.m_instType == CounterSetInstanceType.Single) {
                                throw new ArgumentException(SR.GetString(SR.Perflib_Argument_InvalidInstance, m_counterSet.m_counterSet), "InstanceName");
                            }
                            else {
                                throw new Win32Exception(Status);
                            }

                        default:
                            throw new Win32Exception(Status);
                    }
                }
            }

            m_active = 1;
        }
Пример #4
0
 private void CreateCounterSetInstance()
 {
     this._CounterSet = new CounterSet(base._counterSetRegistrarBase.ProviderId, base._counterSetRegistrarBase.CounterSetId, base._counterSetRegistrarBase.CounterSetInstType);
     foreach (CounterInfo info in base._counterSetRegistrarBase.CounterInfoArray)
     {
         if (info.Name == null)
         {
             this._CounterSet.AddCounter(info.Id, info.Type);
         }
         else
         {
             this._CounterSet.AddCounter(info.Id, info.Type, info.Name);
         }
     }
     string counterSetInstanceName = PSPerfCountersMgr.Instance.GetCounterSetInstanceName();
     this._CounterSetInstance = this._CounterSet.CreateCounterSetInstance(counterSetInstanceName);
 }
        internal unsafe CounterSetInstance(CounterSet counterSetDefined, string instanceName)
        {
            if (counterSetDefined == null)
            {
                throw new ArgumentNullException("counterSetDefined");
            }
            if (instanceName == null)
            {
                throw new ArgumentNullException("InstanceName");
            }
            if (instanceName.Length == 0)
            {
                throw new ArgumentException(System.SR.GetString("Perflib_Argument_EmptyInstanceName"), "InstanceName");
            }
            this.m_counterSet = counterSetDefined;
            this.m_instName   = instanceName;
            this.m_nativeInst = Microsoft.Win32.UnsafeNativeMethods.PerfCreateInstance(this.m_counterSet.m_provider.m_hProvider, ref this.m_counterSet.m_counterSet, this.m_instName, 0);
            int error = (this.m_nativeInst != null) ? 0 : Marshal.GetLastWin32Error();

            if (this.m_nativeInst != null)
            {
                this.m_counters = new CounterSetInstanceCounterDataSet(this);
            }
            else
            {
                switch (error)
                {
                case 0x57:
                    if (this.m_counterSet.m_instType == CounterSetInstanceType.Single)
                    {
                        throw new ArgumentException(System.SR.GetString("Perflib_Argument_InvalidInstance", new object[] { this.m_counterSet.m_counterSet }), "InstanceName");
                    }
                    throw new Win32Exception(error);

                case 0xb7:
                    throw new ArgumentException(System.SR.GetString("Perflib_Argument_InstanceAlreadyExists", new object[] { this.m_instName, this.m_counterSet.m_counterSet }), "InstanceName");

                case 0x490:
                    throw new InvalidOperationException(System.SR.GetString("Perflib_InvalidOperation_CounterSetNotInstalled", new object[] { this.m_counterSet.m_counterSet }));
                }
                throw new Win32Exception(error);
            }
            this.m_active = 1;
        }
Пример #6
0
        internal unsafe CounterSetInstance(CounterSet counterSetDefined, string instanceName)
        {
            if (counterSetDefined == null)
            {
                throw new ArgumentNullException("counterSetDefined");
            }
            if (instanceName == null)
            {
                throw new ArgumentNullException("InstanceName");
            }
            if (instanceName.Length == 0)
            {
                throw new ArgumentException(System.SR.GetString("Perflib_Argument_EmptyInstanceName"), "InstanceName");
            }
            this.m_counterSet = counterSetDefined;
            this.m_instName = instanceName;
            this.m_nativeInst = Microsoft.Win32.UnsafeNativeMethods.PerfCreateInstance(this.m_counterSet.m_provider.m_hProvider, ref this.m_counterSet.m_counterSet, this.m_instName, 0);
            int error = (this.m_nativeInst != null) ? 0 : Marshal.GetLastWin32Error();
            if (error == 0)
            {
                this.m_counters = new CounterSetInstanceCounterDataSet(this);
            }
            else
            {
                switch (error)
                {
                    case 0x57:
                        if (this.m_counterSet.m_instType == CounterSetInstanceType.Single)
                        {
                            throw new ArgumentException(System.SR.GetString("Perflib_Argument_InvalidInstance", new object[] { this.m_counterSet.m_counterSet }), "InstanceName");
                        }
                        throw new Win32Exception(error);

                    case 0xb7:
                        throw new ArgumentException(System.SR.GetString("Perflib_Argument_InstanceAlreadyExists", new object[] { this.m_instName, this.m_counterSet.m_counterSet }), "InstanceName");

                    case 0x490:
                        throw new InvalidOperationException(System.SR.GetString("Perflib_InvalidOperation_CounterSetNotInstalled", new object[] { this.m_counterSet.m_counterSet }));
                }
                throw new Win32Exception(error);
            }
            this.m_active = 1;
        }
Пример #7
0
        static void Main(string[] args)
        {
            // Initialize the provider and counters

            Guid providerId = new Guid("{5AE84FD4-BF72-49c4-936E-A7473237C338}");

            Guid geometricWavesCounterSetId = new Guid("{F7DC6E2D-9A3F-4239-AC8D-28DCE96CCA98}");
            CounterSet geometricWavesCounterSet = new CounterSet(providerId, geometricWavesCounterSetId, CounterSetInstanceType.MultipleAggregate);
            geometricWavesCounterSet.AddCounter(1, CounterType.RawData32); //"Triangle Wave"
            geometricWavesCounterSet.AddCounter(2, CounterType.RawData32); //"Square Wave"
            CounterSetInstance geomCsInstance1 = geometricWavesCounterSet.CreateCounterSetInstance("Instance_1");
            CounterSetInstance geomCsInstance2 = geometricWavesCounterSet.CreateCounterSetInstance("Instance_2");
            CounterSetInstance geomCsInstance3 = geometricWavesCounterSet.CreateCounterSetInstance("Instance_3");

            Guid trigWavesCounterSetId = new Guid("{F89A016D-A5D1-4ce2-8489-D5612FDD2C6F}");
            CounterSet trigWavesCounterSet = new CounterSet(providerId, trigWavesCounterSetId, CounterSetInstanceType.Single);
            trigWavesCounterSet.AddCounter(1, CounterType.RawData32); //"Sine Wave"
            trigWavesCounterSet.AddCounter(2, CounterType.RawData32); //"Cosine Wave"
            trigWavesCounterSet.AddCounter(3, CounterType.RawData32); //"Constant Value"
            trigWavesCounterSet.AddCounter(4, CounterType.RawBase32); //"Constant Number"
            trigWavesCounterSet.AddCounter(5, CounterType.RawFraction32); //"Raw Fraction"
            CounterSetInstance trigCsInstance = trigWavesCounterSet.CreateCounterSetInstance("_Default");

            // Initialize variables used in counter calculations.
            UInt32 Degree = 0;
            UInt32 Base = BASE;
            UInt32 NaturalNumbers = 1;
            double Angle = 0;
            UInt32 Sine = 0;
            UInt32 Cosine = 0;

            // Set the constant counter value.
            trigCsInstance.Counters[4].Value = BASE;

            Console.WriteLine("\tPress any key to quit");
            while (!Console.KeyAvailable)
            {
                // Increment the Degree value to between 0 - 360.
                Degree = (Degree + 10) % 360;

                // Increment the Natural Number counter. Set it to 1 if we reach 100.
                NaturalNumbers = ++NaturalNumbers % 100;

                Angle   = (((double) Degree) * M_PI) / (180.00);
                Sine   = Base + (UInt32) (AMPLITUDE * Math.Sin(Angle));
                Cosine = Base + (UInt32)(AMPLITUDE * Math.Cos(Angle));

                // Set raw counter data for SingleInstanceCounterSet.
                UpdataGeometricWave(geomCsInstance1, 30, Degree);
                UpdataGeometricWave(geomCsInstance2, 50, Degree);
                UpdataGeometricWave(geomCsInstance3, 80, Degree);

                //Update TrigonometricWave counters
                trigCsInstance.Counters[1].Value = Sine;
                trigCsInstance.Counters[2].Value = Cosine;
                trigCsInstance.Counters[3].Value = Base;
                trigCsInstance.Counters[5].Value = NaturalNumbers;

                //Sleep for 1 second before iterating once again to change the counter values.
                Thread.Sleep(TIME_INTERVAL);
            }
        }
Пример #8
0
		protected virtual void Dispose(bool disposeManagedResources)
		{
			if (disposeManagedResources && !this.disposed)
			{
				if (this.counterSetInstance != null)
				{
					this.counterSetInstance.Dispose();
					this.counterSetInstance = null;
				}
				if (this.counterSet != null)
				{
					this.counterSet.Dispose();
					this.counterSet = null;
				}
				this.disposed = true;
			}
		}
        internal static void EnsureCounterSet()
        {
            if (workflowServiceHostCounterSet == null)
            {
                lock (syncRoot)
                {
                    if (workflowServiceHostCounterSet == null)
                    {
                        CounterSet localCounterSet = CreateCounterSet();

                        // Add the counters to the counter set definition.
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsCreated, CounterType.RawData32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsCreatedPerSecond, CounterType.RateOfCountPerSecond32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsExecuting, CounterType.RawData32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsCompleted, CounterType.RawData32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsCompletedPerSecond, CounterType.RateOfCountPerSecond32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsAborted, CounterType.RawData32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsAbortedPerSecond, CounterType.RateOfCountPerSecond32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsInMemory, CounterType.RawData32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsPersisted, CounterType.RawData32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsPersistedPerSecond, CounterType.RateOfCountPerSecond32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsTerminated, CounterType.RawData32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsTerminatedPerSecond, CounterType.RateOfCountPerSecond32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsLoaded, CounterType.RawData32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsLoadedPerSecond, CounterType.RateOfCountPerSecond32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsUnloaded, CounterType.RawData32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsUnloadedPerSecond, CounterType.RateOfCountPerSecond32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsSuspended, CounterType.RawData32, perfCounterNames[(int)PerfCounters.WorkflowsSuspended]);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsSuspendedPerSecond, CounterType.RateOfCountPerSecond32);
                        localCounterSet.AddCounter((int)PerfCounters.WorkflowsIdlePerSecond, CounterType.RateOfCountPerSecond32);
                        localCounterSet.AddCounter((int)PerfCounters.AverageWorkflowLoadTime, CounterType.AverageTimer32);
                        localCounterSet.AddCounter((int)PerfCounters.AverageWorkflowLoadTimeBase, CounterType.AverageBase);
                        localCounterSet.AddCounter((int)PerfCounters.AverageWorkflowPersistTime, CounterType.AverageTimer32);
                        localCounterSet.AddCounter((int)PerfCounters.AverageWorkflowPersistTimeBase, CounterType.AverageBase);

                        workflowServiceHostCounterSet = localCounterSet;
                    }
                }
            }
        }
Пример #10
0
 internal unsafe CounterSetInstance(CounterSet counterSetDefined !!, string instanceName !!)
 internal ServicePerformanceCountersV2(ServiceHostBase serviceHost)
     : base(serviceHost)
 {
     if (serviceCounterSet == null)
     {
         lock (syncRoot)
         {
             if (serviceCounterSet == null)
             {
                 CounterSet localCounterSet = CreateCounterSet();
                 // Add the counters to the counter set definition.
                 localCounterSet.AddCounter((int)PerfCounters.Calls, CounterType.RawData32, perfCounterNames[(int)PerfCounters.Calls]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.CallsPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsOutstanding, CounterType.RawData32, perfCounterNames[(int)PerfCounters.CallsOutstanding]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsFailed, CounterType.RawData32, perfCounterNames[(int)PerfCounters.CallsFailed]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsFailedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.CallsFailedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsFaulted, CounterType.RawData32, perfCounterNames[(int)PerfCounters.CallsFaulted]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsFaultedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.CallsFaultedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.CallDurationBase, CounterType.AverageBase, perfCounterNames[(int)PerfCounters.CallDurationBase]);
                 localCounterSet.AddCounter((int)PerfCounters.CallDuration, CounterType.AverageTimer32, perfCounterNames[(int)PerfCounters.CallDuration]);
                 localCounterSet.AddCounter((int)PerfCounters.SecurityValidationAuthenticationFailures, CounterType.RawData32, perfCounterNames[(int)PerfCounters.SecurityValidationAuthenticationFailures]);
                 localCounterSet.AddCounter((int)PerfCounters.SecurityValidationAuthenticationFailuresPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.SecurityValidationAuthenticationFailuresPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsNotAuthorized, CounterType.RawData32, perfCounterNames[(int)PerfCounters.CallsNotAuthorized]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsNotAuthorizedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.CallsNotAuthorizedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.Instances, CounterType.RawData32, perfCounterNames[(int)PerfCounters.Instances]);
                 localCounterSet.AddCounter((int)PerfCounters.InstancesRate, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.InstancesRate]);
                 localCounterSet.AddCounter((int)PerfCounters.RMSessionsFaulted, CounterType.RawData32, perfCounterNames[(int)PerfCounters.RMSessionsFaulted]);
                 localCounterSet.AddCounter((int)PerfCounters.RMSessionsFaultedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.RMSessionsFaultedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.RMMessagesDropped, CounterType.RawData32, perfCounterNames[(int)PerfCounters.RMMessagesDropped]);
                 localCounterSet.AddCounter((int)PerfCounters.RMMessagesDroppedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.RMMessagesDroppedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.TxFlowed, CounterType.RawData32, perfCounterNames[(int)PerfCounters.TxFlowed]);
                 localCounterSet.AddCounter((int)PerfCounters.TxFlowedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.TxFlowedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.TxCommitted, CounterType.RawData32, perfCounterNames[(int)PerfCounters.TxCommitted]);
                 localCounterSet.AddCounter((int)PerfCounters.TxCommittedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.TxCommittedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.TxAborted, CounterType.RawData32, perfCounterNames[(int)PerfCounters.TxAborted]);
                 localCounterSet.AddCounter((int)PerfCounters.TxAbortedPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.TxAbortedPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.TxInDoubt, CounterType.RawData32, perfCounterNames[(int)PerfCounters.TxInDoubt]);
                 localCounterSet.AddCounter((int)PerfCounters.TxInDoubtPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.TxInDoubtPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.MsmqPoisonMessages, CounterType.RawData32, perfCounterNames[(int)PerfCounters.MsmqPoisonMessages]);
                 localCounterSet.AddCounter((int)PerfCounters.MsmqPoisonMessagesPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.MsmqPoisonMessagesPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.MsmqRejectedMessages, CounterType.RawData32, perfCounterNames[(int)PerfCounters.MsmqRejectedMessages]);
                 localCounterSet.AddCounter((int)PerfCounters.MsmqRejectedMessagesPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.MsmqRejectedMessagesPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.MsmqDroppedMessages, CounterType.RawData32, perfCounterNames[(int)PerfCounters.MsmqDroppedMessages]);
                 localCounterSet.AddCounter((int)PerfCounters.MsmqDroppedMessagesPerSecond, CounterType.RateOfCountPerSecond32, perfCounterNames[(int)PerfCounters.MsmqDroppedMessagesPerSecond]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsPercentMaxCalls, CounterType.RawFraction32, perfCounterNames[(int)PerfCounters.CallsPercentMaxCalls]);
                 localCounterSet.AddCounter((int)PerfCounters.CallsPercentMaxCallsBase, CounterType.RawBase32, perfCounterNames[(int)PerfCounters.CallsPercentMaxCallsBase]);
                 localCounterSet.AddCounter((int)PerfCounters.InstancesPercentMaxInstances, CounterType.RawFraction32, perfCounterNames[(int)PerfCounters.InstancesPercentMaxInstances]);
                 localCounterSet.AddCounter((int)PerfCounters.InstancesPercentMaxInstancesBase, CounterType.RawBase32, perfCounterNames[(int)PerfCounters.InstancesPercentMaxInstancesBase]);
                 localCounterSet.AddCounter((int)PerfCounters.SessionsPercentMaxSessions, CounterType.RawFraction32, perfCounterNames[(int)PerfCounters.SessionsPercentMaxSessions]);
                 localCounterSet.AddCounter((int)PerfCounters.SessionsPercentMaxSessionsBase, CounterType.RawBase32, perfCounterNames[(int)PerfCounters.SessionsPercentMaxSessionsBase]);
                 serviceCounterSet = localCounterSet;
             }
         }
     }
     // Create an instance of the counter set (contains the counter data).
     this.serviceCounterSetInstance = CreateCounterSetInstance(this.InstanceName);
     this.counters = new CounterData[(int)PerfCounters.TotalCounters]; // Cache to dodge dictionary lookups in ServiceModelInstance
     for (int i = 0; i < (int)PerfCounters.TotalCounters; i++)
     {
         this.counters[i] = this.serviceCounterSetInstance.Counters[i];
         this.counters[i].Value = 0;
     }
 }
 internal static void EnsureCounterSet()
 {
     if (operationCounterSet == null)
     {
         lock (syncRoot)
         {
             if (operationCounterSet == null)
             {
                 CounterSet set = CreateCounterSet();
                 set.AddCounter(0, CounterType.RawData32, OperationPerformanceCountersBase.perfCounterNames[0]);
                 set.AddCounter(1, CounterType.RateOfCountPerSecond32, OperationPerformanceCountersBase.perfCounterNames[1]);
                 set.AddCounter(2, CounterType.RawData32, OperationPerformanceCountersBase.perfCounterNames[2]);
                 set.AddCounter(3, CounterType.RawData32, OperationPerformanceCountersBase.perfCounterNames[3]);
                 set.AddCounter(4, CounterType.RateOfCountPerSecond32, OperationPerformanceCountersBase.perfCounterNames[4]);
                 set.AddCounter(5, CounterType.RawData32, OperationPerformanceCountersBase.perfCounterNames[5]);
                 set.AddCounter(6, CounterType.RateOfCountPerSecond32, OperationPerformanceCountersBase.perfCounterNames[6]);
                 set.AddCounter(8, CounterType.AverageBase, OperationPerformanceCountersBase.perfCounterNames[8]);
                 set.AddCounter(7, CounterType.AverageTimer32, OperationPerformanceCountersBase.perfCounterNames[7]);
                 set.AddCounter(9, CounterType.RawData32, OperationPerformanceCountersBase.perfCounterNames[9]);
                 set.AddCounter(10, CounterType.RateOfCountPerSecond32, OperationPerformanceCountersBase.perfCounterNames[10]);
                 set.AddCounter(11, CounterType.RawData32, OperationPerformanceCountersBase.perfCounterNames[11]);
                 set.AddCounter(12, CounterType.RateOfCountPerSecond32, OperationPerformanceCountersBase.perfCounterNames[12]);
                 set.AddCounter(13, CounterType.RawData32, OperationPerformanceCountersBase.perfCounterNames[13]);
                 set.AddCounter(14, CounterType.RateOfCountPerSecond32, OperationPerformanceCountersBase.perfCounterNames[14]);
                 operationCounterSet = set;
             }
         }
     }
 }
Пример #13
0
        private void CreateCounterSetInstance()
        {
            _CounterSet =
                new CounterSet(
                    base._counterSetRegistrarBase.ProviderId,
                    base._counterSetRegistrarBase.CounterSetId,
                    base._counterSetRegistrarBase.CounterSetInstType);

            // Add the counters to the counter set definition.
            foreach (CounterInfo counterInfo in base._counterSetRegistrarBase.CounterInfoArray)
            {
                if (counterInfo.Name == null)
                {
                    _CounterSet.AddCounter(counterInfo.Id, counterInfo.Type);
                }
                else
                {
                    _CounterSet.AddCounter(counterInfo.Id, counterInfo.Type, counterInfo.Name);
                }
            }

            string instanceName = PSPerfCountersMgr.Instance.GetCounterSetInstanceName();
            // Create an instance of the counter set (contains the counter data).
            _CounterSetInstance = _CounterSet.CreateCounterSetInstance(instanceName);
        }