greenhat 0.1.4 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +2 -7
- data/lib/greenhat/shell/helper.rb +31 -4
- data/lib/greenhat/shell/log.rb +11 -1
- data/lib/greenhat/thing/file_types.rb +22 -1
- data/lib/greenhat/thing/kind.rb +1 -1
- data/lib/greenhat/version.rb +1 -1
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6b9e87957f5dfc919379519552041ce83b8daa5923b0e89fc64424e050d8981
|
4
|
+
data.tar.gz: 412b2c4db6613c707c8aad3e39e41a3fb018d1834f5ef17000b11b3af582c639
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da4b45b6433d2c4c786bca4b46dc0cfad9b879796e6040b9efceb5ba5181f329c7d3792aef458fde54698791f03830168aad17b9b7d31191aa2e717407444662
|
7
|
+
data.tar.gz: 3d53ed5c45398acc3a317cc41a5573b82ab1c263e947c94cc419f235efd5bc527905f4484867968535f12aed15c3fbb79abe1d63093402f845c572557b7e288d
|
data/README.md
CHANGED
@@ -14,20 +14,15 @@ Experimental SOS and Log Parser for GitLab
|
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
17
|
-
While potentially so in the future, this is currently not a published gem. To install:
|
18
|
-
|
19
17
|
```
|
20
|
-
|
21
|
-
cd greenhat
|
22
|
-
bundle install
|
23
|
-
bundle exec rake install
|
18
|
+
gem install greenhat
|
24
19
|
```
|
25
20
|
|
26
21
|
## Usage
|
27
22
|
|
28
23
|
```
|
29
24
|
greenhat sos-archive.tar.gz
|
30
|
-
greenhat
|
25
|
+
greenhat production_json.log
|
31
26
|
# launches a console
|
32
27
|
>> help # the program is self-documented through the builtin help command
|
33
28
|
```
|
@@ -56,7 +56,9 @@ module GreenHat
|
|
56
56
|
# --round=2
|
57
57
|
|
58
58
|
def self.param_special_opts
|
59
|
-
%i[
|
59
|
+
%i[
|
60
|
+
slice except stats uniq pluck round archive start end sort limit
|
61
|
+
]
|
60
62
|
end
|
61
63
|
|
62
64
|
# Parameter Extraction
|
@@ -73,8 +75,9 @@ module GreenHat
|
|
73
75
|
# Arg Defaults
|
74
76
|
def self.param_arg_defaults(field)
|
75
77
|
case field
|
76
|
-
when *param_special_opts then []
|
77
78
|
when :round then 2
|
79
|
+
when :limit then [TTY::Screen.height / 2]
|
80
|
+
when *param_special_opts then []
|
78
81
|
else
|
79
82
|
true
|
80
83
|
end
|
@@ -125,7 +128,7 @@ module GreenHat
|
|
125
128
|
end
|
126
129
|
|
127
130
|
# Check if content needs to paged, or if auto_height is off
|
128
|
-
if !args.page && (data
|
131
|
+
if !args.page && count_rows(data)
|
129
132
|
puts data.map { |x| entry_show(x, args) }.compact.join("\n")
|
130
133
|
return true
|
131
134
|
end
|
@@ -142,6 +145,25 @@ module GreenHat
|
|
142
145
|
end
|
143
146
|
end
|
144
147
|
|
148
|
+
# Array/Hash and String pagination check. Don't unncessarily loop through everything
|
149
|
+
def self.count_rows(data)
|
150
|
+
height = TTY::Screen.height
|
151
|
+
size = 0
|
152
|
+
|
153
|
+
data.each do |entry|
|
154
|
+
size += case entry
|
155
|
+
when Hash then entry.keys.count
|
156
|
+
when Array then entry.count
|
157
|
+
else
|
158
|
+
1
|
159
|
+
end
|
160
|
+
|
161
|
+
break if size > height
|
162
|
+
end
|
163
|
+
|
164
|
+
height > size
|
165
|
+
end
|
166
|
+
|
145
167
|
# Entry Shower
|
146
168
|
def self.entry_show(entry, args)
|
147
169
|
case entry
|
@@ -251,7 +273,12 @@ module GreenHat
|
|
251
273
|
# Pluck
|
252
274
|
results = filter_pluck(results, args[:pluck]) if args.key?(:pluck)
|
253
275
|
|
254
|
-
|
276
|
+
# Limit
|
277
|
+
if args[:limit]
|
278
|
+
results[0..args[:limit].map(&:to_s).join.to_i]
|
279
|
+
else
|
280
|
+
results
|
281
|
+
end
|
255
282
|
end
|
256
283
|
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
257
284
|
|
data/lib/greenhat/shell/log.rb
CHANGED
@@ -229,7 +229,12 @@ module GreenHat
|
|
229
229
|
# rubocop:disable Layout/LineLength
|
230
230
|
# TODO: Add a lot more examples
|
231
231
|
def self.filter_examples
|
232
|
-
puts '
|
232
|
+
puts 'Find `done` job for sidekiq, sort by duration, only duration, and show longest first'.colorize(:light_green)
|
233
|
+
puts 'log filter sidekiq/current --job_status=done --sort=duration_s,db_duration_s --slice=duration_s,db_duration_s --reverse'
|
234
|
+
puts
|
235
|
+
puts 'Find 500s only show exceptions'.colorize(:light_green)
|
236
|
+
puts 'log filter --status=500 --slice=exception.message gitlab-rails/production_json.log'
|
237
|
+
puts
|
233
238
|
end
|
234
239
|
# rubocop:enable Layout/LineLength
|
235
240
|
|
@@ -313,6 +318,11 @@ module GreenHat
|
|
313
318
|
puts ' Ex: --archive=dev-gitlab_20210622154626, --archive=202106,202107'
|
314
319
|
puts
|
315
320
|
|
321
|
+
puts '--limit'.colorize(:green)
|
322
|
+
puts ' Limit total number of results. Default to half total screen size'
|
323
|
+
puts ' Ex: --limit; --limit=10'
|
324
|
+
puts
|
325
|
+
|
316
326
|
puts 'Search specific logs'.colorize(:blue)
|
317
327
|
puts ' Any non dash parameters will be the log list to search from'
|
318
328
|
puts " Ex: log filter --path=api sidekiq/current (hint: use `#{'ls'.colorize(:yellow)}` for log names"
|
@@ -1,5 +1,19 @@
|
|
1
1
|
module GreenHat
|
2
|
-
#
|
2
|
+
# -------------------------------------
|
3
|
+
# File Types - Overall Type Parsing!
|
4
|
+
# -------------------------------------
|
5
|
+
# --- Adding a new File ----
|
6
|
+
# Duplicate one of the blocks and then update the name and pattern/regex to identify it
|
7
|
+
#
|
8
|
+
# The 'key' or 'name' is used to generically identify a type of file to be used in other collection tools.
|
9
|
+
# - Looking for errors in `gitlab-workhorse/current` will also include any rotated files via `gitlab-workhorse/@.*`
|
10
|
+
#
|
11
|
+
# Formatters: See `thing/formmaters` for the different kinds of formatters
|
12
|
+
# - `json` for plain json
|
13
|
+
# - `raw` to ignore/just read (e.g. for cat)
|
14
|
+
#
|
15
|
+
# log true/false to be included in the log/filter fields
|
16
|
+
|
3
17
|
# rubocop:disable Metrics/MethodLength, Metrics/ModuleLength
|
4
18
|
module FileTypes
|
5
19
|
def types
|
@@ -109,6 +123,13 @@ module GreenHat
|
|
109
123
|
%r{gitaly/gitaly_ruby_json.log}
|
110
124
|
]
|
111
125
|
},
|
126
|
+
'gitaly/gitaly_lfs_smudge.log' => {
|
127
|
+
format: :json,
|
128
|
+
log: true,
|
129
|
+
pattern: [
|
130
|
+
%r{gitaly/gitaly_lfs_smudge.log}
|
131
|
+
]
|
132
|
+
},
|
112
133
|
'gitlab_status' => {
|
113
134
|
format: :gitlab_status,
|
114
135
|
pattern: [
|
data/lib/greenhat/thing/kind.rb
CHANGED
@@ -67,7 +67,7 @@ module GreenHat
|
|
67
67
|
end
|
68
68
|
|
69
69
|
puts "Unable to determine file type for #{name.colorize(:yellow)}"
|
70
|
-
puts "Use '#{'json'.colorize(:cyan)}'
|
70
|
+
puts "Use '#{'json'.colorize(:cyan)}' or '#{'raw'.colorize(:cyan)}' if there are no matches (see file_types.rb)"
|
71
71
|
|
72
72
|
option = prompt.select('Wat is this?', prompt_list.keys.sort_by(&:length), filter: true)
|
73
73
|
|
data/lib/greenhat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: greenhat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davin Walker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.14'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.14'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.14'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rake
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,6 +192,20 @@ dependencies:
|
|
206
192
|
- - "~>"
|
207
193
|
- !ruby/object:Gem::Version
|
208
194
|
version: '0.8'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: pry
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0.14'
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0.14'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: require_all
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|