public EventlogListener(string protocol, string source, string category, EventLogEntryType[] types, string key, int value, IMonitoringChannel channel)
        {
            if (protocol == null)
                throw new ArgumentNullException("protocol");

            if (key == null)
                throw new ArgumentNullException("key");

            if (channel == null)
                throw new ArgumentNullException("channel");

            this.key = key;
            this.value = value;

            this.channel = channel;
            this.types = types;

            this.protocol = protocol;
            this.source = source;
            this.category = category;

            try
            {
                this.Initialize();
            }
            catch (ArgumentException exception)
            {
                throw new ArgumentException(
                    exception.Message + " (" + protocol + ")",
                    exception);
            }
        }
Exemple #2
0
        private Action CreateReportingAction(AppPoolElement config, out AppPoolListener listener)
        {
            AppPoolListener element = null;

            if (config.WorkingSet && string.IsNullOrEmpty(config.Counter))
            {
                element = new AppPoolListener(config.AppPoolName, "Process", "Working Set");
            }
            else if (!string.IsNullOrEmpty(config.Counter))
            {
                element = new AppPoolListener(config.AppPoolName, config.Category, config.Counter);
            }

            listener = element;

            IMonitoringChannel channel = this.factory.CreateChannel(config.Type, config.Target);

            this.appPools.Add(element);

            return(() =>
            {
                if (element != null)
                {
                    float?value = element.ReportValue();

                    if (value.HasValue)
                    {
                        channel.Report(config.Key, (long)value.Value);
                    }
                }
            });
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LogAssertion" /> class.
        /// </summary>
        public LogAssertion()
        {
            this.factory = new ChannelFactory(
                GraphiteConfiguration.Instance.Graphite,
                GraphiteConfiguration.Instance.StatsD);

            var configuration = GraphiteElmahConfiguration.Instance;

            if (configuration == null)
                throw new InvalidOperationException("No configuration section 'graphite.elmah' found.");

            this.metricKey = configuration.Key ?? "admin.elmah_errors";

            this.channel = this.factory.CreateChannel(
                configuration.Type ?? "counter",
                configuration.Target ?? "statsd");
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LogAssertion" /> class.
        /// </summary>
        public LogAssertion()
        {
            this.factory = new ChannelFactory(
                GraphiteConfiguration.Instance.Graphite,
                GraphiteConfiguration.Instance.StatsD);

            var configuration = GraphiteElmahConfiguration.Instance;

            if (configuration == null)
            {
                throw new InvalidOperationException("No configuration section 'graphite.elmah' found.");
            }

            this.metricKey = configuration.Key ?? "admin.elmah_errors";

            this.channel = this.factory.CreateChannel(
                configuration.Type ?? "counter",
                configuration.Target ?? "statsd");
        }
Exemple #5
0
        public override bool Execute()
        {
            using (var channelFactory = new ChannelFactory(this, null))
            {
                IMonitoringChannel channel = channelFactory.CreateChannel(
                    "gauge",
                    "graphite");

                channel.Report(this.Key, this.Value);

                Console.Out.WriteLine(
                    "Reported value '{0}' for key '{1}' to {2}:{3}.",
                    this.Value,
                    string.IsNullOrEmpty(this.PrefixKey) ? this.Key : (this.PrefixKey + "." + this.Key),
                    this.Address,
                    this.Port);
            }

            return(true);
        }
        public override bool Execute()
        {
            using (var channelFactory = new ChannelFactory(null, this))
            {
                IMonitoringChannel channel = channelFactory.CreateChannel(
                    this.Type.ToString(),
                    "statsd");

                channel.Report(this.Key, this.Value);

                Console.Out.WriteLine(
                    "Reported value '{0}' of type '{1}' for key '{2}' to {3}:{4}.",
                    this.Value,
                    this.Type,
                    string.IsNullOrEmpty(this.PrefixKey) ? this.Key : (this.PrefixKey + "." + this.Key),
                    this.Address,
                    this.Port);
            }

            return(true);
        }
Exemple #7
0
        public EventlogListener(string protocol, string source, string category, EventLogEntryType[] types, string key, int?eventid, int value, bool attacheventidtokey, IMonitoringChannel channel)
        {
            if (protocol == null)
            {
                throw new ArgumentNullException("protocol");
            }

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

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

            this.key                = key;
            this.value              = value;
            this.eventid            = eventid;
            this.attacheventidtokey = attacheventidtokey;

            this.channel = channel;
            this.types   = types;

            this.protocol = protocol;
            this.source   = source;
            this.category = category;

            try
            {
                this.Initialize();
            }
            catch (ArgumentException exception)
            {
                throw new ArgumentException(
                          exception.Message + " (" + protocol + ")",
                          exception);
            }
        }
Exemple #8
0
        private Action CreateReportingAction(AppPoolElement config, out AppPoolListener listener)
        {
            var element = new AppPoolListener(config.AppPoolName);

            listener = element;

            IMonitoringChannel channel = this.factory.CreateChannel(config.Type, config.Target);

            this.appPools.Add(element);

            return(() =>
            {
                if (config.WorkingSet)
                {
                    long?value = element.ReportWorkingSet();

                    if (value.HasValue)
                    {
                        channel.Report(config.Key, value.Value);
                    }
                }
            });
        }
        public GraphiteBackend(IGraphiteConfiguration configuration)
        {
            this.factory = new ChannelFactory(configuration, null);

            this.graphiteChannel = this.factory.CreateChannel("gauge", "graphite");
        }
        public GraphiteBackend(IGraphiteConfiguration configuration)
        {
            this.factory = new ChannelFactory(configuration, null);

            this.graphiteChannel = this.factory.CreateChannel("gauge", "graphite");
        }