greenhat 0.7.3 → 0.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfa1c48eaba3ee835bbb027b9e7314fa8e64d17629d481c7c3aa73d7e00b83a4
4
- data.tar.gz: '0175799c24f2d5c43fda1d50e103446a73ee12600dca511d4d52327128a66767'
3
+ metadata.gz: a519d68faaec2994665e8c6e442923578d6a0f165a2213f3a5ef0e7e45b65903
4
+ data.tar.gz: 1a9f905cf1d9f8738a1658f932b5d14d8ef9964a0bb2360a5438460330e868d1
5
5
  SHA512:
6
- metadata.gz: 95e6819b6e8f333c8537752d863ebc03fb3197e90be7ce92488bd68018c534be2d0db7593056cfa7c716ae43dae1ccf16d9f89ec84c72d4ef3b39fdb65734710
7
- data.tar.gz: db52e83d2c456cd5d217310223ad62ea380e4e27f72ccc2819fa63b4e7734460b121153aaaa318743f3700f9e63eafbe71cda38caac94361cc659b88618edd20
6
+ metadata.gz: 6e9f31443fdb9917069831fc89e39b97f198c3b298bb06b2331dc0788d2f7ca31e4ce65b1f69e0a89e82d6788e810fe0d344a5cb2c74b30aa53d3b7577442f96
7
+ data.tar.gz: 3534f35919122f6b01aaa1570429faf852dc4c91c3e170a55e693cc84207fa391cfb7ad2c85af4cca46a0d83adcbbfaa24ecf1db52bcfa76d08bf38d8c42ad83
data/README.md CHANGED
@@ -12,6 +12,8 @@ Experimental SOS and Log Parser for GitLab
12
12
 
13
13
  `apt-get install libarchive-tools`
14
14
 
15
+ Ruby 3.0 or later, including the headers (such as package `ruby-dev`)
16
+
15
17
  ## Installation
16
18
 
17
19
  ```
@@ -27,7 +27,8 @@ entries = [
27
27
  { header: 'Gitaly', base: 'gitaly/current --level=error --truncate=99', stats: 'error' },
28
28
  { header: 'Praefect', base: 'praefect/current --level=error --truncate=99', stats: 'error' },
29
29
  { header: 'Pages', base: 'gitlab-pages/current --level=error', stats: 'error' },
30
- { header: 'Geo', base: 'gitlab-rails/geo.log --severity=error', stats: 'message' }
30
+ { header: 'Geo', base: 'gitlab-rails/geo.log --severity=error', stats: 'message' },
31
+ { header: 'Elasticsearch', base: 'gitlab-rails/elasticsearch.log --severity=error', stats: 'message' }
31
32
  ]
32
33
 
33
34
  # Filter Logic
@@ -164,3 +164,8 @@ query_if_exists 'gitlab-rails/geo.log --severity=error' do |data|
164
164
  color = data.count.zero? ? :green : :red
165
165
  indent("#{ljust('Geo:', 14, :magenta)} #{data.count.to_s.pastel(color)}", 4)
166
166
  end
167
+
168
+ query_if_exists 'gitlab-rails/elasticsearch.log --severity=error' do |data|
169
+ color = data.count.zero? ? :green : :red
170
+ indent("#{ljust('Elasticsearch:', 14, :magenta)} #{data.count.to_s.pastel(color)}", 4)
171
+ end
@@ -5,7 +5,18 @@ module GreenHat
5
5
  # Make Running more consistent
6
6
  def self.run(file:, args:, flags:, raw_args:)
7
7
  report = GreenHat::Reports::Builder.new(file:, args:, flags:, raw_args:)
8
- output = Archive.all.map do |archive|
8
+
9
+ # Fuzzy Match Archive Names
10
+ archives = Archive.all
11
+ if flags[:archive] && !flags[:archive].empty?
12
+ archives.select! do |a|
13
+ flags[:archive].any? do |x|
14
+ a.name.include? x.to_s
15
+ end
16
+ end
17
+ end
18
+
19
+ output = archives.map do |archive|
9
20
  runner = GreenHat::Reports::Runner.new(
10
21
  archive:,
11
22
  store: report.store.clone,
@@ -21,7 +21,7 @@ module GreenHat
21
21
  def self.filter_flags(word)
22
22
  if word.blank?
23
23
  puts 'Filter Options:'.pastel(:bright_blue)
24
- puts ShellHelper.field_table(filter_opts, 6)
24
+ puts ShellHelper.field_table(filter_opts)
25
25
  puts
26
26
 
27
27
  return []
@@ -218,7 +218,7 @@ module GreenHat
218
218
 
219
219
  # Skip and Print Total if set
220
220
  if flags[:fields]
221
- ShellHelper.fields_print(results)
221
+ ShellHelper.fields_print(files)
222
222
  return true
223
223
  end
224
224
 
@@ -191,7 +191,7 @@ module GreenHat
191
191
  results = filter_except(results, flags[:except]) if flags.key?(:except)
192
192
 
193
193
  # Remove Blank from either slice or except
194
- results.reject!(&:empty?)
194
+ results.reject!(&:blank?)
195
195
 
196
196
  # Sort / Reverse by default
197
197
  if flags.key?(:sort)
@@ -244,50 +244,31 @@ module GreenHat
244
244
  [output]
245
245
  end
246
246
 
247
- # TODO: Clean up -- Verify these aren't needed
248
- # Hash Iteration
249
- # def self.total_count_hash(results, flags)
250
- # results.flat_map do |k, values|
251
- # [k, total_count_array(values, flags)]
252
- # end
253
- # end
247
+ # Table Printer Helper
248
+ def self.fields_print(files)
249
+ fields = ShellHelper.find_things(files).map(&:fields).flatten.uniq
254
250
 
255
- # List Calculation
256
- # def self.total_count_array(results, flags)
257
- # # Option to only return the count
258
- # return results.count if flags[:total] == 'simple'
251
+ # truncate = (TTY::Screen.width - columns) / columns
252
+ # fields.map! { |f| f[0..truncate] }
253
+ puts ShellHelper.field_table(fields)
259
254
 
260
- # output = {}
261
- # output[:total] = results.count
262
- # output[:duration] = Query.calculate_duration(results)
255
+ # ShellHelper.fields_print(files)
256
+ end
263
257
 
264
- # # Sort / Get first and Last
265
- # list = results.select(&:time).map(&:time)
266
- # unless list.blank?
267
- # output[:start] = list.first
268
- # output[:end] = list.last
269
- # end
258
+ # 5 Columns cause issues with resizing
259
+ def self.field_table(list, columns: 4)
260
+ return nil if list.empty?
270
261
 
271
- # # Hide empty results
272
- # output.reject! { |_k, v| v.blank? }
262
+ # Split list into groups based on columns
263
+ groups = list.each_slice((list.size / columns.to_f).ceil).to_a
273
264
 
274
- # render_table(output, flags)
275
- # end
265
+ # Max Width for Table
266
+ truncate = (TTY::Screen.width - groups.count) / groups.count
276
267
 
277
- # Table Printer Helper
278
- def self.fields_print(results)
279
- results.each do |k, v|
280
- puts k
281
- puts field_table(v.map(&:keys).flatten.uniq.sort)
282
- puts
268
+ # Process Truncation
269
+ groups.each do |group|
270
+ group.map! { |f| f[0..truncate]&.to_sym }
283
271
  end
284
- end
285
-
286
- def self.field_table(list, columns = 4)
287
- return nil if list.empty?
288
-
289
- # Keep Alphabetical Sort
290
- groups = list.each_slice((list.size / columns.to_f).round).to_a
291
272
 
292
273
  table = TTY::Table.new do |t|
293
274
  loop do
@@ -297,7 +278,7 @@ module GreenHat
297
278
  end
298
279
  end
299
280
 
300
- table.render(:unicode, padding: [0, 1, 0, 1])
281
+ table.render(:unicode, padding: [0, 1, 0, 1], resize: false)
301
282
  end
302
283
 
303
284
  # Unified Files Interface
@@ -968,6 +968,12 @@ module GreenHat
968
968
  /rpm_verify/
969
969
  ]
970
970
  },
971
+ 'gitlab_system_status' => {
972
+ format: :raw,
973
+ pattern: [
974
+ /gitlab_system_status/
975
+ ]
976
+ },
971
977
  'gitlab-rails/application.log' => {
972
978
  format: :raw,
973
979
  pattern: [
@@ -14,6 +14,9 @@ module GreenHat
14
14
  { message: row }
15
15
  end
16
16
 
17
+ # Skip bad results
18
+ next if result.nil?
19
+
17
20
  # Parsing Time / Recusrive is really slow
18
21
  format_time(result)
19
22
 
@@ -1,3 +1,3 @@
1
1
  module GreenHat
2
- VERSION = '0.7.3'.freeze
2
+ VERSION = '0.7.4'.freeze
3
3
  end
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.7.3
4
+ version: 0.7.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: 2023-11-14 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview