remote_syslog 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +68 -41
- data/examples/log_files.yml.example.advanced +7 -0
- data/lib/remote_syslog.rb +1 -1
- data/lib/remote_syslog/cli.rb +2 -1
- data/lib/remote_syslog/reader.rb +1 -1
- data/remote_syslog.gemspec +3 -3
- metadata +74 -92
- data/examples/log_files.yml.example.syslog +0 -5
data/README.md
CHANGED
@@ -27,8 +27,8 @@ Install the gem, which includes a binary called "remote_syslog":
|
|
27
27
|
$ [sudo] gem install remote_syslog
|
28
28
|
|
29
29
|
Optionally, create a log_files.yml with the log file paths to read and the
|
30
|
-
host/port to log to (see examples/log_files.yml.example). These can also be
|
31
|
-
specified as arguments
|
30
|
+
host/port to log to (see examples/[log_files.yml.example][sample config]). These can also be
|
31
|
+
specified as command-line arguments (below).
|
32
32
|
|
33
33
|
|
34
34
|
## Usage
|
@@ -38,7 +38,7 @@ specified as arguments to the remote_syslog daemon. More below.
|
|
38
38
|
|
39
39
|
Example: remote_syslog -c configs/logs.yml -p 12345 /var/log/mysqld.log
|
40
40
|
|
41
|
-
Options:
|
41
|
+
Options (default):
|
42
42
|
-c, --configfile PATH Path to config (/etc/log_files.yml)
|
43
43
|
-d, --dest-host HOSTNAME Destination syslog hostname or IP (logs.papertrailapp.com)
|
44
44
|
-p, --dest-port PORT Destination syslog port (514)
|
@@ -56,18 +56,23 @@ specified as arguments to the remote_syslog daemon. More below.
|
|
56
56
|
|
57
57
|
## Example
|
58
58
|
|
59
|
-
|
60
|
-
|
59
|
+
Typical:
|
60
|
+
|
61
|
+
$ remote_syslog
|
62
|
+
|
63
|
+
Daemonize and collect messages from files listed in `./config/logs.yml` as
|
64
|
+
well as the file `/var/log/mysqld.log`. Send to port `logs.papertrailapp.com:12345`:
|
61
65
|
|
62
66
|
$ remote_syslog -c configs/logs.yml -p 12345 /var/log/mysqld.log
|
63
67
|
|
64
68
|
Stay attached to the terminal, look for and use `/etc/log_files.yml` if it
|
65
|
-
exists, write PID to `/tmp/remote_syslog.pid`, and send with facility local0
|
69
|
+
exists, write PID to `/tmp/remote_syslog.pid`, and send with facility local0
|
70
|
+
to `a.server.com:514`:
|
66
71
|
|
67
|
-
$ remote_syslog -d a.server.com -f local0 -P /tmp /var/log/mysqld.log
|
72
|
+
$ remote_syslog -D -d a.server.com -f local0 -P /tmp /var/log/mysqld.log
|
68
73
|
|
69
74
|
remote_syslog will daemonize by default. A sample init file is in the gem as
|
70
|
-
remote_syslog.init.d. You may be able to:
|
75
|
+
[remote_syslog.init.d]. You may be able to:
|
71
76
|
|
72
77
|
$ cp examples/remote_syslog.init.d /etc/init.d/remote_syslog
|
73
78
|
|
@@ -78,12 +83,11 @@ pass the `--tls` option when running `remote_syslog`:
|
|
78
83
|
|
79
84
|
$ remote_syslog --tls -p 1234 /var/log/mysqld.log
|
80
85
|
|
81
|
-
|
82
86
|
## Configuration
|
83
87
|
|
84
88
|
By default, the gem looks for a configuration in /etc/log_files.yml.
|
85
89
|
|
86
|
-
The gem comes with a sample config. Optionally:
|
90
|
+
The gem comes with a [sample config]. Optionally:
|
87
91
|
|
88
92
|
$ cp examples/log_files.yml.example /etc/log_files.yml
|
89
93
|
|
@@ -99,55 +103,75 @@ Only 1 destination server is supported; the command-line argument wins.
|
|
99
103
|
host: logs.papertrailapp.com
|
100
104
|
port: 12345
|
101
105
|
|
106
|
+
remote_syslog sends the name of the file without a path ("mysqld.log") as
|
107
|
+
the syslog tag (program name). RFCs 3164 and 5424 limit the tag to 32
|
108
|
+
characters. Longer filenames are truncated to 32 characters.
|
109
|
+
|
110
|
+
## Advanced Configuration (Optional)
|
111
|
+
|
112
|
+
Here's an [advanced config] which uses all options.
|
113
|
+
|
114
|
+
### Override hostname
|
115
|
+
|
116
|
+
Provide `--hostname somehostname` or use the `hostname` configuration option:
|
117
|
+
|
118
|
+
hostname: somehostname
|
119
|
+
|
120
|
+
### Multiple instances
|
121
|
+
|
122
|
+
Run multiple instances to support more than one message-specific file format
|
123
|
+
or to specify unique syslog hostnames.
|
124
|
+
|
125
|
+
To do that, provide an alternate PID filename as a command-line option
|
126
|
+
to the additional instance(s). For example:
|
102
127
|
|
103
|
-
|
128
|
+
--pid-file remote_syslog_2.pid
|
129
|
+
|
130
|
+
### Parse fields from log messages
|
104
131
|
|
105
|
-
|
132
|
+
Rarely needed. Usually only used when remote_syslog is watching files
|
133
|
+
generated by syslogd (rather than by apps), like ``/var/log/messages``.
|
106
134
|
|
107
|
-
|
108
|
-
|
109
|
-
log message, like a timestamp,
|
110
|
-
|
111
|
-
|
135
|
+
remote_syslog can parse the program and hostname from the log line. When one
|
136
|
+
file contains logs from multiple programs (like with syslog), the log line
|
137
|
+
may include text that is not part of the log message, like a timestamp,
|
138
|
+
hostname, or program name. remote_syslog will extract those and use them in
|
139
|
+
the corresponding syslog packet fields.
|
112
140
|
|
113
|
-
To do that,
|
114
|
-
|
115
|
-
|
141
|
+
To do that, use the config file option `parse_fields` with the name of a
|
142
|
+
format supported by remote_syslog, or your own regex. Included format names
|
143
|
+
are `syslog` and `rfc3339`. For example:
|
116
144
|
|
117
145
|
parse_fields: syslog
|
118
146
|
|
119
|
-
The `syslog` regex
|
147
|
+
The included `syslog` format uses the regex `(\w+ \d+ \S+) (\S+) ([^:]+): (.*)`
|
148
|
+
to parse standard syslog lines like this:
|
120
149
|
|
121
150
|
Jul 18 08:25:08 hostname programname[1234]: The log message
|
122
151
|
|
123
|
-
|
124
|
-
timestamps like:
|
125
|
-
2011-07-16T08:25:08.651413-07:00 hostname programname[1234]: The log message
|
126
|
-
|
127
|
-
Or provide your own regex that includes these 4 backreferences, in order:
|
128
|
-
timestamp, system name, program name, message. Match and return empty
|
129
|
-
strings for any empty positions where the log value should be ignored.
|
130
|
-
For example, in the log:
|
152
|
+
The included `rfc3339` format uses the regex `(\S+) (\S+) ([^: ]+):? (.*)` to
|
153
|
+
parse syslog lines with high-precision RFC 3339 timestamps, like this:
|
131
154
|
|
132
|
-
|
155
|
+
2011-07-16T08:25:08.651413-07:00 hostname programname[1234]: The log message
|
133
156
|
|
134
|
-
|
135
|
-
|
157
|
+
To parse a format other than those, provide your own regex. It should include
|
158
|
+
4 backreferences to parse, in order: timestamp, system name, program name,
|
159
|
+
message.
|
136
160
|
|
137
|
-
|
161
|
+
Match and return empty strings for any empty positions where the log line
|
162
|
+
doesn't provide a value. For example, given the log message:
|
138
163
|
|
139
|
-
|
164
|
+
something-meaningless The log message
|
140
165
|
|
166
|
+
One could use a regex to ignore "something-meaningless" (and not to extract
|
167
|
+
a program or hostname). To ignore that prefix and return 3 empty values
|
168
|
+
then the log message, use parse_fields with this regex:
|
141
169
|
|
142
|
-
|
170
|
+
parse_fields: "something-meaningless ()()()(.*)"
|
143
171
|
|
144
|
-
|
145
|
-
|
146
|
-
an alternative PID filename as a command-line option to additional
|
147
|
-
instance(s), such as:
|
172
|
+
Per-file regexes are not supported. Run multiple instances with different
|
173
|
+
config files.
|
148
174
|
|
149
|
-
--pid-file remote_syslog_2.pid
|
150
|
-
|
151
175
|
|
152
176
|
## Reporting bugs
|
153
177
|
|
@@ -166,6 +190,9 @@ Once you've made your great commits:
|
|
166
190
|
5. Create a Pull Request or an [Issue][is] with a link to your branch
|
167
191
|
6. That's it!
|
168
192
|
|
193
|
+
[sample config]: https://github.com/papertrail/remote_syslog/blob/master/examples/log_files.yml.example
|
194
|
+
[remote_syslog.init.d]: https://github.com/papertrail/remote_syslog/blob/master/examples/remote_syslog.init.d
|
195
|
+
[advanced config]: https://github.com/papertrail/remote_syslog/blob/master/examples/log_files.yml.example.advanced
|
169
196
|
[fk]: http://help.github.com/forking/
|
170
197
|
[is]: https://github.com/papertrail/remote_syslog/issues/
|
171
198
|
[Papertrail]: http://papertrailapp.com/
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# see README - demonstrates all optional arguments
|
2
|
+
files: [/var/log/httpd/access_log, /opt/misc/*]
|
3
|
+
hostname: www42 # override OS hostname
|
4
|
+
parse_fields: syslog # predefined regex name or double-quoted regex
|
5
|
+
destination:
|
6
|
+
host: logs.papertrailapp.com
|
7
|
+
port: 12345 # optional, defaults to 514
|
data/lib/remote_syslog.rb
CHANGED
data/lib/remote_syslog/cli.rb
CHANGED
@@ -49,7 +49,7 @@ module RemoteSyslog
|
|
49
49
|
opts.separator ''
|
50
50
|
opts.separator "Example: remote_syslog -c configs/logs.yml -p 12345 /var/log/mysqld.log"
|
51
51
|
opts.separator ''
|
52
|
-
opts.separator "Options:"
|
52
|
+
opts.separator "Options (default):"
|
53
53
|
|
54
54
|
opts.on("-c", "--configfile PATH", "Path to config (/etc/log_files.yml)") do |v|
|
55
55
|
@configfile = File.expand_path(v)
|
@@ -152,6 +152,7 @@ module RemoteSyslog
|
|
152
152
|
end
|
153
153
|
|
154
154
|
def start
|
155
|
+
puts "Watching #{@files.length} files/paths. Sending to #{@dest_host}:#{@dest_port} (#{@tls ? 'TCP/TLS' : 'UDP'})."
|
155
156
|
EventMachine.run do
|
156
157
|
if @tls
|
157
158
|
connection = TlsEndpoint.new(@dest_host, @dest_port)
|
data/lib/remote_syslog/reader.rb
CHANGED
data/remote_syslog.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
## If your rubyforge_project name is different, then edit it and comment out
|
9
9
|
## the sub! line in the Rakefile
|
10
10
|
s.name = 'remote_syslog'
|
11
|
-
s.version = '1.4.
|
12
|
-
s.date = '2011-
|
11
|
+
s.version = '1.4.2'
|
12
|
+
s.date = '2011-12-07'
|
13
13
|
s.rubyforge_project = 'remote_syslog'
|
14
14
|
|
15
15
|
## Make sure your summary is short. The description may be as long
|
@@ -61,7 +61,7 @@ Gem::Specification.new do |s|
|
|
61
61
|
Rakefile
|
62
62
|
bin/remote_syslog
|
63
63
|
examples/log_files.yml.example
|
64
|
-
examples/log_files.yml.example.
|
64
|
+
examples/log_files.yml.example.advanced
|
65
65
|
examples/remote_syslog.init.d
|
66
66
|
examples/remote_syslog.supervisor.conf
|
67
67
|
lib/remote_syslog.rb
|
metadata
CHANGED
@@ -1,106 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_syslog
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 4
|
8
|
-
- 1
|
9
|
-
version: 1.4.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.2
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Troy Davis
|
13
9
|
- Eric Lindvall
|
14
10
|
autorequire:
|
15
11
|
bindir: bin
|
16
12
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2011-12-07 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
22
16
|
name: daemons
|
23
|
-
|
24
|
-
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
17
|
+
requirement: &70345349040060 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
31
23
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: eventmachine
|
35
24
|
prerelease: false
|
36
|
-
|
37
|
-
|
25
|
+
version_requirements: *70345349040060
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: eventmachine
|
28
|
+
requirement: &70345349039500 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
38
31
|
- - ~>
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
segments:
|
41
|
-
- 0
|
42
|
-
- 12
|
43
|
-
- 10
|
32
|
+
- !ruby/object:Gem::Version
|
44
33
|
version: 0.12.10
|
45
34
|
type: :runtime
|
46
|
-
version_requirements: *id002
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: eventmachine-tail
|
49
35
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
36
|
+
version_requirements: *70345349039500
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: eventmachine-tail
|
39
|
+
requirement: &70345349055440 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
57
45
|
type: :runtime
|
58
|
-
version_requirements: *id003
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
|
-
name: syslog_protocol
|
61
46
|
prerelease: false
|
62
|
-
|
63
|
-
|
47
|
+
version_requirements: *70345349055440
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: syslog_protocol
|
50
|
+
requirement: &70345349054880 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
64
53
|
- - ~>
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
segments:
|
67
|
-
- 0
|
68
|
-
- 9
|
69
|
-
- 1
|
54
|
+
- !ruby/object:Gem::Version
|
70
55
|
version: 0.9.1
|
71
56
|
type: :runtime
|
72
|
-
version_requirements: *id004
|
73
|
-
- !ruby/object:Gem::Dependency
|
74
|
-
name: em-resolv-replace
|
75
57
|
prerelease: false
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
58
|
+
version_requirements: *70345349054880
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: em-resolv-replace
|
61
|
+
requirement: &70345349054460 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
83
67
|
type: :runtime
|
84
|
-
|
85
|
-
|
86
|
-
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *70345349054460
|
70
|
+
description: Lightweight daemon to tail one or more log files and transmit UDP syslog
|
71
|
+
messages to a remote syslog host (centralized log aggregation). Generates UDP packets
|
72
|
+
itself instead of depending on a system syslog daemon, so it doesn't affect system-wide
|
73
|
+
logging configuration.
|
74
|
+
email:
|
87
75
|
- troy@sevenscale.com
|
88
76
|
- eric@sevenscale.com
|
89
|
-
executables:
|
77
|
+
executables:
|
90
78
|
- remote_syslog
|
91
79
|
extensions: []
|
92
|
-
|
93
|
-
extra_rdoc_files:
|
80
|
+
extra_rdoc_files:
|
94
81
|
- README.md
|
95
82
|
- LICENSE
|
96
|
-
files:
|
83
|
+
files:
|
97
84
|
- Gemfile
|
98
85
|
- LICENSE
|
99
86
|
- README.md
|
100
87
|
- Rakefile
|
101
88
|
- bin/remote_syslog
|
102
89
|
- examples/log_files.yml.example
|
103
|
-
- examples/log_files.yml.example.
|
90
|
+
- examples/log_files.yml.example.advanced
|
104
91
|
- examples/remote_syslog.init.d
|
105
92
|
- examples/remote_syslog.supervisor.conf
|
106
93
|
- lib/remote_syslog.rb
|
@@ -109,35 +96,30 @@ files:
|
|
109
96
|
- lib/remote_syslog/tls_endpoint.rb
|
110
97
|
- lib/remote_syslog/udp_endpoint.rb
|
111
98
|
- remote_syslog.gemspec
|
112
|
-
has_rdoc: true
|
113
99
|
homepage: http://github.com/papertrail/remote_syslog
|
114
100
|
licenses: []
|
115
|
-
|
116
101
|
post_install_message:
|
117
|
-
rdoc_options:
|
102
|
+
rdoc_options:
|
118
103
|
- --charset=UTF-8
|
119
|
-
require_paths:
|
104
|
+
require_paths:
|
120
105
|
- lib
|
121
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
133
|
-
- 0
|
134
|
-
version: "0"
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
135
118
|
requirements: []
|
136
|
-
|
137
119
|
rubyforge_project: remote_syslog
|
138
|
-
rubygems_version: 1.
|
120
|
+
rubygems_version: 1.8.7
|
139
121
|
signing_key:
|
140
122
|
specification_version: 2
|
141
|
-
summary: Monitor plain text log file(s) for new entries and send to remote syslog
|
123
|
+
summary: Monitor plain text log file(s) for new entries and send to remote syslog
|
124
|
+
collector
|
142
125
|
test_files: []
|
143
|
-
|