File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
hanlon_microkernel/facter Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 17
17
lshw_c_cpu_str = %x[sudo #{ lshw_cmd } -c cpu 2> /dev/null]
18
18
19
19
# process the results from lshw -c cpu
20
+ cpus = 0
20
21
lshw_c_cpu_str . split ( /\s \s \* -/ ) . each do |definition |
21
22
unless definition . empty?
22
23
lines = definition . split ( /\n / )
23
24
# section title is on the first line
24
25
cpu = lines . shift . tr ( ':' , '' )
26
+ cpus += 1
25
27
# Create a hash of attributes for each section (i.e. cpu)
26
28
attribs = Hash [ lines . collect { |l | l =~ /^\s *([^:]+):\s +(.*)\s *$/ ; v = $2; [ $1. gsub ( /\s / , '_' ) , v ] } ]
27
29
attribs . each_pair do |attrib , val |
32
34
end
33
35
end
34
36
37
+ # report on the number of CPUs
38
+ Facter . add ( "mk_hw_cpu_count" ) do
39
+ setcode { cpus }
40
+ end
35
41
36
42
# process the results from lscpu
37
43
facts_to_report = %w{ Architecture BogoMIPS Byte_Order CPU_MHz CPU_family CPU_op-modes
Original file line number Diff line number Diff line change 17
17
lshw_c_disk_str = %x[sudo #{ lshw_cmd } -c disk 2> /dev/null]
18
18
19
19
# process the results from lshw -c disk
20
+ disks = 0
20
21
lshw_c_disk_str . split ( /\s \s \* -/ ) . each do |definition |
21
22
unless definition . empty?
22
23
lines = definition . split ( /\n / )
23
24
# section title is on the first line
24
25
disk = lines . shift . tr ( ':' , '' )
26
+ disks += 1
25
27
# Create a hash of attributes for each section (i.e. cpu)
26
28
attribs = Hash [ lines . collect { |l | l =~ /^\s *([^:]+):\s +(.*)\s *$/ ; v = $2; [ $1. gsub ( /\s / , '_' ) , v ] } ]
27
29
attribs . each_pair do |attrib , val |
31
33
end
32
34
end
33
35
end
36
+
37
+ Facter . add ( "mk_hw_disk_count" ) do
38
+ setcode { disks }
39
+ end
Original file line number Diff line number Diff line change 17
17
lshw_c_network_str = %x[sudo #{ lshw_cmd } -c network 2> /dev/null]
18
18
19
19
# process the results from lshw -c network
20
+ nics = 0
20
21
lshw_c_network_str . split ( /\s \s \* -/ ) . each do |definition |
21
22
unless definition . empty?
22
23
lines = definition . split ( /\n / )
23
24
# section title is on the first line
24
25
network = lines . shift . tr ( ':' , '' )
26
+ nics += 1
25
27
# Create a hash of attributes for each section (i.e. cpu)
26
28
attribs = Hash [ lines . collect { |l | l =~ /^\s *([^:]+):\s +(.*)\s *$/ ; v = $2; [ $1. gsub ( /\s / , '_' ) , v ] } ]
27
29
attribs . each_pair do |attrib , val |
31
33
end
32
34
end
33
35
end
36
+
37
+ # report on the number NICs found
38
+ Facter . add ( "mk_hw_nic_count" ) do
39
+ setcode { nics }
40
+ end
You can’t perform that action at this time.
0 commit comments