jls-grok 0.2.3091 → 0.2.3092

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ task :default => [:package]
2
+
3
+ task :package do
4
+ system("make -C ext clean; rm ext/Makefile")
5
+ system("svn up")
6
+ system("gem build grok.gemspec")
7
+ end
8
+
9
+ task :publish do
10
+ latest_gem = %x{ls -t jls-grok*.gem}.split("\n").first
11
+ system("gem push #{latest_gem}")
12
+ end
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Simple web application that will let you feed grok's discovery feature
4
+ # a bunch of data, and grok will show you patterns found and the results
5
+ # of that pattern as matched against the same input.
6
+
7
+ require 'rubygems'
8
+ require 'sinatra'
9
+ require 'grok'
10
+
11
+ get '/' do
12
+ redirect "/demo/grok-discover/index"
13
+ end
14
+
15
+ get "/demo/grok-discover/index" do
16
+ haml :index
17
+ end
18
+
19
+ post "/demo/grok-discover/grok" do
20
+ grok = Grok.new
21
+ grok.add_patterns_from_file("/usr/local/share/grok/patterns/base")
22
+ @results = []
23
+ params[:data].split("\n").each do |line|
24
+ pattern = grok.discover(line)
25
+ grok.compile(pattern)
26
+ match = grok.match(line)
27
+ puts "Got input: #{line}"
28
+ puts " => pattern: (#{match != false}) #{pattern}"
29
+ @results << {
30
+ :input => line,
31
+ :pattern => grok.pattern.gsub(/\\Q|\\E/, ""),
32
+ :full_pattern => grok.expanded_pattern,
33
+ :match => (match and match.captures or false),
34
+ }
35
+ end
36
+ haml :grok
37
+ end
38
+
39
+ get "/demo/grok-discover/style.css" do
40
+ sass :style
41
+ end
42
+
43
+ __END__
44
+ @@ style
45
+ h1
46
+ color: red
47
+ .original
48
+ .regexp
49
+ display: block
50
+ border: 1px solid grey
51
+ padding: 1em
52
+
53
+ .results
54
+ width: 80%
55
+ margin-left: auto
56
+ th
57
+ text-align: left
58
+ td
59
+ border-top: 1px solid black
60
+ @@ layout
61
+ %html
62
+ %head
63
+ %title Grok Web
64
+ %link{:rel => "stylesheet", :href => "/demo/grok-discover/style.css"}
65
+ %body
66
+ =yield
67
+
68
+ @@ index
69
+ #header
70
+ %h1 Grok Web
71
+ #content
72
+ Paste some log data below. I'll do my best to have grok generate a pattern for you.
73
+
74
+ %p
75
+ Learn more about grok here:
76
+ %a{:href => "http://code.google.com/p/semicomplete/wiki/Grok"} Grok
77
+
78
+ %p
79
+ This is running off of my cable modem for now, so if it's sluggish, that's
80
+ why. Be gentle.
81
+ %form{:action => "/demo/grok-discover/grok", :method => "post"}
82
+ %textarea{:name => "data", :rows => 10, :cols => 80}
83
+ %br
84
+ %input{:type => "submit", :value=>"submit"}
85
+
86
+ @@ grok
87
+ #header
88
+ %h1 Grok Results
89
+ %h3
90
+ %a{:href => "/demo/grok-discover/index"} Try more?
91
+ #content
92
+ %p
93
+ Below is grok's analysis of the data you provided. Each line is analyzed
94
+ separately. It uses grok's standard library of known patterns to give you a
95
+ pattern that grok can use to match more logs like the lines you provided.
96
+ %p
97
+ The results may not be perfect, but it gives you a head start on coming up with
98
+ log patterns for
99
+ %a{:href => "http://code.google.com/p/semicomplete/wiki/Grok"} grok
100
+ and
101
+ %a{:href => "http://code.google.com/p/logstash/"} logstash
102
+ %ol
103
+ - @results.each do |result|
104
+ %li
105
+ %p.original
106
+ %b Original:
107
+ %br= result[:input]
108
+ %p
109
+ %b Pattern:
110
+ %br
111
+ %span.pattern= result[:pattern]
112
+ %p
113
+ %b
114
+ Generated Regular Expression
115
+ %small
116
+ %i You could have written this by hand, be glad you didn't have to.
117
+ %code.regexp= result[:full_pattern].gsub("<", "&lt;")
118
+ %p
119
+ If you wanted to test this, you can paste the above expression into
120
+ pcretest(1) and it should match your input.
121
+ %p
122
+ %b Capture Results
123
+ %table.results
124
+ %tr
125
+ %th Name
126
+ %th Value
127
+ - result[:match].each do |key,val|
128
+ - val.each do |v|
129
+ %tr
130
+ %td= key
131
+ %td= v
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+
4
+ require "rubygems"
5
+ require "grok"
6
+ require "pp"
7
+
8
+ grok = Grok.new
9
+
10
+ # Load some default patterns that ship with grok.
11
+ # See also:
12
+ # http://code.google.com/p/semicomplete/source/browse/grok/patterns/base
13
+ grok.add_patterns_from_file("/usr/local/share/grok/patterns/base")
14
+
15
+ # Using the patterns we know, try to build a grok pattern that best matches
16
+ # a string we give. Let's try Time.now.to_s, which has this format;
17
+ # => Fri Apr 16 19:15:27 -0700 2010
18
+ input = "Time is #{Time.now}"
19
+ pattern = grok.discover(input)
20
+
21
+ puts "Input: #{input}"
22
+ puts "Pattern: #{pattern}"
23
+ grok.compile(pattern)
24
+
25
+ # Sleep to change time.
26
+ puts "Sleeping so time changes and we can test against another input."
27
+ sleep(2)
28
+ match = grok.match("Time is #{Time.now.to_s}")
29
+ puts "Resulting capture:"
30
+ pp match.captures
31
+
32
+ # When run, the output should look something like this:
33
+ # % ruby pattern-discovery.rb
34
+ # Pattern: Time is Fri %{SYSLOGDATE} %{BASE10NUM} 2010
35
+ # {"BASE10NUM"=>["-0700"],
36
+ # "SYSLOGDATE"=>["Apr 16 19:17:38"],
37
+ # "TIME"=>["19:17:38"],
38
+ # "MONTH"=>["Apr"],
39
+ # "MONTHDAY"=>["16"]}
data/examples/test.rb ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+
4
+ require "rubygems"
5
+ require "grok"
6
+ require "pp"
7
+
8
+ grok = Grok.new
9
+
10
+ # Load some default patterns that ship with grok.
11
+ # See also:
12
+ # http://code.google.com/p/semicomplete/source/browse/grok/patterns/base
13
+ grok.add_patterns_from_file("../..//patterns/base")
14
+
15
+ # Using the patterns we know, try to build a grok pattern that best matches
16
+ # a string we give. Let's try Time.now.to_s, which has this format;
17
+ # => Fri Apr 16 19:15:27 -0700 2010
18
+ input = "2010-04-18T15:06:02Z"
19
+ pattern = "%{TIMESTAMP_ISO8601}"
20
+ grok.compile(pattern)
21
+ grok.compile(pattern)
22
+ puts "Input: #{input}"
23
+ puts "Pattern: #{pattern}"
24
+ puts "Full: #{grok.expanded_pattern}"
25
+
26
+ match = grok.match(input)
27
+ if match
28
+ puts "Resulting capture:"
29
+ pp match.captures
30
+ end
data/grok.gemspec ADDED
@@ -0,0 +1,60 @@
1
+ Gem::Specification.new do |spec|
2
+ files = <<-FILES
3
+ INSTALL
4
+ Rakefile
5
+ examples
6
+ examples/grok-web.rb
7
+ examples/pattern-discovery.rb
8
+ examples/test.rb
9
+ ext
10
+ ext/extconf.rb
11
+ ext/rgrok.h
12
+ ext/ruby_grok.c
13
+ ext/ruby_grokdiscover.c
14
+ ext/ruby_grokmatch.c
15
+ ext/ruby_grokmatch.h
16
+ grok.gemspec
17
+ lib
18
+ lib/grok
19
+ lib/grok.rb
20
+ lib/grok/pile.rb
21
+ test
22
+ test/Makefile
23
+ test/alltests.rb
24
+ test/core
25
+ test/general
26
+ test/general/basic_test.rb
27
+ test/general/captures_test.rb
28
+ test/patterns
29
+ test/patterns/day.rb
30
+ test/patterns/host.rb
31
+ test/patterns/ip.input
32
+ test/patterns/ip.rb
33
+ test/patterns/iso8601.rb
34
+ test/patterns/month.rb
35
+ test/patterns/number.rb
36
+ test/patterns/path.rb
37
+ test/patterns/prog.rb
38
+ test/patterns/quotedstring.rb
39
+ test/patterns/uri.rb
40
+ test/run.sh
41
+ test/speedtest.rb
42
+ FILES
43
+
44
+ files = files.gsub(/ +/, "").split("\n")
45
+
46
+ svnrev = %x{svn info}.split("\n").grep(/Revision:/).first.split(" ").last.to_i
47
+ spec.name = "jls-grok"
48
+ spec.version = "0.2.#{svnrev}"
49
+
50
+ spec.summary = "grok bindings for ruby"
51
+ spec.description = "Grok ruby bindings - pattern match/extraction tool"
52
+ spec.files = files
53
+ spec.require_paths << "ext"
54
+ spec.extensions = ["ext/extconf.rb"]
55
+
56
+ spec.author = "Jordan Sissel"
57
+ spec.email = "jls@semicomplete.com"
58
+ spec.homepage = "http://code.google.com/p/semicomplete/wiki/Grok"
59
+ end
60
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3091
9
- version: 0.2.3091
8
+ - 3092
9
+ version: 0.2.3092
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jordan Sissel
@@ -27,39 +27,38 @@ extensions:
27
27
  extra_rdoc_files: []
28
28
 
29
29
  files:
30
- - sample.rb
31
30
  - INSTALL
32
- - ext/ruby_grok.c
33
- - ext/mkmf.log
34
- - ext/Makefile
31
+ - Rakefile
32
+ - examples/grok-web.rb
33
+ - examples/pattern-discovery.rb
34
+ - examples/test.rb
35
+ - ext/extconf.rb
35
36
  - ext/rgrok.h
37
+ - ext/ruby_grok.c
38
+ - ext/ruby_grokdiscover.c
36
39
  - ext/ruby_grokmatch.c
37
40
  - ext/ruby_grokmatch.h
38
- - ext/extconf.rb
39
- - ext/ruby_grok.o
40
- - ext/ruby_grokdiscover.c
41
- - ext/ruby_grokdiscover.o
42
- - ext/ruby_grokmatch.o
43
- - test/general/basic_test.rb
44
- - test/general/captures_test.rb
45
- - test/core
41
+ - grok.gemspec
42
+ - lib/grok.rb
43
+ - lib/grok/pile.rb
46
44
  - test/Makefile
47
45
  - test/alltests.rb
48
- - test/speedtest.rb
49
- - test/patterns/quotedstring.rb
46
+ - test/core
47
+ - test/general/basic_test.rb
48
+ - test/general/captures_test.rb
50
49
  - test/patterns/day.rb
51
50
  - test/patterns/host.rb
52
- - test/patterns/number.rb
53
- - test/patterns/iso8601.rb
54
51
  - test/patterns/ip.input
55
52
  - test/patterns/ip.rb
56
- - test/patterns/path.rb
53
+ - test/patterns/iso8601.rb
57
54
  - test/patterns/month.rb
58
- - test/patterns/uri.rb
55
+ - test/patterns/number.rb
56
+ - test/patterns/path.rb
59
57
  - test/patterns/prog.rb
58
+ - test/patterns/quotedstring.rb
59
+ - test/patterns/uri.rb
60
60
  - test/run.sh
61
- - lib/grok.rb
62
- - lib/grok/pile.rb
61
+ - test/speedtest.rb
63
62
  has_rdoc: true
64
63
  homepage: http://code.google.com/p/semicomplete/wiki/Grok
65
64
  licenses: []
data/ext/Makefile DELETED
@@ -1,157 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- #### Start of system configuration section. ####
5
-
6
- srcdir = .
7
- topdir = /usr/lib/ruby/1.8/x86_64-linux
8
- hdrdir = $(topdir)
9
- VPATH = $(srcdir):$(topdir):$(hdrdir)
10
- exec_prefix = $(prefix)
11
- prefix = $(DESTDIR)/usr
12
- sharedstatedir = $(prefix)/com
13
- mandir = $(prefix)/share/man
14
- psdir = $(docdir)
15
- oldincludedir = $(DESTDIR)/usr/include
16
- localedir = $(datarootdir)/locale
17
- bindir = $(exec_prefix)/bin
18
- libexecdir = $(prefix)/lib/ruby1.8
19
- sitedir = $(DESTDIR)/usr/local/lib/site_ruby
20
- htmldir = $(docdir)
21
- vendorarchdir = $(vendorlibdir)/$(sitearch)
22
- includedir = $(prefix)/include
23
- infodir = $(prefix)/share/info
24
- vendorlibdir = $(vendordir)/$(ruby_version)
25
- sysconfdir = $(DESTDIR)/etc
26
- libdir = $(exec_prefix)/lib
27
- sbindir = $(exec_prefix)/sbin
28
- rubylibdir = $(libdir)/ruby/$(ruby_version)
29
- docdir = $(datarootdir)/doc/$(PACKAGE)
30
- dvidir = $(docdir)
31
- vendordir = $(libdir)/ruby/vendor_ruby
32
- datarootdir = $(prefix)/share
33
- pdfdir = $(docdir)
34
- archdir = $(rubylibdir)/$(arch)
35
- sitearchdir = $(sitelibdir)/$(sitearch)
36
- datadir = $(datarootdir)
37
- localstatedir = $(DESTDIR)/var
38
- sitelibdir = $(sitedir)/$(ruby_version)
39
-
40
- CC = gcc
41
- LIBRUBY = $(LIBRUBY_SO)
42
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
43
- LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
44
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
45
-
46
- RUBY_EXTCONF_H =
47
- CFLAGS = -fPIC -fno-strict-aliasing -g -g -O2 -fPIC $(cflags)
48
- INCFLAGS = -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I.
49
- DEFS =
50
- CPPFLAGS =
51
- CXXFLAGS = $(CFLAGS)
52
- ldflags = -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic
53
- dldflags =
54
- archflag =
55
- DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
56
- LDSHARED = $(CC) -shared
57
- AR = ar
58
- EXEEXT =
59
-
60
- RUBY_INSTALL_NAME = ruby1.8
61
- RUBY_SO_NAME = ruby1.8
62
- arch = x86_64-linux
63
- sitearch = x86_64-linux
64
- ruby_version = 1.8
65
- ruby = /usr/bin/ruby1.8
66
- RUBY = $(ruby)
67
- RM = rm -f
68
- MAKEDIRS = mkdir -p
69
- INSTALL = /usr/bin/install -c
70
- INSTALL_PROG = $(INSTALL) -m 0755
71
- INSTALL_DATA = $(INSTALL) -m 644
72
- COPY = cp
73
-
74
- #### End of system configuration section. ####
75
-
76
- preload =
77
-
78
- libpath = . $(libdir)
79
- LIBPATH = -L. -L$(libdir)
80
- DEFFILE =
81
-
82
- CLEANFILES = mkmf.log
83
- DISTCLEANFILES =
84
-
85
- extout =
86
- extout_prefix =
87
- target_prefix =
88
- LOCAL_LIBS =
89
- LIBS = $(LIBRUBYARG_SHARED) -lgrok -lpthread -lrt -ldl -lcrypt -lm -lc
90
- SRCS = ruby_grok.c ruby_grokmatch.c ruby_grokdiscover.c
91
- OBJS = ruby_grok.o ruby_grokmatch.o ruby_grokdiscover.o
92
- TARGET = Grok
93
- DLLIB = $(TARGET).so
94
- EXTSTATIC =
95
- STATIC_LIB =
96
-
97
- BINDIR = $(bindir)
98
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
99
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
100
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
101
-
102
- TARGET_SO = $(DLLIB)
103
- CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
104
- CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
105
-
106
- all: $(DLLIB)
107
- static: $(STATIC_LIB)
108
-
109
- clean:
110
- @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
111
-
112
- distclean: clean
113
- @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
114
- @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
115
-
116
- realclean: distclean
117
- install: install-so install-rb
118
-
119
- install-so: $(RUBYARCHDIR)
120
- install-so: $(RUBYARCHDIR)/$(DLLIB)
121
- $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
122
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
123
- install-rb: pre-install-rb install-rb-default
124
- install-rb-default: pre-install-rb-default
125
- pre-install-rb: Makefile
126
- pre-install-rb-default: Makefile
127
- $(RUBYARCHDIR):
128
- $(MAKEDIRS) $@
129
-
130
- site-install: site-install-so site-install-rb
131
- site-install-so: install-so
132
- site-install-rb: install-rb
133
-
134
- .SUFFIXES: .c .m .cc .cxx .cpp .C .o
135
-
136
- .cc.o:
137
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
138
-
139
- .cxx.o:
140
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
141
-
142
- .cpp.o:
143
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
144
-
145
- .C.o:
146
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
147
-
148
- .c.o:
149
- $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
150
-
151
- $(DLLIB): $(OBJS) Makefile
152
- @-$(RM) $@
153
- $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
154
-
155
-
156
-
157
- $(OBJS): ruby.h defines.h
data/ext/mkmf.log DELETED
@@ -1,102 +0,0 @@
1
- find_header: checking for grok.h in /usr/local/include,../../... -------------------- yes
2
-
3
- "gcc -E -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -o conftest.i"
4
- checked program was:
5
- /* begin */
6
- 1: #include <grok.h>
7
- /* end */
8
-
9
- --------------------
10
-
11
- find_library: checking for grok_init() in -lsgrok... -------------------- no
12
-
13
- "gcc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -lruby1.8-static -lsgrok -lpthread -lrt -ldl -lcrypt -lm -lc"
14
- conftest.c: In function 't':
15
- conftest.c:3: error: 'grok_init' undeclared (first use in this function)
16
- conftest.c:3: error: (Each undeclared identifier is reported only once
17
- conftest.c:3: error: for each function it appears in.)
18
- checked program was:
19
- /* begin */
20
- 1: /*top*/
21
- 2: int main() { return 0; }
22
- 3: int t() { void ((*volatile p)()); p = (void ((*)()))grok_init; return 0; }
23
- /* end */
24
-
25
- "gcc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -lruby1.8-static -lsgrok -lpthread -lrt -ldl -lcrypt -lm -lc"
26
- /usr/bin/ld: cannot find -lsgrok
27
- collect2: ld returned 1 exit status
28
- checked program was:
29
- /* begin */
30
- 1: /*top*/
31
- 2: int main() { return 0; }
32
- 3: int t() { grok_init(); return 0; }
33
- /* end */
34
-
35
- "gcc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -L. -L/usr/lib -L../ -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -lruby1.8-static -lsgrok -lpthread -lrt -ldl -lcrypt -lm -lc"
36
- conftest.c: In function 't':
37
- conftest.c:3: error: 'grok_init' undeclared (first use in this function)
38
- conftest.c:3: error: (Each undeclared identifier is reported only once
39
- conftest.c:3: error: for each function it appears in.)
40
- checked program was:
41
- /* begin */
42
- 1: /*top*/
43
- 2: int main() { return 0; }
44
- 3: int t() { void ((*volatile p)()); p = (void ((*)()))grok_init; return 0; }
45
- /* end */
46
-
47
- "gcc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -L. -L/usr/lib -L../ -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -lruby1.8-static -lsgrok -lpthread -lrt -ldl -lcrypt -lm -lc"
48
- /usr/bin/ld: cannot find -lsgrok
49
- collect2: ld returned 1 exit status
50
- checked program was:
51
- /* begin */
52
- 1: /*top*/
53
- 2: int main() { return 0; }
54
- 3: int t() { grok_init(); return 0; }
55
- /* end */
56
-
57
- "gcc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -L. -L/usr/lib -L../../ -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -lruby1.8-static -lsgrok -lpthread -lrt -ldl -lcrypt -lm -lc"
58
- conftest.c: In function 't':
59
- conftest.c:3: error: 'grok_init' undeclared (first use in this function)
60
- conftest.c:3: error: (Each undeclared identifier is reported only once
61
- conftest.c:3: error: for each function it appears in.)
62
- checked program was:
63
- /* begin */
64
- 1: /*top*/
65
- 2: int main() { return 0; }
66
- 3: int t() { void ((*volatile p)()); p = (void ((*)()))grok_init; return 0; }
67
- /* end */
68
-
69
- "gcc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -L. -L/usr/lib -L../../ -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -lruby1.8-static -lsgrok -lpthread -lrt -ldl -lcrypt -lm -lc"
70
- /usr/bin/ld: cannot find -lsgrok
71
- collect2: ld returned 1 exit status
72
- checked program was:
73
- /* begin */
74
- 1: /*top*/
75
- 2: int main() { return 0; }
76
- 3: int t() { grok_init(); return 0; }
77
- /* end */
78
-
79
- "gcc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -L. -L/usr/lib -L/usr/local/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -lruby1.8-static -lsgrok -lpthread -lrt -ldl -lcrypt -lm -lc"
80
- conftest.c: In function 't':
81
- conftest.c:3: error: 'grok_init' undeclared (first use in this function)
82
- conftest.c:3: error: (Each undeclared identifier is reported only once
83
- conftest.c:3: error: for each function it appears in.)
84
- checked program was:
85
- /* begin */
86
- 1: /*top*/
87
- 2: int main() { return 0; }
88
- 3: int t() { void ((*volatile p)()); p = (void ((*)()))grok_init; return 0; }
89
- /* end */
90
-
91
- "gcc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -L. -L/usr/lib -L/usr/local/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -lruby1.8-static -lsgrok -lpthread -lrt -ldl -lcrypt -lm -lc"
92
- /usr/bin/ld: cannot find -lsgrok
93
- collect2: ld returned 1 exit status
94
- checked program was:
95
- /* begin */
96
- 1: /*top*/
97
- 2: int main() { return 0; }
98
- 3: int t() { grok_init(); return 0; }
99
- /* end */
100
-
101
- --------------------
102
-
data/ext/ruby_grok.o DELETED
Binary file
Binary file
data/ext/ruby_grokmatch.o DELETED
Binary file
data/sample.rb DELETED
@@ -1,43 +0,0 @@
1
- require "Grok"
2
- require "pp"
3
-
4
- patterns = {}
5
-
6
- matches = [
7
- #"%{SYSLOGBASE} Accepted %{NOTSPACE:method} for %{DATA:user} from %{IPORHOST:client} port %{INT:port}",
8
- #"%{SYSLOGBASE} Did not receive identification string from %{IPORHOST:client}",
9
- #"%{SYSLOGBASE} error: PAM: authentication error for %{DATA:user} from %{IPORHOST:client}",
10
- "%{SYSLOGBASE} .*"
11
- #"%{COMBINEDAPACHELOG}",
12
- #"%{UNINDEXED}hello (?=%{GREEDYDATA})%{WORD}"
13
-
14
- #"( *%{DATA:key}:%{NOTSPACE:value})+"
15
- ]
16
-
17
- groks = matches.collect do |m|
18
- g = Grok.new
19
- g.add_patterns_from_file("../patterns/base")
20
- g.compile(m)
21
- g
22
- end
23
-
24
- bytes = 0
25
- time_start = Time.now.to_f
26
- $stdin.each do |line|
27
- groks.each do |grok|
28
- m = grok.match(line)
29
- if m
30
- #data = Hash.new { |h,k| h[k] = Array.new }
31
- #m.each_capture do |key, value|
32
- #data[key] << value
33
- #end
34
- #pp data
35
- pp m.captures
36
- #bytes += line.length
37
- break
38
- end
39
- end
40
- end
41
-
42
- #time_end = Time.now.to_f
43
- #puts "parse rate: #{ (bytes / 1024) / (time_end - time_start) }"