예제 #1
0
        public Kernel(GraphiteConfiguration configuration, GraphiteSystemConfiguration systemConfiguration)
        {
            this.factory = new ChannelFactory(configuration.Graphite, configuration.StatsD);

            foreach (var listener in systemConfiguration.EventlogListeners.Cast <EventlogListenerElement>())
            {
                this.CreateEventlogListener(listener);
            }

            this.scheduler = new Scheduler();

            foreach (var listener in systemConfiguration.CounterListeners.Cast <CounterListenerElement>())
            {
                Action action;

                try
                {
                    action = this.CreateReportingAction(listener);

                    this.scheduler.Add(action, listener.Interval);
                }
                catch (InvalidOperationException)
                {
                    if (!listener.Retry)
                    {
                        throw;
                    }

                    this.retryCreation.Add(listener);
                }
            }

            if (this.retryCreation.Any())
            {
                this.scheduler.Add(this.RetryCounterCreation, RetryInterval);
            }

            foreach (var appPool in systemConfiguration.AppPool.Cast <AppPoolElement>())
            {
                AppPoolListener element;

                var action = this.CreateReportingAction(appPool, out element);

                this.scheduler.Add(action, appPool.Interval);

                // Reread counter instance name every 90 seconds
                this.scheduler.Add(() => element.LoadCounterName(), 90);
            }

            this.scheduler.Start();
        }
예제 #2
0
        public void Configure(string collectorName, XElement configElement, ISystemMetricsService systemMetrics)
        {
            _systemMetrics = systemMetrics;
            Completion     = new Task(() => { IsActive = false; });
            _senderBlock   = new ActionBlock <GraphiteLine>(message => SendLine(message), Utility.OneAtATimeExecution());
            IsActive       = true;

            var config = new GraphiteConfiguration(configElement.Attribute("host").Value, configElement.ToInt("port"));

            var ipAddress = Utility.HostToIPv4Address(config.Host);

            _client = new UdpClient();
            _client.Connect(ipAddress, config.Port);
        }
예제 #3
0
        public void Configure(string collectorName, XElement configElement, ISystemMetricsService systemMetrics)
        {
            _log            = SuperCheapIOC.Resolve <ILog>();
            _systemMetrics  = systemMetrics;
            _completionTask = new Task(() => { _isActive = false; });
            _senderBlock    = new ActionBlock <GraphiteLine>((message) => SendLine(message), Utility.UnboundedExecution());
            _isActive       = true;

            var config = new GraphiteConfiguration(configElement.Attribute("host").Value, configElement.ToInt("port"));

            var ipAddress = Utility.HostToIPv4Address(config.Host);

            _client = new UdpClient();
            _client.Connect(ipAddress, config.Port);
        }
예제 #4
0
        internal MetricsPipe(GraphiteConfiguration configuration, IMetricsPipeProvider provider, Func <IStopwatch> watch)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

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

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

            this.factory = new ChannelFactory(configuration.Graphite, configuration.StatsD);

            MetricsPipe.provider = provider;

            this.watch = watch();
        }