greenhat 0.6.1 → 0.6.4

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.
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.6.1
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Davin Walker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-08 00:00:00.000000000 Z
11
+ date: 2022-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amazing_print
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.12'
89
+ version: '1.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.12'
96
+ version: '1.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: actionview
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '1.5'
145
+ version: '1.6'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '1.5'
152
+ version: '1.6'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: dotenv
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0.14'
237
+ - !ruby/object:Gem::Dependency
238
+ name: puma
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '5.6'
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '5.6'
237
251
  - !ruby/object:Gem::Dependency
238
252
  name: require_all
239
253
  requirement: !ruby/object:Gem::Requirement
@@ -276,6 +290,20 @@ dependencies:
276
290
  - - "~>"
277
291
  - !ruby/object:Gem::Version
278
292
  version: '1.6'
293
+ - !ruby/object:Gem::Dependency
294
+ name: sinatra
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - "~>"
298
+ - !ruby/object:Gem::Version
299
+ version: '2.2'
300
+ type: :runtime
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - "~>"
305
+ - !ruby/object:Gem::Version
306
+ version: '2.2'
279
307
  - !ruby/object:Gem::Dependency
280
308
  name: slim
281
309
  requirement: !ruby/object:Gem::Requirement
@@ -430,20 +458,6 @@ dependencies:
430
458
  - - "~>"
431
459
  - !ruby/object:Gem::Version
432
460
  version: '0.5'
433
- - !ruby/object:Gem::Dependency
434
- name: warning
435
- requirement: !ruby/object:Gem::Requirement
436
- requirements:
437
- - - "~>"
438
- - !ruby/object:Gem::Version
439
- version: '1.2'
440
- type: :runtime
441
- prerelease: false
442
- version_requirements: !ruby/object:Gem::Requirement
443
- requirements:
444
- - - "~>"
445
- - !ruby/object:Gem::Version
446
- version: '1.2'
447
461
  description: Experimental SOS and Log Parser for GitLab
448
462
  email:
449
463
  - dwalker@gitlab.com
@@ -478,6 +492,7 @@ files:
478
492
  - lib/greenhat/reports/reports/errors.rb
479
493
  - lib/greenhat/reports/reports/faststats.rb
480
494
  - lib/greenhat/reports/reports/full.rb
495
+ - lib/greenhat/reports/reports/full_markdown.rb
481
496
  - lib/greenhat/reports/runner.rb
482
497
  - lib/greenhat/reports/shared.rb
483
498
  - lib/greenhat/reports/shell_helper.rb
@@ -503,7 +518,6 @@ files:
503
518
  - lib/greenhat/shell/platform.rb
504
519
  - lib/greenhat/shell/process.rb
505
520
  - lib/greenhat/shell/query.rb
506
- - lib/greenhat/shell/report.rb
507
521
  - lib/greenhat/shell/reports.rb
508
522
  - lib/greenhat/shell/shell_helper.rb
509
523
  - lib/greenhat/thing.rb
@@ -513,10 +527,12 @@ files:
513
527
  - lib/greenhat/thing/formatters/clean_raw.rb
514
528
  - lib/greenhat/thing/formatters/colon_split_strip.rb
515
529
  - lib/greenhat/thing/formatters/dotenv.rb
530
+ - lib/greenhat/thing/formatters/exporters.rb
516
531
  - lib/greenhat/thing/formatters/format.rb
517
532
  - lib/greenhat/thing/formatters/free_m.rb
518
533
  - lib/greenhat/thing/formatters/gitlab_ctl_tail.rb
519
534
  - lib/greenhat/thing/formatters/gitlab_status.rb
535
+ - lib/greenhat/thing/formatters/identify_db.rb
520
536
  - lib/greenhat/thing/formatters/json.rb
521
537
  - lib/greenhat/thing/formatters/json_shellwords.rb
522
538
  - lib/greenhat/thing/formatters/kube_json.rb
@@ -588,14 +604,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
588
604
  requirements:
589
605
  - - ">="
590
606
  - !ruby/object:Gem::Version
591
- version: 3.0.0
607
+ version: 2.7.5
592
608
  required_rubygems_version: !ruby/object:Gem::Requirement
593
609
  requirements:
594
610
  - - ">="
595
611
  - !ruby/object:Gem::Version
596
612
  version: '0'
597
613
  requirements: []
598
- rubygems_version: 3.2.32
614
+ rubygems_version: 3.1.6
599
615
  signing_key:
600
616
  specification_version: 4
601
617
  summary: GitLab SOS Tool
@@ -1,415 +0,0 @@
1
- # Deprecated in favor of reports module
2
- # TODO: Remove
3
- # module GreenHat
4
- # # Root Level Shell / Report Helper
5
- # module Shell
6
- # def self.report(raw)
7
-
8
- # _files, flags, _args = Args.parse(raw)
9
-
10
- # archives = if flags.archive
11
- # Archive.all.select do |archive|
12
- # flags.archive.any? { |x| archive.name.include? x.to_s }
13
- # end
14
- # else
15
- # Archive.all
16
- # end
17
-
18
- # output = archives.map { |x| x.report(flags) }.map(&:show).flatten
19
-
20
- # flags[:page] = true if flags.full && !flags.raw
21
-
22
- # ShellHelper.show(output, flags)
23
- # end
24
- # end
25
- # end
26
-
27
- # module GreenHat
28
- # # Report Generator Helper
29
- #
30
- # class Report
31
- # include ActionView::Helpers::NumberHelper
32
-
33
- # attr_accessor :archive, :flags, :host, :os_release, :selinux_status, :cpu, :uname,
34
- # :timedatectl, :uptime, :meminfo, :gitlab_manifest, :gitlab_status,
35
- # :production_log, :api_log, :sidekiq_log,
36
- # :exceptions_log, :gitaly_log, :free_m, :disk_free
37
-
38
- # # Find Needed Files for Report
39
- #
40
- # def initialize(archive, flags)
41
- # self.archive = archive
42
- # self.flags = flags
43
- # self.host = archive.things.find { |x| x.name == 'hostname' }
44
- # self.os_release = archive.things.find { |x| x.name == 'etc/os-release' }
45
- # self.selinux_status = archive.things.find { |x| x.name == 'sestatus' }
46
- # self.cpu = archive.things.find { |x| x.name == 'lscpu' }
47
- # self.uname = archive.things.find { |x| x.name == 'uname' }
48
- # self.timedatectl = archive.things.find { |x| x.name == 'timedatectl' }
49
- # self.uptime = archive.things.find { |x| x.name == 'uptime' }
50
- # self.meminfo = archive.things.find { |x| x.name == 'meminfo' }
51
- # self.free_m = archive.things.find { |x| x.name == 'free_m' }
52
- # self.gitlab_manifest = archive.things.find { |x| x.name == 'gitlab/version-manifest.json' }
53
- # self.gitlab_status = archive.things.find { |x| x.name == 'gitlab_status' }
54
- # self.production_log = archive.things.find { |x| x.name == 'gitlab-rails/production_json.log' }
55
- # self.api_log = archive.things.find { |x| x.name == 'gitlab-rails/api_json.log' }
56
- # self.exceptions_log = archive.things.find { |x| x.name == 'gitlab-rails/exceptions_json.log' }
57
- # self.gitaly_log = archive.things.find { |x| x.name == 'gitaly/current' }
58
- # self.sidekiq_log = archive.things.find { |x| x.name == 'sidekiq/current' }
59
- # self.disk_free = archive.things.find { |x| x.name == 'df_hT' }
60
- # end
61
-
62
- # def show
63
- # output = [
64
- # archive.friendly_name.pastel(:blue)
65
- # ]
66
-
67
- # # OS
68
- # output << 'OS'.pastel(:bright_yellow)
69
- # output << hostname if host
70
- # output << distro if os_release
71
- # output << selinux if selinux_status
72
- # # output << arch if cpu
73
- # output << kernel if uname
74
- # output << sys_time if timedatectl
75
- # output << sys_uptime if uptime
76
- # output << load_average if uptime && cpu
77
- # output << ''
78
-
79
- # # Memory
80
- # if meminfo || free_m
81
- # output << 'Memory'.pastel(:bright_yellow)
82
- # output << memory_perc if meminfo
83
- # output << memory_free if free_m
84
- # output << ''
85
- # end
86
-
87
- # # Disk
88
- # if disk_free
89
- # output << disks
90
- # output << ''
91
- # end
92
-
93
- # # Gitlab
94
- # output << 'GitLab'.pastel(:bright_yellow) if gitlab_manifest
95
- # output << gitlab_version if gitlab_manifest
96
- # output << gitlab_services if gitlab_status
97
- # output << title('Errors') if production_log || api_log || sidekiq_log
98
- # output << production_errors if production_log
99
- # output << application_errors if archive.thing?('gitlab-rails/application_json.log')
100
- # output << sidekiq_errors if sidekiq_log
101
- # output << api_errors if api_log
102
- # output << exception_errors if exceptions_log
103
- # output << gitaly_errors if gitaly_log
104
- # output << workhorse_errors if archive.thing?('gitlab-workhorse/current')
105
-
106
- # full(output) if flags.full
107
-
108
- # # Final Space / Return
109
- # output << ''
110
- # output
111
- # end
112
- # # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
113
-
114
- # def full(output)
115
- # output << ''
116
- # output << 'FastStats Top'
117
- # Shell::Faststats.top(['--raw'], true).each { |x| output << x } # Page Row Helper
118
- # output << ''
119
-
120
- # output << 'FastStats Errors'
121
- # Shell::Faststats.errors(['--raw'], true).each { |x| output << x } # Page Row Helper
122
- # output << ''
123
- # end
124
-
125
- # def exception_errors
126
- # count = exceptions_log.data.count
127
- # color = count.zero? ? :green : :red
128
-
129
- # [
130
- # title(' Exception', :bright_red, 18),
131
- # count.to_s.pastel(color)
132
- # ].join
133
- # end
134
-
135
- # def workhorse_errors
136
- # results = ShellHelper.filter_internal([
137
- # 'gitlab-workhorse/current',
138
- # '--level=error',
139
- # "--archive=#{archive.name}"
140
- # ].join(' '))
141
-
142
- # color = results.count.zero? ? :green : :red
143
-
144
- # [
145
- # title(' Workhorse', :bright_red, 18),
146
- # results.count.to_s.pastel(color)
147
- # ].join
148
- # end
149
-
150
- # def gitaly_errors
151
- # count = gitaly_log.data.count { |x| x.level == 'error' }
152
- # color = count.zero? ? :green : :red
153
-
154
- # [
155
- # title(' Gitaly', :bright_red, 18),
156
- # count.to_s.pastel(color)
157
- # ].join
158
- # end
159
-
160
- # def production_errors
161
- # count = production_log.data.count { |x| x.status == 500 }
162
- # color = count.zero? ? :green : :red
163
-
164
- # [
165
- # title(' Production', :bright_red, 18),
166
- # count.to_s.pastel(color)
167
- # ].join
168
- # end
169
-
170
- # def api_errors
171
- # count = api_log.data.count { |x| x.status == 500 }
172
- # color = count.zero? ? :green : :red
173
-
174
- # [
175
- # title(' API', :bright_red, 18),
176
- # count.to_s.pastel(color)
177
- # ].join
178
- # end
179
-
180
- # def application_errors
181
- # results = ShellHelper.filter_internal([
182
- # 'gitlab-rails/application_json.log',
183
- # '--message!="Cannot obtain an exclusive lease"',
184
- # '--severity=error',
185
- # "--archive=#{archive.name}"
186
- # ].join(' '))
187
-
188
- # count = results.count { |x| x&.severity == 'ERROR' }
189
- # color = count.zero? ? :green : :red
190
-
191
- # [
192
- # title(' Application', :bright_red, 18),
193
- # count.to_s.pastel(color)
194
- # ].join
195
- # end
196
-
197
- # def sidekiq_errors
198
- # count = sidekiq_log.data.count { |x| x&.severity == 'ERROR' }
199
- # color = count.zero? ? :green : :red
200
-
201
- # [
202
- # title(' Sidekiq', :bright_red, 18),
203
- # count.to_s.pastel(color)
204
- # ].join
205
- # end
206
-
207
- # def gitlab_services
208
- # [
209
- # title('Services'),
210
- # "\n ",
211
- # GitLab.services(archive, 3)
212
- # ].join
213
- # rescue StandardError => e
214
- # LogBot.fatal('GitLab Services', message: e.message, backtrace: e.backtrace.first)
215
- # end
216
-
217
- # def gitlab_version
218
- # [
219
- # title('Version'),
220
- # gitlab_manifest.data.build_version
221
- # ].join
222
- # end
223
-
224
- # def hostname
225
- # [
226
- # title('Hostname'),
227
- # host.data.first
228
- # ].join
229
- # end
230
-
231
- # def distro
232
- # [
233
- # title('Distro'),
234
- # "[#{os_release.data.ID}] ".pastel(:bright_black),
235
- # os_release.data.PRETTY_NAME
236
- # ].join
237
- # end
238
-
239
- # def selinux
240
- # return nil if selinux_status.data.nil?
241
-
242
- # status = selinux_status.data['SELinux status']
243
- # status_color = status == 'enabled' ? :green : :red
244
-
245
- # [
246
- # title('SeLinux'),
247
- # status.pastel(status_color),
248
- # ' (',
249
- # selinux_status.data['Current mode'],
250
- # ')'
251
- # ].join
252
- # end
253
-
254
- # def arch
255
- # [
256
- # title('Arch'),
257
- # cpu.data.Architecture
258
- # ].join
259
- # end
260
-
261
- # def kernel
262
- # # TODO: Better way to consistently get uname info?
263
- # value, build = uname.data.first.split[2].split('-')
264
- # [
265
- # title('Kernel'),
266
- # value,
267
- # " (#{build})".pastel(:bright_black)
268
- # ].join
269
- # end
270
-
271
- # # Helper for finding if NTP is enabled
272
- # def ntp_keys
273
- # [
274
- # 'Network time on', 'NTP enabled', 'NTP service', 'System clock synchronized'
275
- # ]
276
- # end
277
-
278
- # def sys_time
279
- # # Ignore if Empty
280
- # return false if timedatectl.data.nil?
281
-
282
- # ntp_statuses = timedatectl.data.slice(*ntp_keys).values.compact
283
-
284
- # enabled = %w[active yes] & ntp_statuses
285
- # ntp_status = ntp_statuses.first
286
- # ntp_color = enabled.empty? ? :red : :green
287
-
288
- # # Fall Back
289
- # ntp_status ||= 'unknown'
290
-
291
- # [
292
- # title('Sys Time'),
293
- # timedatectl.data['Local time'],
294
- # ' (ntp: '.pastel(:bright_black),
295
- # ntp_status.pastel(ntp_color),
296
- # ')'.pastel(:bright_black)
297
- # ].join
298
- # end
299
-
300
- # # Strip/Simplify Uptime
301
- # def sys_uptime
302
- # init = uptime.data.first.split(', load average').first.strip
303
-
304
- # [
305
- # title('Uptime'),
306
- # init.split('up ', 2).last
307
- # ].join
308
- # end
309
-
310
- # def load_average
311
- # cpu_count = cpu.data['CPU(s)'].to_i
312
- # intervals = uptime.data.first.split('load average: ', 2).last.split(', ').map(&:to_f)
313
-
314
- # # Generate Colorized Text for Output
315
- # intervals_text = intervals.map do |interval|
316
- # value = percent(interval, cpu_count)
317
- # color = value > 100 ? :red : :green
318
- # [
319
- # interval,
320
- # ' (',
321
- # "#{value}%".pastel(color),
322
- # ')'
323
- # ].join
324
- # end
325
-
326
- # [
327
- # title('LoadAvg'),
328
- # "[CPU #{cpu_count}] ".pastel(:bright_white),
329
- # intervals_text.join(', ')
330
- # ].join
331
- # end
332
-
333
- # def memory_perc
334
- # total = ShellHelper.human_size_to_number(meminfo.data['MemTotal'])
335
- # free = ShellHelper.human_size_to_number(meminfo.data['MemFree'])
336
- # used = percent((total - free), total)
337
-
338
- # [
339
- # title('Usage'),
340
- # ' ['.pastel(:bright_black),
341
- # '='.pastel(:green) * (used / 2),
342
- # ' ' * (50 - (used / 2)),
343
- # ']'.pastel(:bright_black),
344
- # " #{100 - percent(free, total)}%".pastel(:green) # Inverse
345
- # ].join
346
- # end
347
-
348
- # def memory_free
349
- # free = free_m.data.find { |x| x.kind == 'Mem' }
350
-
351
- # return unless free
352
-
353
- # formatted_mem = free_m.data.map { |x| GreenHat::Memory.memory_row x }
354
-
355
- # output = []
356
- # unless free.total.blank?
357
- # output << title('Total', :cyan, 14)
358
- # output << number_to_human_size(free.total.to_i * (1024**2))
359
- # output << "\n"
360
- # end
361
-
362
- # unless free.total.blank?
363
- # output << title('Used', :yellow, 14)
364
- # output << number_to_human_size(free.used.to_i * (1024**2))
365
- # output << "\n"
366
- # end
367
-
368
- # unless free.total.blank?
369
- # output << title('Free', :blue, 14)
370
- # output << number_to_human_size(free.free.to_i * (1024**2))
371
- # output << "\n"
372
- # end
373
-
374
- # unless free.total.blank?
375
- # output << title('Available', :green, 14)
376
- # output << number_to_human_size(free.available.to_i * (1024**2))
377
- # output << "\n"
378
- # end
379
-
380
- # output << "\n"
381
- # output << formatted_mem.map { |x| x.prepend ' ' * 2 }.join("\n")
382
-
383
- # output.join
384
- # rescue StandardError => e
385
- # LogBot.fatal('Memory', message: e.message, backtrace: e.backtrace.first)
386
- # end
387
-
388
- # def disks
389
- # # GreenHat::Disk.df({archive: []})
390
- # file = GreenHat::Disk.df({ archive: [archive.name] })
391
-
392
- # disk_list = GreenHat::Disk.format_output(file.first, false, 3)
393
-
394
- # # Preapre / Indent List
395
- # [
396
- # 'Disks'.pastel(:bright_yellow) + ' (Top % Usage)'.pastel(:bright_black),
397
- # "\n",
398
- # disk_list.each { |x| x.prepend(' ' * 4) }.join("\n")
399
- # ].join
400
- # end
401
-
402
- # # ----------------------------
403
- # # Helpers
404
- # # ----------------------------
405
- # def percent(value, total)
406
- # ((value / total.to_f) * 100).round
407
- # end
408
-
409
- # # Helper to Make Cyan Titles
410
- # def title(name, color = :cyan, ljust = 12)
411
- # " #{name}:".ljust(ljust).pastel(color)
412
- # end
413
- # end
414
- # # rubocop:enable Metrics/ClassLength
415
- # end