ohai 16.4.11 → 16.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +11 -6
- data/bin/ohai +1 -1
- data/lib/ohai.rb +1 -1
- data/lib/ohai/application.rb +39 -0
- data/lib/ohai/common/dmi.rb +7 -3
- data/lib/ohai/config.rb +2 -3
- data/lib/ohai/dsl.rb +1 -1
- data/lib/ohai/dsl/plugin.rb +12 -5
- data/lib/ohai/dsl/plugin/versionvii.rb +28 -16
- data/lib/ohai/exception.rb +1 -1
- data/lib/ohai/hints.rb +1 -1
- data/lib/ohai/loader.rb +1 -1
- data/lib/ohai/log.rb +1 -1
- data/lib/ohai/mixin/azure_metadata.rb +1 -1
- data/lib/ohai/mixin/chef_utils_wiring.rb +51 -0
- data/lib/ohai/mixin/command.rb +3 -54
- data/lib/ohai/mixin/constant_helper.rb +1 -1
- data/lib/ohai/mixin/dmi_decode.rb +1 -1
- data/lib/ohai/mixin/do_metadata.rb +1 -1
- data/lib/ohai/mixin/ec2_metadata.rb +3 -3
- data/lib/ohai/mixin/http_helper.rb +1 -1
- data/lib/ohai/mixin/network_helper.rb +1 -1
- data/lib/ohai/mixin/os.rb +67 -2
- data/lib/ohai/mixin/scaleway_metadata.rb +1 -1
- data/lib/ohai/mixin/seconds_to_human.rb +1 -1
- data/lib/ohai/mixin/shell_out.rb +50 -0
- data/lib/ohai/mixin/string.rb +1 -1
- data/lib/ohai/mixin/train_helpers.rb +35 -0
- data/lib/ohai/mixin/which.rb +38 -0
- data/lib/ohai/plugin_config.rb +1 -1
- data/lib/ohai/plugins/aix/kernel.rb +1 -1
- data/lib/ohai/plugins/aix/memory.rb +3 -3
- data/lib/ohai/plugins/aix/network.rb +1 -1
- data/lib/ohai/plugins/aix/platform.rb +1 -1
- data/lib/ohai/plugins/aix/uptime.rb +1 -1
- data/lib/ohai/plugins/aix/virtualization.rb +1 -1
- data/lib/ohai/plugins/azure.rb +25 -5
- data/lib/ohai/plugins/bsd/virtualization.rb +3 -3
- data/lib/ohai/plugins/chef.rb +1 -1
- data/lib/ohai/plugins/cloud.rb +1 -1
- data/lib/ohai/plugins/command.rb +1 -1
- data/lib/ohai/plugins/cpu.rb +6 -6
- data/lib/ohai/plugins/darwin/memory.rb +1 -1
- data/lib/ohai/plugins/darwin/network.rb +1 -1
- data/lib/ohai/plugins/darwin/platform.rb +2 -2
- data/lib/ohai/plugins/darwin/virtualization.rb +2 -2
- data/lib/ohai/plugins/dmi.rb +1 -1
- data/lib/ohai/plugins/docker.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +15 -9
- data/lib/ohai/plugins/erlang.rb +1 -1
- data/lib/ohai/plugins/eucalyptus.rb +1 -1
- data/lib/ohai/plugins/filesystem.rb +4 -4
- data/lib/ohai/plugins/fips.rb +1 -1
- data/lib/ohai/plugins/gce.rb +2 -2
- data/lib/ohai/plugins/hostname.rb +1 -1
- data/lib/ohai/plugins/init_package.rb +2 -2
- data/lib/ohai/plugins/java.rb +1 -1
- data/lib/ohai/plugins/joyent.rb +2 -2
- data/lib/ohai/plugins/kernel.rb +9 -5
- data/lib/ohai/plugins/keys.rb +1 -1
- data/lib/ohai/plugins/languages.rb +1 -1
- data/lib/ohai/plugins/libvirt.rb +1 -1
- data/lib/ohai/plugins/linode.rb +1 -1
- data/lib/ohai/plugins/linux/block_device.rb +9 -9
- data/lib/ohai/plugins/linux/interrupts.rb +3 -3
- data/lib/ohai/plugins/linux/ipc.rb +1 -1
- data/lib/ohai/plugins/linux/lsb.rb +4 -4
- data/lib/ohai/plugins/linux/machineid.rb +4 -4
- data/lib/ohai/plugins/linux/mdadm.rb +2 -2
- data/lib/ohai/plugins/linux/memory.rb +2 -2
- data/lib/ohai/plugins/linux/network.rb +13 -13
- data/lib/ohai/plugins/linux/platform.rb +30 -30
- data/lib/ohai/plugins/linux/virtualization.rb +24 -24
- data/lib/ohai/plugins/network.rb +1 -1
- data/lib/ohai/plugins/ohai_time.rb +2 -2
- data/lib/ohai/plugins/openstack.rb +1 -1
- data/lib/ohai/plugins/os.rb +5 -1
- data/lib/ohai/plugins/packages.rb +20 -0
- data/lib/ohai/plugins/passwd.rb +57 -1
- data/lib/ohai/plugins/perl.rb +1 -1
- data/lib/ohai/plugins/platform.rb +1 -1
- data/lib/ohai/plugins/powershell.rb +1 -1
- data/lib/ohai/plugins/ps.rb +1 -1
- data/lib/ohai/plugins/python.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +2 -2
- data/lib/ohai/plugins/scaleway.rb +1 -1
- data/lib/ohai/plugins/shard.rb +1 -1
- data/lib/ohai/plugins/shells.rb +3 -3
- data/lib/ohai/plugins/softlayer.rb +1 -1
- data/lib/ohai/plugins/solaris2/dmi.rb +1 -1
- data/lib/ohai/plugins/solaris2/network.rb +6 -8
- data/lib/ohai/plugins/solaris2/platform.rb +3 -3
- data/lib/ohai/plugins/solaris2/virtualization.rb +2 -2
- data/lib/ohai/plugins/ssh_host_key.rb +13 -13
- data/lib/ohai/plugins/train.rb +35 -0
- data/lib/ohai/plugins/uptime.rb +2 -2
- data/lib/ohai/plugins/virtualbox.rb +1 -1
- data/lib/ohai/plugins/vmware.rb +2 -2
- data/lib/ohai/plugins/windows/drivers.rb +1 -1
- data/lib/ohai/plugins/windows/network.rb +2 -2
- data/lib/ohai/plugins/windows/platform.rb +1 -1
- data/lib/ohai/plugins/windows/system_enclosure.rb +1 -1
- data/lib/ohai/plugins/windows/virtualization.rb +1 -1
- data/lib/ohai/plugins/zpools.rb +1 -1
- data/lib/ohai/provides_map.rb +1 -1
- data/lib/ohai/runner.rb +5 -1
- data/lib/ohai/system.rb +34 -7
- data/lib/ohai/train_transport.rb +28 -0
- data/lib/ohai/util/file_helper.rb +4 -37
- data/lib/ohai/util/win32.rb +1 -1
- data/lib/ohai/version.rb +3 -3
- data/ohai.gemspec +7 -7
- metadata +80 -60
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
3
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -49,7 +49,7 @@ Ohai.plugin(:Virtualization) do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# detect from modules
|
52
|
-
so = shell_out(
|
52
|
+
so = shell_out(Ohai.abs_path("/sbin/kldstat").to_s)
|
53
53
|
so.stdout.lines do |line|
|
54
54
|
case line
|
55
55
|
when /vboxdrv/
|
@@ -66,7 +66,7 @@ Ohai.plugin(:Virtualization) do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
# Detect bhyve by presence of /dev/vmm
|
69
|
-
if
|
69
|
+
if file_exist?("/dev/vmm")
|
70
70
|
virtualization[:system] = "bhyve"
|
71
71
|
virtualization[:role] = "host"
|
72
72
|
virtualization[:systems][:bhyve] = "host"
|
data/lib/ohai/plugins/chef.rb
CHANGED
data/lib/ohai/plugins/cloud.rb
CHANGED
data/lib/ohai/plugins/command.rb
CHANGED
data/lib/ohai/plugins/cpu.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
9
9
|
# Author:: Isa Farnik (<isa@chef.io>)
|
10
10
|
# Author:: Doug MacEachern <dougm@vmware.com>
|
11
|
-
# Copyright:: Copyright (c)
|
11
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
12
12
|
# License:: Apache License, Version 2.0
|
13
13
|
#
|
14
14
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -30,7 +30,7 @@ Ohai.plugin(:CPU) do
|
|
30
30
|
def parse_bsd_dmesg(&block)
|
31
31
|
cpuinfo = Mash.new
|
32
32
|
cpuinfo["flags"] = []
|
33
|
-
|
33
|
+
file_open("/var/run/dmesg.boot").each do |line|
|
34
34
|
case line
|
35
35
|
when /CPU:\s+(.+) \(([\d.]+).+\)/
|
36
36
|
cpuinfo["model_name"] = $1
|
@@ -53,7 +53,7 @@ Ohai.plugin(:CPU) do
|
|
53
53
|
cpu_number = 0
|
54
54
|
current_cpu = nil
|
55
55
|
|
56
|
-
|
56
|
+
file_open("/proc/cpuinfo").each do |line|
|
57
57
|
case line
|
58
58
|
when /processor\s+:\s(.+)/
|
59
59
|
cpuinfo[$1] = Mash.new
|
@@ -61,7 +61,7 @@ Ohai.plugin(:CPU) do
|
|
61
61
|
cpu_number += 1
|
62
62
|
when /vendor_id\s+:\s(.+)/
|
63
63
|
vendor_id = $1
|
64
|
-
if vendor_id
|
64
|
+
if vendor_id.include?("IBM/S390")
|
65
65
|
cpuinfo["vendor_id"] = vendor_id
|
66
66
|
else
|
67
67
|
cpuinfo[current_cpu]["vendor_id"] = vendor_id
|
@@ -212,7 +212,7 @@ Ohai.plugin(:CPU) do
|
|
212
212
|
# to scrape from dmesg.boot is the cpu feature list.
|
213
213
|
# cpu0: FPU,V86,DE,PSE,TSC,MSR,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,SBF,EST,TM2
|
214
214
|
|
215
|
-
|
215
|
+
file_open("/var/run/dmesg.boot").each do |line|
|
216
216
|
case line
|
217
217
|
when /cpu\d+:\s+([A-Z]+$|[A-Z]+,.*$)/
|
218
218
|
cpuinfo["flags"] = $1.downcase.split(",")
|
@@ -235,7 +235,7 @@ Ohai.plugin(:CPU) do
|
|
235
235
|
# available instruction set
|
236
236
|
# cpu0 at mainbus0 apid 0: Intel 686-class, 2134MHz, id 0x6f6
|
237
237
|
|
238
|
-
|
238
|
+
file_open("/var/run/dmesg.boot").each do |line|
|
239
239
|
case line
|
240
240
|
when /cpu[\d\w\s]+:\s([\w\s\-]+),\s+(\w+),/
|
241
241
|
cpuinfo[:model_name] = $1
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Patrick Collins (<pat@burned.com>)
|
3
|
-
# Copyright:: Copyright (c)
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) Chef Software
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -20,7 +20,7 @@ Ohai.plugin(:Platform) do
|
|
20
20
|
provides "platform", "platform_version", "platform_build", "platform_family"
|
21
21
|
|
22
22
|
collect_data(:darwin) do
|
23
|
-
so = shell_out(
|
23
|
+
so = shell_out(Ohai.abs_path( "/usr/bin/sw_vers" ).to_s)
|
24
24
|
so.stdout.lines do |line|
|
25
25
|
case line
|
26
26
|
when /^ProductVersion:\s+(.+)$/
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Author:: Pavel Yudin (<pyudin@parallels.com>)
|
3
3
|
# Author:: Tim Smith (<tsmith@chef.io>)
|
4
4
|
# Copyright:: Copyright (c) 2015 Pavel Yudin
|
5
|
-
# Copyright:: Copyright (c)
|
5
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -35,7 +35,7 @@ Ohai.plugin(:Virtualization) do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def fusion_exists?
|
38
|
-
|
38
|
+
file_exist?("/Applications/VMware\ Fusion.app/")
|
39
39
|
end
|
40
40
|
|
41
41
|
def docker_exists?
|
data/lib/ohai/plugins/dmi.rb
CHANGED
@@ -76,7 +76,7 @@ Ohai.plugin(:DMI) do
|
|
76
76
|
dmi[:table_location] = table_location[1]
|
77
77
|
|
78
78
|
elsif ( handle = handle_line.match(line) )
|
79
|
-
unless Ohai::Common::DMI.
|
79
|
+
unless Ohai::Common::DMI.allowlisted_ids.include?(handle[2].to_i)
|
80
80
|
dmi_record = nil
|
81
81
|
next
|
82
82
|
end
|
data/lib/ohai/plugins/docker.rb
CHANGED
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Author:: Benjamin Black (<bb@chef.io>)
|
4
4
|
# Author:: Christopher Brown (<cb@chef.io>)
|
5
5
|
# Author:: Tim Smith (<tsmith@chef.io>)
|
6
|
-
# Copyright:: Copyright (c)
|
6
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
7
7
|
# License:: Apache License, Version 2.0
|
8
8
|
#
|
9
9
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -97,8 +97,8 @@ Ohai.plugin(:EC2) do
|
|
97
97
|
# @param path[String] abs path to the file
|
98
98
|
# @return [String] contents of the file if it exists
|
99
99
|
def file_val_if_exists(path)
|
100
|
-
if
|
101
|
-
|
100
|
+
if file_exist?(path)
|
101
|
+
file_read(path)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -114,7 +114,7 @@ Ohai.plugin(:EC2) do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
collect_data do
|
117
|
-
require "base64"
|
117
|
+
require "base64" unless defined?(Base64)
|
118
118
|
|
119
119
|
if looks_like_ec2?
|
120
120
|
logger.trace("Plugin EC2: looks_like_ec2? == true")
|
@@ -122,11 +122,17 @@ Ohai.plugin(:EC2) do
|
|
122
122
|
fetch_metadata.each do |k, v|
|
123
123
|
# fetch_metadata returns IAM security credentials, including the IAM user's
|
124
124
|
# secret access key. We'd rather not have ohai send this information
|
125
|
-
# to the server.
|
126
|
-
#
|
127
|
-
|
128
|
-
|
129
|
-
|
125
|
+
# to the server. If the instance is associated with an IAM role we grab
|
126
|
+
# only the "info" key and the IAM role name.
|
127
|
+
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html
|
128
|
+
if k == "iam" && !hint?("iam")
|
129
|
+
ec2[:iam] = v.select { |key, value| key == "info" }
|
130
|
+
if v["security-credentials"] && v["security-credentials"].keys.length == 1
|
131
|
+
ec2[:iam]["role_name"] = v["security-credentials"].keys[0]
|
132
|
+
end
|
133
|
+
else
|
134
|
+
ec2[k] = v
|
135
|
+
end
|
130
136
|
end
|
131
137
|
ec2[:userdata] = fetch_userdata
|
132
138
|
ec2[:account_id] = fetch_dynamic_data["accountId"]
|
data/lib/ohai/plugins/erlang.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Joe Williams (<joe@joetify.com>)
|
3
|
-
# Copyright:: Copyright (c)
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Author:: Tim Dysinger (<tim@dysinger.net>)
|
3
3
|
# Author:: Benjamin Black (<bb@chef.io>)
|
4
4
|
# Author:: Christopher Brown (<cb@chef.io>)
|
5
|
-
# Copyright:: Copyright (c)
|
5
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
7
7
|
# Author:: Isa Farnik (<isa@chef.io>)
|
8
8
|
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
9
|
-
# Copyright:: Copyright (c)
|
9
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
10
10
|
# Copyright:: Copyright (c) 2015 Facebook, Inc.
|
11
11
|
# License:: Apache License, Version 2.0
|
12
12
|
#
|
@@ -29,7 +29,7 @@ Ohai.plugin(:Filesystem) do
|
|
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,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Matt Wrock (<matt@mattwrock.com>)
|
3
|
-
# Copyright:: Copyright (c)
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
data/lib/ohai/plugins/gce.rb
CHANGED
@@ -40,8 +40,8 @@ Ohai.plugin(:GCE) do
|
|
40
40
|
# @param path[String] abs path to the file
|
41
41
|
# @return [String] contents of the file if it exists
|
42
42
|
def file_val_if_exists(path)
|
43
|
-
if
|
44
|
-
|
43
|
+
if file_exist?(path)
|
44
|
+
file_read(path)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
7
7
|
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
8
8
|
# Author:: Isa Farnik (<isa@chef.io>)
|
9
|
-
# Copyright:: Copyright (c)
|
9
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
10
10
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
11
11
|
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
12
12
|
# Copyright:: Copyright (c) 2010 VMware, Inc.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Caleb Tennis (<caleb.tennis@gmail.com>)
|
3
|
-
# Copyright:: Copyright (c)
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -20,6 +20,6 @@ Ohai.plugin(:InitPackage) do
|
|
20
20
|
provides "init_package"
|
21
21
|
|
22
22
|
collect_data(:linux) do
|
23
|
-
init_package
|
23
|
+
init_package file_exist?("/proc/1/comm") ? file_open("/proc/1/comm").gets.chomp : "init"
|
24
24
|
end
|
25
25
|
end
|
data/lib/ohai/plugins/java.rb
CHANGED
data/lib/ohai/plugins/joyent.rb
CHANGED
@@ -25,7 +25,7 @@ Ohai.plugin(:Joyent) do
|
|
25
25
|
depends "os", "platform", "virtualization"
|
26
26
|
|
27
27
|
def collect_product_file
|
28
|
-
data =
|
28
|
+
data = file_read("/etc/product") rescue nil
|
29
29
|
if data
|
30
30
|
data.strip.split("\n")
|
31
31
|
else
|
@@ -34,7 +34,7 @@ Ohai.plugin(:Joyent) do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def collect_pkgsrc
|
37
|
-
data =
|
37
|
+
data = file_read("/opt/local/etc/pkg_install.conf") rescue nil
|
38
38
|
if data
|
39
39
|
/PKG_PATH=(.*)/.match(data)[1] rescue nil
|
40
40
|
end
|
data/lib/ohai/plugins/kernel.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Author:: Bryan McLellan (<btm@loftninjas.org>)
|
5
5
|
# Author:: Claire McQuin (<claire@chef.io>)
|
6
6
|
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
7
|
-
# Copyright:: Copyright (c) Chef Software
|
7
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
8
8
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
9
9
|
# License:: Apache License, Version 2.0
|
10
10
|
#
|
@@ -42,7 +42,7 @@ Ohai.plugin(:Kernel) do
|
|
42
42
|
# @return [Mash]
|
43
43
|
def bsd_modules(path)
|
44
44
|
modules = Mash.new
|
45
|
-
so = shell_out(
|
45
|
+
so = shell_out(Ohai.abs_path(path).to_s)
|
46
46
|
so.stdout.lines do |line|
|
47
47
|
# 1 7 0xc0400000 97f830 kernel
|
48
48
|
if line =~ /(\d+)\s+(\d+)\s+([0-9a-fx]+)\s+([0-9a-fx]+)\s+([a-zA-Z0-9\_]+)/
|
@@ -156,6 +156,10 @@ Ohai.plugin(:Kernel) do
|
|
156
156
|
].include?(name)
|
157
157
|
end
|
158
158
|
|
159
|
+
collect_data(:target) do
|
160
|
+
# intentionally left blank
|
161
|
+
end
|
162
|
+
|
159
163
|
collect_data(:default) do
|
160
164
|
kernel init_kernel
|
161
165
|
end
|
@@ -204,8 +208,8 @@ Ohai.plugin(:Kernel) do
|
|
204
208
|
if line =~ /([a-zA-Z0-9\_]+)\s+(\d+)\s+(\d+)/
|
205
209
|
modules[$1] = { size: $2, refcount: $3 }
|
206
210
|
# Making sure to get the module version that has been loaded
|
207
|
-
if
|
208
|
-
version =
|
211
|
+
if file_exist?("/sys/module/#{$1}/version")
|
212
|
+
version = file_read("/sys/module/#{$1}/version").chomp.strip
|
209
213
|
modules[$1]["version"] = version unless version.empty?
|
210
214
|
end
|
211
215
|
end
|
@@ -230,7 +234,7 @@ Ohai.plugin(:Kernel) do
|
|
230
234
|
so = shell_out("uname -s")
|
231
235
|
kernel[:os] = so.stdout.split($/)[0]
|
232
236
|
|
233
|
-
so =
|
237
|
+
so = file_open("/etc/release", &:gets)
|
234
238
|
md = /(?<update>\d.*\d)/.match(so)
|
235
239
|
kernel[:update] = md[:update] if md
|
236
240
|
|
data/lib/ohai/plugins/keys.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Cookbook Name:: apache2
|
3
3
|
# Recipe:: default
|
4
4
|
#
|
5
|
-
# Copyright
|
5
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
# you may not use this file except in compliance with the License.
|
data/lib/ohai/plugins/libvirt.rb
CHANGED
data/lib/ohai/plugins/linode.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c)
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -20,24 +20,24 @@ Ohai.plugin(:BlockDevice) do
|
|
20
20
|
provides "block_device"
|
21
21
|
|
22
22
|
collect_data(:linux) do
|
23
|
-
if
|
23
|
+
if file_exist?("/sys/block")
|
24
24
|
block = Mash.new
|
25
|
-
|
25
|
+
dir_glob("/sys/block/*").each do |block_device_dir|
|
26
26
|
dir = File.basename(block_device_dir)
|
27
27
|
block[dir] = Mash.new
|
28
28
|
%w{size removable}.each do |check|
|
29
|
-
if
|
30
|
-
|
29
|
+
if file_exist?("/sys/block/#{dir}/#{check}")
|
30
|
+
file_open("/sys/block/#{dir}/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
|
31
31
|
end
|
32
32
|
end
|
33
33
|
%w{model rev state timeout vendor queue_depth}.each do |check|
|
34
|
-
if
|
35
|
-
|
34
|
+
if file_exist?("/sys/block/#{dir}/device/#{check}")
|
35
|
+
file_open("/sys/block/#{dir}/device/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
|
36
36
|
end
|
37
37
|
end
|
38
38
|
%w{rotational physical_block_size logical_block_size}.each do |check|
|
39
|
-
if
|
40
|
-
|
39
|
+
if file_exist?("/sys/block/#{dir}/queue/#{check}")
|
40
|
+
file_open("/sys/block/#{dir}/queue/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|