Exemplo n.º 1
0
            public PerfCounter Groups;              // # of entities tracked

            /// <summary>
            /// Initializes the service's performance counters from the performance
            /// counter set passed.
            /// </summary>
            /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
            /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
            public Perf(PerfCounterSet perfCounters, string perfPrefix)
            {
                Install(perfCounters, perfPrefix);

                if (perfPrefix == null)
                {
                    perfPrefix = string.Empty;
                }

                if (perfCounters != null)
                {
                    IPGeocode     = perfCounters[perfPrefix + IPGeocode_Name];
                    FixesReceived = perfCounters[perfPrefix + FixesReceived_Name];
                    FixesArchived = perfCounters[perfPrefix + FixesArchived_Name];
                    Runtime       = perfCounters[perfPrefix + Runtime_Name];
                    Entities      = perfCounters[perfPrefix + Entities_Name];
                    Groups        = perfCounters[perfPrefix + Groups_Name];
                }
                else
                {
                    IPGeocode                  =
                        FixesReceived          =
                            FixesArchived      =
                                Runtime        =
                                    Entities   =
                                        Groups = PerfCounter.Stub;
                }
            }
Exemplo n.º 2
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.º 3
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.º 4
0
            /// <summary>
            /// Installs the service's performance counters by adding them to the
            /// performance counter set passed.
            /// </summary>
            /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
            /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
            public static void Install(PerfCounterSet perfCounters, string perfPrefix)
            {
                if (perfCounters == null)
                {
                    return;
                }

                if (perfPrefix == null)
                {
                    perfPrefix = string.Empty;
                }

                perfCounters.Add(new PerfCounter(perfPrefix + IsMaster_Name, "Indicates if this is the cluster master (0/1)", PerformanceCounterType.NumberOfItems32));
                perfCounters.Add(new PerfCounter(perfPrefix + AdminMessageRate_Name, "Admin Messages/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + AdminByteRate_Name, "Admin Bytes/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + BroadcastReceiveMessageRate_Name, "Broadcast Messages Received/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + BroadcastReceiveByteRate_Name, "Broadcast Receive Bytes/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + BroadcastSendMessageRate_Name, "Broadcast Messages Sent/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + BroadcastSendByteRate_Name, "Broadcast Send Bytes/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + TotalMessageRate_Name, "Total Messages (sent or received)/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + TotalByteRate_Name, "Total Bytes (sent or received)/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + ServerCount_Name, "Number of UDP broadcast servers in the cluster", PerformanceCounterType.NumberOfItems32));
                perfCounters.Add(new PerfCounter(perfPrefix + ClientCount_Name, "Number of UDP broadcast clients in the cluster", PerformanceCounterType.NumberOfItems32));
                perfCounters.Add(new PerfCounter(perfPrefix + Runtime_Name, "Service runtime in minutes", PerformanceCounterType.NumberOfItems32));
            }
Exemplo n.º 5
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.º 6
0
        /// <summary>
        /// Installs the service's performance counters by adding them to the
        /// performance counter set passed.
        /// </summary>
        /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
        public static void Install(PerfCounterSet perfCounters)
        {
            if (perfCounters == null)
            {
                return;
            }

            perfCounters.Add(new PerfCounter(Runtime_Name, "Service runtime in minutes", PerformanceCounterType.NumberOfItems32));
            perfCounters.Add(new PerfCounter(TotalCalls_Name, "Total active calls", PerformanceCounterType.NumberOfItems32));
            perfCounters.Add(new PerfCounter(TotalCallRate_Name, "Total Call Rate", PerformanceCounterType.RateOfCountsPerSecond32));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Associates the service handler with a message router by registering
        /// the necessary application message handlers.
        /// </summary>
        /// <param name="router">The message router.</param>
        /// <param name="settings">The configuration settings.</param>
        /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
        /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
        /// <remarks>
        /// <para>
        /// Applications that expose performance counters will pass a non-<c>null</c> <b>perfCounters</b>
        /// instance.  The service handler should add any counters it implements to this set.
        /// If <paramref name="perfPrefix" /> is not <c>null</c> then any counters added should prefix their
        /// names with this parameter.
        /// </para>
        /// </remarks>
        public void Start(MsgRouter router, GeoTrackerServerSettings settings, PerfCounterSet perfCounters, string perfPrefix)
        {
            if (this.isRunning)
            {
                throw new InvalidOperationException("This node has already been started.");
            }

            if (router == null)
            {
                throw new ArgumentNullException("router");
            }

            // Initialize the performance counters

            this.startTime = DateTime.UtcNow;
            this.perf      = new Perf(perfCounters, perfPrefix);

            // General initialization

            this.settings      = settings;
            this.bkTimer       = new GatedTimer(new TimerCallback(OnBkTimer), null, settings.BkInterval);
            this.ipGeocoder    = new IPGeocoder(this);
            this.clusterClient = Helper.CreateInstance <ITopologyProvider>(settings.ClusterTopology);
            this.clusterServer = Helper.CreateInstance <ITopologyProvider>(settings.ClusterTopology);
            this.fixCache      = new GeoFixCache(settings);
            this.archiver      = Helper.CreateInstance <IGeoFixArchiver>(settings.GeoFixArchiver);

            EntityState.MaxEntityFixes = settings.MaxEntityGeoFixes;

            try
            {
                // Initialize the router

                this.router = router;
                this.router.Dispatcher.AddTarget(this, "GeoTrackerServerEP", new SimpleEPMunger(settings.ServerEP), null);

                // Initialize the cluster

                this.clusterClient.OpenClient(router, settings.ClusterEP, settings.ClusterArgs);
                this.clusterServer.OpenServer(router, "GeoTrackerClusterEP", settings.ClusterEP, this, settings.ClusterArgs);

                // Start the archiver.

                archiver.Start(this, settings.GeoFixArchiverArgs);

                this.isRunning = true;
            }
            catch
            {
                Stop();
                throw;
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Associates the service handler with a message router by registering
        /// the necessary application message handlers.
        /// </summary>
        /// <param name="router">The message router.</param>
        /// <param name="keyPrefix">The configuration key prefix or (null to use <b>LillTek.Datacenter.ConfigService</b>).</param>
        /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
        /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
        /// <remarks>
        /// <para>
        /// Applications that expose performance counters will pass a non-<c>null</c> <b>perfCounters</b>
        /// instance.  The service handler should add any counters it implements to this set.
        /// If <paramref name="perfPrefix" /> is not <c>null</c> then any counters added should prefix their
        /// names with this parameter.
        /// </para>
        /// </remarks>
        public void Start(MsgRouter router, string keyPrefix, PerfCounterSet perfCounters, string perfPrefix)
        {
            Config config;

            // Make sure that the LillTek.Datacenter message types have been
            // registered with the LillTek.Messaging subsystem.

            LillTek.Datacenter.Global.RegisterMsgTypes();

            // Verify the router parameter

            if (router == null)
            {
                throw new ArgumentNullException("router", "Router cannot be null.");
            }

            if (this.router != null)
            {
                throw new InvalidOperationException("This handler has already been started.");
            }

            // Determine the location of the settings folder

            if (keyPrefix == null)
            {
                keyPrefix = ConfigPrefix;
            }

            config = new Config(keyPrefix);

            settingsFolder = config.Get("SettingsFolder");
            if (settingsFolder == null)
            {
                settingsFolder = Helper.EntryAssemblyFolder + Helper.PathSepString + "Settings";
            }

            if (!settingsFolder.EndsWith(Helper.PathSepString))
            {
                settingsFolder += Helper.PathSepString;
            }

            if (!Directory.Exists(settingsFolder.Substring(0, settingsFolder.Length - 1)))
            {
                throw new FileNotFoundException(string.Format("Settings folder [{0}] does not exist.", settingsFolder));
            }

            // Register the handler and get ready to accept client requests

            this.router = router;
            router.Dispatcher.AddTarget(this);
        }
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.DynDnsClientPerf);
            PerfCounterSet perfCounters;

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

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

            return(perfCounters);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Establishes a session with the authentication extension.
        /// </summary>
        /// <param name="args">The extension specific arguments (see the remarks).</param>
        /// <param name="query">Not used.</param>
        /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
        /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
        /// <remarks>
        /// <para>
        /// This extension recognises the following arguments:
        /// </para>
        /// <list type="table">
        ///     <item>
        ///         <term>IsAD</term>
        ///         <description>
        ///         Set this to "true" or "yes" if the directory server is Microsoft Active Directory.
        ///         This argument defaults to "true".
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>AuthType</term>
        ///         <description>
        ///         Specifies the authentication method.  The possible values are <b>Basic</b>, <b>Digest</b>,
        ///         <b>DPA</b>, <b>External</b>, <b>Kerberos</b>, <b>MSN</b>, <b>Negotiate</b>, <b>NTLM</b>,
        ///         or <b>Sicily</b>.  This argument defaults to "Digest".
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>Servers</term>
        ///         <description>
        ///         Specifies zero or more LDAP server host  names or IP addresses separated by commas.
        ///         This argument defaults an empty list.  <b>Note that due to an unresolved bug with
        ///         default Active Directory support, at least one LDAP server must be explicitly
        ///         specified in the current build.</b>
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>DNSHost</term>
        ///         <description>
        ///         Set this to "true" or "yes" if the host names specified by <b>Servers</b> should be
        ///         interpreted as fully qualified DNS host names.  If set to "no" or "false", the
        ///         host names can be interpreted as an IP address or a DNS host name and if no host
        ///         is specified, then an Active Directory server associated with the computer account
        ///         will be used.  This argument defaults to "false".
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>UDP</term>
        ///         <description>
        ///         Set this to "true" or "yes" to enable UDP the connection over UDP, rather than over TCP/IP.
        ///         This argument defaults to "false".
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>MaxCacheTime</term>
        ///         <description>
        ///         Specifies the maximum time clients should retain authentication information.
        ///         This is expressed in the same format as timespans parsed by <see cref="Config.Parse(string,TimeSpan)" />.
        ///         This argument defaults to "5m".
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutCount</term>
        ///         <description>
        ///         Specifies the limiting failed authentication count.  Accounts
        ///         will be locked when the fail count reaches this number.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutThreshold</term>
        ///         <description>
        ///         The period of time that can elapse between failed authentication
        ///         attempts where the failed attempts will <b>not</b> be counted against the
        ///         <b>LockoutCount</b>.  Set this to <see cref="TimeSpan.Zero" />
        ///         to disable account lockout for the realm.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutTime</term>
        ///         <description>
        ///         The period of time an account will remain locked after being locked
        ///         out due to too many failed authentication attempts.
        ///         </description>
        ///     </item>
        /// </list>
        /// <para>
        /// The defaults values for the arguments were selected so that ommiting all arguments
        /// will configure the extension so that it authenticates against the Active Directory
        /// domain the computer belongs to.  There are some problems with some combinations of
        /// parameters.
        /// </para>
        /// <note>
        /// All calls to <see cref="Open" /> must be matched with a call
        /// to <see cref="Close" /> or <see cref="Dispose" />.
        /// </note>
        /// </remarks>
        public void Open(ArgCollection args, string query, PerfCounterSet perfCounters, string perfPrefix)
        {
            using (TimedLock.Lock(this))
            {
                if (IsOpen)
                {
                    throw new AuthenticationException("Authentication extension is already open.");
                }

                perf = new Perf(perfCounters, perfPrefix);

                // Load the arguments

                isAD = args.Get("IsAD", true);

                switch (args.Get("AuthType", "Digest").ToUpper())
                {
                case "BASIC":       authType = AuthType.Basic; break;

                case "DIGEST":      authType = AuthType.Digest; break;

                case "DPA":         authType = AuthType.Dpa; break;

                case "EXTERNAL":    authType = AuthType.External; break;

                case "KERBEROS":    authType = AuthType.Kerberos; break;

                case "MSN":         authType = AuthType.Msn; break;

                case "NEGOTIATE":   authType = AuthType.Negotiate; break;

                case "NTLM":        authType = AuthType.Ntlm; break;

                case "SICILY":      authType = AuthType.Sicily; break;

                default: throw new AuthenticationException("Unexpected authentication type argument [{0}].", args.Get("AuthType", "Negotiate"));
                }

                servers = args.Get("Servers", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < servers.Length; i++)
                {
                    servers[i] = servers[i].Trim();
                }

                dnsHosts     = args.Get("DNSHost", false);
                udp          = args.Get("UDP", false);
                maxCacheTime = args.Get("MaxCacheTime", TimeSpan.FromMinutes(5));
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Establishes a session with the authentication extension.
        /// </summary>
        /// <param name="args">The extension specific arguments (see the remarks).</param>
        /// <param name="query">Ignored for this extension.</param>
        /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
        /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
        /// <remarks>
        /// <para>
        /// This extension recognises the following arguments:
        /// </para>
        /// <list type="table">
        ///     <item>
        ///         <term>Servers</term>
        ///         <description>
        ///         Specifies the list of RADIUS server network bindings specifying the
        ///         IP address or host name of the server as well as the port number
        ///         or well-known port name.  Each server binding is formatted as
        ///         described by <see cref="NetworkBinding.Parse" /> and the server
        ///         bindings are separated by commas.  This argument must be present.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>Secret</term>
        ///         <description>
        ///         The shared secret to be used to secure RADIUS packets delivered
        ///         between this client and the any of the RADIUS servers.  This
        ///         string may include any valid characters besides semi-colons.
        ///         This argument must be present.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>SocketBuffer</term>
        ///         <description>
        ///         Byte size of the client socket's send and receive buffers.  Default
        ///         value is 32K.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>NetworkBinding</term>
        ///         <description>
        ///         <para>
        ///         Specifies the IP address of the network card the client is
        ///         and port bindings.  Use an IP address of ANY to bind to
        ///         all network interfaces.  ANY is suitable for single homed machines.
        ///         Machines that are actually connected to multiple networks should
        ///         specify a specific network binding here to ensure that the NAS-IP-Address
        ///         of RADIUS authentication packets are initialized properly.
        ///         </para>
        ///         <para>
        ///         A specific port number may be selected or 0 can be specified,
        ///         indicating that the operating system should select a free port.
        ///         </para>
        ///         <para>
        ///         Default value is ANY:0.
        ///         </para>
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>PortCount</term>
        ///         <description>
        ///         The number of RADIUS client UDP ports to open.  Multiple ports may
        ///         be required under high authentication loads.  Default value is 4.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>RetryInterval</term>
        ///         <description>
        ///         Maximum time to wait for a response packet from a RADIUS before retransmitting
        ///         an authentication request.  Default is 5 seconds.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term></term>
        ///         <description>
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>BkTaskInterval</term>
        ///         <description>
        ///         The interval at which background tasks such as retransmitting
        ///         a request should be processed.  Default is 1 second.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>MaxTransmissions</term>
        ///         <description>
        ///         The maximum number of authentication transmission attempts before aborting
        ///         with an authentication with a timeout.  Default is 4.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>RealmFormat</term>
        ///         <description>
        ///         Specifies how user names are to be generated from the
        ///         <b>realm</b> and <b>account</b> components.  See
        ///         <see cref="RealmFormat" /> for more information.
        ///         The possible values are: <b>Slash</b> and <b>Email</b>.
        ///         Default is <b>Email</b>.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>MaxCacheTime</term>
        ///         <description>
        ///         Specifies the maximum time clients should retain authentication information.
        ///         This is expressed in the same format as timespans parsed by <see cref="Config.Parse(string,TimeSpan)" />.
        ///         This argument defaults to "5m".
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutCount</term>
        ///         <description>
        ///         Specifies the limiting failed authentication count.  Accounts
        ///         will be locked when the fail count reaches this number.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutThreshold</term>
        ///         <description>
        ///         The period of time that can elapse between failed authentication
        ///         attempts where the failed attempts will <b>not</b> be counted against the
        ///         <b>LockoutCount</b>.  Set this to <see cref="TimeSpan.Zero" />
        ///         to disable account lockout for the realm.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutTime</term>
        ///         <description>
        ///         The period of time an account will remain locked after being locked
        ///         out due to too many failed authentication attempts.
        ///         </description>
        ///     </item>
        /// </list>
        /// <note>
        /// All calls to <see cref="Open" /> must be matched with a call
        /// to <see cref="Close" /> or <see cref="Dispose" />.
        /// </note>
        /// </remarks>
        public void Open(ArgCollection args, string query, PerfCounterSet perfCounters, string perfPrefix)
        {
            RadiusClientSettings settings;

            string[] rawBindings;
            List <NetworkBinding> bindings;
            string secret;

            using (TimedLock.Lock(this))
            {
                if (IsOpen)
                {
                    throw new AuthenticationException("Authentication extension is already open.");
                }

                perf = new Perf(perfCounters, perfPrefix);

                rawBindings = args.Get("servers", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (rawBindings.Length == 0)
                {
                    throw new AuthenticationException("RADUIS authentication extension requires at least one server network binding.");
                }

                bindings = new List <NetworkBinding>(rawBindings.Length);
                for (int i = 0; i < rawBindings.Length; i++)
                {
                    bindings.Add(NetworkBinding.Parse(rawBindings[i]));
                }

                secret = args.Get("secret", (string)null);
                if (secret == null || secret.Length == 0)
                {
                    throw new AuthenticationException("RADIUS authentication extension requires a shared NAS secret.");
                }

                settings = new RadiusClientSettings(bindings.ToArray(), secret);
                settings.SocketBuffer     = args.Get("SocketBuffer", settings.SocketBuffer);
                settings.NetworkBinding   = args.Get("NetworkBinding", settings.NetworkBinding);
                settings.PortCount        = args.Get("PortCount", settings.PortCount);
                settings.RetryInterval    = args.Get("RetryInterval", settings.RetryInterval);
                settings.BkTaskInterval   = args.Get("BkTaskInterval", settings.BkTaskInterval);
                settings.MaxTransmissions = args.Get("settings.MaxTransmissions", settings.MaxTransmissions);
                settings.RealmFormat      = args.Get <RealmFormat>("RealmFormat", settings.RealmFormat);

                maxCacheTime = args.Get("MaxCacheTime", TimeSpan.FromMinutes(5));

                radiusClient.Open(settings);
            }
        }
Exemplo n.º 12
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.º 13
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.º 14
0
            /// <summary>
            /// Installs the service's performance counters by adding them to the
            /// performance counter set passed.
            /// </summary>
            /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
            /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
            public static void Install(PerfCounterSet perfCounters, string perfPrefix)
            {
                if (perfCounters == null)
                {
                    return;
                }

                if (perfPrefix == null)
                {
                    perfPrefix = string.Empty;
                }

                perfCounters.Add(new PerfCounter(perfPrefix + Queries_Name, "RADIUS authentication queries/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + Exceptions_Name, "RADIUS exceptions/sec", PerformanceCounterType.RateOfCountsPerSecond32));
            }
Exemplo n.º 15
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.º 16
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.º 17
0
            /// <summary>
            /// Installs the service's performance counters by adding them to the
            /// performance counter set passed.
            /// </summary>
            /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
            /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
            public static void Install(PerfCounterSet perfCounters, string perfPrefix)
            {
                if (perfCounters == null)
                {
                    return;
                }

                if (perfPrefix == null)
                {
                    perfPrefix = string.Empty;
                }

                perfCounters.Add(new PerfCounter(perfPrefix + Queries_Name, "Number of health check queries/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + Status_Name, "Health Status (1=healthy)", PerformanceCounterType.NumberOfItems32));
                perfCounters.Add(new PerfCounter(perfPrefix + Runtime_Name, "Service runtime in minutes", PerformanceCounterType.NumberOfItems32));
            }
Exemplo n.º 18
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.º 19
0
            /// <summary>
            /// Installs the service's performance counters by adding them to the
            /// performance counter set passed.
            /// </summary>
            /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
            /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
            public static void Install(PerfCounterSet perfCounters, string perfPrefix)
            {
                if (perfCounters == null)
                {
                    return;
                }

                if (perfPrefix == null)
                {
                    perfPrefix = string.Empty;
                }

                perfCounters.Add(new PerfCounter(perfPrefix + Uploads_Name, "Application executable packages received/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + Deliveries_Name, "Application executable packages deliveries/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + CacheLoads_Name, "Application executable package cache loads/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + Runtime_Name, "Service runtime in minutes", PerformanceCounterType.NumberOfItems32));
            }
Exemplo n.º 20
0
        /// <summary>
        /// Establishes a session with the authentication extension.
        /// </summary>
        /// <param name="args">The extension specific arguments (see the remarks).</param>
        /// <param name="query">Ignored for this extension.</param>
        /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
        /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
        /// <remarks>
        /// <para>
        /// This extension recognises the following arguments:
        /// </para>
        /// <list type="table">
        ///     <item>
        ///         <term>Key</term>
        ///         <description>
        ///         The fully qualified name of the configuration key array with the credentials.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>MaxCacheTime</term>
        ///         <description>
        ///         Specifies the maximum time clients should retain authentication information.
        ///         This is expressed in the same format as timespans parsed by <see cref="Config.Parse(string,TimeSpan)" />.
        ///         This argument defaults to "5m".
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutCount</term>
        ///         <description>
        ///         Specifies the limiting failed authentication count.  Accounts
        ///         will be locked when the fail count reaches this number.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutThreshold</term>
        ///         <description>
        ///         The period of time that can elapse between failed authentication
        ///         attempts where the failed attempts will <b>not</b> be counted against the
        ///         <b>LockoutCount</b>.  Set this to <see cref="TimeSpan.Zero" />
        ///         to disable account lockout for the realm.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutTime</term>
        ///         <description>
        ///         The period of time an account will remain locked after being locked
        ///         out due to too many failed authentication attempts.
        ///         </description>
        ///     </item>
        /// </list>
        /// <para>
        /// The credentials are loaded from a configuration array holding a list
        /// of accounts, one array element, with the account fields separated by semicolons.
        /// The required fields are <b>Realm</b>, <b>Account</b>, and <b>Password</b>
        /// in that order.  Here's an example:
        /// </para>
        /// <code language="none">
        ///     Accounts[0] = lilltek.com;jeff.lill;foobar
        ///     Accounts[1] = lilltek.com;joe.blow;little.debbie
        ///     Accounts[2] = lilltek.com;jane.doe;fancy.pants
        ///     Accounts[3] = amex.com;[email protected];password.123
        /// </code>
        /// <note>
        /// All calls to <see cref="Open" /> must be matched with a call
        /// to <see cref="Close" /> or <see cref="Dispose" />.
        /// </note>
        /// </remarks>
        public void Open(ArgCollection args, string query, PerfCounterSet perfCounters, string perfPrefix)
        {
            using (TimedLock.Lock(this))
            {
                string   key;
                string[] accounts;
                string[] fields;

                if (IsOpen)
                {
                    throw new AuthenticationException("Authentication extension is already open.");
                }

                perf         = new Perf(perfCounters, perfPrefix);
                maxCacheTime = args.Get("MaxCacheTime", TimeSpan.FromMinutes(5));

                key = args.Get("Key", (string)null);
                if (key == null)
                {
                    throw new AuthenticationException("Authentication extension argument [{0}] not found.");
                }

                accounts = Config.Global.GetArray(key);
                if (accounts == null)
                {
                    accounts = new string[0];
                }

                credentials = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

                for (int i = 0; i < accounts.Length; i++)
                {
                    fields = accounts[i].Split(new char[] { ';' }, StringSplitOptions.None);
                    if (fields.Length != 3)
                    {
                        throw new AuthenticationException("Invalid account credentials in setting [{0}[{1}]].", key, i);
                    }

                    key = fields[0].Trim() + ":" + fields[1].Trim();
                    if (!credentials.ContainsKey(key))
                    {
                        credentials.Add(key, fields[2].Trim());
                    }
                }
            }
        }
Exemplo n.º 21
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.º 22
0
            /// <summary>
            /// Installs the service's performance counters by adding them to the
            /// performance counter set passed.
            /// </summary>
            /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
            /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
            public static void Install(PerfCounterSet perfCounters, string perfPrefix)
            {
                if (perfCounters == null)
                {
                    return;
                }

                if (perfPrefix == null)
                {
                    perfPrefix = string.Empty;
                }

                perfCounters.Add(new PerfCounter(perfPrefix + IPGeocode_Name, "IP Geocode queries/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + FixesReceived_Name, "Location fixes received/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + FixesArchived_Name, "Location fixes received/sec", PerformanceCounterType.RateOfCountsPerSecond32));
                perfCounters.Add(new PerfCounter(perfPrefix + Runtime_Name, "Service runtime in minutes", PerformanceCounterType.NumberOfItems32));
                perfCounters.Add(new PerfCounter(perfPrefix + Entities_Name, "Number of entities tracked", PerformanceCounterType.NumberOfItems32));
                perfCounters.Add(new PerfCounter(perfPrefix + Groups_Name, "Number of groups tracked", PerformanceCounterType.NumberOfItems32));
            }
Exemplo n.º 23
0
        /// <summary>
        /// Initializes the service's performance counters.
        /// </summary>
        public static void Initialize()
        {
            var perfCounters = new PerfCounterSet(false, true, SwitchConst.NeonSwitchPerf, SwitchConst.NeonSwitchName);

            Install(perfCounters);

            if (perfCounters != null)
            {
                Runtime       = perfCounters[Runtime_Name];
                TotalCalls    = perfCounters[TotalCalls_Name];
                TotalCallRate = perfCounters[TotalCallRate_Name];
            }
            else
            {
                Runtime               =
                    TotalCalls        =
                        TotalCallRate = PerfCounter.Stub;
            }
        }
Exemplo n.º 24
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();
            }
        }
Exemplo n.º 25
0
            public PerfCounter   Exceptions;           // Exceptions/sec

            /// <summary>
            /// Initializes the service's performance counters from the performance
            /// counter set passed.
            /// </summary>
            /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
            /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
            public Perf(PerfCounterSet perfCounters, string perfPrefix)
            {
                Install(perfCounters, perfPrefix);

                if (perfPrefix == null)
                {
                    perfPrefix = string.Empty;
                }

                if (perfCounters != null)
                {
                    Queries    = perfCounters[perfPrefix + Queries_Name];
                    Exceptions = perfCounters[perfPrefix + Exceptions_Name];
                }
                else
                {
                    Queries        =
                        Exceptions = PerfCounter.Stub;
                }
            }
Exemplo n.º 26
0
        /// <summary>
        /// Establishes a session with the authentication extension.
        /// </summary>
        /// <param name="args">The extension specific arguments (see the remarks).</param>
        /// <param name="query">Ignored for this extension.</param>
        /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
        /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
        /// <remarks>
        /// <para>
        /// This extension recognises the following arguments:
        /// </para>
        /// <list type="table">
        ///     <item>
        ///         <term>Path</term>
        ///         <description>
        ///         The fully qualified path to the credential file.  This argument is required.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>Reload</term>
        ///         <description>
        ///         Indicates whether the credentials file should be reloaded before every authentication
        ///         attempt.  This can have values such as "yes"/"no" or "true"/"false".  This argument
        ///         defaults to "true".
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>MaxCacheTime</term>
        ///         <description>
        ///         Specifies the maximum time clients should retain authentication information.
        ///         This is expressed in the same format as timespans parsed by <see cref="Config.Parse(string,TimeSpan)" />.
        ///         This argument defaults to "5m".
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutCount</term>
        ///         <description>
        ///         Specifies the limiting failed authentication count.  Accounts
        ///         will be locked when the fail count reaches this number.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutThreshold</term>
        ///         <description>
        ///         The period of time that can elapse between failed authentication
        ///         attempts where the failed attempts will <b>not</b> be counted against the
        ///         <b>LockoutCount</b>.  Set this to <see cref="TimeSpan.Zero" />
        ///         to disable account lockout for the realm.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutTime</term>
        ///         <description>
        ///         The period of time an account will remain locked after being locked
        ///         out due to too many failed authentication attempts.
        ///         </description>
        ///     </item>
        /// </list>
        /// <note>
        /// All calls to <see cref="Open" /> must be matched with a call
        /// to <see cref="Close" /> or <see cref="Dispose" />.
        /// </note>
        /// </remarks>
        public void Open(ArgCollection args, string query, PerfCounterSet perfCounters, string perfPrefix)
        {
            using (TimedLock.Lock(this))
            {
                if (IsOpen)
                {
                    throw new AuthenticationException("Authentication extension is already open.");
                }

                perf         = new Perf(perfCounters, perfPrefix);
                path         = EnvironmentVars.Expand(args["Path"]);
                reload       = args.Get("Reload", true);
                maxCacheTime = args.Get("MaxCacheTime", TimeSpan.FromMinutes(5));

                if (!reload)
                {
                    credentials = LoadCredentials();
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Establishes a session with the authentication extension.
        /// </summary>
        /// <param name="args">The extension specific arguments (see the remarks).</param>
        /// <param name="query">The database query template (see the remarks).</param>
        /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
        /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
        /// <remarks>
        /// <para>
        /// This extension recognises the following arguments:
        /// </para>
        /// <list type="table">
        ///     <item>
        ///         <term>Connection String</term>
        ///         <description>
        ///         All of the arguments that are not explicitly described below will be
        ///         collected together as the ODBC connection string.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>MaxCacheTime</term>
        ///         <description>
        ///         Specifies the maximum time clients should retain authentication information.
        ///         This is expressed in the same format as timespans parsed by <see cref="Config.Parse(string,TimeSpan)" />.
        ///         This argument defaults to "5m".
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutCount</term>
        ///         <description>
        ///         Specifies the limiting failed authentication count.  Accounts
        ///         will be locked when the fail count reaches this number.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutThreshold</term>
        ///         <description>
        ///         The period of time that can elapse between failed authentication
        ///         attempts where the failed attempts will <b>not</b> be counted against the
        ///         <b>LockoutCount</b>.  Set this to <see cref="TimeSpan.Zero" />
        ///         to disable account lockout for the realm.
        ///         </description>
        ///     </item>
        ///     <item>
        ///         <term>LockoutTime</term>
        ///         <description>
        ///         The period of time an account will remain locked after being locked
        ///         out due to too many failed authentication attempts.
        ///         </description>
        ///     </item>
        /// </list>
        /// <note>
        /// All calls to <see cref="Open" /> must be matched with a call
        /// to <see cref="Close" /> or <see cref="Dispose" />.
        /// </note>
        /// </remarks>
        public void Open(ArgCollection args, string query, PerfCounterSet perfCounters, string perfPrefix)
        {
            var sb = new StringBuilder(128);

            using (TimedLock.Lock(this))
            {
                if (IsOpen)
                {
                    throw new AuthenticationException("Authentication extension is already open.");
                }

                perf          = new Perf(perfCounters, perfPrefix);
                queryTemplate = query;

                // Process the built-in arguments

                maxCacheTime = args.Get("MaxCacheTime", TimeSpan.FromMinutes(5));

                // Build the connection string

                foreach (string key in args)
                {
                    switch (key.ToLowerInvariant())
                    {
                    case "maxcachetime":
                    case "LockoutCount":
                    case "LockoutThreshold":
                    case "LockoutTime":

                        break;          // Ignore the built-in arguments.

                    default:

                        sb.AppendFormat("{0}={1};", key, args[key]);
                        break;
                    }
                }

                conString = sb.ToString();
            }
        }
Exemplo n.º 28
0
            public PerfCounter Runtime;                        // Service runtime in minutes

            /// <summary>
            /// Initializes the service's performance counters from the performance
            /// counter set passed.
            /// </summary>
            /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
            /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
            public Perf(PerfCounterSet perfCounters, string perfPrefix)
            {
                Install(perfCounters, perfPrefix);

                if (perfPrefix == null)
                {
                    perfPrefix = string.Empty;
                }

                if (perfCounters != null)
                {
                    IsMaster                    = perfCounters[perfPrefix + IsMaster_Name];
                    AdminMessageRate            = perfCounters[perfPrefix + AdminMessageRate_Name];
                    AdminByteRate               = perfCounters[perfPrefix + AdminByteRate_Name];
                    BroadcastReceiveMessageRate = perfCounters[perfPrefix + BroadcastReceiveMessageRate_Name];
                    BroadcastReceiveByteRate    = perfCounters[perfPrefix + BroadcastReceiveByteRate_Name];
                    BroadcastSendMessageRate    = perfCounters[perfPrefix + BroadcastSendMessageRate_Name];
                    BroadcastSendByteRate       = perfCounters[perfPrefix + BroadcastSendByteRate_Name];
                    TotalMessageRate            = perfCounters[perfPrefix + TotalMessageRate_Name];
                    TotalByteRate               = perfCounters[perfPrefix + TotalByteRate_Name];
                    ServerCount                 = perfCounters[perfPrefix + ServerCount_Name];
                    ClientCount                 = perfCounters[perfPrefix + ClientCount_Name];
                    Runtime = perfCounters[perfPrefix + Runtime_Name];
                }
                else
                {
                    IsMaster              =
                        AdminMessageRate  =
                            AdminByteRate =
                                BroadcastReceiveMessageRate             =
                                    BroadcastReceiveByteRate            =
                                        BroadcastSendMessageRate        =
                                            BroadcastSendByteRate       =
                                                TotalMessageRate        =
                                                    TotalByteRate       =
                                                        ServerCount     =
                                                            ClientCount =
                                                                Runtime = PerfCounter.Stub;
                }
            }
Exemplo n.º 29
0
            public PerfCounter Runtime;    // Service runtime in minutes

            /// <summary>
            /// Initializes the service's performance counters from the performance
            /// counter set passed.
            /// </summary>
            /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
            /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
            public Perf(PerfCounterSet perfCounters, string perfPrefix)
            {
                Install(perfCounters, perfPrefix);

                if (perfPrefix == null)
                {
                    perfPrefix = string.Empty;
                }

                if (perfCounters != null)
                {
                    Queries = perfCounters[perfPrefix + Queries_Name];
                    Status  = perfCounters[perfPrefix + Status_Name];
                    Runtime = perfCounters[perfPrefix + Runtime_Name];
                }
                else
                {
                    Queries         =
                        Status      =
                            Runtime = PerfCounter.Stub;
                }
            }
Exemplo n.º 30
0
            public PerfCounter Runtime;            // Service runtime in minutes

            /// <summary>
            /// Initializes the service's performance counters from the performance
            /// counter set passed.
            /// </summary>
            /// <param name="perfCounters">The application's performance counter set (or <c>null</c>).</param>
            /// <param name="perfPrefix">The string to prefix any performance counter names (or <c>null</c>).</param>
            public Perf(PerfCounterSet perfCounters, string perfPrefix)
            {
                Install(perfCounters, perfPrefix);

                if (perfPrefix == null)
                {
                    perfPrefix = string.Empty;
                }

                if (perfCounters != null)
                {
                    Uploads    = perfCounters[perfPrefix + Uploads_Name];
                    Deliveries = perfCounters[perfPrefix + Deliveries_Name];
                    CacheLoads = perfCounters[perfPrefix + CacheLoads_Name];
                    Runtime    = perfCounters[perfPrefix + Runtime_Name];
                }
                else
                {
                    Uploads             =
                        Deliveries      =
                            CacheLoads  =
                                Runtime = PerfCounter.Stub;
                }
            }