File no-ohai.patch of Package gitlab-ce
Index: gitlab-ce/Gemfile
===================================================================
--- gitlab-ce.orig/Gemfile
+++ gitlab-ce/Gemfile
@@ -144,7 +144,7 @@ gem 'acme-client', '~> 2.0.19', feature_
gem 'browser', '~> 5.3.1', feature_category: :shared
# OS detection for usage ping
-gem 'ohai', '~> 18.1', feature_category: :product_analytics
+# gem 'ohai', '~> 18.1', feature_category: :product_analytics
# GPG
gem 'gpgme', '~> 2.0.24', feature_category: :source_code_management
Index: gitlab-ce/lib/gitlab/usage/metrics/instrumentations/operating_system_metric.rb
===================================================================
--- gitlab-ce.orig/lib/gitlab/usage/metrics/instrumentations/operating_system_metric.rb
+++ gitlab-ce/lib/gitlab/usage/metrics/instrumentations/operating_system_metric.rb
@@ -6,16 +6,32 @@ module Gitlab
module Instrumentations
class OperatingSystemMetric < GenericMetric
value do
- ohai_data = Ohai::System.new.tap do |oh|
- oh.all_plugins(['platform'])
- end.data
+ # ohai_data = Ohai::System.new.tap do |oh|
+ # oh.all_plugins(['platform'])
+ # end.data
- platform = ohai_data['platform']
- if ohai_data['platform'] == 'debian' && ohai_data['kernel']['machine']&.include?('armv')
- platform = 'raspbian'
- end
+ # platform = ohai_data['platform']
+ # if ohai_data['platform'] == 'debian' && ohai_data['kernel']['machine']&.include?('armv')
+ # platform = 'raspbian'
+ # end
- "#{platform}-#{ohai_data['platform_version']}"
+ # "#{platform}-#{ohai_data['platform_version']}"
+ fc = File.read("/etc/os-release")
+ platform = nil
+ version = nil
+ fc.each_line do |line|
+ line.chomp!
+ next if line =~ /^#/
+ if mo = /\A(?<key>[^=]+)="(?<value>[^"]+)"/.match(line)
+ case mo[:key]
+ when 'ID'
+ platform=mo[:value]
+ when 'VERSION_ID'
+ version=mo[:value]
+ end
+ end
+ end
+ "#{platform}-#{version}"
end
end
end