openfact 5.3.0 → 5.4.0
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/lib/facter/facts/openbsd/processors/count.rb +16 -0
- data/lib/facter/framework/cli/cli.rb +5 -5
- data/lib/facter/framework/core/file_loader.rb +2 -0
- data/lib/facter/resolvers/linux/processors.rb +1 -1
- data/lib/facter/resolvers/openbsd/processors.rb +52 -0
- data/lib/facter/util/linux/dhcp.rb +10 -1
- data/lib/facter/util/linux.rb +49 -0
- data/lib/facter/version.rb +1 -1
- metadata +34 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f6d2e82c285041a67df8e09555f99b036c71b809b0f2de5b1bf51bffbd4ba6b6
|
|
4
|
+
data.tar.gz: ed4379f690cc03afd6e55a34f9b92ef71f4092c1f39a5e141f962957cc13da16
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c355f5cade881c26c9bb534e0db6a60cb1a3bbd4ff9a58d95b43cbe512155b797bdccb9acbc7e2cba5b97b048472c65190a35a7c736a26e604c2749af0627716
|
|
7
|
+
data.tar.gz: 2f767582f751bbc74a73dd7dd26457f4bcd2c201a2cadfe7fc8aab38b8904a29cc7b3438265bc37de04f6e960c24b1a573c62a4b575025df73f2af524b0bf1d2
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Facts
|
|
4
|
+
module Openbsd
|
|
5
|
+
module Processors
|
|
6
|
+
class Count
|
|
7
|
+
FACT_NAME = 'processors.count'
|
|
8
|
+
|
|
9
|
+
def call_the_resolver
|
|
10
|
+
fact_value = Facter::Resolvers::Openbsd::Processors.resolve(:online_count)
|
|
11
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -201,11 +201,11 @@ module Facter
|
|
|
201
201
|
Cli.commands.values
|
|
202
202
|
.select { |command_class| command_class.instance_of?(Thor::Command) }
|
|
203
203
|
.each do |command|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
help_command_options << build_option(
|
|
205
|
+
command['name'],
|
|
206
|
+
[command['usage'].split(',')[1]],
|
|
207
|
+
command['description']
|
|
208
|
+
)
|
|
209
209
|
end
|
|
210
210
|
|
|
211
211
|
help_command_options
|
|
@@ -709,6 +709,7 @@ os_hierarchy.each do |os|
|
|
|
709
709
|
require_relative '../../facts/openbsd/os/hardware'
|
|
710
710
|
require_relative '../../facts/openbsd/os/name'
|
|
711
711
|
require_relative '../../facts/openbsd/os/release'
|
|
712
|
+
require_relative '../../facts/openbsd/processors/count'
|
|
712
713
|
require_relative '../../facts/openbsd/processors/isa'
|
|
713
714
|
require_relative '../../facts/openbsd/ruby/platform'
|
|
714
715
|
require_relative '../../facts/openbsd/ruby/sitedir'
|
|
@@ -721,6 +722,7 @@ os_hierarchy.each do |os|
|
|
|
721
722
|
require_relative '../../resolvers/openbsd/dhcp'
|
|
722
723
|
require_relative '../../resolvers/openbsd/dmi'
|
|
723
724
|
require_relative '../../resolvers/openbsd/mountpoints'
|
|
725
|
+
require_relative '../../resolvers/openbsd/processors'
|
|
724
726
|
require_relative '../../resolvers/openbsd/virtual'
|
|
725
727
|
|
|
726
728
|
when 'openwrt'
|
|
@@ -70,7 +70,7 @@ module Facter
|
|
|
70
70
|
.select { |dir| dir =~ /cpu[0-9]+$/ }
|
|
71
71
|
.select { |dir| File.exist?("/sys/devices/system/cpu/#{dir}/topology/physical_package_id") }
|
|
72
72
|
.map do |dir|
|
|
73
|
-
|
|
73
|
+
Facter::Util::FileHelper.safe_read("/sys/devices/system/cpu/#{dir}/topology/physical_package_id").strip
|
|
74
74
|
end
|
|
75
75
|
.uniq.count
|
|
76
76
|
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../../facter/resolvers/bsd/processors'
|
|
4
|
+
|
|
5
|
+
module Facter
|
|
6
|
+
module Resolvers
|
|
7
|
+
module Openbsd
|
|
8
|
+
class Processors < BaseResolver
|
|
9
|
+
init_resolver
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def post_resolve(fact_name, _options)
|
|
15
|
+
@fact_list.fetch(fact_name) { collect_processors_info(fact_name) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def collect_processors_info(fact_name)
|
|
19
|
+
require_relative '../../../facter/resolvers/bsd/ffi/ffi_helper'
|
|
20
|
+
|
|
21
|
+
count = online_count
|
|
22
|
+
model = processor_model
|
|
23
|
+
speed = processor_speed
|
|
24
|
+
|
|
25
|
+
@fact_list[:online_count] = count
|
|
26
|
+
@fact_list[:model] = Array.new(count, model) if online_count && model
|
|
27
|
+
@fact_list[:speed] = speed * 1000 * 1000 if speed
|
|
28
|
+
|
|
29
|
+
@fact_list[fact_name]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
CTL_HW = 6
|
|
33
|
+
HW_MODEL = 2
|
|
34
|
+
HW_NCPUONLINE = 25
|
|
35
|
+
HW_CPUSPEED = 12
|
|
36
|
+
|
|
37
|
+
def processor_model
|
|
38
|
+
Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_MODEL])
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def online_count
|
|
42
|
+
Facter::Bsd::FfiHelper.sysctl(:uint32_t, [CTL_HW, HW_NCPUONLINE])
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def processor_speed
|
|
46
|
+
Facter::Bsd::FfiHelper.sysctl(:uint32_t, [CTL_HW, HW_CPUSPEED])
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'facter/util/linux'
|
|
4
|
+
|
|
3
5
|
module Facter
|
|
4
6
|
module Util
|
|
5
7
|
module Linux
|
|
@@ -73,11 +75,18 @@ module Facter
|
|
|
73
75
|
end
|
|
74
76
|
|
|
75
77
|
def search_with_dhcpcd_command(interface_name)
|
|
76
|
-
|
|
78
|
+
return if interface_name == 'lo'
|
|
77
79
|
|
|
78
80
|
@dhcpcd_command ||= Facter::Core::Execution.which('dhcpcd')
|
|
79
81
|
return unless @dhcpcd_command
|
|
80
82
|
|
|
83
|
+
unless Facter::Util::Linux.process_running?('dhcpcd')
|
|
84
|
+
@log.debug('Skipping dhcpcd -U because dhcpcd daemon is not running')
|
|
85
|
+
return
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
@log.debug("Attempt to get DHCP for interface #{interface_name}, from dhcpcd command")
|
|
89
|
+
|
|
81
90
|
output = Facter::Core::Execution.execute("#{@dhcpcd_command} -U #{interface_name}", logger: @log)
|
|
82
91
|
dhcp = output.match(/dhcp_server_identifier='(.*)'/)
|
|
83
92
|
dhcp[1] if dhcp
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Facter
|
|
4
|
+
module Util
|
|
5
|
+
module Linux
|
|
6
|
+
def self.process_running?(process_name)
|
|
7
|
+
pidfiles = Dir.glob("{/run,/var/run}/#{process_name}{,*,/}*.pid")
|
|
8
|
+
pidfiles.each do |pf|
|
|
9
|
+
next unless File.file?(pf)
|
|
10
|
+
|
|
11
|
+
pid = begin
|
|
12
|
+
Integer(Facter::Util::FileHelper.safe_read(pf, '').strip, 10)
|
|
13
|
+
rescue StandardError
|
|
14
|
+
nil
|
|
15
|
+
end
|
|
16
|
+
next unless pid&.positive?
|
|
17
|
+
|
|
18
|
+
begin
|
|
19
|
+
# Doesn't actually kill, just detects if the process exists
|
|
20
|
+
Process.kill(0, pid)
|
|
21
|
+
return true if proc_comm(pid) == process_name || proc_cmdline(pid)&.match?(%r{(^|\s|/)#{process_name}(\s|$)})
|
|
22
|
+
rescue Errno::ESRCH
|
|
23
|
+
# If we can't confirm identity, still treat it as not running to be safe.
|
|
24
|
+
next
|
|
25
|
+
rescue Errno::EPERM
|
|
26
|
+
# Exists but we can't inspect it; assume it's running.
|
|
27
|
+
return true
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Fallback: Try to find it in /proc
|
|
32
|
+
return false unless Dir.exist?('/proc')
|
|
33
|
+
|
|
34
|
+
Dir.glob('/proc/[0-9]*/comm').any? do |path|
|
|
35
|
+
Facter::Util::FileHelper.safe_read(path, nil)&.strip == process_name
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.proc_comm(pid)
|
|
40
|
+
Facter::Util::FileHelper.safe_read("/proc/#{pid}/comm", nil)&.strip
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.proc_cmdline(pid)
|
|
44
|
+
raw = Facter::Util::FileHelper.safe_read("/proc/#{pid}/cmdline", nil)
|
|
45
|
+
raw&.tr("\0", ' ')
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/facter/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openfact
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OpenVox Project
|
|
@@ -18,7 +18,7 @@ dependencies:
|
|
|
18
18
|
version: 1.15.5
|
|
19
19
|
- - "<"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 1.
|
|
21
|
+
version: 1.18.0
|
|
22
22
|
- - "!="
|
|
23
23
|
- !ruby/object:Gem::Version
|
|
24
24
|
version: 1.16.0
|
|
@@ -37,7 +37,7 @@ dependencies:
|
|
|
37
37
|
version: 1.15.5
|
|
38
38
|
- - "<"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.
|
|
40
|
+
version: 1.18.0
|
|
41
41
|
- - "!="
|
|
42
42
|
- !ruby/object:Gem::Version
|
|
43
43
|
version: 1.16.0
|
|
@@ -90,7 +90,7 @@ dependencies:
|
|
|
90
90
|
version: '1.28'
|
|
91
91
|
- - "<"
|
|
92
92
|
- !ruby/object:Gem::Version
|
|
93
|
-
version: '1.
|
|
93
|
+
version: '1.85'
|
|
94
94
|
type: :development
|
|
95
95
|
prerelease: false
|
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -100,49 +100,69 @@ dependencies:
|
|
|
100
100
|
version: '1.28'
|
|
101
101
|
- - "<"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '1.
|
|
103
|
+
version: '1.85'
|
|
104
104
|
- !ruby/object:Gem::Dependency
|
|
105
105
|
name: rubocop-performance
|
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 1.5
|
|
110
|
+
version: '1.5'
|
|
111
111
|
type: :development
|
|
112
112
|
prerelease: false
|
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
115
|
- - "~>"
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: 1.5
|
|
117
|
+
version: '1.5'
|
|
118
|
+
- !ruby/object:Gem::Dependency
|
|
119
|
+
name: rubocop-rake
|
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "<"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '1'
|
|
125
|
+
type: :development
|
|
126
|
+
prerelease: false
|
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "<"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '1'
|
|
118
132
|
- !ruby/object:Gem::Dependency
|
|
119
133
|
name: rubocop-rspec
|
|
120
134
|
requirement: !ruby/object:Gem::Requirement
|
|
121
135
|
requirements:
|
|
122
|
-
- - "
|
|
136
|
+
- - ">="
|
|
123
137
|
- !ruby/object:Gem::Version
|
|
124
138
|
version: '2.10'
|
|
139
|
+
- - "<"
|
|
140
|
+
- !ruby/object:Gem::Version
|
|
141
|
+
version: '4'
|
|
125
142
|
type: :development
|
|
126
143
|
prerelease: false
|
|
127
144
|
version_requirements: !ruby/object:Gem::Requirement
|
|
128
145
|
requirements:
|
|
129
|
-
- - "
|
|
146
|
+
- - ">="
|
|
130
147
|
- !ruby/object:Gem::Version
|
|
131
148
|
version: '2.10'
|
|
149
|
+
- - "<"
|
|
150
|
+
- !ruby/object:Gem::Version
|
|
151
|
+
version: '4'
|
|
132
152
|
- !ruby/object:Gem::Dependency
|
|
133
153
|
name: simplecov
|
|
134
154
|
requirement: !ruby/object:Gem::Requirement
|
|
135
155
|
requirements:
|
|
136
156
|
- - "~>"
|
|
137
157
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: 0.17
|
|
158
|
+
version: '0.17'
|
|
139
159
|
type: :development
|
|
140
160
|
prerelease: false
|
|
141
161
|
version_requirements: !ruby/object:Gem::Requirement
|
|
142
162
|
requirements:
|
|
143
163
|
- - "~>"
|
|
144
164
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: 0.17
|
|
165
|
+
version: '0.17'
|
|
146
166
|
- !ruby/object:Gem::Dependency
|
|
147
167
|
name: sys-filesystem
|
|
148
168
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -814,6 +834,7 @@ files:
|
|
|
814
834
|
- lib/facter/facts/openbsd/os/name.rb
|
|
815
835
|
- lib/facter/facts/openbsd/os/release.rb
|
|
816
836
|
- lib/facter/facts/openbsd/path.rb
|
|
837
|
+
- lib/facter/facts/openbsd/processors/count.rb
|
|
817
838
|
- lib/facter/facts/openbsd/processors/isa.rb
|
|
818
839
|
- lib/facter/facts/openbsd/ruby/platform.rb
|
|
819
840
|
- lib/facter/facts/openbsd/ruby/sitedir.rb
|
|
@@ -1145,6 +1166,7 @@ files:
|
|
|
1145
1166
|
- lib/facter/resolvers/openbsd/dhcp.rb
|
|
1146
1167
|
- lib/facter/resolvers/openbsd/dmi.rb
|
|
1147
1168
|
- lib/facter/resolvers/openbsd/mountpoints.rb
|
|
1169
|
+
- lib/facter/resolvers/openbsd/processors.rb
|
|
1148
1170
|
- lib/facter/resolvers/openbsd/virtual.rb
|
|
1149
1171
|
- lib/facter/resolvers/os_release.rb
|
|
1150
1172
|
- lib/facter/resolvers/partitions.rb
|
|
@@ -1223,6 +1245,7 @@ files:
|
|
|
1223
1245
|
- lib/facter/util/facts/uptime_parser.rb
|
|
1224
1246
|
- lib/facter/util/facts/windows_release_finder.rb
|
|
1225
1247
|
- lib/facter/util/file_helper.rb
|
|
1248
|
+
- lib/facter/util/linux.rb
|
|
1226
1249
|
- lib/facter/util/linux/dhcp.rb
|
|
1227
1250
|
- lib/facter/util/linux/if_inet6.rb
|
|
1228
1251
|
- lib/facter/util/linux/proc.rb
|