ohai 14.15.0 → 15.0.35

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/ohai/application.rb +0 -4
  4. data/lib/ohai/common/dmi.rb +43 -43
  5. data/lib/ohai/config.rb +1 -1
  6. data/lib/ohai/loader.rb +32 -47
  7. data/lib/ohai/mixin/dmi_decode.rb +29 -32
  8. data/lib/ohai/mixin/os.rb +0 -2
  9. data/lib/ohai/mixin/softlayer_metadata.rb +5 -5
  10. data/lib/ohai/plugins/aix/virtualization.rb +4 -4
  11. data/lib/ohai/plugins/bsd/virtualization.rb +10 -12
  12. data/lib/ohai/plugins/c.rb +0 -20
  13. data/lib/ohai/plugins/elixir.rb +13 -13
  14. data/lib/ohai/plugins/filesystem.rb +10 -10
  15. data/lib/ohai/plugins/gce.rb +42 -8
  16. data/lib/ohai/plugins/go.rb +11 -11
  17. data/lib/ohai/plugins/groovy.rb +12 -12
  18. data/lib/ohai/plugins/hostname.rb +9 -2
  19. data/lib/ohai/plugins/linux/fips.rb +2 -9
  20. data/lib/ohai/plugins/linux/memory.rb +5 -0
  21. data/lib/ohai/plugins/linux/network.rb +1 -1
  22. data/lib/ohai/plugins/linux/platform.rb +84 -83
  23. data/lib/ohai/plugins/linux/systemd_paths.rb +0 -3
  24. data/lib/ohai/plugins/linux/virtualization.rb +10 -20
  25. data/lib/ohai/plugins/lua.rb +13 -13
  26. data/lib/ohai/plugins/mono.rb +23 -23
  27. data/lib/ohai/plugins/nodejs.rb +13 -13
  28. data/lib/ohai/plugins/openstack.rb +1 -1
  29. data/lib/ohai/plugins/packages.rb +1 -28
  30. data/lib/ohai/plugins/perl.rb +17 -17
  31. data/lib/ohai/plugins/php.rb +22 -22
  32. data/lib/ohai/plugins/powershell.rb +30 -30
  33. data/lib/ohai/plugins/ps.rb +1 -1
  34. data/lib/ohai/plugins/python.rb +15 -15
  35. data/lib/ohai/plugins/rust.rb +11 -11
  36. data/lib/ohai/plugins/solaris2/dmi.rb +48 -48
  37. data/lib/ohai/plugins/solaris2/virtualization.rb +8 -10
  38. data/lib/ohai/plugins/virtualbox.rb +21 -21
  39. data/lib/ohai/plugins/windows/filesystem.rb +2 -2
  40. data/lib/ohai/plugins/windows/fips.rb +2 -21
  41. data/lib/ohai/plugins/windows/virtualization.rb +9 -35
  42. data/lib/ohai/runner.rb +2 -2
  43. data/lib/ohai/system.rb +0 -17
  44. data/lib/ohai/version.rb +1 -1
  45. data/ohai.gemspec +2 -2
  46. data/spec/data/plugins/rpmquery.output +0 -2
  47. data/spec/functional/application_spec.rb +1 -1
  48. data/spec/functional/loader_spec.rb +2 -2
  49. data/spec/functional/plugins/powershell_spec.rb +2 -2
  50. data/spec/functional/plugins/root_group_spec.rb +1 -1
  51. data/spec/functional/plugins/windows/uptime_spec.rb +2 -2
  52. data/spec/ohai_spec.rb +1 -1
  53. data/spec/unit/application_spec.rb +1 -1
  54. data/spec/unit/config_spec.rb +1 -1
  55. data/spec/unit/dsl/plugin_spec.rb +1 -1
  56. data/spec/unit/hints_spec.rb +2 -2
  57. data/spec/unit/loader_spec.rb +12 -12
  58. data/spec/unit/mixin/azure_metadata_spec.rb +1 -1
  59. data/spec/unit/mixin/command_spec.rb +1 -1
  60. data/spec/unit/mixin/dmi_decode.rb +68 -0
  61. data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
  62. data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
  63. data/spec/unit/plugin_config_spec.rb +1 -1
  64. data/spec/unit/plugins/abort_spec.rb +9 -9
  65. data/spec/unit/plugins/aix/cpu_spec.rb +4 -4
  66. data/spec/unit/plugins/aix/filesystem_spec.rb +5 -5
  67. data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
  68. data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
  69. data/spec/unit/plugins/aix/memory_spec.rb +1 -1
  70. data/spec/unit/plugins/aix/network_spec.rb +6 -6
  71. data/spec/unit/plugins/aix/platform_spec.rb +1 -1
  72. data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
  73. data/spec/unit/plugins/aix/virtualization_spec.rb +2 -2
  74. data/spec/unit/plugins/azure_spec.rb +1 -1
  75. data/spec/unit/plugins/bsd/filesystem_spec.rb +4 -4
  76. data/spec/unit/plugins/bsd/virtualization_spec.rb +3 -3
  77. data/spec/unit/plugins/c_spec.rb +1 -53
  78. data/spec/unit/plugins/chef_spec.rb +1 -1
  79. data/spec/unit/plugins/cloud_spec.rb +1 -1
  80. data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
  81. data/spec/unit/plugins/darwin/filesystem_spec.rb +5 -5
  82. data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
  83. data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +3 -3
  84. data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
  85. data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
  86. data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
  87. data/spec/unit/plugins/darwin/network_spec.rb +1 -1
  88. data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
  89. data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
  90. data/spec/unit/plugins/dmi_spec.rb +1 -1
  91. data/spec/unit/plugins/docker_spec.rb +1 -1
  92. data/spec/unit/plugins/ec2_spec.rb +1 -1
  93. data/spec/unit/plugins/elixir_spec.rb +1 -1
  94. data/spec/unit/plugins/erlang_spec.rb +1 -1
  95. data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
  96. data/spec/unit/plugins/fail_spec.rb +28 -28
  97. data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
  98. data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
  99. data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
  100. data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
  101. data/spec/unit/plugins/gce_spec.rb +1 -1
  102. data/spec/unit/plugins/go_spec.rb +1 -1
  103. data/spec/unit/plugins/groovy_spec.rb +1 -1
  104. data/spec/unit/plugins/haskell_spec.rb +1 -1
  105. data/spec/unit/plugins/hostname_spec.rb +68 -1
  106. data/spec/unit/plugins/init_package_spec.rb +1 -1
  107. data/spec/unit/plugins/java_spec.rb +1 -1
  108. data/spec/unit/plugins/joyent_spec.rb +3 -3
  109. data/spec/unit/plugins/kernel_spec.rb +1 -1
  110. data/spec/unit/plugins/linode_spec.rb +1 -1
  111. data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
  112. data/spec/unit/plugins/linux/cpu_spec.rb +6 -6
  113. data/spec/unit/plugins/linux/filesystem_spec.rb +21 -21
  114. data/spec/unit/plugins/linux/fips_spec.rb +13 -45
  115. data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
  116. data/spec/unit/plugins/linux/hostnamectl_spec.rb +2 -2
  117. data/spec/unit/plugins/linux/kernel_spec.rb +8 -8
  118. data/spec/unit/plugins/linux/lsb_spec.rb +3 -3
  119. data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
  120. data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
  121. data/spec/unit/plugins/linux/mdadm_spec.rb +2 -2
  122. data/spec/unit/plugins/linux/memory_spec.rb +26 -1
  123. data/spec/unit/plugins/linux/network_spec.rb +37 -37
  124. data/spec/unit/plugins/linux/platform_spec.rb +580 -837
  125. data/spec/unit/plugins/linux/sessions_spec.rb +2 -2
  126. data/spec/unit/plugins/linux/systemd_paths_spec.rb +1 -1
  127. data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
  128. data/spec/unit/plugins/linux/virtualization_spec.rb +28 -227
  129. data/spec/unit/plugins/lua_spec.rb +1 -1
  130. data/spec/unit/plugins/mono_spec.rb +2 -2
  131. data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
  132. data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
  133. data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
  134. data/spec/unit/plugins/network_spec.rb +11 -11
  135. data/spec/unit/plugins/nodejs_spec.rb +1 -1
  136. data/spec/unit/plugins/ohai_spec.rb +1 -1
  137. data/spec/unit/plugins/ohai_time_spec.rb +1 -1
  138. data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
  139. data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
  140. data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
  141. data/spec/unit/plugins/openstack_spec.rb +8 -4
  142. data/spec/unit/plugins/os_spec.rb +1 -1
  143. data/spec/unit/plugins/packages_spec.rb +1 -21
  144. data/spec/unit/plugins/passwd_spec.rb +1 -1
  145. data/spec/unit/plugins/perl_spec.rb +1 -1
  146. data/spec/unit/plugins/php_spec.rb +6 -6
  147. data/spec/unit/plugins/platform_spec.rb +1 -1
  148. data/spec/unit/plugins/powershell_spec.rb +3 -3
  149. data/spec/unit/plugins/python_spec.rb +1 -1
  150. data/spec/unit/plugins/rackspace_spec.rb +2 -2
  151. data/spec/unit/plugins/root_group_spec.rb +1 -11
  152. data/spec/unit/plugins/ruby_spec.rb +1 -1
  153. data/spec/unit/plugins/rust_spec.rb +1 -1
  154. data/spec/unit/plugins/scala_spec.rb +1 -1
  155. data/spec/unit/plugins/scsi_spec.rb +2 -2
  156. data/spec/unit/plugins/shard_spec.rb +1 -1
  157. data/spec/unit/plugins/shells_spec.rb +1 -1
  158. data/spec/unit/plugins/softlayer_spec.rb +1 -1
  159. data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
  160. data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
  161. data/spec/unit/plugins/solaris2/filesystem.rb +4 -4
  162. data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
  163. data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
  164. data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
  165. data/spec/unit/plugins/solaris2/network_spec.rb +6 -6
  166. data/spec/unit/plugins/solaris2/platform_spec.rb +3 -3
  167. data/spec/unit/plugins/solaris2/virtualization_spec.rb +41 -69
  168. data/spec/unit/plugins/ssh_host_keys_spec.rb +3 -3
  169. data/spec/unit/plugins/sysconf_spec.rb +2 -2
  170. data/spec/unit/plugins/timezone_spec.rb +1 -1
  171. data/spec/unit/plugins/virtualbox_spec.rb +1 -1
  172. data/spec/unit/plugins/vmware_spec.rb +1 -1
  173. data/spec/unit/plugins/windows/cpu_spec.rb +1 -2
  174. data/spec/unit/plugins/windows/filesystem_spec.rb +2 -2
  175. data/spec/unit/plugins/windows/fips_spec.rb +17 -77
  176. data/spec/unit/plugins/windows/kernel_spec.rb +1 -1
  177. data/spec/unit/plugins/windows/memory_spec.rb +2 -2
  178. data/spec/unit/plugins/windows/network_spec.rb +1 -1
  179. data/spec/unit/plugins/windows/system_enclosure_spec.rb +1 -1
  180. data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
  181. data/spec/unit/plugins/windows/virtualization_spec.rb +20 -238
  182. data/spec/unit/plugins/zpools_spec.rb +7 -7
  183. data/spec/unit/provides_map_spec.rb +1 -1
  184. data/spec/unit/runner_spec.rb +1 -1
  185. data/spec/unit/system_spec.rb +10 -77
  186. data/spec/unit/util/file_helper_spec.rb +1 -1
  187. data/spec/unit/util/ip_helper_spec.rb +1 -1
  188. metadata +6 -9
  189. data/lib/ohai/plugins/darwin/system_profiler.rb +0 -72
  190. data/lib/ohai/util/win32/group_helper.rb +0 -76
  191. data/spec/unit/plugins/darwin/system_profiler_output.rb +0 -79524
  192. data/spec/unit/plugins/darwin/system_profiler_spec.rb +0 -40
@@ -19,9 +19,6 @@
19
19
  Ohai.plugin(:SystemdPaths) do
20
20
  provides "systemd_paths"
21
21
 
22
- require "ohai/util/file_helper"
23
- include Ohai::Util::FileHelper
24
-
25
22
  collect_data(:linux) do
26
23
  systemd_path_path = which("systemd-path")
27
24
  if systemd_path_path
@@ -17,9 +17,10 @@
17
17
  #
18
18
 
19
19
  Ohai.plugin(:Virtualization) do
20
+ provides "virtualization"
21
+ depends "dmi"
20
22
  require "ohai/mixin/dmi_decode"
21
23
  include Ohai::Mixin::DmiDecode
22
- provides "virtualization"
23
24
 
24
25
  def lxc_version_exists?
25
26
  which("lxc-version") || which("lxc-start")
@@ -129,25 +130,14 @@ Ohai.plugin(:Virtualization) do
129
130
  virtualization[:systems][:openvz] = "guest"
130
131
  end
131
132
 
132
- # Detect Parallels virtual machine from pci devices
133
- if File.exist?("/proc/bus/pci/devices")
134
- if File.read("/proc/bus/pci/devices") =~ /1ab84000/
135
- logger.trace("Plugin Virtualization: /proc/bus/pci/devices contains '1ab84000' pci device. Detecting as parallels guest")
136
- virtualization[:system] = "parallels"
137
- virtualization[:role] = "guest"
138
- virtualization[:systems][:parallels] = "guest"
139
- end
140
- end
141
-
142
- # parse dmidecode to discover various virtualization guests
143
- if File.exist?("/usr/sbin/dmidecode")
144
- guest = guest_from_dmi(shell_out("dmidecode").stdout)
145
- if guest
146
- logger.trace("Plugin Virtualization: dmidecode contains string indicating #{guest} guest")
147
- virtualization[:system] = guest
148
- virtualization[:role] = "guest"
149
- virtualization[:systems][guest.to_sym] = "guest"
150
- end
133
+ # parse dmi to discover various virtualization guests
134
+ logger.trace("Looking up #{get_attribute(:dmi, :system, :manufacturer)}, #{get_attribute(:dmi, :system, :product)} #{get_attribute(:dmi, :system, :version)}")
135
+ guest = guest_from_dmi_data(get_attribute(:dmi, :system, :manufacturer), get_attribute(:dmi, :system, :product), get_attribute(:dmi, :system, :version))
136
+ if guest
137
+ logger.trace("Plugin Virtualization: DMI data indicates #{guest} guest")
138
+ virtualization[:system] = guest
139
+ virtualization[:role] = "guest"
140
+ virtualization[:systems][guest.to_sym] = "guest"
151
141
  end
152
142
 
153
143
  # Detect Hyper-V guest and the hostname of the host
@@ -21,19 +21,19 @@ Ohai.plugin(:Lua) do
21
21
  depends "languages"
22
22
 
23
23
  collect_data do
24
- begin
25
- so = shell_out("lua -v")
26
- # Sample output:
27
- # Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
28
- if so.exitstatus == 0
29
- lua = Mash.new
30
- # at some point in lua's history they went from outputting the version
31
- # on stderr to doing it on stdout. This handles old / new versions
32
- lua[:version] = so.stdout.empty? ? so.stderr.split[1] : so.stdout.split[1]
33
- languages[:lua] = lua if lua[:version]
34
- end
35
- rescue Ohai::Exceptions::Exec
36
- logger.trace('Plugin Lua: Could not shell_out "lua -v". Skipping plugin')
24
+
25
+ so = shell_out("lua -v")
26
+ # Sample output:
27
+ # Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
28
+ if so.exitstatus == 0
29
+ lua = Mash.new
30
+ # at some point in lua's history they went from outputting the version
31
+ # on stderr to doing it on stdout. This handles old / new versions
32
+ lua[:version] = so.stdout.empty? ? so.stderr.split[1] : so.stdout.split[1]
33
+ languages[:lua] = lua if lua[:version]
37
34
  end
35
+ rescue Ohai::Exceptions::Exec
36
+ logger.trace('Plugin Lua: Could not shell_out "lua -v". Skipping plugin')
37
+
38
38
  end
39
39
  end
@@ -21,30 +21,30 @@ Ohai.plugin(:Mono) do
21
21
  depends "languages"
22
22
 
23
23
  collect_data do
24
- begin
25
- so = shell_out("mono -V")
26
- # Sample output:
27
- # Mono JIT compiler version 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 30 13:57:48 PDT 2016)
28
- # Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
29
- # TLS: normal
30
- # SIGSEGV: altstack
31
- # Notification: kqueue
32
- # Architecture: amd64
33
- # Disabled: none
34
- # Misc: softtrace
35
- # LLVM: supported, not enabled.
36
- # GC: sgen
37
- if so.exitstatus == 0
38
- mono = Mash.new
39
- output = so.stdout.split
40
- mono[:version] = output[4] unless output[4].nil?
41
- if output.length >= 12
42
- mono[:builddate] = "%s %s %s %s %s %s" % [output[7], output[8], output[9], output[10], output[11], output[12].delete!(")")]
43
- end
44
- languages[:mono] = mono unless mono.empty?
24
+
25
+ so = shell_out("mono -V")
26
+ # Sample output:
27
+ # Mono JIT compiler version 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 30 13:57:48 PDT 2016)
28
+ # Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
29
+ # TLS: normal
30
+ # SIGSEGV: altstack
31
+ # Notification: kqueue
32
+ # Architecture: amd64
33
+ # Disabled: none
34
+ # Misc: softtrace
35
+ # LLVM: supported, not enabled.
36
+ # GC: sgen
37
+ if so.exitstatus == 0
38
+ mono = Mash.new
39
+ output = so.stdout.split
40
+ mono[:version] = output[4] unless output[4].nil?
41
+ if output.length >= 12
42
+ mono[:builddate] = "%s %s %s %s %s %s" % [output[7], output[8], output[9], output[10], output[11], output[12].delete!(")")]
45
43
  end
46
- rescue Ohai::Exceptions::Exec
47
- logger.trace('Plugin Mono: Could not shell_out "mono -V". Skipping plugin')
44
+ languages[:mono] = mono unless mono.empty?
48
45
  end
46
+ rescue Ohai::Exceptions::Exec
47
+ logger.trace('Plugin Mono: Could not shell_out "mono -V". Skipping plugin')
48
+
49
49
  end
50
50
  end
@@ -21,20 +21,20 @@ Ohai.plugin(:Nodejs) do
21
21
  depends "languages"
22
22
 
23
23
  collect_data do
24
- begin
25
- so = shell_out("node -v")
26
- # Sample output:
27
- # v5.10.1
28
- if so.exitstatus == 0
29
- nodejs = Mash.new
30
- output = so.stdout.split
31
- if output.length >= 1
32
- nodejs[:version] = output[0][1..output[0].length]
33
- end
34
- languages[:nodejs] = nodejs if nodejs[:version]
24
+
25
+ so = shell_out("node -v")
26
+ # Sample output:
27
+ # v5.10.1
28
+ if so.exitstatus == 0
29
+ nodejs = Mash.new
30
+ output = so.stdout.split
31
+ if output.length >= 1
32
+ nodejs[:version] = output[0][1..output[0].length]
35
33
  end
36
- rescue Ohai::Exceptions::Exec
37
- logger.trace('Plugin Nodejs: Could not shell_out "node -v". Skipping plugin')
34
+ languages[:nodejs] = nodejs if nodejs[:version]
38
35
  end
36
+ rescue Ohai::Exceptions::Exec
37
+ logger.trace('Plugin Nodejs: Could not shell_out "node -v". Skipping plugin')
38
+
39
39
  end
40
40
  end
@@ -69,7 +69,7 @@ Ohai.plugin(:Openstack) do
69
69
  # fetch the metadata if we can do a simple socket connect first
70
70
  if can_socket_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, timeout)
71
71
  fetch_metadata.each do |k, v|
72
- openstack[k] = v
72
+ openstack[k] = v unless v.empty?
73
73
  end
74
74
  logger.trace("Plugin Openstack: Successfully fetched Openstack metadata from the metadata endpoint")
75
75
  else
@@ -50,34 +50,7 @@ Ohai.plugin(:Packages) do
50
50
 
51
51
  pkgs.each do |pkg|
52
52
  name, epoch, version, release, installdate, arch = pkg.split
53
- if packages[name]
54
- # We have more than one package with this exact name!
55
- # Create an "versions" array for tracking all versions of packages with this name.
56
- # The top-level package information will be the first one returned by rpm -qa,
57
- # all versions go in this list, with the same information they'd normally have.
58
- if packages[name]["versions"].nil?
59
- # add the data of the first package to the list, so that all versions are in the list.
60
- packages[name]["versions"] = []
61
- packages[name]["versions"] << Mash.new({ "epoch" => packages[name]["epoch"],
62
- "version" => packages[name]["version"],
63
- "release" => packages[name]["release"],
64
- "installdate" => packages[name]["installdate"],
65
- "arch" => packages[name]["arch"] })
66
- end
67
- packages[name]["versions"] << Mash.new({ "epoch" => epoch, "version" => version, "release" => release, "installdate" => installdate, "arch" => arch }) # Add this package version to the list
68
- # When this was originally written, it didn't account for multiple versions of the same package
69
- # so it just kept clobbering the package data if it encountered multiple versions
70
- # of the same package. As a result, the last duplicate returned by rpm -qa was what was present;
71
- # here we clobber that data for compatibility. Note that we can't overwrite the entire hash
72
- # without losing the versions array.
73
- packages[name]["epoch"] = epoch
74
- packages[name]["version"] = version
75
- packages[name]["release"] = release
76
- packages[name]["installdate"] = installdate
77
- packages[name]["arch"] = arch
78
- else
79
- packages[name] = { "epoch" => epoch, "version" => version, "release" => release, "installdate" => installdate, "arch" => arch }
80
- end
53
+ packages[name] = { "epoch" => epoch, "version" => version, "release" => release, "installdate" => installdate, "arch" => arch }
81
54
  end
82
55
 
83
56
  when "arch"
@@ -21,25 +21,25 @@ Ohai.plugin(:Perl) do
21
21
  depends "languages"
22
22
 
23
23
  collect_data do
24
- begin
25
- so = shell_out("perl -V:version -V:archname")
26
- # Sample output:
27
- # version='5.18.2';
28
- # archname='darwin-thread-multi-2level';
29
- if so.exitstatus == 0
30
- perl = Mash.new
31
- so.stdout.split(/\r?\n/).each do |line|
32
- case line
33
- when /^version=\'(.+)\';$/
34
- perl[:version] = $1
35
- when /^archname=\'(.+)\';$/
36
- perl[:archname] = $1
37
- end
24
+
25
+ so = shell_out("perl -V:version -V:archname")
26
+ # Sample output:
27
+ # version='5.18.2';
28
+ # archname='darwin-thread-multi-2level';
29
+ if so.exitstatus == 0
30
+ perl = Mash.new
31
+ so.stdout.split(/\r?\n/).each do |line|
32
+ case line
33
+ when /^version=\'(.+)\';$/
34
+ perl[:version] = $1
35
+ when /^archname=\'(.+)\';$/
36
+ perl[:archname] = $1
38
37
  end
39
- languages[:perl] = perl unless perl.empty?
40
38
  end
41
- rescue Ohai::Exceptions::Exec
42
- logger.trace('Plugin Perl: Could not shell_out "perl -V:version -V:archname". Skipping plugin')
39
+ languages[:perl] = perl unless perl.empty?
43
40
  end
41
+ rescue Ohai::Exceptions::Exec
42
+ logger.trace('Plugin Perl: Could not shell_out "perl -V:version -V:archname". Skipping plugin')
43
+
44
44
  end
45
45
  end
@@ -23,30 +23,30 @@ Ohai.plugin(:PHP) do
23
23
  depends "languages"
24
24
 
25
25
  collect_data do
26
- begin
27
- so = shell_out("php -v")
28
- # Sample output:
29
- # PHP 5.5.31 (cli) (built: Feb 20 2016 20:33:10)
30
- # Copyright (c) 1997-2015 The PHP Group
31
- # Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
32
- if so.exitstatus == 0
33
- php = Mash.new
34
- so.stdout.each_line do |line|
35
- case line
36
- when /^PHP (\S+)(?:.*built: ([^)]+))?/
37
- php[:version] = $1
38
- php[:builddate] = $2
39
- when /Zend Engine v([^\s]+),/
40
- php[:zend_engine_version] = $1
41
- when /Zend OPcache v([^\s]+),/
42
- php[:zend_opcache_version] = $1
43
- end
44
- end
45
26
 
46
- languages[:php] = php unless php.empty?
27
+ so = shell_out("php -v")
28
+ # Sample output:
29
+ # PHP 5.5.31 (cli) (built: Feb 20 2016 20:33:10)
30
+ # Copyright (c) 1997-2015 The PHP Group
31
+ # Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
32
+ if so.exitstatus == 0
33
+ php = Mash.new
34
+ so.stdout.each_line do |line|
35
+ case line
36
+ when /^PHP (\S+)(?:.*built: ([^)]+))?/
37
+ php[:version] = $1
38
+ php[:builddate] = $2
39
+ when /Zend Engine v([^\s]+),/
40
+ php[:zend_engine_version] = $1
41
+ when /Zend OPcache v([^\s]+),/
42
+ php[:zend_opcache_version] = $1
43
+ end
47
44
  end
48
- rescue Ohai::Exceptions::Exec
49
- logger.trace('Plugin Php: Could not shell_out "php -v". Skipping plugin')
45
+
46
+ languages[:php] = php unless php.empty?
50
47
  end
48
+ rescue Ohai::Exceptions::Exec
49
+ logger.trace('Plugin Php: Could not shell_out "php -v". Skipping plugin')
50
+
51
51
  end
52
52
  end
@@ -20,39 +20,39 @@ Ohai.plugin(:Powershell) do
20
20
  depends "languages"
21
21
 
22
22
  collect_data(:windows) do
23
- begin
24
- so = shell_out("powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable")
25
- # Sample output:
26
- #
27
- # Name Value
28
- # ---- -----
29
- # PSVersion 4.0
30
- # WSManStackVersion 3.0
31
- # SerializationVersion 1.1.0.1
32
- # CLRVersion 4.0.30319.34014
33
- # BuildVersion 6.3.9600.16394
34
- # PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
35
- # PSRemotingProtocolVersion 2.2
36
23
 
37
- if so.exitstatus == 0
38
- powershell = Mash.new
39
- version_info = {}
40
- so.stdout.strip.each_line do |line|
41
- kv = line.strip.split(/\s+/, 2)
42
- version_info[kv[0]] = kv[1] if kv.length == 2
43
- end
44
- powershell[:version] = version_info["PSVersion"]
45
- powershell[:ws_man_stack_version] = version_info["WSManStackVersion"]
46
- powershell[:serialization_version] = version_info["SerializationVersion"]
47
- powershell[:clr_version] = version_info["CLRVersion"]
48
- powershell[:build_version] = version_info["BuildVersion"]
49
- powershell[:compatible_versions] = parse_compatible_versions
50
- powershell[:remoting_protocol_version] = version_info["PSRemotingProtocolVersion"]
51
- languages[:powershell] = powershell unless powershell.empty?
24
+ so = shell_out("powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable")
25
+ # Sample output:
26
+ #
27
+ # Name Value
28
+ # ---- -----
29
+ # PSVersion 4.0
30
+ # WSManStackVersion 3.0
31
+ # SerializationVersion 1.1.0.1
32
+ # CLRVersion 4.0.30319.34014
33
+ # BuildVersion 6.3.9600.16394
34
+ # PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
35
+ # PSRemotingProtocolVersion 2.2
36
+
37
+ if so.exitstatus == 0
38
+ powershell = Mash.new
39
+ version_info = {}
40
+ so.stdout.strip.each_line do |line|
41
+ kv = line.strip.split(/\s+/, 2)
42
+ version_info[kv[0]] = kv[1] if kv.length == 2
52
43
  end
53
- rescue Ohai::Exceptions::Exec
54
- logger.trace('Plugin Powershell: Could not shell_out "powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable". Skipping plugin')
44
+ powershell[:version] = version_info["PSVersion"]
45
+ powershell[:ws_man_stack_version] = version_info["WSManStackVersion"]
46
+ powershell[:serialization_version] = version_info["SerializationVersion"]
47
+ powershell[:clr_version] = version_info["CLRVersion"]
48
+ powershell[:build_version] = version_info["BuildVersion"]
49
+ powershell[:compatible_versions] = parse_compatible_versions
50
+ powershell[:remoting_protocol_version] = version_info["PSRemotingProtocolVersion"]
51
+ languages[:powershell] = powershell unless powershell.empty?
55
52
  end
53
+ rescue Ohai::Exceptions::Exec
54
+ logger.trace('Plugin Powershell: Could not shell_out "powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable". Skipping plugin')
55
+
56
56
  end
57
57
 
58
58
  def version_command
@@ -23,7 +23,7 @@ Ohai.plugin(:PS) do
23
23
  provides "command/ps"
24
24
  depends "command"
25
25
 
26
- collect_data(:aix, :darwin, :hpux, :linux, :solaris2) do
26
+ collect_data(:aix, :darwin, :linux, :solaris2) do
27
27
  command[:ps] = "ps -ef"
28
28
  end
29
29
 
@@ -22,22 +22,22 @@ Ohai.plugin(:Python) do
22
22
  depends "languages"
23
23
 
24
24
  collect_data do
25
- begin
26
- so = shell_out("python -c \"import sys; print (sys.version)\"")
27
- # Sample output:
28
- # 2.7.11 (default, Dec 26 2015, 17:47:53)
29
- # [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]
30
- if so.exitstatus == 0
31
- python = Mash.new
32
- output = so.stdout.split
33
- python[:version] = output[0]
34
- if output.length >= 6
35
- python[:builddate] = "%s %s %s %s" % [output[2], output[3], output[4], output[5].delete!(")")]
36
- end
37
- languages[:python] = python unless python.empty?
25
+
26
+ so = shell_out("python -c \"import sys; print (sys.version)\"")
27
+ # Sample output:
28
+ # 2.7.11 (default, Dec 26 2015, 17:47:53)
29
+ # [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]
30
+ if so.exitstatus == 0
31
+ python = Mash.new
32
+ output = so.stdout.split
33
+ python[:version] = output[0]
34
+ if output.length >= 6
35
+ python[:builddate] = "%s %s %s %s" % [output[2], output[3], output[4], output[5].delete!(")")]
38
36
  end
39
- rescue Ohai::Exceptions::Exec
40
- logger.trace('Plugin Python: Could not shell_out "python -c "import sys; print (sys.version)"". Skipping plugin')
37
+ languages[:python] = python unless python.empty?
41
38
  end
39
+ rescue Ohai::Exceptions::Exec
40
+ logger.trace('Plugin Python: Could not shell_out "python -c "import sys; print (sys.version)"". Skipping plugin')
41
+
42
42
  end
43
43
  end
@@ -18,17 +18,17 @@ Ohai.plugin(:Rust) do
18
18
  depends "languages"
19
19
 
20
20
  collect_data do
21
- begin
22
- so = shell_out("rustc --version")
23
- # Sample output:
24
- # rustc 1.7.0
25
- if so.exitstatus == 0
26
- rust = Mash.new
27
- rust[:version] = so.stdout.split[1]
28
- languages[:rust] = rust if rust[:version]
29
- end
30
- rescue Ohai::Exceptions::Exec
31
- logger.trace('Plugin Rust: Could not shell_out "rustc --version". Skipping plugin')
21
+
22
+ so = shell_out("rustc --version")
23
+ # Sample output:
24
+ # rustc 1.7.0
25
+ if so.exitstatus == 0
26
+ rust = Mash.new
27
+ rust[:version] = so.stdout.split[1]
28
+ languages[:rust] = rust if rust[:version]
32
29
  end
30
+ rescue Ohai::Exceptions::Exec
31
+ logger.trace('Plugin Rust: Could not shell_out "rustc --version". Skipping plugin')
32
+
33
33
  end
34
34
  end