logstash-lite 0.2.20101208111718 → 0.2.20101222161646

Sign up to get free protection for your applications and to get access to all the features.
data/bin/logstash CHANGED
@@ -8,11 +8,12 @@ require "logstash/agent"
8
8
  require "optparse"
9
9
  require "yaml"
10
10
 
11
- Settings = Struct.new(:config_file, :daemonize, :logfile)
11
+ Settings = Struct.new(:config_file, :daemonize, :logfile, :verbose)
12
12
 
13
13
  settings = Settings.new
14
14
  settings.daemonize = false
15
15
  settings.config_file = nil
16
+ settings.verbose = 0
16
17
  progname = File.basename($0)
17
18
 
18
19
  opts = OptionParser.new do |opts|
@@ -30,6 +31,10 @@ opts = OptionParser.new do |opts|
30
31
  opts.on("-l", "--log FILE", "Log to a given path. Default is stdout.") do |path|
31
32
  settings.logfile = path
32
33
  end
34
+
35
+ opts.on("-v", "Increase verbosity (not yet used)") do
36
+ settings.verbose += 1
37
+ end
33
38
  end
34
39
 
35
40
  begin
@@ -62,6 +67,7 @@ if settings.daemonize
62
67
  exit(0)
63
68
  end
64
69
  end
70
+
65
71
  agent = LogStash::Agent.new(config)
66
72
  if settings.logfile
67
73
  agent.log_to(settings.logfile)
data/etc/init/logstash ADDED
@@ -0,0 +1,68 @@
1
+ #! /bin/sh
2
+ #
3
+ # Logstash Start/Stop logstash
4
+ #
5
+ # chkconfig: 345 99 99
6
+ # description: Logstash
7
+ # processname: logstash
8
+
9
+ logstash_bin="/usr/bin/logstash"
10
+ logstash_conf="/etc/logstash/logstash.yaml"
11
+ logstash_log="/var/log/logstash/logstash.log"
12
+ NICE_LEVEL="-n 19"
13
+
14
+ find_logstash_process () {
15
+ PIDTEMP=`ps ux | grep ruby | grep logstash | awk '{ print $2 }'`
16
+ # Pid not found
17
+ if [ "x$PIDTEMP" = "x" ]; then
18
+ PID=-1
19
+ else
20
+ PID=$PIDTEMP
21
+ fi
22
+ }
23
+
24
+ start () {
25
+ LOG_DIR=`dirname ${logstash_log}`
26
+ if [ ! -d $LOG_DIR ]; then
27
+ echo "Log dir ${LOG_DIR} doesn't exist. Creating"
28
+ mkdir $LOG_DIR
29
+ fi
30
+ nice ${NICE_LEVEL} ${logstash_bin} -d -f ${logstash_conf} -l ${logstash_log}
31
+ }
32
+
33
+ stop () {
34
+ find_logstash_process
35
+ if [ $PID -ne -1 ]; then
36
+ kill $PID
37
+ fi
38
+ }
39
+
40
+ case $1 in
41
+ start)
42
+ start
43
+ ;;
44
+ stop)
45
+ stop
46
+ exit 0
47
+ ;;
48
+ reload)
49
+ stop
50
+ start
51
+ ;;
52
+ restart)
53
+ stop
54
+ start
55
+ ;;
56
+ status)
57
+ find_logstash_process
58
+ if [ $PID -gt 0 ]; then
59
+ exit 0
60
+ else
61
+ exit 1
62
+ fi
63
+ ;;
64
+ *)
65
+ echo $"Usage: $0 {start|stop|restart|reload|status}"
66
+ RETVAL=1
67
+ esac
68
+ exit 0
@@ -38,10 +38,9 @@ class LogStash::Filters::Grok < LogStash::Filters::Base
38
38
  pile = @grokpiles[event.type]
39
39
  grok, match = pile.match(message)
40
40
  end # @grokpiles.include?(event.type)
41
- # TODO(2.0): support grok pattern discovery
42
- else
41
+ else
42
+ return
43
43
  @logger.info("Unknown type for #{event.source} (type: #{event.type})")
44
- @logger.debug(event.to_hash)
45
44
  end
46
45
 
47
46
  if match
@@ -99,9 +99,42 @@ class LogStash::Web::Server < Sinatra::Base
99
99
  body haml :"search/ajax", :layout => !request.xhr?
100
100
  end # elasticsearch.search
101
101
  end # apost '/search/ajax'
102
-
103
102
  end # class LogStashWeb
104
103
 
104
+ require "optparse"
105
+
106
+ Settings = Struct.new(:daemonize, :logfile)
107
+ settings = Settings.new
108
+ progname = File.basename($0)
109
+
110
+ opts = OptionParser.new do |opts|
111
+ opts.banner = "Usage: #{progname} [options]"
112
+
113
+ opts.on("-d", "--daemonize", "Daemonize (default is run in foreground)") do
114
+ settings.daemonize = true
115
+ end
116
+
117
+ opts.on("-l", "--log FILE", "Log to a given path. Default is stdout.") do |path|
118
+ settings.logfile = path
119
+ end
120
+ end
121
+
122
+ opts.parse!
123
+
124
+ if settings.daemonize
125
+ if Process.fork == nil
126
+ Process.setsid
127
+ else
128
+ exit(0)
129
+ end
130
+ end
131
+
132
+ if settings.logfile
133
+ logfile = File.open(settings.logfile, "w")
134
+ STDOUT.reopen(logfile)
135
+ STDERR.reopen(logfile)
136
+ end
137
+
105
138
  Rack::Handler::Thin.run(
106
139
  Rack::CommonLogger.new( \
107
140
  Rack::ShowExceptions.new( \
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-lite
3
3
  version: !ruby/object:Gem::Version
4
- hash: 40202416223451
4
+ hash: 40202444323275
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 20101208111718
10
- version: 0.2.20101208111718
9
+ - 20101222161646
10
+ version: 0.2.20101222161646
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jordan Sissel
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-12-08 00:00:00 -08:00
19
+ date: 2010-12-22 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -217,6 +217,7 @@ files:
217
217
  - examples/sample-agent-in-ruby.rb
218
218
  - etc/tograylog.yaml
219
219
  - etc/logstash-elasticsearch-rabbitmq-river.yaml
220
+ - etc/init/logstash
220
221
  - etc/logstash-nagios.yaml
221
222
  - etc/logstash-reader.yaml
222
223
  - etc/logstash-stomp-input.yaml