コード例 #1
0
        public LogsListener(TimberWinR.Parser.LogParameters arguments, CancellationToken cancelToken)
            : base(cancelToken, "Win32-FileLog")
        {
            Stop = false;

            EnsureRollingCaught();

             _codecArguments = arguments.CodecArguments;

            _codecArguments = arguments.CodecArguments;
            if (_codecArguments != null && _codecArguments.Type == CodecArguments.CodecType.multiline)
                _codec = new Multiline(_codecArguments);

            if (!string.IsNullOrEmpty(arguments.Type))
                SetTypeName(arguments.Type);

            _receivedMessages = 0;
            _arguments = arguments;
            _pollingIntervalInSeconds = arguments.Interval;

            IsWildcardFilePattern = arguments.Location.Contains('*');

            foreach (string srcFile in _arguments.Location.Split(','))
            {
                string file = srcFile.Trim();
                string dir = Path.GetDirectoryName(file);
                if (string.IsNullOrEmpty(dir))
                    dir = Environment.CurrentDirectory;
                string fileSpec = Path.Combine(dir, file);

                Task.Factory.StartNew(() => FileWatcher(fileSpec));
            }
        }
コード例 #2
0
ファイル: Redis.cs プロジェクト: schmidt4brains/TimberWinR
        public RedisOutput(TimberWinR.Manager manager, Parser.RedisOutputParameters parameters, CancellationToken cancelToken)
            : base(cancelToken, "Redis")
        {
            _redisDepth = 0;
            _batchCount = parameters.BatchCount;
            _maxBatchCount = parameters.MaxBatchCount;
            // Make sure maxBatchCount is larger than batchCount
            if (_maxBatchCount <= _batchCount)
                _maxBatchCount = _batchCount * 10;

            _manager = manager;
            _redisHostIndex = 0;
            _redisHosts = parameters.Host;
            _jsonQueue = new List<string>();
            _port = parameters.Port;
            _timeout = parameters.Timeout;
            _logstashIndexName = parameters.Index;
            _interval = parameters.Interval;
            _numThreads = parameters.NumThreads;
            _errorCount = 0;
            _lastErrorTimeUTC = null;
            _maxQueueSize = parameters.MaxQueueSize;
            _queueOverflowDiscardOldest = parameters.QueueOverflowDiscardOldest;
            _batchCounter = new BatchCounter(_batchCount, _maxBatchCount);
            _currentBatchCount = _batchCount;

            for (int i = 0; i < parameters.NumThreads; i++)
            {
                var redisThread = new Task(RedisSender, cancelToken);
                redisThread.Start();
            }
        }
コード例 #3
0
ファイル: StatsD.cs プロジェクト: schmidt4brains/TimberWinR
        public StatsDOutput(TimberWinR.Manager manager, Parser.StatsDOutputParameters parameters, CancellationToken cancelToken)
            : base(cancelToken, "StatsD")
        {
            _params = parameters;
            _manager = manager;
            _port = parameters.Port;
            _host = parameters.Host;
            _interval = parameters.Interval;
            _flushSize = parameters.FlushSize;
            _idleFlushTimeSeconds = parameters.IdleFlushTimeInSeconds;
            _maxQueueSize = parameters.MaxQueueSize;
            _queueOverflowDiscardOldest = parameters.QueueOverflowDiscardOldest;
            _numThreads = parameters.NumThreads;
            _jsonQueue = new List<JObject>();

            var metricsConfig = new MetricsConfig
            {
                StatsdServerName = _host,
                Prefix = parameters.Namespace,
            };

            StatsdClient.Metrics.Configure(metricsConfig);

            for (int i = 0; i < _numThreads; i++)
            {
                Task.Factory.StartNew(StatsDSender, cancelToken, TaskCreationOptions.LongRunning, TaskScheduler.Current);
            }
        }
コード例 #4
0
        public TailFileListener(TimberWinR.Parser.TailFileArguments arguments,
            CancellationToken cancelToken)
            : base(cancelToken, "Win32-TailLog")
        {
            Stop = false;

            EnsureRollingCaught();

            _codecArguments = arguments.CodecArguments;
            if (_codecArguments != null && _codecArguments.Type == CodecArguments.CodecType.multiline)
                _codec = new Multiline(_codecArguments);

            if (!string.IsNullOrEmpty(arguments.Type))
                SetTypeName(arguments.Type);

            _receivedMessages = 0;
            _arguments = arguments;
            _pollingIntervalInSeconds = arguments.Interval;

            foreach (string srcFile in _arguments.Location.Split(','))
            {
                string file = srcFile.Trim();
                Task.Factory.StartNew(() => TailFileWatcher(file));
            }
        }
コード例 #5
0
        public StdinListener(TimberWinR.Parser.Stdin arguments, CancellationToken cancelToken)
            : base(cancelToken, "Win32-Console")
        {
            _codecArguments = arguments.CodecArguments;
            if (_codecArguments != null && _codecArguments.Type == CodecArguments.CodecType.multiline)
                _codec = new Multiline(_codecArguments);

            _listenThread = new Thread(new ThreadStart(ListenToStdin));
            _listenThread.Start();
        }
コード例 #6
0
 public W3CInputListener(TimberWinR.Parser.W3CLogParameters arguments, CancellationToken cancelToken, int pollingIntervalInSeconds = 5)
     : base(cancelToken, "Win32-W3CLog")
 {
     _arguments = arguments;
     _receivedMessages = 0;
     _pollingIntervalInSeconds = pollingIntervalInSeconds;
     foreach (string loc in _arguments.Location.Split(','))
     {
         string hive = loc.Trim();
         Task.Factory.StartNew(() => IISW3CWatcher(loc));
     }
 }
コード例 #7
0
        public GeneratorInput(TimberWinR.Parser.GeneratorParameters parameters, CancellationToken cancelToken)
            : base(cancelToken, "Win32-InputGen")
        {
            _params = parameters;

            if (_params.CodecArguments != null)
            {
                switch (_params.CodecArguments.Type)
                {
                    case CodecArguments.CodecType.json:
                        _codec = new JsonCodec(_params.CodecArguments);
                        break;
                    case CodecArguments.CodecType.multiline:
                        _codec = new Multiline(_params.CodecArguments);
                        break;
                    case CodecArguments.CodecType.plain:
                        _codec = new PlainCodec(_params.CodecArguments);
                        break;
                }
            }

            _listenThread = new Thread(new ThreadStart(GenerateData));
            _listenThread.Start();
        }