papertrail 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +20 -1
- data/lib/papertrail.rb +1 -1
- data/lib/papertrail/cli.rb +11 -1
- data/lib/papertrail/cli_add_system.rb +7 -4
- data/lib/papertrail/cli_helpers.rb +11 -0
- data/lib/papertrail/connection.rb +4 -2
- data/papertrail.gemspec +3 -2
- metadata +18 -6
data/README.md
CHANGED
@@ -60,9 +60,12 @@ You may want to alias "trail" to "papertrail", like:
|
|
60
60
|
-s, --system SYSTEM System to search
|
61
61
|
-g, --group GROUP Group to search
|
62
62
|
-j, --json Output raw json data
|
63
|
+
--min-time MIN Earliest time to search from.
|
64
|
+
--max-time MAX Latest time to search from.
|
65
|
+
|
63
66
|
|
64
67
|
Usage:
|
65
|
-
papertrail [-f] [-s system] [-g group] [-d seconds] [-c papertrail.yml] [-j] [query]
|
68
|
+
papertrail [-f] [-s system] [-g group] [-d seconds] [-c papertrail.yml] [-j] [--min-time mintime] [--max-time maxtime] [query]
|
66
69
|
|
67
70
|
Examples:
|
68
71
|
papertrail -f
|
@@ -71,6 +74,7 @@ You may want to alias "trail" to "papertrail", like:
|
|
71
74
|
papertrail -s ns1 "connection refused"
|
72
75
|
papertrail -f "(www OR db) (nginx OR pgsql) -accepted"
|
73
76
|
papertrail -f -g Production "(nginx OR pgsql) -accepted"
|
77
|
+
papertrail -g Production --min-time 'yesterday at noon' --max-time 'today at 4am'
|
74
78
|
|
75
79
|
More: http://papertrailapp.com/
|
76
80
|
|
@@ -107,6 +111,21 @@ word for the program name:
|
|
107
111
|
the "1;31;43" are bold (1), foreground red (31), background yellow (43),
|
108
112
|
and can be any ANSI [escape characters].
|
109
113
|
|
114
|
+
### UTF-8 (non-English searches)
|
115
|
+
|
116
|
+
When searching in a language other than English, if you get no matches, you
|
117
|
+
may need to explicitly tell Ruby to use UTF-8. Ruby 1.9 honors the `LANG`
|
118
|
+
shell environment variable, and your shell may not set it to `UTF-8`.
|
119
|
+
|
120
|
+
To test, try:
|
121
|
+
|
122
|
+
ruby -E:UTF-8 -S papertrail your_search
|
123
|
+
|
124
|
+
If that works, add `-E:UTF-8` to the `RUBYOPT` variable to set the encoding
|
125
|
+
at invocation. For example, to persist that in a `.bashrc`:
|
126
|
+
|
127
|
+
export RUBYOPT="-E:UTF-8"
|
128
|
+
|
110
129
|
|
111
130
|
## Contribute
|
112
131
|
|
data/lib/papertrail.rb
CHANGED
data/lib/papertrail/cli.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
require 'yaml'
|
3
|
+
require 'chronic'
|
3
4
|
|
4
5
|
require 'papertrail/connection'
|
5
6
|
require 'papertrail/cli_helpers'
|
@@ -50,6 +51,12 @@ module Papertrail
|
|
50
51
|
opts.on("-j", "--json", "Output raw json data") do |v|
|
51
52
|
options[:json] = true
|
52
53
|
end
|
54
|
+
opts.on("--min-time MIN", "Earliest time to search from.") do |v|
|
55
|
+
options[:min_time] = v
|
56
|
+
end
|
57
|
+
opts.on("--max-time MAX", "Latest time to search from.") do |v|
|
58
|
+
options[:max_time] = v
|
59
|
+
end
|
53
60
|
|
54
61
|
opts.separator usage
|
55
62
|
end.parse!
|
@@ -77,6 +84,8 @@ module Papertrail
|
|
77
84
|
end
|
78
85
|
end
|
79
86
|
|
87
|
+
set_min_max_time!(options, query_options)
|
88
|
+
|
80
89
|
search_query = connection.query(ARGV[0], query_options)
|
81
90
|
|
82
91
|
if options[:follow]
|
@@ -106,7 +115,7 @@ module Papertrail
|
|
106
115
|
<<-EOF
|
107
116
|
|
108
117
|
Usage:
|
109
|
-
papertrail [-f] [-s system] [-g group] [-d seconds] [-c papertrail.yml] [-j] [query]
|
118
|
+
papertrail [-f] [-s system] [-g group] [-d seconds] [-c papertrail.yml] [-j] [--min-time mintime] [--max-time maxtime] [query]
|
110
119
|
|
111
120
|
Examples:
|
112
121
|
papertrail -f
|
@@ -115,6 +124,7 @@ module Papertrail
|
|
115
124
|
papertrail -s ns1 "connection refused"
|
116
125
|
papertrail -f "(www OR db) (nginx OR pgsql) -accepted"
|
117
126
|
papertrail -f -g Production "(nginx OR pgsql) -accepted"
|
127
|
+
papertrail -g Production --min-time 'yesterday at noon' --max-time 'today at 4am'
|
118
128
|
|
119
129
|
More: https://papertrailapp.com/
|
120
130
|
|
@@ -36,6 +36,9 @@ module Papertrail
|
|
36
36
|
opts.on("-s", "--system SYSTEM", "Name of system to add") do |v|
|
37
37
|
options[:system] = v
|
38
38
|
end
|
39
|
+
opts.on("-n", "--hostname HOSTNAME", "Optional hostname which can be used to filter events from the same IP by syslog hostname") do |v|
|
40
|
+
options[:hostname] = v
|
41
|
+
end
|
39
42
|
opts.on("-i", "--ip-address IP_ADDRESS", "IP address of system") do |v|
|
40
43
|
options[:ip] = v
|
41
44
|
end
|
@@ -52,13 +55,13 @@ module Papertrail
|
|
52
55
|
raise OptionParser::MissingArgument, 'ip' if options[:ip].nil?
|
53
56
|
|
54
57
|
connection = Papertrail::Connection.new(options)
|
55
|
-
|
58
|
+
|
56
59
|
# Bail if system already exists
|
57
60
|
if connection.show_source(options[:system])
|
58
61
|
exit 0
|
59
62
|
end
|
60
63
|
|
61
|
-
if connection.register_source(options[:system], options[:ip])
|
64
|
+
if connection.register_source(options[:system], options[:ip], options[:hostname])
|
62
65
|
exit 0
|
63
66
|
end
|
64
67
|
|
@@ -72,8 +75,8 @@ module Papertrail
|
|
72
75
|
def usage
|
73
76
|
<<-EOF
|
74
77
|
|
75
|
-
Usage:
|
76
|
-
papertrail-add-system [-s system] [-i ip-address] [-c papertrail.yml]
|
78
|
+
Usage:
|
79
|
+
papertrail-add-system [-s system] [-i ip-address] [-n hostname] [-c papertrail.yml]
|
77
80
|
|
78
81
|
Example:
|
79
82
|
papertrail-add-system -s mysystemname -i 1.2.3.4
|
@@ -21,5 +21,16 @@ module Papertrail
|
|
21
21
|
|
22
22
|
new_hash
|
23
23
|
end
|
24
|
+
|
25
|
+
def set_min_max_time!(opts, q_opts)
|
26
|
+
q_opts[:min_time] = parse_time(opts[:min_time]).to_i if opts[:min_time]
|
27
|
+
q_opts[:max_time] = parse_time(opts[:max_time]).to_i if opts[:max_time]
|
28
|
+
end
|
29
|
+
|
30
|
+
def parse_time(tstring)
|
31
|
+
Chronic.parse(tstring) ||
|
32
|
+
raise(ArgumentError, "Could not parse time string '#{tstring}'")
|
33
|
+
end
|
34
|
+
|
24
35
|
end
|
25
36
|
end
|
@@ -96,8 +96,10 @@ module Papertrail
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
def register_source(name, ip_address)
|
100
|
-
|
99
|
+
def register_source(name, ip_address, hostname = nil)
|
100
|
+
opts = { :name => name, :ip_address => ip_address }
|
101
|
+
opts.merge! :hostname => hostname unless hostname.nil?
|
102
|
+
@connection.post("systems.json", :system => opts)
|
101
103
|
end
|
102
104
|
|
103
105
|
def unregister_source(name)
|
data/papertrail.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'papertrail'
|
16
|
-
s.version = '0.9.
|
17
|
-
s.date = '2012-
|
16
|
+
s.version = '0.9.5'
|
17
|
+
s.date = '2012-09-27'
|
18
18
|
s.rubyforge_project = 'papertrail'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -51,6 +51,7 @@ Gem::Specification.new do |s|
|
|
51
51
|
## that are needed for an end user to actually USE your code.
|
52
52
|
s.add_dependency('addressable')
|
53
53
|
s.add_dependency('yajl-ruby')
|
54
|
+
s.add_dependency('chronic')
|
54
55
|
s.add_dependency('faraday', [ '>= 0.6', '< 0.9' ])
|
55
56
|
s.add_dependency('faraday_middleware', [ '~> 0.8.4' ])
|
56
57
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 5
|
9
|
+
version: 0.9.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Papertrail
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-
|
17
|
+
date: 2012-09-27 00:00:00 -07:00
|
18
18
|
default_executable: papertrail
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -44,6 +44,18 @@ dependencies:
|
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
type: :runtime
|
46
46
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
version: "0"
|
53
|
+
name: chronic
|
54
|
+
requirement: *id003
|
55
|
+
prerelease: false
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
type: :runtime
|
58
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
47
59
|
requirements:
|
48
60
|
- - ">="
|
49
61
|
- !ruby/object:Gem::Version
|
@@ -58,11 +70,11 @@ dependencies:
|
|
58
70
|
- 9
|
59
71
|
version: "0.9"
|
60
72
|
name: faraday
|
61
|
-
requirement: *
|
73
|
+
requirement: *id004
|
62
74
|
prerelease: false
|
63
75
|
- !ruby/object:Gem::Dependency
|
64
76
|
type: :runtime
|
65
|
-
version_requirements: &
|
77
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
66
78
|
requirements:
|
67
79
|
- - ~>
|
68
80
|
- !ruby/object:Gem::Version
|
@@ -72,7 +84,7 @@ dependencies:
|
|
72
84
|
- 4
|
73
85
|
version: 0.8.4
|
74
86
|
name: faraday_middleware
|
75
|
-
requirement: *
|
87
|
+
requirement: *id005
|
76
88
|
prerelease: false
|
77
89
|
description: Command-line client for Papertrail hosted log management service. Tails and searches app server logs and system syslog. Supports Boolean search and works with grep and pipe output (Unix).
|
78
90
|
email: troy@sevenscale.com
|