ohai 16.6.5 → 16.10.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -11
  3. data/bin/ohai +1 -0
  4. data/lib/ohai.rb +1 -0
  5. data/lib/ohai/application.rb +1 -0
  6. data/lib/ohai/common/dmi.rb +1 -0
  7. data/lib/ohai/config.rb +1 -0
  8. data/lib/ohai/dsl.rb +1 -0
  9. data/lib/ohai/dsl/plugin.rb +2 -1
  10. data/lib/ohai/dsl/plugin/versionvii.rb +1 -2
  11. data/lib/ohai/exception.rb +1 -0
  12. data/lib/ohai/hints.rb +1 -0
  13. data/lib/ohai/log.rb +1 -0
  14. data/lib/ohai/mash.rb +1 -0
  15. data/lib/ohai/mixin/azure_metadata.rb +4 -3
  16. data/lib/ohai/mixin/chef_utils_wiring.rb +1 -0
  17. data/lib/ohai/mixin/command.rb +1 -0
  18. data/lib/ohai/mixin/constant_helper.rb +1 -0
  19. data/lib/ohai/mixin/dmi_decode.rb +1 -0
  20. data/lib/ohai/mixin/do_metadata.rb +3 -2
  21. data/lib/ohai/mixin/ec2_metadata.rb +37 -11
  22. data/lib/ohai/mixin/gce_metadata.rb +4 -3
  23. data/lib/ohai/mixin/http_helper.rb +1 -0
  24. data/lib/ohai/mixin/network_helper.rb +1 -0
  25. data/lib/ohai/mixin/os.rb +1 -0
  26. data/lib/ohai/mixin/scaleway_metadata.rb +3 -2
  27. data/lib/ohai/mixin/seconds_to_human.rb +1 -0
  28. data/lib/ohai/mixin/shell_out.rb +1 -0
  29. data/lib/ohai/mixin/softlayer_metadata.rb +2 -1
  30. data/lib/ohai/mixin/string.rb +1 -0
  31. data/lib/ohai/mixin/train_helpers.rb +1 -0
  32. data/lib/ohai/mixin/which.rb +1 -0
  33. data/lib/ohai/plugin_config.rb +1 -0
  34. data/lib/ohai/plugins/aix/kernel.rb +7 -4
  35. data/lib/ohai/plugins/aix/memory.rb +4 -3
  36. data/lib/ohai/plugins/aix/network.rb +51 -58
  37. data/lib/ohai/plugins/aix/platform.rb +3 -2
  38. data/lib/ohai/plugins/aix/uptime.rb +3 -2
  39. data/lib/ohai/plugins/aix/virtualization.rb +6 -6
  40. data/lib/ohai/plugins/azure.rb +1 -0
  41. data/lib/ohai/plugins/bsd/virtualization.rb +2 -1
  42. data/lib/ohai/plugins/c.rb +4 -3
  43. data/lib/ohai/plugins/chef.rb +1 -0
  44. data/lib/ohai/plugins/cloud.rb +2 -1
  45. data/lib/ohai/plugins/command.rb +1 -0
  46. data/lib/ohai/plugins/cpu.rb +27 -28
  47. data/lib/ohai/plugins/darwin/hardware.rb +1 -0
  48. data/lib/ohai/plugins/darwin/memory.rb +2 -3
  49. data/lib/ohai/plugins/darwin/network.rb +8 -9
  50. data/lib/ohai/plugins/darwin/platform.rb +1 -0
  51. data/lib/ohai/plugins/darwin/virtualization.rb +1 -0
  52. data/lib/ohai/plugins/digital_ocean.rb +3 -1
  53. data/lib/ohai/plugins/dmi.rb +5 -4
  54. data/lib/ohai/plugins/docker.rb +2 -1
  55. data/lib/ohai/plugins/dragonflybsd/memory.rb +9 -8
  56. data/lib/ohai/plugins/dragonflybsd/network.rb +1 -0
  57. data/lib/ohai/plugins/dragonflybsd/platform.rb +3 -2
  58. data/lib/ohai/plugins/ec2.rb +4 -0
  59. data/lib/ohai/plugins/elixir.rb +1 -1
  60. data/lib/ohai/plugins/erlang.rb +1 -0
  61. data/lib/ohai/plugins/eucalyptus.rb +4 -1
  62. data/lib/ohai/plugins/filesystem.rb +1 -1
  63. data/lib/ohai/plugins/fips.rb +1 -0
  64. data/lib/ohai/plugins/freebsd/memory.rb +9 -8
  65. data/lib/ohai/plugins/freebsd/network.rb +1 -0
  66. data/lib/ohai/plugins/freebsd/platform.rb +3 -2
  67. data/lib/ohai/plugins/gce.rb +1 -0
  68. data/lib/ohai/plugins/go.rb +1 -1
  69. data/lib/ohai/plugins/groovy.rb +1 -1
  70. data/lib/ohai/plugins/grub2.rb +40 -0
  71. data/lib/ohai/plugins/haskell.rb +1 -0
  72. data/lib/ohai/plugins/hostname.rb +2 -2
  73. data/lib/ohai/plugins/init_package.rb +1 -0
  74. data/lib/ohai/plugins/java.rb +1 -0
  75. data/lib/ohai/plugins/kernel.rb +7 -8
  76. data/lib/ohai/plugins/keys.rb +1 -0
  77. data/lib/ohai/plugins/languages.rb +1 -0
  78. data/lib/ohai/plugins/libvirt.rb +4 -3
  79. data/lib/ohai/plugins/linode.rb +22 -14
  80. data/lib/ohai/plugins/linux/block_device.rb +1 -0
  81. data/lib/ohai/plugins/linux/hostnamectl.rb +3 -2
  82. data/lib/ohai/plugins/linux/interrupts.rb +1 -0
  83. data/lib/ohai/plugins/linux/ipc.rb +1 -0
  84. data/lib/ohai/plugins/linux/lsb.rb +6 -19
  85. data/lib/ohai/plugins/linux/lspci.rb +1 -1
  86. data/lib/ohai/plugins/linux/machineid.rb +1 -0
  87. data/lib/ohai/plugins/linux/mdadm.rb +1 -0
  88. data/lib/ohai/plugins/linux/memory.rb +37 -36
  89. data/lib/ohai/plugins/linux/network.rb +30 -4
  90. data/lib/ohai/plugins/linux/platform.rb +6 -2
  91. data/lib/ohai/plugins/linux/selinux.rb +1 -0
  92. data/lib/ohai/plugins/linux/sessions.rb +1 -0
  93. data/lib/ohai/plugins/linux/sysctl.rb +1 -0
  94. data/lib/ohai/plugins/linux/systemd_paths.rb +1 -0
  95. data/lib/ohai/plugins/linux/virtualization.rb +1 -0
  96. data/lib/ohai/plugins/lua.rb +1 -1
  97. data/lib/ohai/plugins/mono.rb +1 -1
  98. data/lib/ohai/plugins/netbsd/memory.rb +1 -0
  99. data/lib/ohai/plugins/netbsd/network.rb +1 -0
  100. data/lib/ohai/plugins/netbsd/platform.rb +3 -2
  101. data/lib/ohai/plugins/network.rb +2 -1
  102. data/lib/ohai/plugins/nodejs.rb +1 -1
  103. data/lib/ohai/plugins/ohai.rb +1 -0
  104. data/lib/ohai/plugins/ohai_time.rb +1 -0
  105. data/lib/ohai/plugins/openbsd/memory.rb +1 -0
  106. data/lib/ohai/plugins/openbsd/network.rb +1 -0
  107. data/lib/ohai/plugins/openbsd/platform.rb +3 -2
  108. data/lib/ohai/plugins/openstack.rb +1 -0
  109. data/lib/ohai/plugins/os.rb +2 -1
  110. data/lib/ohai/plugins/packages.rb +2 -1
  111. data/lib/ohai/plugins/passwd.rb +2 -1
  112. data/lib/ohai/plugins/perl.rb +1 -1
  113. data/lib/ohai/plugins/php.rb +1 -1
  114. data/lib/ohai/plugins/platform.rb +1 -0
  115. data/lib/ohai/plugins/powershell.rb +1 -1
  116. data/lib/ohai/plugins/ps.rb +1 -0
  117. data/lib/ohai/plugins/python.rb +1 -1
  118. data/lib/ohai/plugins/rackspace.rb +6 -5
  119. data/lib/ohai/plugins/root_group.rb +1 -0
  120. data/lib/ohai/plugins/ruby.rb +3 -2
  121. data/lib/ohai/plugins/rust.rb +1 -1
  122. data/lib/ohai/plugins/scala.rb +1 -0
  123. data/lib/ohai/plugins/scaleway.rb +2 -1
  124. data/lib/ohai/plugins/scsi.rb +1 -1
  125. data/lib/ohai/plugins/shard.rb +1 -1
  126. data/lib/ohai/plugins/shells.rb +1 -0
  127. data/lib/ohai/plugins/softlayer.rb +1 -0
  128. data/lib/ohai/plugins/solaris2/dmi.rb +1 -0
  129. data/lib/ohai/plugins/solaris2/memory.rb +1 -0
  130. data/lib/ohai/plugins/solaris2/network.rb +2 -1
  131. data/lib/ohai/plugins/solaris2/platform.rb +6 -12
  132. data/lib/ohai/plugins/solaris2/virtualization.rb +3 -3
  133. data/lib/ohai/plugins/ssh_host_key.rb +1 -0
  134. data/lib/ohai/plugins/sysconf.rb +1 -0
  135. data/lib/ohai/plugins/timezone.rb +1 -0
  136. data/lib/ohai/plugins/train.rb +1 -1
  137. data/lib/ohai/plugins/uptime.rb +2 -1
  138. data/lib/ohai/plugins/virtualbox.rb +2 -1
  139. data/lib/ohai/plugins/vmware.rb +2 -2
  140. data/lib/ohai/plugins/windows/dmi.rb +1 -0
  141. data/lib/ohai/plugins/windows/drivers.rb +1 -0
  142. data/lib/ohai/plugins/windows/memory.rb +1 -0
  143. data/lib/ohai/plugins/windows/network.rb +2 -1
  144. data/lib/ohai/plugins/windows/platform.rb +1 -0
  145. data/lib/ohai/plugins/windows/system_enclosure.rb +1 -0
  146. data/lib/ohai/plugins/windows/virtualization.rb +1 -0
  147. data/lib/ohai/plugins/zpools.rb +5 -3
  148. data/lib/ohai/provides_map.rb +1 -0
  149. data/lib/ohai/runner.rb +3 -4
  150. data/lib/ohai/system.rb +1 -0
  151. data/lib/ohai/train_transport.rb +1 -0
  152. data/lib/ohai/util/file_helper.rb +1 -0
  153. data/lib/ohai/util/ip_helper.rb +2 -1
  154. data/lib/ohai/util/win32.rb +1 -0
  155. data/lib/ohai/version.rb +2 -1
  156. data/ohai.gemspec +2 -1
  157. metadata +14 -14
  158. data/lib/ohai/plugins/joyent.rb +0 -77
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Joshua Timberman <joshua@chef.io>
3
4
  # Author:: Isa Farnik (<isa@chef.io>)
@@ -24,10 +25,10 @@ Ohai.plugin(:Memory) do
24
25
  memory Mash.new
25
26
  memory[:swap] = Mash.new
26
27
 
27
- meminfo = shell_out("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").stdout
28
+ meminfo = shell_out("svmon -G -O unit=KB,summary=longreal | grep '[0-9]'").stdout
28
29
  total_in_mb, _u, free_in_mb = meminfo.split
29
- memory[:total] = "#{total_in_mb.to_i * 1024}kB"
30
- memory[:free] = "#{free_in_mb.to_i * 1024}kB"
30
+ memory[:total] = "#{total_in_mb.to_i}kB"
31
+ memory[:free] = "#{free_in_mb.to_i}kB"
31
32
 
32
33
  swap_info = shell_out("swap -s").stdout.split # returns swap info in 4K blocks
33
34
  memory[:swap]["total"] = "#{swap_info[2].to_i * 4}kB"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
3
4
  # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
@@ -21,7 +22,7 @@
21
22
  Ohai.plugin(:Network) do
22
23
  require_relative "../../mixin/network_helper"
23
24
 
24
- provides "network", "counters/network", "macaddress"
25
+ provides "network", "network/interfaces", "counters/network", "macaddress"
25
26
 
26
27
  include Ohai::Mixin::NetworkHelper
27
28
 
@@ -37,46 +38,44 @@ Ohai.plugin(:Network) do
37
38
  # => state up/down (ifconfig/lsattr)
38
39
  # => arp (arp -an)
39
40
 
40
- iface = Mash.new
41
+ ifaces = Mash.new
41
42
 
42
43
  network Mash.new unless network
43
- network[:interfaces] ||= Mash.new
44
44
 
45
45
  # We unfortunately have to do things a bit different here, if ohai is running
46
46
  # within a WPAR. For instance, the WPAR isn't aware of some of its own networking
47
- # minutia such as default gateway/route.
47
+ # minutia such as default gateway/route. lpars return 0 here. wpars return > 0
48
48
  unless shell_out("uname -W").stdout.to_i > 0
49
49
  # :default_interface, :default_gateway - route -n get 0
50
- so = shell_out("netstat -rn |grep default")
51
- so.stdout.lines.each do |line|
52
- items = line.split(" ")
53
- if items[0] == "default"
54
- network[:default_gateway] = items[1]
55
- network[:default_interface] = items[5]
56
- end
57
- end
50
+ default_line = shell_out("netstat -rn")
51
+ .stdout
52
+ .each_line
53
+ .detect { |l| l.start_with?("default") }
54
+ .split
55
+ network[:default_gateway] = default_line[1]
56
+ network[:default_interface] = default_line[5]
58
57
  end
59
58
 
60
- # Splits the ifconfig output to 1 line per interface
61
- if_so = shell_out("ifconfig -a")
62
- if_so.stdout.gsub(/\n(\w+\d+)/, '___\1').split("___").each do |intraface|
63
- splat = intraface.split(":")
64
- interface = splat[0]
65
- line = splat[1..-1][0]
66
- iface[interface] = Mash.new
67
- iface[interface][:state] = (line.include?("<UP,") ? "up" : "down")
68
-
69
- intraface.lines.each do |lin|
70
- case lin
59
+ # Splits the ifconfig output into arrays of interface strings
60
+ shell_out("ifconfig -a").stdout.split(/\n(?=\w)/).each do |int_lines|
61
+ int_name, int_data = int_lines.split(":", 2)
62
+
63
+ ifaces[int_name] = Mash.new
64
+ ifaces[int_name][:addresses] ||= Mash.new
65
+ ifaces[int_name][:state] = (int_data.include?("<UP,") ? "up" : "down")
66
+
67
+ int_data.each_line do |line|
68
+ case line
71
69
  when /flags=\S+<(\S+)>/
72
- iface[interface][:flags] = $1.split(",")
73
- iface[interface][:metric] = $1 if lin =~ /metric\s(\S+)/
70
+ ifaces[int_name][:flags] = $1.split(",")
71
+ ifaces[int_name][:metric] = $1 if line =~ /metric\s(\S+)/
74
72
  else
75
73
  # We have key value pairs.
76
- if lin =~ %r{inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(/(\d{1,2}))?}
77
- tmp_addr, tmp_prefix = $1, $3
74
+ if line =~ %r{inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(/(\d{1,2}))?}
75
+ tmp_addr = $1
76
+ tmp_prefix = $3
78
77
  if tmp_prefix.nil?
79
- netmask = hex_to_dec_netmask($1) if lin =~ /netmask\s0x(\S+)\s/
78
+ netmask = hex_to_dec_netmask($1) if line =~ /netmask\s0x(\S+)\s/
80
79
  unless netmask
81
80
  tmp_prefix ||= "32"
82
81
  netmask = IPAddr.new("255.255.255.255").mask(tmp_prefix.to_i).to_s
@@ -85,57 +84,51 @@ Ohai.plugin(:Network) do
85
84
  netmask = IPAddr.new("255.255.255.255").mask(tmp_prefix.to_i).to_s
86
85
  end
87
86
 
88
- iface[interface][:addresses] ||= Mash.new
89
- iface[interface][:addresses][tmp_addr] = { "family" => "inet", "prefixlen" => tmp_prefix }
90
- iface[interface][:addresses][tmp_addr][:netmask] = netmask
87
+ ifaces[int_name][:addresses][tmp_addr] = { "family" => "inet", "prefixlen" => tmp_prefix }
88
+ ifaces[int_name][:addresses][tmp_addr][:netmask] = netmask
91
89
 
92
- if lin =~ /broadcast\s(\S+)\s/
93
- iface[interface][:addresses][tmp_addr][:broadcast] = $1
90
+ if line =~ /broadcast\s(\S+)\s/
91
+ ifaces[int_name][:addresses][tmp_addr][:broadcast] = $1
94
92
  end
95
- elsif lin =~ %r{inet6 ([a-f0-9\:]+)%?([\d]*)/?(\d*)?}
96
- # TODO do we have more properties on inet6 in aix? broadcast
97
- iface[interface][:addresses] ||= Mash.new
98
- iface[interface][:addresses][$1] = { "family" => "inet6", "zone_index" => $2, "prefixlen" => $3 }
93
+ elsif line =~ %r{inet6 ([a-f0-9\:]+)%?(\d*)/?(\d*)?}
94
+ # TODO: do we have more properties on inet6 in aix? broadcast
95
+ ifaces[int_name][:addresses] ||= Mash.new
96
+ ifaces[int_name][:addresses][$1] = { "family" => "inet6", "zone_index" => $2, "prefixlen" => $3 }
99
97
  else
100
- # load all key-values, example "tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1"
101
- properties = lin.split
102
- n = properties.length / 2 - 1
103
- (0..n).each do |i|
104
- iface[interface][properties[i * 2]] = properties[(i * 2 + 1)]
98
+ # add all key value data into the interface mash
99
+ # for example "tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1"
100
+ # has keys tcp_sendspace, tcp_recvspace, and rfc1323
101
+ line.split.each_slice(2) do |key, value|
102
+ ifaces[int_name][key] = value
105
103
  end
106
104
  end
107
105
  end
108
106
  end
109
107
 
110
108
  # Query macaddress
111
- e_so = shell_out("entstat -d #{interface} | grep \"Hardware Address\"")
112
- iface[interface][:addresses] ||= Mash.new
113
- e_so.stdout.lines.each do |l|
114
- if l =~ /Hardware Address: (\S+)/
115
- iface[interface][:addresses][$1.upcase] = { "family" => "lladdr" }
116
- macaddress $1.upcase unless shell_out("uname -W").stdout.to_i > 0
117
- end
109
+ shell_out("entstat -d #{int_name}").stdout =~ /Hardware Address: (\S+)/
110
+ if $1
111
+ ifaces[int_name][:addresses][$1.upcase] = { "family" => "lladdr" }
112
+ macaddress $1.upcase unless shell_out("uname -W").stdout.to_i > 0
118
113
  end
119
114
  end # ifconfig stdout
120
115
 
121
116
  # Query routes information
122
117
  %w{inet inet6}.each do |family|
123
- so_n = shell_out("netstat -nrf #{family}")
124
- so_n.stdout.lines.each do |line|
118
+ shell_out("netstat -nrf #{family}").stdout.each_line do |line|
125
119
  if line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\S+)/
126
120
  interface = $6
127
- iface[interface][:routes] = [] unless iface[interface][:routes]
128
- iface[interface][:routes] << Mash.new( destination: $1, family: family,
129
- via: $2, flags: $3)
121
+ ifaces[interface][:routes] ||= []
122
+ ifaces[interface][:routes] << Mash.new( destination: $1, family: family,
123
+ via: $2, flags: $3)
130
124
  end
131
125
  end
132
126
  end
133
127
 
134
128
  # List the arp entries in system.
135
- so = shell_out("arp -an")
136
129
  count = 0
137
- so.stdout.lines.each do |line|
138
- network[:arp] ||= Mash.new
130
+ network[:arp] ||= Mash.new
131
+ shell_out("arp -an").stdout.each_line do |line|
139
132
  if line =~ /\s*(\S+) \((\S+)\) at ([a-fA-F0-9\:]+) \[(\w+)\] stored in bucket/
140
133
  network[:arp][count] ||= Mash.new
141
134
  network[:arp][count][:remote_host] = $1
@@ -144,6 +137,6 @@ Ohai.plugin(:Network) do
144
137
  count += 1
145
138
  end
146
139
  end
147
- network["interfaces"] = iface
140
+ network["interfaces"] = ifaces
148
141
  end
149
142
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Joshua Timberman <joshua@chef.io>
3
4
  # Author:: Isa Farnik (<isa@chef.io>)
@@ -22,8 +23,8 @@ Ohai.plugin(:Platform) do
22
23
  depends "kernel"
23
24
 
24
25
  collect_data(:aix) do
25
- platform kernel[:name]
26
+ platform "aix"
27
+ platform_family "aix"
26
28
  platform_version [kernel[:version], kernel[:release]].join(".")
27
- platform_family platform
28
29
  end
29
30
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Kurt Yoder (<ktyopscode@yoderhome.com>)
3
4
  # Author:: Isa Farnik (<isa@chef.io>)
@@ -40,9 +41,9 @@ Ohai.plugin(:Uptime) do
40
41
  when /^\d+-\d/
41
42
  (d, h, m, s) = so.split(/[-:]/)
42
43
  when /^\d+:\d+:\d/
43
- (h, m, s) = so.split(/[:]/)
44
+ (h, m, s) = so.split(":")
44
45
  else
45
- (m, s) = so.split(/[:]/)
46
+ (m, s) = so.split(":")
46
47
  end
47
48
  elapsed_seconds = ((d.to_i * 86400) + (h.to_i * 3600) + (m.to_i * 60) + s.to_i)
48
49
 
@@ -23,17 +23,14 @@ Ohai.plugin(:Virtualization) do
23
23
  collect_data(:aix) do
24
24
  virtualization Mash.new
25
25
 
26
- so = shell_out("uname -L")
27
- lpar_no = so.stdout.split($/)[0].split(/\s/)[0]
28
- lpar_name = so.stdout.split($/)[0].split(/\s/)[1]
26
+ lpar_no, lpar_name = shell_out("uname -L").stdout.split(nil, 2)
29
27
 
30
28
  unless lpar_no.to_i == -1 || (lpar_no.to_i == 1 && lpar_name == "NULL")
31
29
  virtualization[:lpar_no] = lpar_no
32
30
  virtualization[:lpar_name] = lpar_name
33
31
  end
34
32
 
35
- so = shell_out("uname -W")
36
- wpar_no = so.stdout.split($/)[0]
33
+ wpar_no = shell_out("uname -W").stdout.strip
37
34
  if wpar_no.to_i > 0
38
35
  virtualization[:wpar_no] = wpar_no
39
36
  else
@@ -41,8 +38,11 @@ Ohai.plugin(:Virtualization) do
41
38
  so = shell_out("lswpar -L").stdout.scan(/={65}.*?(?:EXPORTED\n\n)+/m)
42
39
  wpars = Mash.new
43
40
  so.each do |wpar|
44
- wpar_name = wpar.lines[1].split[0]
41
+ wpar_heading = wpar.lines[1].split
42
+ wpar_name = wpar_heading[0]
43
+
45
44
  wpars[wpar_name] = Mash.new
45
+ wpars[wpar_name][:state] = wpar_heading[2].downcase
46
46
 
47
47
  wpar.scan(/^[A-Z]{4,}.*?[A-Z\:0-9]$.*?\n\n/m).each do |section|
48
48
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Copyright:: Copyright (c) Chef Software Inc.
2
3
  # License:: Apache License, Version 2.0
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Bryan McLellan (btm@loftninjas.org)
3
4
  # Copyright:: Copyright (c) 2009 Bryan McLellan
@@ -30,7 +31,7 @@ Ohai.plugin(:Virtualization) do
30
31
 
31
32
  # detect when in a jail or when a jail is actively running (not in stopped state)
32
33
  so = shell_out("sysctl -n security.jail.jailed")
33
- if so.stdout.split($/)[0].to_i == 1
34
+ if so.stdout.strip.to_i == 1
34
35
  virtualization[:system] = "jail"
35
36
  virtualization[:role] = "guest"
36
37
  virtualization[:systems][:jail] = "guest"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Doug MacEachern <dougm@vmware.com>
3
4
  # Copyright:: Copyright (c) 2010 VMware, Inc.
@@ -122,12 +123,12 @@ Ohai.plugin(:C) do
122
123
  end
123
124
 
124
125
  def collect_xlc
125
- # ibm xlc
126
-
126
+ # IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)
127
+ # Version: 13.01.0003.0000
127
128
  so = shell_out("xlc -qversion")
128
129
  if so.exitstatus == 0 || (so.exitstatus >> 8) == 249
129
130
  description = so.stdout.split($/).first
130
- if description =~ /V(\d+\.\d+)/
131
+ if description =~ /V(\d+\.\d+(.\d+)?)/
131
132
  @c[:xlc] = Mash.new
132
133
  @c[:xlc][:version] = $1
133
134
  @c[:xlc][:description] = description.strip
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Tollef Fog Heen <tfheen@err.no>
3
4
  # Copyright:: Copyright (c) 2010 Tollef Fog Heen
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Cary Penniman (<cary@rightscale.com>)
3
4
  # License:: Apache License, Version 2.0
@@ -109,7 +110,7 @@ Ohai.plugin(:Cloud) do
109
110
  ipaddr = ""
110
111
  begin
111
112
  ipaddr = IPAddr.new(ip)
112
- raise ArgumentError, "not valid #{address_family} address" unless (address_family == :ipv4) ? ipaddr.ipv4? : ipaddr.ipv6?
113
+ raise ArgumentError, "not valid #{address_family} address" unless address_family == :ipv4 ? ipaddr.ipv4? : ipaddr.ipv6?
113
114
  rescue ArgumentError => e
114
115
  raise "ERROR: the ohai 'cloud' plugin failed with an IP address of '#{ip}' : #{e.message}"
115
116
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Author:: Bryan McLellan (btm@loftninjas.org)
@@ -35,11 +36,9 @@ Ohai.plugin(:CPU) do
35
36
  when /CPU:\s+(.+) \(([\d.]+).+\)/
36
37
  cpuinfo["model_name"] = $1
37
38
  cpuinfo["mhz"] = $2
38
- when /Features=.+<(.+)>/
39
+ when /Features=.+<(.+)>/, /Features2=[a-f\dx]+<(.+)>/
39
40
  cpuinfo["flags"].concat($1.downcase.split(","))
40
41
  # Features2=0x80000001<SSE3,<b31>>
41
- when /Features2=[a-f\dx]+<(.+)>/
42
- cpuinfo["flags"].concat($1.downcase.split(","))
43
42
  else
44
43
  yield(cpuinfo, line)
45
44
  end
@@ -86,15 +85,15 @@ Ohai.plugin(:CPU) do
86
85
  when /cache size\s+:\s(.+)/
87
86
  cpuinfo[current_cpu]["cache_size"] = $1
88
87
  when /flags\s+:\s(.+)/
89
- cpuinfo[current_cpu]["flags"] = $1.split(" ")
88
+ cpuinfo[current_cpu]["flags"] = $1.split
90
89
  when /BogoMIPS\s+:\s(.+)/
91
90
  cpuinfo[current_cpu]["bogomips"] = $1
92
91
  when /Features\s+:\s(.+)/
93
- cpuinfo[current_cpu]["features"] = $1.split(" ")
92
+ cpuinfo[current_cpu]["features"] = $1.split
94
93
  when /bogomips per cpu:\s(.+)/
95
94
  cpuinfo["bogomips_per_cpu"] = $1
96
95
  when /features\s+:\s(.+)/
97
- cpuinfo["features"] = $1.split(" ")
96
+ cpuinfo["features"] = $1.split
98
97
  when /processor\s(\d):\s(.+)/
99
98
  current_cpu = $1
100
99
  cpu_number += 1
@@ -201,7 +200,7 @@ Ohai.plugin(:CPU) do
201
200
  end
202
201
 
203
202
  so = shell_out("sysctl -n hw.ncpu")
204
- info[:total] = so.stdout.split($/)[0].to_i
203
+ info[:total] = so.stdout.strip.to_i
205
204
  cpu info
206
205
  end
207
206
 
@@ -221,7 +220,7 @@ Ohai.plugin(:CPU) do
221
220
 
222
221
  [["hw.model", :model_name], ["hw.ncpu", :total], ["hw.cpuspeed", :mhz]].each do |param, node|
223
222
  so = shell_out("sysctl -n #{param}")
224
- cpuinfo[node] = so.stdout.split($/)[0]
223
+ cpuinfo[node] = so.stdout.strip
225
224
  end
226
225
 
227
226
  cpu cpuinfo
@@ -279,7 +278,7 @@ Ohai.plugin(:CPU) do
279
278
  when /^machdep.cpu.stepping: (.*)$/
280
279
  cpu[:stepping] = Regexp.last_match[1].to_i
281
280
  when /^machdep.cpu.features: (.*)$/
282
- cpu[:flags] = Regexp.last_match[1].downcase.split(" ")
281
+ cpu[:flags] = Regexp.last_match[1].downcase.split
283
282
  end
284
283
  end
285
284
  end
@@ -349,25 +348,25 @@ Ohai.plugin(:CPU) do
349
348
  key = kv.shift
350
349
  value = kv.join(" ").chomp
351
350
  case key
352
- when /chip_id/
353
- cpu[instance]["socket"] = value
354
- cpusockets.push(value) if cpusockets.index(value).nil?
355
- when /cpu_type/
356
- cpu[instance]["arch"] = value
357
- when /clock_MHz/
358
- cpu[instance]["mhz"] = value
359
- when /brand/
360
- cpu[instance]["model_name"] = value.sub(/\s+/, " ")
361
- when /^state$/
362
- cpu[instance]["state"] = value
363
- cpu["cpustates"][value] ||= 0
364
- cpu["cpustates"][value] += 1
365
- when /core_id/
366
- cpu[instance]["core_id"] = value
367
- # Detect hyperthreading/multithreading
368
- cpucores.push(value) if cpucores.index(value).nil?
369
- when /family|fpu_type|model|stepping|vendor_id/
370
- cpu[instance][key] = value
351
+ when /chip_id/
352
+ cpu[instance]["socket"] = value
353
+ cpusockets.push(value) if cpusockets.index(value).nil?
354
+ when /cpu_type/
355
+ cpu[instance]["arch"] = value
356
+ when /clock_MHz/
357
+ cpu[instance]["mhz"] = value
358
+ when /brand/
359
+ cpu[instance]["model_name"] = value.sub(/\s+/, " ")
360
+ when /^state$/
361
+ cpu[instance]["state"] = value
362
+ cpu["cpustates"][value] ||= 0
363
+ cpu["cpustates"][value] += 1
364
+ when /core_id/
365
+ cpu[instance]["core_id"] = value
366
+ # Detect hyperthreading/multithreading
367
+ cpucores.push(value) if cpucores.index(value).nil?
368
+ when /family|fpu_type|model|stepping|vendor_id/
369
+ cpu[instance][key] = value
371
370
  end
372
371
  end
373
372
  cpu["cores"] = cpucores.size
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Nate Walck (<nate.walck@gmail.com>)
3
4
  # Copyright:: Copyright (c) 2016-present Facebook, Inc.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Patrick Collins (<pat@burned.com>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -43,9 +44,7 @@ Ohai.plugin(:Memory) do
43
44
  megabyte_val = (pages * page_size) / 1024 / 1024.0
44
45
  total_consumed += megabyte_val
45
46
  case match
46
- when "wired down"
47
- active += megabyte_val.to_i
48
- when "active"
47
+ when "wired down", "active"
49
48
  active += megabyte_val.to_i
50
49
  when "inactive"
51
50
  inactive += megabyte_val.to_i