ohai 16.5.4 → 16.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -8
- data/bin/ohai +1 -0
- data/lib/ohai.rb +1 -0
- data/lib/ohai/application.rb +40 -0
- data/lib/ohai/common/dmi.rb +8 -3
- data/lib/ohai/config.rb +1 -0
- data/lib/ohai/dsl.rb +1 -0
- data/lib/ohai/dsl/plugin.rb +9 -1
- data/lib/ohai/dsl/plugin/versionvii.rb +28 -17
- data/lib/ohai/exception.rb +1 -0
- data/lib/ohai/hints.rb +1 -0
- data/lib/ohai/log.rb +1 -0
- data/lib/ohai/mash.rb +1 -0
- data/lib/ohai/mixin/azure_metadata.rb +4 -3
- data/lib/ohai/mixin/chef_utils_wiring.rb +14 -1
- data/lib/ohai/mixin/command.rb +1 -0
- data/lib/ohai/mixin/constant_helper.rb +1 -0
- data/lib/ohai/mixin/dmi_decode.rb +1 -0
- data/lib/ohai/mixin/do_metadata.rb +3 -2
- data/lib/ohai/mixin/ec2_metadata.rb +10 -9
- data/lib/ohai/mixin/gce_metadata.rb +4 -3
- data/lib/ohai/mixin/http_helper.rb +1 -0
- data/lib/ohai/mixin/network_helper.rb +1 -0
- data/lib/ohai/mixin/os.rb +67 -1
- data/lib/ohai/mixin/scaleway_metadata.rb +3 -2
- data/lib/ohai/mixin/seconds_to_human.rb +1 -0
- data/lib/ohai/mixin/shell_out.rb +1 -0
- data/lib/ohai/mixin/softlayer_metadata.rb +2 -1
- data/lib/ohai/mixin/string.rb +1 -0
- data/lib/ohai/mixin/train_helpers.rb +36 -0
- data/lib/ohai/mixin/which.rb +1 -0
- data/lib/ohai/plugin_config.rb +1 -0
- data/lib/ohai/plugins/aix/kernel.rb +7 -4
- data/lib/ohai/plugins/aix/memory.rb +4 -3
- data/lib/ohai/plugins/aix/network.rb +51 -58
- data/lib/ohai/plugins/aix/platform.rb +3 -2
- data/lib/ohai/plugins/aix/uptime.rb +3 -2
- data/lib/ohai/plugins/aix/virtualization.rb +6 -6
- data/lib/ohai/plugins/azure.rb +25 -4
- data/lib/ohai/plugins/bsd/virtualization.rb +3 -2
- data/lib/ohai/plugins/c.rb +4 -3
- data/lib/ohai/plugins/chef.rb +2 -1
- data/lib/ohai/plugins/cloud.rb +2 -1
- data/lib/ohai/plugins/command.rb +1 -0
- data/lib/ohai/plugins/cpu.rb +31 -32
- data/lib/ohai/plugins/darwin/hardware.rb +1 -0
- data/lib/ohai/plugins/darwin/memory.rb +2 -3
- data/lib/ohai/plugins/darwin/network.rb +8 -9
- data/lib/ohai/plugins/darwin/platform.rb +1 -0
- data/lib/ohai/plugins/darwin/virtualization.rb +2 -1
- data/lib/ohai/plugins/digital_ocean.rb +3 -1
- data/lib/ohai/plugins/dmi.rb +6 -5
- data/lib/ohai/plugins/docker.rb +2 -1
- data/lib/ohai/plugins/dragonflybsd/memory.rb +9 -8
- data/lib/ohai/plugins/dragonflybsd/network.rb +1 -0
- data/lib/ohai/plugins/dragonflybsd/platform.rb +3 -2
- data/lib/ohai/plugins/ec2.rb +14 -7
- data/lib/ohai/plugins/elixir.rb +1 -1
- data/lib/ohai/plugins/erlang.rb +1 -0
- data/lib/ohai/plugins/eucalyptus.rb +4 -1
- data/lib/ohai/plugins/filesystem.rb +4 -4
- data/lib/ohai/plugins/fips.rb +1 -0
- data/lib/ohai/plugins/freebsd/memory.rb +9 -8
- data/lib/ohai/plugins/freebsd/network.rb +1 -0
- data/lib/ohai/plugins/freebsd/platform.rb +3 -2
- data/lib/ohai/plugins/gce.rb +3 -2
- data/lib/ohai/plugins/go.rb +1 -1
- data/lib/ohai/plugins/groovy.rb +1 -1
- data/lib/ohai/plugins/grub2.rb +40 -0
- data/lib/ohai/plugins/haskell.rb +1 -0
- data/lib/ohai/plugins/hostname.rb +2 -2
- data/lib/ohai/plugins/init_package.rb +2 -1
- data/lib/ohai/plugins/java.rb +1 -0
- data/lib/ohai/plugins/kernel.rb +14 -11
- data/lib/ohai/plugins/keys.rb +1 -0
- data/lib/ohai/plugins/languages.rb +1 -0
- data/lib/ohai/plugins/libvirt.rb +4 -3
- data/lib/ohai/plugins/linode.rb +22 -14
- data/lib/ohai/plugins/linux/block_device.rb +9 -8
- data/lib/ohai/plugins/linux/hostnamectl.rb +3 -2
- data/lib/ohai/plugins/linux/interrupts.rb +4 -3
- data/lib/ohai/plugins/linux/ipc.rb +2 -1
- data/lib/ohai/plugins/linux/lsb.rb +7 -20
- data/lib/ohai/plugins/linux/lspci.rb +1 -1
- data/lib/ohai/plugins/linux/machineid.rb +5 -4
- data/lib/ohai/plugins/linux/mdadm.rb +3 -2
- data/lib/ohai/plugins/linux/memory.rb +38 -37
- data/lib/ohai/plugins/linux/network.rb +7 -6
- data/lib/ohai/plugins/linux/platform.rb +31 -30
- data/lib/ohai/plugins/linux/selinux.rb +1 -0
- data/lib/ohai/plugins/linux/sessions.rb +1 -0
- data/lib/ohai/plugins/linux/sysctl.rb +1 -0
- data/lib/ohai/plugins/linux/systemd_paths.rb +1 -0
- data/lib/ohai/plugins/linux/virtualization.rb +24 -23
- data/lib/ohai/plugins/lua.rb +1 -1
- data/lib/ohai/plugins/mono.rb +1 -1
- data/lib/ohai/plugins/netbsd/memory.rb +1 -0
- data/lib/ohai/plugins/netbsd/network.rb +1 -0
- data/lib/ohai/plugins/netbsd/platform.rb +3 -2
- data/lib/ohai/plugins/network.rb +2 -1
- data/lib/ohai/plugins/nodejs.rb +1 -1
- data/lib/ohai/plugins/ohai.rb +1 -0
- data/lib/ohai/plugins/ohai_time.rb +2 -1
- data/lib/ohai/plugins/openbsd/memory.rb +1 -0
- data/lib/ohai/plugins/openbsd/network.rb +1 -0
- data/lib/ohai/plugins/openbsd/platform.rb +3 -2
- data/lib/ohai/plugins/openstack.rb +1 -0
- data/lib/ohai/plugins/os.rb +6 -1
- data/lib/ohai/plugins/packages.rb +2 -1
- data/lib/ohai/plugins/passwd.rb +58 -1
- data/lib/ohai/plugins/perl.rb +1 -1
- data/lib/ohai/plugins/php.rb +1 -1
- data/lib/ohai/plugins/platform.rb +1 -0
- data/lib/ohai/plugins/powershell.rb +1 -1
- data/lib/ohai/plugins/ps.rb +1 -0
- data/lib/ohai/plugins/python.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +6 -5
- data/lib/ohai/plugins/root_group.rb +1 -0
- data/lib/ohai/plugins/ruby.rb +3 -2
- data/lib/ohai/plugins/rust.rb +1 -1
- data/lib/ohai/plugins/scala.rb +1 -0
- data/lib/ohai/plugins/scaleway.rb +3 -2
- data/lib/ohai/plugins/scsi.rb +1 -1
- data/lib/ohai/plugins/shard.rb +1 -1
- data/lib/ohai/plugins/shells.rb +3 -2
- data/lib/ohai/plugins/softlayer.rb +1 -0
- data/lib/ohai/plugins/solaris2/dmi.rb +2 -1
- data/lib/ohai/plugins/solaris2/memory.rb +1 -0
- data/lib/ohai/plugins/solaris2/network.rb +2 -1
- data/lib/ohai/plugins/solaris2/platform.rb +8 -14
- data/lib/ohai/plugins/solaris2/virtualization.rb +4 -4
- data/lib/ohai/plugins/ssh_host_key.rb +13 -12
- data/lib/ohai/plugins/sysconf.rb +1 -0
- data/lib/ohai/plugins/timezone.rb +1 -0
- data/lib/ohai/plugins/train.rb +35 -0
- data/lib/ohai/plugins/uptime.rb +2 -1
- data/lib/ohai/plugins/virtualbox.rb +2 -1
- data/lib/ohai/plugins/vmware.rb +3 -3
- data/lib/ohai/plugins/windows/dmi.rb +1 -0
- data/lib/ohai/plugins/windows/drivers.rb +1 -0
- data/lib/ohai/plugins/windows/memory.rb +1 -0
- data/lib/ohai/plugins/windows/network.rb +2 -1
- data/lib/ohai/plugins/windows/platform.rb +1 -0
- data/lib/ohai/plugins/windows/system_enclosure.rb +1 -0
- data/lib/ohai/plugins/windows/virtualization.rb +1 -0
- data/lib/ohai/plugins/zpools.rb +5 -3
- data/lib/ohai/provides_map.rb +1 -0
- data/lib/ohai/runner.rb +7 -4
- data/lib/ohai/system.rb +33 -4
- data/lib/ohai/train_transport.rb +29 -0
- data/lib/ohai/util/file_helper.rb +1 -0
- data/lib/ohai/util/ip_helper.rb +2 -1
- data/lib/ohai/util/win32.rb +1 -0
- data/lib/ohai/version.rb +2 -1
- data/ohai.gemspec +3 -1
- metadata +21 -4
- data/lib/ohai/plugins/joyent.rb +0 -77
data/lib/ohai/plugins/docker.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Copyright:: Copyright (c) Chef Software Inc.
|
3
4
|
# License:: Apache License, Version 2.0
|
@@ -47,7 +48,7 @@ Ohai.plugin(:Docker) do
|
|
47
48
|
docker[:swarm] = shellout_data["Swarm"]
|
48
49
|
end
|
49
50
|
|
50
|
-
collect_data do
|
51
|
+
collect_data(:linux, :windows, :darwin) do
|
51
52
|
require "json" unless defined?(JSON)
|
52
53
|
|
53
54
|
if virtualization[:systems][:docker]
|
@@ -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
|
@@ -25,22 +26,22 @@ Ohai.plugin(:Memory) do
|
|
25
26
|
|
26
27
|
# /usr/src/sys/sys/vmmeter.h
|
27
28
|
so = shell_out("sysctl -n vm.stats.vm.v_page_size")
|
28
|
-
memory[:page_size] = so.stdout.
|
29
|
+
memory[:page_size] = so.stdout.strip
|
29
30
|
so = shell_out("sysctl -n vm.stats.vm.v_page_count")
|
30
|
-
memory[:page_count] = so.stdout.
|
31
|
+
memory[:page_count] = so.stdout.strip
|
31
32
|
memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
|
32
33
|
so = shell_out("sysctl -n vm.stats.vm.v_free_count")
|
33
|
-
memory[:free] = memory[:page_size].to_i * so.stdout.
|
34
|
+
memory[:free] = memory[:page_size].to_i * so.stdout.strip.to_i
|
34
35
|
so = shell_out("sysctl -n vm.status.vm.v_active_count")
|
35
|
-
memory[:active] = memory[:page_size].to_i * so.stdout.
|
36
|
+
memory[:active] = memory[:page_size].to_i * so.stdout.strip.to_i
|
36
37
|
so = shell_out("sysctl -n vm.status.vm.v_inactive_count")
|
37
|
-
memory[:inactive] = memory[:page_size].to_i * so.stdout.
|
38
|
+
memory[:inactive] = memory[:page_size].to_i * so.stdout.strip.to_i
|
38
39
|
so = shell_out("sysctl -n vm.stats.vm.v_cache_count")
|
39
|
-
memory[:cache] = memory[:page_size].to_i * so.stdout.
|
40
|
+
memory[:cache] = memory[:page_size].to_i * so.stdout.strip.to_i
|
40
41
|
so = shell_out("sysctl -n vm.stats.vm.v_wire_count")
|
41
|
-
memory[:wired] = memory[:page_size].to_i * so.stdout.
|
42
|
+
memory[:wired] = memory[:page_size].to_i * so.stdout.strip.to_i
|
42
43
|
so = shell_out("sysctl -n vfs.bufspace")
|
43
|
-
memory[:buffers] = so.stdout.
|
44
|
+
memory[:buffers] = so.stdout.strip
|
44
45
|
|
45
46
|
so = shell_out("swapinfo")
|
46
47
|
so.stdout.lines do |line|
|
@@ -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
|
@@ -20,8 +21,8 @@ Ohai.plugin(:Platform) do
|
|
20
21
|
provides "platform", "platform_version", "platform_family"
|
21
22
|
|
22
23
|
collect_data(:dragonflybsd) do
|
23
|
-
platform shell_out("uname -s").stdout.
|
24
|
-
platform_version shell_out("uname -r").stdout.
|
24
|
+
platform shell_out("uname -s").stdout.strip.downcase
|
25
|
+
platform_version shell_out("uname -r").stdout.strip
|
25
26
|
platform_family "dragonflybsd"
|
26
27
|
end
|
27
28
|
end
|
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Tim Dysinger (<tim@dysinger.net>)
|
3
4
|
# Author:: Benjamin Black (<bb@chef.io>)
|
@@ -97,8 +98,8 @@ Ohai.plugin(:EC2) do
|
|
97
98
|
# @param path[String] abs path to the file
|
98
99
|
# @return [String] contents of the file if it exists
|
99
100
|
def file_val_if_exists(path)
|
100
|
-
if
|
101
|
-
|
101
|
+
if file_exist?(path)
|
102
|
+
file_read(path)
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
@@ -122,11 +123,17 @@ Ohai.plugin(:EC2) do
|
|
122
123
|
fetch_metadata.each do |k, v|
|
123
124
|
# fetch_metadata returns IAM security credentials, including the IAM user's
|
124
125
|
# secret access key. We'd rather not have ohai send this information
|
125
|
-
# to the server.
|
126
|
-
#
|
127
|
-
|
128
|
-
|
129
|
-
|
126
|
+
# to the server. If the instance is associated with an IAM role we grab
|
127
|
+
# only the "info" key and the IAM role name.
|
128
|
+
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html
|
129
|
+
if k == "iam" && !hint?("iam")
|
130
|
+
ec2[:iam] = v.select { |key, value| key == "info" }
|
131
|
+
if v["security-credentials"] && v["security-credentials"].keys.length == 1
|
132
|
+
ec2[:iam]["role_name"] = v["security-credentials"].keys[0]
|
133
|
+
end
|
134
|
+
else
|
135
|
+
ec2[k] = v
|
136
|
+
end
|
130
137
|
end
|
131
138
|
ec2[:userdata] = fetch_userdata
|
132
139
|
ec2[:account_id] = fetch_dynamic_data["accountId"]
|
data/lib/ohai/plugins/elixir.rb
CHANGED
data/lib/ohai/plugins/erlang.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Tim Dysinger (<tim@dysinger.net>)
|
3
4
|
# Author:: Benjamin Black (<bb@chef.io>)
|
@@ -28,6 +29,8 @@ Ohai.plugin(:Eucalyptus) do
|
|
28
29
|
provides "eucalyptus"
|
29
30
|
depends "network/interfaces"
|
30
31
|
|
32
|
+
MAC_MATCH = /^[dD]0:0[dD]:/.freeze
|
33
|
+
|
31
34
|
# returns the mac address from the collection of all address types
|
32
35
|
def get_mac_address(addresses)
|
33
36
|
detected_addresses = addresses.detect { |address, keypair| keypair == { "family" => "lladdr" } }
|
@@ -42,7 +45,7 @@ Ohai.plugin(:Eucalyptus) do
|
|
42
45
|
def has_euca_mac?
|
43
46
|
network[:interfaces].each_value do |iface|
|
44
47
|
mac = get_mac_address(iface[:addresses])
|
45
|
-
if
|
48
|
+
if MAC_MATCH.match?(mac)
|
46
49
|
logger.trace("Plugin Eucalyptus: has_euca_mac? == true (#{mac})")
|
47
50
|
return true
|
48
51
|
end
|
@@ -24,12 +24,12 @@
|
|
24
24
|
#
|
25
25
|
|
26
26
|
Ohai.plugin(:Filesystem) do
|
27
|
-
provides "filesystem"
|
27
|
+
provides "filesystem".freeze
|
28
28
|
|
29
29
|
def find_device(name)
|
30
30
|
%w{/dev /dev/mapper}.each do |dir|
|
31
31
|
path = File.join(dir, name)
|
32
|
-
return path if
|
32
|
+
return path if file_exist?(path)
|
33
33
|
end
|
34
34
|
name
|
35
35
|
end
|
@@ -371,11 +371,11 @@ Ohai.plugin(:Filesystem) do
|
|
371
371
|
end
|
372
372
|
|
373
373
|
# Grab any missing mount information from /proc/mounts
|
374
|
-
if
|
374
|
+
if file_exist?("/proc/mounts")
|
375
375
|
mounts = ""
|
376
376
|
# Due to https://tickets.opscode.com/browse/OHAI-196
|
377
377
|
# we have to non-block read dev files. Ew.
|
378
|
-
f =
|
378
|
+
f = file_open("/proc/mounts")
|
379
379
|
loop do
|
380
380
|
data = f.read_nonblock(4096)
|
381
381
|
mounts << data
|
data/lib/ohai/plugins/fips.rb
CHANGED
@@ -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
|
@@ -25,22 +26,22 @@ Ohai.plugin(:Memory) do
|
|
25
26
|
|
26
27
|
# /usr/src/sys/sys/vmmeter.h
|
27
28
|
so = shell_out("sysctl -n vm.stats.vm.v_page_size")
|
28
|
-
memory[:page_size] = so.stdout.
|
29
|
+
memory[:page_size] = so.stdout.strip
|
29
30
|
so = shell_out("sysctl -n vm.stats.vm.v_page_count")
|
30
|
-
memory[:page_count] = so.stdout.
|
31
|
+
memory[:page_count] = so.stdout.strip
|
31
32
|
memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
|
32
33
|
so = shell_out("sysctl -n vm.stats.vm.v_free_count")
|
33
|
-
memory[:free] = memory[:page_size].to_i * so.stdout.
|
34
|
+
memory[:free] = memory[:page_size].to_i * so.stdout.strip.to_i
|
34
35
|
so = shell_out("sysctl -n vm.status.vm.v_active_count")
|
35
|
-
memory[:active] = memory[:page_size].to_i * so.stdout.
|
36
|
+
memory[:active] = memory[:page_size].to_i * so.stdout.strip.to_i
|
36
37
|
so = shell_out("sysctl -n vm.status.vm.v_inactive_count")
|
37
|
-
memory[:inactive] = memory[:page_size].to_i * so.stdout.
|
38
|
+
memory[:inactive] = memory[:page_size].to_i * so.stdout.strip.to_i
|
38
39
|
so = shell_out("sysctl -n vm.stats.vm.v_cache_count")
|
39
|
-
memory[:cache] = memory[:page_size].to_i * so.stdout.
|
40
|
+
memory[:cache] = memory[:page_size].to_i * so.stdout.strip.to_i
|
40
41
|
so = shell_out("sysctl -n vm.stats.vm.v_wire_count")
|
41
|
-
memory[:wired] = memory[:page_size].to_i * so.stdout.
|
42
|
+
memory[:wired] = memory[:page_size].to_i * so.stdout.strip.to_i
|
42
43
|
so = shell_out("sysctl -n vfs.bufspace")
|
43
|
-
memory[:buffers] = so.stdout.
|
44
|
+
memory[:buffers] = so.stdout.strip
|
44
45
|
|
45
46
|
so = shell_out("swapinfo")
|
46
47
|
so.stdout.lines do |line|
|
@@ -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
|
@@ -20,8 +21,8 @@ Ohai.plugin(:Platform) do
|
|
20
21
|
provides "platform", "platform_version", "platform_family"
|
21
22
|
|
22
23
|
collect_data(:freebsd) do
|
23
|
-
platform shell_out("uname -s").stdout.
|
24
|
-
platform_version shell_out("uname -r").stdout.
|
24
|
+
platform shell_out("uname -s").stdout.strip.downcase
|
25
|
+
platform_version shell_out("uname -r").stdout.strip
|
25
26
|
platform_family "freebsd"
|
26
27
|
end
|
27
28
|
end
|
data/lib/ohai/plugins/gce.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Ranjib Dey (<dey.ranjib@google.com>)
|
3
4
|
# License:: Apache License, Version 2.0
|
@@ -40,8 +41,8 @@ Ohai.plugin(:GCE) do
|
|
40
41
|
# @param path[String] abs path to the file
|
41
42
|
# @return [String] contents of the file if it exists
|
42
43
|
def file_val_if_exists(path)
|
43
|
-
if
|
44
|
-
|
44
|
+
if file_exist?(path)
|
45
|
+
file_read(path)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
data/lib/ohai/plugins/go.rb
CHANGED
data/lib/ohai/plugins/groovy.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Davide Cavalca <dcavalca@fb.com>
|
4
|
+
# Copyright:: Copyright (c) 2020 Facebook
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
Ohai.plugin(:Grub2) do
|
21
|
+
provides "grub2/environment"
|
22
|
+
optional true
|
23
|
+
|
24
|
+
collect_data(:dragonflybsd, :freebsd, :linux, :netbsd) do
|
25
|
+
editenv_path = which("grub2-editenv")
|
26
|
+
if editenv_path
|
27
|
+
editenv_out = shell_out("#{editenv_path} list")
|
28
|
+
|
29
|
+
grub2 Mash.new unless grub2
|
30
|
+
grub2[:environment] ||= Mash.new
|
31
|
+
|
32
|
+
editenv_out.stdout.each_line do |line|
|
33
|
+
key, val = line.split("=", 2)
|
34
|
+
grub2[:environment][key] = val.strip
|
35
|
+
end
|
36
|
+
else
|
37
|
+
logger.trace("Plugin Grub2: Could not find grub2-editenv. Skipping plugin.")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/ohai/plugins/haskell.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
4
|
# Author:: Benjamin Black (<nostromo@gmail.com>)
|
@@ -37,8 +38,7 @@ Ohai.plugin(:Hostname) do
|
|
37
38
|
# fqdn and domain may be broken if DNS is broken on the host
|
38
39
|
|
39
40
|
def from_cmd(cmd)
|
40
|
-
|
41
|
-
so.stdout.split($/)[0]
|
41
|
+
shell_out(cmd).stdout.strip
|
42
42
|
end
|
43
43
|
|
44
44
|
# forward and reverse lookup to canonicalize FQDN (hostname -f equivalent)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Caleb Tennis (<caleb.tennis@gmail.com>)
|
3
4
|
# Copyright:: Copyright (c) Chef Software Inc.
|
@@ -20,6 +21,6 @@ Ohai.plugin(:InitPackage) do
|
|
20
21
|
provides "init_package"
|
21
22
|
|
22
23
|
collect_data(:linux) do
|
23
|
-
init_package
|
24
|
+
init_package file_exist?("/proc/1/comm") ? file_open("/proc/1/comm").gets.chomp : "init"
|
24
25
|
end
|
25
26
|
end
|
data/lib/ohai/plugins/java.rb
CHANGED
data/lib/ohai/plugins/kernel.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
4
|
# Author:: Benjamin Black (<nostromo@gmail.com>)
|
@@ -33,7 +34,7 @@ Ohai.plugin(:Kernel) do
|
|
33
34
|
["uname -v", :version], ["uname -m", :machine],
|
34
35
|
["uname -p", :processor]].each do |cmd, property|
|
35
36
|
so = shell_out(cmd)
|
36
|
-
kernel[property] = so.stdout.
|
37
|
+
kernel[property] = so.stdout.strip
|
37
38
|
end
|
38
39
|
kernel
|
39
40
|
end
|
@@ -114,7 +115,6 @@ Ohai.plugin(:Kernel) do
|
|
114
115
|
when 16 then "WIN95"
|
115
116
|
when 17 then "WIN98"
|
116
117
|
when 19 then "WINCE"
|
117
|
-
else nil
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -133,7 +133,6 @@ Ohai.plugin(:Kernel) do
|
|
133
133
|
when 6 then "Appliance PC"
|
134
134
|
when 7 then "Performance Server"
|
135
135
|
when 8 then "Maximum"
|
136
|
-
else nil
|
137
136
|
end
|
138
137
|
end
|
139
138
|
|
@@ -156,6 +155,10 @@ Ohai.plugin(:Kernel) do
|
|
156
155
|
].include?(name)
|
157
156
|
end
|
158
157
|
|
158
|
+
collect_data(:target) do
|
159
|
+
# intentionally left blank
|
160
|
+
end
|
161
|
+
|
159
162
|
collect_data(:default) do
|
160
163
|
kernel init_kernel
|
161
164
|
end
|
@@ -165,7 +168,7 @@ Ohai.plugin(:Kernel) do
|
|
165
168
|
kernel[:os] = kernel[:name]
|
166
169
|
|
167
170
|
so = shell_out("sysctl -n hw.optional.x86_64")
|
168
|
-
if so.stdout.
|
171
|
+
if so.stdout.strip.to_i == 1
|
169
172
|
kernel[:machine] = "x86_64"
|
170
173
|
end
|
171
174
|
|
@@ -185,7 +188,7 @@ Ohai.plugin(:Kernel) do
|
|
185
188
|
kernel[:os] = kernel[:name]
|
186
189
|
|
187
190
|
so = shell_out("uname -i")
|
188
|
-
kernel[:ident] = so.stdout.
|
191
|
+
kernel[:ident] = so.stdout.strip
|
189
192
|
so = shell_out("sysctl kern.securelevel")
|
190
193
|
kernel[:securelevel] = so.stdout.split($/).select { |e| e =~ /kern.securelevel: (.+)$/ }
|
191
194
|
|
@@ -196,7 +199,7 @@ Ohai.plugin(:Kernel) do
|
|
196
199
|
kernel init_kernel
|
197
200
|
|
198
201
|
so = shell_out("uname -o")
|
199
|
-
kernel[:os] = so.stdout.
|
202
|
+
kernel[:os] = so.stdout.strip
|
200
203
|
|
201
204
|
modules = Mash.new
|
202
205
|
so = shell_out("env lsmod")
|
@@ -204,8 +207,8 @@ Ohai.plugin(:Kernel) do
|
|
204
207
|
if line =~ /([a-zA-Z0-9\_]+)\s+(\d+)\s+(\d+)/
|
205
208
|
modules[$1] = { size: $2, refcount: $3 }
|
206
209
|
# Making sure to get the module version that has been loaded
|
207
|
-
if
|
208
|
-
version =
|
210
|
+
if file_exist?("/sys/module/#{$1}/version")
|
211
|
+
version = file_read("/sys/module/#{$1}/version").chomp.strip
|
209
212
|
modules[$1]["version"] = version unless version.empty?
|
210
213
|
end
|
211
214
|
end
|
@@ -228,9 +231,9 @@ Ohai.plugin(:Kernel) do
|
|
228
231
|
kernel init_kernel
|
229
232
|
|
230
233
|
so = shell_out("uname -s")
|
231
|
-
kernel[:os] = so.stdout.
|
234
|
+
kernel[:os] = so.stdout.strip
|
232
235
|
|
233
|
-
so =
|
236
|
+
so = file_open("/etc/release", &:gets)
|
234
237
|
md = /(?<update>\d.*\d)/.match(so)
|
235
238
|
kernel[:update] = md[:update] if md
|
236
239
|
|
@@ -240,7 +243,7 @@ Ohai.plugin(:Kernel) do
|
|
240
243
|
# EXAMPLE:
|
241
244
|
# Id Loadaddr Size Info Rev Module Name
|
242
245
|
# 6 1180000 4623 1 1 specfs (filesystem for specfs)
|
243
|
-
module_description =
|
246
|
+
module_description = /\s*(\d+)\s+([a-f\d]+)\s+([a-f\d]+)\s+(?:[\-\d]+)\s+(?:\d+)\s+(\S+)\s+\((.+)\)$/
|
244
247
|
so.stdout.lines do |line|
|
245
248
|
if ( mod = module_description.match(line) )
|
246
249
|
modules[mod[4]] = { id: mod[1].to_i, loadaddr: mod[2], size: mod[3].to_i(16), description: mod[5] }
|