Exemplo n.º 1
0
        public void PerfCounterSet_Instances()
        {
            PerfCounterSet counters = new PerfCounterSet(true, true, "Test_Instances", "Test Help");
            PerfCounter    A_ONE, A_TWO, B_ONE, B_TWO;

            try
            {
                counters.Add(new PerfCounter("A", "A Help", PerformanceCounterType.NumberOfItems32));
                counters.Add(new PerfCounter("B", "B Help", PerformanceCounterType.NumberOfItems32));

                counters.Install();

                A_ONE = counters["A", "ONE"];
                A_TWO = counters["A", "TWO"];
                B_ONE = counters["B", "ONE"];
                B_TWO = counters["B", "TWO"];

                A_ONE.IncrementBy(1);
                A_TWO.IncrementBy(2);
                B_ONE.IncrementBy(3);
                B_TWO.IncrementBy(4);

                Assert.AreEqual(1, A_ONE.RawValue);
                Assert.AreEqual(2, A_TWO.RawValue);
                Assert.AreEqual(3, B_ONE.RawValue);
                Assert.AreEqual(4, B_TWO.RawValue);
            }
            finally
            {
                counters.Uninstall();
            }
        }
Exemplo n.º 2
0
        public void PerfCounterSet_Related2()
        {
            PerfCounterSet counters = new PerfCounterSet(false, true, "Test_Related2", "Test Help");
            PerfCounter    A, B, C;

            try
            {
                counters.Add(new PerfCounter("A", "A Help", PerformanceCounterType.NumberOfItems32));
                counters.Add(new PerfCounter("B", "B Help", PerformanceCounterType.NumberOfItems32));
                counters.Add(new PerfCounter("C", "C Help", PerformanceCounterType.NumberOfItems32));

                counters.Relate("A", "C");
                counters.Relate("B", "C");

                counters.Install();

                A = counters["A"];
                B = counters["B"];
                C = counters["C"];

                Assert.AreEqual(0, C.RawValue);
                A.Increment();
                Assert.AreEqual(1, C.RawValue);
                B.IncrementBy(5);
                Assert.AreEqual(6, C.RawValue);
                A.Decrement();
                Assert.AreEqual(5, C.RawValue);
            }
            finally
            {
                counters.Uninstall();
            }
        }
Exemplo n.º 3
0
        public void PerfCounterSet_Install_Uninstall()
        {
            PerfCounterSet counters = new PerfCounterSet(false, true, "Test_Install_Uninstall", "Test Help");
            PerfCounter    A, B;

            try
            {
                counters.Add(new PerfCounter("A", "A Help", PerformanceCounterType.NumberOfItems32));
                counters.Add(new PerfCounter("B", "B Help", PerformanceCounterType.NumberOfItems32));

                counters.Install();

                A = counters["A"];
                Assert.IsNotNull(A.Counter);
                Assert.AreEqual(0, A.RawValue);

                Assert.AreEqual(1, A.Increment());
                Assert.AreEqual(1, A.RawValue);

                B = counters["B"];
                B.IncrementBy(55);
                Assert.AreEqual(55, B.RawValue);
            }
            finally
            {
                counters.Uninstall();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Handles the performance counter installation if they don't
        /// already exist.
        /// </summary>
        /// <returns>The application's <see cref="PerfCounterSet" />.</returns>
        public static PerfCounterSet InstallPerfCounters()
        {
            bool           exists = PerformanceCounterCategory.Exists(Const.DynDnsClientPerf);
            PerfCounterSet perfCounters;

            perfCounters = new PerfCounterSet(false, true, Const.DynDnsClientPerf, Const.DynDnsClientName);

            if (!exists)
            {
                perfCounters.Install();
            }

            return(perfCounters);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the performance counter installation if they don't
        /// already exist.
        /// </summary>
        /// <returns>The application's <see cref="PerfCounterSet" />.</returns>
        public static PerfCounterSet InstallPerfCounters()
        {
            bool           exists = PerformanceCounterCategory.Exists(Const.HeartbeatPerf);
            PerfCounterSet perfCounters;

            perfCounters = new PerfCounterSet(false, true, Const.HeartbeatPerf, Const.HeartbeatName);

            if (!exists)
            {
                HeartbeatHandler.InstallPerfCounters(perfCounters, null);
                perfCounters.Install();
            }

            return(perfCounters);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handles the performance counter installation if they don't
        /// already exist.
        /// </summary>
        /// <returns>The application's <see cref="PerfCounterSet" />.</returns>
        public static PerfCounterSet InstallPerfCounters()
        {
            bool           exists = PerformanceCounterCategory.Exists(Const.BroadcastServerPerf);
            PerfCounterSet perfCounters;

            perfCounters = new PerfCounterSet(false, true, Const.BroadcastServerPerf, Const.BroadcastServerName);

            if (!exists)
            {
                UdpBroadcastServer.InstallPerfCounters(perfCounters, null);
                perfCounters.Install();
            }

            return(perfCounters);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handles the performance counter installation if they don't
        /// already exist.
        /// </summary>
        /// <returns>The application's <see cref="PerfCounterSet" />.</returns>
        public static PerfCounterSet InstallPerfCounters()
        {
            bool           exists = PerformanceCounterCategory.Exists(Const.MessageQueuePerf);
            PerfCounterSet perfCounters;

            perfCounters = new PerfCounterSet(false, true, Const.MessageQueuePerf, Const.MessageQueueName);

            if (!exists)
            {
                MsgQueueHandler.InstallPerfCounters(perfCounters, null);
                perfCounters.Install();
            }

            return(perfCounters);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Handles the performance counter installation if they don't
        /// already exist.
        /// </summary>
        /// <returns>The application's <see cref="PerfCounterSet" />.</returns>
        public static PerfCounterSet InstallPerfCounters()
        {
            bool           exists = PerformanceCounterCategory.Exists(SwitchConst.NeonSwitchPerf);
            PerfCounterSet perfCounters;

            perfCounters = new PerfCounterSet(false, true, SwitchConst.NeonSwitchPerf, SwitchConst.NeonSwitchName);

            if (!exists)
            {
                CorePerf.Install(perfCounters);

                perfCounters.Install();
            }

            return(perfCounters);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Handles the performance counter installation if they don't
        /// already exist.
        /// </summary>
        /// <returns>The application's <see cref="PerfCounterSet" />.</returns>
        public static PerfCounterSet InstallPerfCounters()
        {
            bool           exists = PerformanceCounterCategory.Exists(Const.GeoTrackerPerf);
            PerfCounterSet perfCounters;

            perfCounters = new PerfCounterSet(false, true, Const.GeoTrackerPerf, Const.GeoTrackerName);

            if (!exists)
            {
                GeoTrackerNode.InstallPerfCounters(perfCounters, null);

                perfCounters.Install();
            }

            return(perfCounters);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Handles the performance counter installation if they don't
        /// already exist.
        /// </summary>
        /// <returns>The application's <see cref="PerfCounterSet" />.</returns>
        public static PerfCounterSet InstallPerfCounters()
        {
            bool           exists = PerformanceCounterCategory.Exists(Const.AuthServicePerf);
            PerfCounterSet perfCounters;

            perfCounters = new PerfCounterSet(false, true, Const.AuthServicePerf, Const.AuthServiceName);

            if (!exists)
            {
                AuthServiceHandler.InstallPerfCounters(perfCounters, null);
                AuthenticationEngine.InstallPerfCounters(perfCounters, null);

                perfCounters.Install();
            }

            return(perfCounters);
        }
Exemplo n.º 11
0
        public void PerfCounterSet_Related_Instance()
        {
            PerfCounterSet counters = new PerfCounterSet(true, true, "Test_Related_Instance", "Test Help");
            PerfCounter    A1, B1, C1;
            PerfCounter    A2, B2, C2;

            try
            {
                counters.Add(new PerfCounter("A", "A Help", PerformanceCounterType.NumberOfItems32));
                counters.Add(new PerfCounter("B", "B Help", PerformanceCounterType.NumberOfItems32));
                counters.Add(new PerfCounter("C", "C Help", PerformanceCounterType.NumberOfItems32));

                counters.Relate("A", "C");
                counters.Relate("B", "C");

                counters.Install();

                A1 = counters["A", "1"];
                B1 = counters["B", "1"];
                C1 = counters["C", "1"];
                A2 = counters["A", "2"];
                B2 = counters["B", "2"];
                C2 = counters["C", "2"];

                Assert.AreEqual(0, C1.RawValue);
                A1.Increment();
                Assert.AreEqual(1, C1.RawValue);
                B1.IncrementBy(5);
                Assert.AreEqual(6, C1.RawValue);
                A1.Decrement();
                Assert.AreEqual(5, C1.RawValue);

                Assert.AreEqual(0, C2.RawValue);
                A2.IncrementBy(100);
                Assert.AreEqual(100, C2.RawValue);
                B2.IncrementBy(100);
                Assert.AreEqual(200, C2.RawValue);
            }
            finally
            {
                counters.Uninstall();
            }
        }