greenhat 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/greenhat/accessors/disk.rb +1 -3
- data/lib/greenhat/accessors/gitlab.rb +5 -2
- data/lib/greenhat/archive.rb +7 -2
- data/lib/greenhat/cli.rb +36 -0
- data/lib/greenhat/host.rb +25 -37
- data/lib/greenhat/shell/args.rb +22 -9
- data/lib/greenhat/shell/faststats.rb +23 -3
- data/lib/greenhat/shell/field_helper.rb +1 -1
- data/lib/greenhat/shell/filter_help.rb +32 -10
- data/lib/greenhat/shell/log.rb +142 -7
- data/lib/greenhat/shell/markdown.rb +16 -8
- data/lib/greenhat/shell/old_search_helper.rb +54 -0
- data/lib/greenhat/shell/page.rb +1 -1
- data/lib/greenhat/shell/pipe.rb +31 -0
- data/lib/greenhat/shell/platform.rb +28 -0
- data/lib/greenhat/shell/report.rb +47 -15
- data/lib/greenhat/shell/shell_helper.rb +92 -101
- data/lib/greenhat/shell.rb +7 -0
- data/lib/greenhat/thing/file_types.rb +28 -0
- data/lib/greenhat/thing/formatters/json.rb +4 -0
- data/lib/greenhat/thing/formatters/nginx.rb +6 -2
- data/lib/greenhat/thing/formatters/time_space.rb +0 -16
- data/lib/greenhat/thing/helpers.rb +12 -0
- data/lib/greenhat/thing.rb +10 -0
- data/lib/greenhat/version.rb +1 -1
- data/lib/greenhat/views/api.slim +55 -0
- data/lib/greenhat/views/chart.slim +42 -0
- data/lib/greenhat/views/chart_template.slim +31 -0
- data/lib/greenhat/views/chartkick.js +21 -0
- data/lib/greenhat/views/css.slim +47 -0
- data/lib/greenhat/views/gitaly.slim +53 -0
- data/lib/greenhat/views/headers.slim +16 -0
- data/lib/greenhat/views/index-old.slim +51 -0
- data/lib/greenhat/views/index.slim +14 -14
- data/lib/greenhat/views/info.slim +17 -18
- data/lib/greenhat/views/production.slim +55 -0
- data/lib/greenhat/views/sidekiq.slim +55 -0
- data/lib/greenhat/views/time.slim +63 -0
- data/lib/greenhat/views/workhorse.slim +16 -0
- data/lib/greenhat/web/api.rb +94 -0
- data/lib/greenhat/web/chartkick_shim.rb +14 -0
- data/lib/greenhat/web/faststats.rb +44 -0
- data/lib/greenhat/web/gitaly.rb +65 -0
- data/lib/greenhat/web/helpers.rb +198 -0
- data/lib/greenhat/web/production.rb +104 -0
- data/lib/greenhat/web/sidekiq.rb +73 -0
- data/lib/greenhat/web/stats_helpers.rb +74 -0
- data/lib/greenhat/web/time.rb +36 -0
- data/lib/greenhat/web/workhorse.rb +43 -0
- data/lib/greenhat/web.rb +63 -19
- data/lib/greenhat.rb +1 -0
- metadata +68 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9cc86956963d9d4d6a11b8d84b3a047d66bbbd3ac1c0cbb45f7e9f91d0a55e2
|
4
|
+
data.tar.gz: c4df69de408709de93713f4e2a98ce6263f15b83c28bc3c353589368bb325efd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 813350d41deb97b978afc55d3aad33e3bf1b383a721ab3a33b8ed56cfdd4b2158ba5c6e7368839d3f7ac74e53614c644e2f92a3a6ccc64608d1b89c5274396a1
|
7
|
+
data.tar.gz: 78074ff71327905079cbd603d640d09625d4e49bf1dc9e8a7e7823b8ba923d1abb0c69c833a0a956aa6d0e1af92e53bbae97015827d83219d8c384abf8a349b0
|
@@ -30,7 +30,6 @@ module GreenHat
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Unified Output Handler
|
33
|
-
# rubocop:disable Metrics/MethodLength
|
34
33
|
def self.format_output(file, name = false, limit = nil, filter = %w[tmpfs loop])
|
35
34
|
output = []
|
36
35
|
|
@@ -62,7 +61,7 @@ module GreenHat
|
|
62
61
|
disk.use.rjust(5).ljust(5).pastel(:green),
|
63
62
|
' ['.pastel(:blue),
|
64
63
|
('=' * (disk.use.to_i / 2)).pastel(:green),
|
65
|
-
' ' * (50 - disk.use.to_i / 2),
|
64
|
+
' ' * (50 - (disk.use.to_i / 2)),
|
66
65
|
']'.pastel(:blue)
|
67
66
|
].join
|
68
67
|
|
@@ -78,7 +77,6 @@ module GreenHat
|
|
78
77
|
|
79
78
|
output
|
80
79
|
end
|
81
|
-
# rubocop:enable Metrics/MethodLength
|
82
80
|
|
83
81
|
# Unified Output Handler
|
84
82
|
def self.markdown_format(file, name = false, limit = nil, filter = %w[tmpfs loop])
|
@@ -35,6 +35,7 @@ module GreenHat
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# Show GitLab Services in a grid / include versions
|
38
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
38
39
|
def self.services(archive, indent = 0)
|
39
40
|
manifest = archive.things.find { |x| x.type == 'gitlab/version-manifest.json' }
|
40
41
|
gitlab_status = archive.things.find { |x| x.name == 'gitlab_status' }
|
@@ -43,6 +44,7 @@ module GreenHat
|
|
43
44
|
|
44
45
|
list = gitlab_status.data.keys.sort.map do |service|
|
45
46
|
color = gitlab_status.data.dig(service, 0, :status) == 'run' ? :green : :red
|
47
|
+
status = gitlab_status.data.dig(service, 0, :status) == 'run' ? '↑' : '↓'
|
46
48
|
|
47
49
|
# Collect Service version from manifest
|
48
50
|
version = manifest.data.software[service.to_sym]&.display_version
|
@@ -50,7 +52,7 @@ module GreenHat
|
|
50
52
|
# If able to identify version use / fallback
|
51
53
|
if version
|
52
54
|
[
|
53
|
-
service.pastel(color),
|
55
|
+
"#{service}#{status}".pastel(color),
|
54
56
|
"(#{version})".pastel(:bright_black)
|
55
57
|
].join(' ')
|
56
58
|
else
|
@@ -71,13 +73,14 @@ module GreenHat
|
|
71
73
|
|
72
74
|
table.render(:unicode, padding: [0, 1, 0, 1], indent: indent)
|
73
75
|
end
|
76
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
74
77
|
|
75
78
|
def self.services_markdown(archive)
|
76
79
|
# manifest = archive.things.find { |x| x.type == 'gitlab/version-manifest.json' }
|
77
80
|
gitlab_status = archive.things.find { |x| x.name == 'gitlab_status' }
|
78
81
|
|
79
82
|
list = gitlab_status.data.keys.sort.map do |service|
|
80
|
-
status = gitlab_status.data.dig(service, 0, :status) == 'run' ? '↑' : '
|
83
|
+
status = gitlab_status.data.dig(service, 0, :status) == 'run' ? '↑' : '↓'
|
81
84
|
|
82
85
|
"#{service}#{status}"
|
83
86
|
end
|
data/lib/greenhat/archive.rb
CHANGED
@@ -102,11 +102,16 @@ class Archive < Teron
|
|
102
102
|
"#<Archive name: '#{name}'>"
|
103
103
|
end
|
104
104
|
|
105
|
-
def report
|
106
|
-
GreenHat::Report.new(self)
|
105
|
+
def report(flags)
|
106
|
+
GreenHat::Report.new(self, flags)
|
107
107
|
end
|
108
108
|
|
109
109
|
def report_markdown
|
110
110
|
GreenHat::ReportMarkdown.new(self)
|
111
111
|
end
|
112
|
+
|
113
|
+
# Helper for finding thing
|
114
|
+
def thing?(thing_name = 'gitlab-workhorse/current')
|
115
|
+
things.find { |x| x.name == thing_name }
|
116
|
+
end
|
112
117
|
end
|
data/lib/greenhat/cli.rb
CHANGED
@@ -348,6 +348,7 @@ module GreenHat
|
|
348
348
|
@quiet = !@quiet
|
349
349
|
end
|
350
350
|
|
351
|
+
# rubocop:disable Metrics/MethodLength
|
351
352
|
def self.cli_help
|
352
353
|
Shell.version
|
353
354
|
puts
|
@@ -361,6 +362,14 @@ module GreenHat
|
|
361
362
|
puts ' Run `report` against archives and exit'
|
362
363
|
puts
|
363
364
|
|
365
|
+
puts ' --full-report, -f'.pastel(:green)
|
366
|
+
puts ' Run `report` with all details. e.g. include fast-stats top/errors'
|
367
|
+
puts
|
368
|
+
|
369
|
+
puts ' --markdown, -m'.pastel(:green)
|
370
|
+
puts ' Run `markdown_report` against archives and exit'
|
371
|
+
puts
|
372
|
+
|
364
373
|
puts ' --quiet, -r'.pastel(:green)
|
365
374
|
puts ' Surpress GreenHat logging output'
|
366
375
|
puts
|
@@ -373,10 +382,19 @@ module GreenHat
|
|
373
382
|
puts ' Run and then exit a GreenHat Shell command'
|
374
383
|
puts
|
375
384
|
|
385
|
+
puts ' --web, -w'.pastel(:green)
|
386
|
+
puts ' Start Sinatra Webservice on load (4567)'
|
387
|
+
puts
|
388
|
+
|
389
|
+
puts ' --no-color, -n'.pastel(:green)
|
390
|
+
puts ' Disable color output'
|
391
|
+
puts
|
392
|
+
|
376
393
|
puts ' --version, -v'.pastel(:green)
|
377
394
|
puts ' Print version and exit'
|
378
395
|
puts
|
379
396
|
end
|
397
|
+
# rubocop:enable Metrics/MethodLength
|
380
398
|
|
381
399
|
# Arguments before general processing
|
382
400
|
def self.pre_args(flags, files)
|
@@ -408,21 +426,38 @@ module GreenHat
|
|
408
426
|
|
409
427
|
# Arguments to be handled after general processing
|
410
428
|
def self.post_args(flags)
|
429
|
+
# Supress Color
|
430
|
+
GreenHat::Settings.settings[:color] = false if flags?(%i[no-color n], flags)
|
431
|
+
|
411
432
|
# Run report and exit / Don't Clear for reports
|
412
433
|
if flags?(%i[report r], flags)
|
413
434
|
@quiet = true
|
414
435
|
# Don't Use Pagination
|
415
436
|
GreenHat::Shell.report(['--raw'])
|
416
437
|
exit 0
|
438
|
+
elsif flags?(%i[full-report f], flags)
|
439
|
+
@quiet = true
|
440
|
+
# Don't Use Pagination
|
441
|
+
GreenHat::Shell.report(['--raw', '--full'])
|
442
|
+
exit 0
|
443
|
+
elsif flags?(%i[markdown m], flags)
|
444
|
+
@quiet = true
|
445
|
+
# Don't Use Pagination
|
446
|
+
GreenHat::Shell.markdown_report(['--raw'])
|
447
|
+
exit 0
|
417
448
|
else
|
418
449
|
clear_screen
|
419
450
|
end
|
451
|
+
end
|
420
452
|
|
453
|
+
def self.post_setup(flags)
|
421
454
|
# CTL Tails need to be parsed for new 'things'
|
422
455
|
Thing.where(kind: :gitlab_tail)&.map(&:process)
|
423
456
|
Thing.where(kind: :kube_webservice)&.map(&:process)
|
424
457
|
|
425
458
|
Thing.all.each(&:process) if flags?(%i[load l], flags)
|
459
|
+
|
460
|
+
Shell.web if flags?(%i[web w], flags)
|
426
461
|
end
|
427
462
|
|
428
463
|
# Helper to Simplify checking flags
|
@@ -438,6 +473,7 @@ module GreenHat
|
|
438
473
|
load_files files
|
439
474
|
run_command(args) if args.any? { |arg| run_command?(arg) }
|
440
475
|
post_args(flags)
|
476
|
+
post_setup(flags)
|
441
477
|
|
442
478
|
value ||= '' # Empty Start
|
443
479
|
|
data/lib/greenhat/host.rb
CHANGED
@@ -14,17 +14,23 @@ class Host < Teron
|
|
14
14
|
# end
|
15
15
|
|
16
16
|
def archive_name
|
17
|
-
|
17
|
+
archive.friendly_name
|
18
18
|
end
|
19
19
|
|
20
20
|
def find_file(file_name)
|
21
21
|
files.find { |x| x.name == file_name }
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
24
|
+
def things
|
25
|
+
archive.things
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
+
def find_thing(param)
|
29
|
+
things.find { |x| x.name.include? param }
|
30
|
+
end
|
31
|
+
|
32
|
+
def icon
|
33
|
+
release = find_thing('etc/os-release').data['ID_LIKE']
|
28
34
|
|
29
35
|
if release.include? 'ubuntu'
|
30
36
|
'fa-ubuntu'
|
@@ -57,41 +63,36 @@ class Host < Teron
|
|
57
63
|
end
|
58
64
|
# ---------------------------
|
59
65
|
|
60
|
-
def
|
61
|
-
file =
|
66
|
+
def gitlab_version
|
67
|
+
file = find_thing 'gitlab/version-manifest.json'
|
62
68
|
return nil unless file
|
63
69
|
|
64
|
-
|
70
|
+
file.data.build_version
|
65
71
|
end
|
66
72
|
|
67
73
|
def uptime
|
68
|
-
file =
|
74
|
+
file = find_thing 'uptime'
|
69
75
|
return nil unless file
|
70
76
|
|
71
77
|
file.raw
|
72
78
|
end
|
73
79
|
|
74
80
|
def uname
|
75
|
-
file =
|
81
|
+
file = find_thing 'uname'
|
76
82
|
return nil unless file
|
77
83
|
|
78
84
|
file.raw.join
|
79
85
|
end
|
80
86
|
|
81
87
|
def cpuinfo
|
82
|
-
file =
|
88
|
+
file = find_thing 'lscpu'
|
83
89
|
return nil unless file
|
84
90
|
|
85
|
-
file.
|
86
|
-
all = cpu.split("\n").map do |row|
|
87
|
-
row.delete("\t").split(': ')
|
88
|
-
end
|
89
|
-
{ details: all[1..], order: all[0].last }
|
90
|
-
end
|
91
|
+
file.data
|
91
92
|
end
|
92
93
|
|
93
94
|
def cpu_speed
|
94
|
-
file =
|
95
|
+
file = find_thing 'lscpu'
|
95
96
|
return nil unless file
|
96
97
|
|
97
98
|
details = file.raw.find { |x| x.include? 'MHz' }
|
@@ -99,7 +100,7 @@ class Host < Teron
|
|
99
100
|
end
|
100
101
|
|
101
102
|
def total_memory
|
102
|
-
file =
|
103
|
+
file = find_thing 'free_m'
|
103
104
|
return nil unless file
|
104
105
|
|
105
106
|
value = file.raw.dig(1, 1).to_i
|
@@ -107,28 +108,28 @@ class Host < Teron
|
|
107
108
|
end
|
108
109
|
|
109
110
|
def free_m
|
110
|
-
file =
|
111
|
+
file = find_thing 'free_m'
|
111
112
|
return nil unless file
|
112
113
|
|
113
114
|
file.raw
|
114
115
|
end
|
115
116
|
|
116
117
|
def df_h
|
117
|
-
file =
|
118
|
+
file = find_thing 'df_h'
|
118
119
|
return nil unless file
|
119
120
|
|
120
121
|
file.raw
|
121
122
|
end
|
122
123
|
|
123
124
|
def netstat
|
124
|
-
file =
|
125
|
+
file = find_thing 'netstat'
|
125
126
|
return nil unless file
|
126
127
|
|
127
128
|
file.raw
|
128
129
|
end
|
129
130
|
|
130
131
|
def ulimit
|
131
|
-
file =
|
132
|
+
file = find_thing 'ulimit'
|
132
133
|
return nil unless file
|
133
134
|
|
134
135
|
results = file.raw.map do |entry|
|
@@ -142,7 +143,7 @@ class Host < Teron
|
|
142
143
|
end
|
143
144
|
|
144
145
|
def processes
|
145
|
-
file =
|
146
|
+
file = find_thing 'ps'
|
146
147
|
return nil unless file
|
147
148
|
|
148
149
|
headers = file.raw.first.split(' ', 11)
|
@@ -155,7 +156,7 @@ class Host < Teron
|
|
155
156
|
end
|
156
157
|
|
157
158
|
def systemctl_unit_files
|
158
|
-
file =
|
159
|
+
file = find_thing 'systemctl_unit_files'
|
159
160
|
return nil unless file
|
160
161
|
|
161
162
|
all = file.raw[1..-2].map do |x|
|
@@ -167,16 +168,3 @@ class Host < Teron
|
|
167
168
|
all.sort_by(&:unit)
|
168
169
|
end
|
169
170
|
end
|
170
|
-
|
171
|
-
# # Slim Wrapper
|
172
|
-
# class List
|
173
|
-
# attr_accessor :hosts
|
174
|
-
|
175
|
-
# def initialize
|
176
|
-
# self.hosts = []
|
177
|
-
# end
|
178
|
-
|
179
|
-
# def slim(file, host = nil)
|
180
|
-
# Slim::Template.new("#{__dir__}/views/#{file}.slim").render(host)
|
181
|
-
# end
|
182
|
-
# end
|
data/lib/greenhat/shell/args.rb
CHANGED
@@ -1,12 +1,5 @@
|
|
1
1
|
module GreenHat
|
2
2
|
# Module for Argument Parsing
|
3
|
-
# Possible Args
|
4
|
-
# --value=thing
|
5
|
-
# --value / Default => --value=thing
|
6
|
-
# --flag
|
7
|
-
# --slice=value,value2
|
8
|
-
# files
|
9
|
-
|
10
3
|
# Variable Breakdown
|
11
4
|
# Args:Array supplied or default values for entry looping action
|
12
5
|
# Flags:Hash Key/Value filter Actionables
|
@@ -15,7 +8,14 @@ module GreenHat
|
|
15
8
|
def self.parse(raw, skip_flags = [])
|
16
9
|
# Don't affect original object / Better deep clone?
|
17
10
|
cmd = raw.clone
|
18
|
-
|
11
|
+
|
12
|
+
# Handle Pipe Params
|
13
|
+
pipe = nil
|
14
|
+
if cmd.include?('|')
|
15
|
+
list = cmd.split('|')
|
16
|
+
cmd = list.shift
|
17
|
+
pipe = list.map { |x| x.join(' ') }.join('|')
|
18
|
+
end
|
19
19
|
|
20
20
|
# Extract Files
|
21
21
|
files = cmd.grep_v(/^-+([^=]+)/)
|
@@ -33,6 +33,9 @@ module GreenHat
|
|
33
33
|
# And / Or
|
34
34
|
flag_defaults(flags, skip_flags)
|
35
35
|
|
36
|
+
# Set command includes
|
37
|
+
flags[:pipe] = pipe if pipe
|
38
|
+
|
36
39
|
[files, flags, args]
|
37
40
|
end
|
38
41
|
|
@@ -78,19 +81,29 @@ module GreenHat
|
|
78
81
|
# Arg Scan (Split -- values into keys)
|
79
82
|
def self.arg_scan(arg)
|
80
83
|
arg.scan(/^-+([^=]+)=(.*)/).map do |field, value|
|
84
|
+
logic = :include?
|
81
85
|
bang = false
|
86
|
+
|
87
|
+
# Exclude Logic
|
82
88
|
if field.include? '!'
|
83
89
|
field.delete!('!')
|
84
90
|
bang = true
|
85
91
|
end
|
86
92
|
|
93
|
+
# Numeric Magic Logic
|
94
|
+
logic = :<= if field.include? '<'
|
95
|
+
logic = :>= if field.include? '>'
|
96
|
+
field.delete!('<')
|
97
|
+
field.delete!('>')
|
98
|
+
|
87
99
|
# Symbolize
|
88
100
|
field = field.to_sym
|
89
101
|
|
90
102
|
{
|
91
103
|
field: field,
|
92
104
|
value: arg_normalize(field, value),
|
93
|
-
bang: bang
|
105
|
+
bang: bang,
|
106
|
+
logic: logic
|
94
107
|
}
|
95
108
|
end
|
96
109
|
end
|
@@ -137,7 +137,7 @@ module GreenHat
|
|
137
137
|
# --limit=X
|
138
138
|
# --sort=count,fail,max,median,min,p95,p99,rps,score
|
139
139
|
# ========================================================================
|
140
|
-
def self.top(raw)
|
140
|
+
def self.top(raw = [], internal = false)
|
141
141
|
unless TTY::Which.exist? 'fast-stats'
|
142
142
|
faststats_installation
|
143
143
|
return false
|
@@ -155,6 +155,9 @@ module GreenHat
|
|
155
155
|
]
|
156
156
|
end
|
157
157
|
|
158
|
+
# Quick exit for internal processing
|
159
|
+
return results.flatten if internal
|
160
|
+
|
158
161
|
ShellHelper.show(results.flatten, flags)
|
159
162
|
end
|
160
163
|
# ========================================================================
|
@@ -162,14 +165,14 @@ module GreenHat
|
|
162
165
|
# ========================================================================
|
163
166
|
# ===== [ Fast Stats - Errors ] ====================
|
164
167
|
# ========================================================================
|
165
|
-
def self.errors(raw)
|
168
|
+
def self.errors(raw = [], internal = false)
|
166
169
|
unless TTY::Which.exist? 'fast-stats'
|
167
170
|
faststats_installation
|
168
171
|
return false
|
169
172
|
end
|
170
173
|
|
171
174
|
# Add Color Output
|
172
|
-
raw.push '--color-output'
|
175
|
+
raw.push '--color-output' if Settings.settings.color?
|
173
176
|
files, flags, cmd = ShellHelper::Faststats.parse(raw)
|
174
177
|
|
175
178
|
LogBot.debug('FastStats CMD', cmd) if ENV['DEBUG']
|
@@ -182,6 +185,9 @@ module GreenHat
|
|
182
185
|
]
|
183
186
|
end
|
184
187
|
|
188
|
+
# Quick exit for internal processing
|
189
|
+
return results.flatten if internal
|
190
|
+
|
185
191
|
ShellHelper.show(results.flatten, flags)
|
186
192
|
end
|
187
193
|
# ========================================================================
|
@@ -236,6 +242,20 @@ module GreenHat
|
|
236
242
|
files.any? { |x| thing.name.include? x }
|
237
243
|
end
|
238
244
|
end
|
245
|
+
|
246
|
+
# =====================================
|
247
|
+
# Internal Helpers
|
248
|
+
# =====================================
|
249
|
+
def self.faststats?
|
250
|
+
TTY::Which.exist?('fast-stats')
|
251
|
+
end
|
252
|
+
|
253
|
+
def self.run(thing, cmd = '')
|
254
|
+
# Blank return if cannot possibly run
|
255
|
+
return {} unless thing || !faststats?
|
256
|
+
|
257
|
+
Oj.load `fast-stats #{cmd} #{thing.file} --format=json`
|
258
|
+
end
|
239
259
|
end
|
240
260
|
end
|
241
261
|
end
|
@@ -2,7 +2,7 @@ module GreenHat
|
|
2
2
|
# CLI Helper
|
3
3
|
module ShellHelper
|
4
4
|
# Unify Filter / Filter Help
|
5
|
-
# rubocop:disable Metrics/MethodLength,Metrics/ModuleLength
|
5
|
+
# rubocop:disable Metrics/MethodLength,Metrics/ModuleLength,Layout/LineLength
|
6
6
|
module Filter
|
7
7
|
def self.help
|
8
8
|
puts "\u2500".pastel(:cyan) * 20
|
@@ -38,7 +38,7 @@ module GreenHat
|
|
38
38
|
puts
|
39
39
|
|
40
40
|
puts '--total'.pastel(:green)
|
41
|
-
puts '
|
41
|
+
puts ' Show total count, duration, start/end time for matching entries'
|
42
42
|
puts
|
43
43
|
|
44
44
|
puts '--fields'.pastel(:green)
|
@@ -138,17 +138,39 @@ module GreenHat
|
|
138
138
|
puts ' Ex: --truncate=200, --truncate=2048"'
|
139
139
|
puts
|
140
140
|
|
141
|
-
puts 'Field Searching'.pastel(:blue)
|
142
|
-
puts ' --[key]=[value]'
|
143
|
-
puts ' Search in key for value'
|
144
|
-
puts ' Example: --path=mirror/pull'
|
145
|
-
puts
|
146
|
-
|
147
141
|
puts 'Search specific logs'.pastel(:blue)
|
148
142
|
puts ' Any non dash parameters will be the log list to search from'
|
149
143
|
puts " Ex: log filter --path=api sidekiq/current (hint: use `#{'ls'.pastel(:yellow)}` for log names"
|
150
144
|
puts
|
151
145
|
|
146
|
+
puts 'General (Field) Searching'.pastel(:blue)
|
147
|
+
puts " There are different ways filter within specific keys/fields within log. The baseline is #{'--[key]=[value]'.pastel(:green)}"
|
148
|
+
puts ' This will, by default, select any entries with any partial match (case insensitive) of [value] in the entry [key]'
|
149
|
+
puts ' Example: --path=mirror/pull'
|
150
|
+
puts
|
151
|
+
|
152
|
+
puts " You can modify logic with params like: #{'case'.pastel(:green)}, #{'exact'.pastel(:green)}"
|
153
|
+
puts ' Ex Case turn on case sensitivity, exact will change from the inclusive to only exact matching.'
|
154
|
+
puts
|
155
|
+
|
156
|
+
puts " You can also use multiple #{'--[key]=[value]'.pastel(:green)} to narrow down, or combine it with #{'or'.pastel(:green)} to be more inclusive"
|
157
|
+
puts ' Ex nginx/gitlab_access.log --http_user_agent=gitlab-runner --path=/api/v4/jobs/request'
|
158
|
+
puts ' This will look through the access logs for anything that is a runner (user agent) and hitting the request endpoint'
|
159
|
+
puts
|
160
|
+
|
161
|
+
puts " You can also modify whether a field search excluded or a integer (and technically string) comparison by changing the operator: #{'(!= >= <=)'.pastel(:green)}"
|
162
|
+
puts ' Ex "nginx/gitlab_access.log --http_user_agent=gitlab-runner --http_user_agent!=13.12.0" will exclude any entries with 13.12.0/13.12 runners'
|
163
|
+
puts ' Ex "sidekiq/current --duration_s>=5 --class!=LdapSyncWorker" Duration over 5 that is not an ldap job'
|
164
|
+
puts
|
165
|
+
|
166
|
+
puts 'Pipe to Shell'.pastel(:blue)
|
167
|
+
puts ' This is very experimental! The idea is to take all the output from the search and allow a pipe into a traditional shell command.'
|
168
|
+
puts ' Due to the arg parsing its not a straight send to the terminal. You may need to escape quotes.'
|
169
|
+
puts ' Order is relevant, no arguments after the pipe'
|
170
|
+
puts
|
171
|
+
puts ' <files> <params> | grep path'
|
172
|
+
puts
|
173
|
+
|
152
174
|
puts 'Example Queries'.pastel(:blue)
|
153
175
|
puts " Also see #{'examples'.pastel(:bright_blue)} for even more examples"
|
154
176
|
puts ' log filter --class=BuildFinishedWorker sidekiq/current --slice=time,message'
|
@@ -202,7 +224,7 @@ module GreenHat
|
|
202
224
|
|
203
225
|
total: [
|
204
226
|
'--total'.pastel(:green),
|
205
|
-
'
|
227
|
+
' Show total count, duration, start/end time for matching entries'
|
206
228
|
],
|
207
229
|
|
208
230
|
fields: [
|
@@ -357,7 +379,7 @@ module GreenHat
|
|
357
379
|
|
358
380
|
}
|
359
381
|
end
|
360
|
-
# rubocop:enable Metrics/MethodLength,Metrics/ModuleLength
|
382
|
+
# rubocop:enable Metrics/MethodLength,Metrics/ModuleLength,Layout/LineLength
|
361
383
|
end
|
362
384
|
end
|
363
385
|
end
|