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
data/lib/ohai/plugins/network.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");
|
@@ -19,7 +19,7 @@
|
|
19
19
|
Ohai.plugin(:OhaiTime) do
|
20
20
|
provides "ohai_time"
|
21
21
|
|
22
|
-
collect_data do
|
22
|
+
collect_data(:default, :target) do
|
23
23
|
ohai_time Time.now.to_f
|
24
24
|
end
|
25
25
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Matt Ray (<matt@chef.io>)
|
3
3
|
# Author:: Tim Smith (<tsmith@chef.io>)
|
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");
|
data/lib/ohai/plugins/os.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
3
|
# Author:: Isa Farnik (<isa@chef.io>)
|
4
4
|
# Author:: Richard Manyanza (<liseki@nyikacraftsmen.com>)
|
5
|
-
# Copyright:: Copyright (c)
|
5
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
6
|
# Copyright:: Copyright (c) 2014 Richard Manyanza.
|
7
7
|
# License:: Apache License, Version 2.0
|
8
8
|
#
|
@@ -37,6 +37,10 @@ Ohai.plugin(:OS) do
|
|
37
37
|
os_version shell_out("sysctl -n kern.osreldate").stdout.split($/)[0]
|
38
38
|
end
|
39
39
|
|
40
|
+
collect_data(:target) do
|
41
|
+
os collect_os
|
42
|
+
end
|
43
|
+
|
40
44
|
collect_data do
|
41
45
|
os collect_os
|
42
46
|
os_version kernel[:release]
|
@@ -209,4 +209,24 @@ Ohai.plugin(:Packages) do
|
|
209
209
|
collect_ips_packages
|
210
210
|
collect_sysv_packages
|
211
211
|
end
|
212
|
+
|
213
|
+
def collect_system_profiler_apps
|
214
|
+
require "plist"
|
215
|
+
sp_std = shell_out("system_profiler SPApplicationsDataType -xml")
|
216
|
+
results = Plist.parse_xml(sp_std.stdout)
|
217
|
+
sw_array = results[0]["_items"]
|
218
|
+
sw_array.each do |pkg|
|
219
|
+
packages[pkg["_name"]] = {
|
220
|
+
"version" => pkg["version"],
|
221
|
+
"lastmodified" => pkg["lastModified"],
|
222
|
+
"source" => pkg["obtained_from"],
|
223
|
+
}
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
collect_data(:darwin) do
|
228
|
+
packages Mash.new
|
229
|
+
collect_system_profiler_apps
|
230
|
+
end
|
231
|
+
|
212
232
|
end
|
data/lib/ohai/plugins/passwd.rb
CHANGED
@@ -42,6 +42,62 @@ Ohai.plugin(:Passwd) do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
collect_data(:windows) do
|
45
|
-
|
45
|
+
require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
|
46
|
+
|
47
|
+
unless etc
|
48
|
+
etc Mash.new
|
49
|
+
|
50
|
+
wmi = WmiLite::Wmi.new
|
51
|
+
|
52
|
+
etc[:passwd] = Mash.new
|
53
|
+
users = wmi.query("SELECT * FROM Win32_UserAccount WHERE LocalAccount = True")
|
54
|
+
users.each do |user|
|
55
|
+
uname = user["Name"].strip.downcase
|
56
|
+
Ohai::Log.debug("processing user #{uname}")
|
57
|
+
etc[:passwd][uname] = Mash.new
|
58
|
+
wmi_obj = user.wmi_ole_object
|
59
|
+
wmi_obj.properties_.each do |key|
|
60
|
+
etc[:passwd][uname][key.name.downcase] = user[key.name]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
etc[:group] = Mash.new
|
65
|
+
groups = wmi.query("SELECT * FROM Win32_Group WHERE LocalAccount = True")
|
66
|
+
groups.each do |group|
|
67
|
+
gname = group["Name"].strip.downcase
|
68
|
+
Ohai::Log.debug("processing group #{gname}")
|
69
|
+
etc[:group][gname] = Mash.new
|
70
|
+
wmi_obj = group.wmi_ole_object
|
71
|
+
wmi_obj.properties_.each do |key|
|
72
|
+
etc[:group][gname][key.name.downcase] = group[key.name]
|
73
|
+
end
|
74
|
+
|
75
|
+
# This is the primary reason that we're using WMI instead of powershell
|
76
|
+
# cmdlets - the powershell start up cost is huge, and you *must* do this
|
77
|
+
# query for every. single. group. individually.
|
78
|
+
|
79
|
+
# The query returns nothing unless you specify domain *and* name, it's
|
80
|
+
# a path, not a set of queries.
|
81
|
+
subq = "Win32_Group.Domain='#{group["Domain"]}',Name='#{group["Name"]}'"
|
82
|
+
members = wmi.query(
|
83
|
+
"SELECT * FROM Win32_GroupUser WHERE GroupComponent=\"#{subq}\""
|
84
|
+
)
|
85
|
+
etc[:group][gname]["members"] = members.map do |member|
|
86
|
+
mi = {}
|
87
|
+
info = Hash[
|
88
|
+
member["partcomponent"].split(",").map { |x| x.split("=") }.map { |a, b| [a, b.undump] }
|
89
|
+
]
|
90
|
+
if info.keys.any? { |x| x.match?("Win32_UserAccount") }
|
91
|
+
mi["type"] = :user
|
92
|
+
else
|
93
|
+
# Note: the type here is actually Win32_SystemAccount, because,
|
94
|
+
# that's what groups are in the Windows universe.
|
95
|
+
mi["type"] = :group
|
96
|
+
end
|
97
|
+
mi["name"] = info["Name"]
|
98
|
+
mi
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
46
102
|
end
|
47
103
|
end
|
data/lib/ohai/plugins/perl.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Joshua Timberman (<joshua@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");
|
data/lib/ohai/plugins/ps.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
3
|
# Author:: Bryan McLellan (<btm@loftninjas.org>)
|
4
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
5
5
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
data/lib/ohai/plugins/python.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Thom May (<thom@clearairturbulence.org>)
|
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");
|
@@ -161,8 +161,8 @@ Ohai.plugin(:Rackspace) do
|
|
161
161
|
unless rackspace[:public_ip].nil?
|
162
162
|
rackspace[:public_hostname] = begin
|
163
163
|
Resolv.getname(rackspace[:public_ip])
|
164
|
-
|
165
|
-
|
164
|
+
rescue Resolv::ResolvError, Resolv::ResolvTimeout
|
165
|
+
rackspace[:public_ip]
|
166
166
|
end
|
167
167
|
end
|
168
168
|
rackspace[:local_ipv4] = rackspace[:private_ip]
|
@@ -26,7 +26,7 @@ Ohai.plugin(:Scaleway) do
|
|
26
26
|
# looks for `scaleway` keyword in kernel command line
|
27
27
|
# @return [Boolean] do we have the keyword or not?
|
28
28
|
def has_scaleway_cmdline?
|
29
|
-
if
|
29
|
+
if file_exist?("/proc/cmdline") && /scaleway/.match?(file_read("/proc/cmdline"))
|
30
30
|
logger.trace("Plugin Scaleway: has_scaleway_cmdline? == true")
|
31
31
|
return true
|
32
32
|
end
|
data/lib/ohai/plugins/shard.rb
CHANGED
@@ -52,7 +52,7 @@ Ohai.plugin(:ShardSeed) do
|
|
52
52
|
def digest_algorithm
|
53
53
|
case Ohai.config[:plugin][:shard_seed][:digest_algorithm] || default_digest_algorithm
|
54
54
|
when "md5"
|
55
|
-
require "digest/md5"
|
55
|
+
require "digest/md5" unless defined?(Digest::MD5)
|
56
56
|
Digest::MD5
|
57
57
|
when "sha256"
|
58
58
|
require "openssl/digest"
|
data/lib/ohai/plugins/shells.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Tim Smith (<tsmith@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,9 +20,9 @@ Ohai.plugin(:Shells) do
|
|
20
20
|
provides "shells"
|
21
21
|
|
22
22
|
collect_data do
|
23
|
-
if
|
23
|
+
if file_exist?("/etc/shells")
|
24
24
|
shells []
|
25
|
-
|
25
|
+
file_open("/etc/shells").readlines.each do |line|
|
26
26
|
# remove carriage returns and skip over comments / empty lines
|
27
27
|
shells << line.chomp if line[0] == "/"
|
28
28
|
end
|
@@ -39,7 +39,7 @@ Ohai.plugin(:Softlayer) do
|
|
39
39
|
logger.trace("Plugin Softlayer: looks_like_softlayer? == true")
|
40
40
|
metadata = fetch_metadata
|
41
41
|
softlayer Mash.new
|
42
|
-
metadata
|
42
|
+
metadata&.each { |k, v| softlayer[k] = v }
|
43
43
|
else
|
44
44
|
logger.trace("Plugin Softlayer: looks_like_softlayer? == false")
|
45
45
|
end
|
@@ -128,7 +128,7 @@ Ohai.plugin(:DMI) do
|
|
128
128
|
id = smb_to_id[header_information[3]]
|
129
129
|
|
130
130
|
# Don't overcapture for now (OHAI-260)
|
131
|
-
unless Ohai::Common::DMI.
|
131
|
+
unless Ohai::Common::DMI.allowlisted_ids.include?(id)
|
132
132
|
dmi_record = nil
|
133
133
|
next
|
134
134
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Benjamin Black (<nostromo@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");
|
@@ -86,7 +86,7 @@ Ohai.plugin(:Network) do
|
|
86
86
|
|
87
87
|
def full_interface_name(iface, part_name, index)
|
88
88
|
iface.each do |name, attrs|
|
89
|
-
next unless attrs
|
89
|
+
next unless attrs.respond_to?(:[])
|
90
90
|
return name if /^#{part_name}($|:)/.match(name) && attrs[:index] == index
|
91
91
|
end
|
92
92
|
|
@@ -155,12 +155,10 @@ Ohai.plugin(:Network) do
|
|
155
155
|
break
|
156
156
|
end
|
157
157
|
end
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
break
|
163
|
-
end
|
158
|
+
iface[ifn][:arp]&.each_key do |addr|
|
159
|
+
if addr.eql?(iaddr)
|
160
|
+
iface[ifn][:addresses][iface[ifn][:arp][iaddr]] = { "family" => "lladdr" }
|
161
|
+
break
|
164
162
|
end
|
165
163
|
end
|
166
164
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Benjamin Black (<nostromo@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,7 +20,7 @@ Ohai.plugin(:Platform) do
|
|
20
20
|
provides "platform", "platform_version", "platform_build", "platform_family"
|
21
21
|
|
22
22
|
collect_data(:solaris2) do
|
23
|
-
if
|
23
|
+
if file_exist?("/sbin/uname")
|
24
24
|
uname_exec = "/sbin/uname"
|
25
25
|
else
|
26
26
|
uname_exec = "uname"
|
@@ -35,7 +35,7 @@ Ohai.plugin(:Platform) do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
38
|
+
file_open("/etc/release") do |file|
|
39
39
|
while ( line = file.gets )
|
40
40
|
case line
|
41
41
|
when /^.*(SmartOS).*$/
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Sean Walbran (<seanwalbran@gmail.com>)
|
3
3
|
# Author:: Kurt Yoder (<ktyopscode@yoderhome.com>)
|
4
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
5
5
|
# Copyright:: Copyright (c) 2010 Kurt Yoder
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
@@ -34,7 +34,7 @@ Ohai.plugin(:Virtualization) do
|
|
34
34
|
|
35
35
|
# Detect paravirt KVM/QEMU from cpuinfo, report as KVM
|
36
36
|
psrinfo_path = Ohai.abs_path( "/usr/sbin/psrinfo" )
|
37
|
-
if
|
37
|
+
if file_exist?(psrinfo_path)
|
38
38
|
so = shell_out("#{psrinfo_path} -pv")
|
39
39
|
if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(so.stdout)
|
40
40
|
virtualization[:system] = "kvm"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Bryan McLellan <btm@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");
|
@@ -38,9 +38,9 @@ Ohai.plugin(:SSHHostKey) do
|
|
38
38
|
collect_data do
|
39
39
|
keys[:ssh] = Mash.new
|
40
40
|
|
41
|
-
sshd_config = if
|
41
|
+
sshd_config = if file_exist?("/etc/ssh/sshd_config")
|
42
42
|
"/etc/ssh/sshd_config"
|
43
|
-
elsif
|
43
|
+
elsif file_exist?("/etc/sshd_config")
|
44
44
|
# Darwin
|
45
45
|
"/etc/sshd_config"
|
46
46
|
else
|
@@ -49,11 +49,11 @@ Ohai.plugin(:SSHHostKey) do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
if sshd_config
|
52
|
-
|
52
|
+
file_open(sshd_config) do |conf|
|
53
53
|
conf.each_line do |line|
|
54
54
|
if /^hostkey\s/i.match?(line)
|
55
55
|
pub_file = "#{line.split[1]}.pub"
|
56
|
-
content =
|
56
|
+
content = file_read(pub_file).split
|
57
57
|
key_type, key_subtype = extract_keytype?(content)
|
58
58
|
keys[:ssh]["host_#{key_type}_public"] = content[1] unless key_type.nil?
|
59
59
|
keys[:ssh]["host_#{key_type}_type"] = key_subtype unless key_subtype.nil?
|
@@ -62,22 +62,22 @@ Ohai.plugin(:SSHHostKey) do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
if keys[:ssh][:host_dsa_public].nil? &&
|
66
|
-
keys[:ssh][:host_dsa_public] =
|
65
|
+
if keys[:ssh][:host_dsa_public].nil? && file_exist?("/etc/ssh/ssh_host_dsa_key.pub")
|
66
|
+
keys[:ssh][:host_dsa_public] = file_read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
|
67
67
|
end
|
68
68
|
|
69
|
-
if keys[:ssh][:host_rsa_public].nil? &&
|
70
|
-
keys[:ssh][:host_rsa_public] =
|
69
|
+
if keys[:ssh][:host_rsa_public].nil? && file_exist?("/etc/ssh/ssh_host_rsa_key.pub")
|
70
|
+
keys[:ssh][:host_rsa_public] = file_read("/etc/ssh/ssh_host_rsa_key.pub").split[1]
|
71
71
|
end
|
72
72
|
|
73
|
-
if keys[:ssh][:host_ecdsa_public].nil? &&
|
74
|
-
content =
|
73
|
+
if keys[:ssh][:host_ecdsa_public].nil? && file_exist?("/etc/ssh/ssh_host_ecdsa_key.pub")
|
74
|
+
content = file_read("/etc/ssh/ssh_host_ecdsa_key.pub")
|
75
75
|
keys[:ssh][:host_ecdsa_public] = content.split[1]
|
76
76
|
keys[:ssh][:host_ecdsa_type] = content.split[0]
|
77
77
|
end
|
78
78
|
|
79
|
-
if keys[:ssh][:host_ed25519_public].nil? &&
|
80
|
-
keys[:ssh][:host_ed25519_public] =
|
79
|
+
if keys[:ssh][:host_ed25519_public].nil? && file_exist?("/etc/ssh/ssh_host_ed25519_key.pub")
|
80
|
+
keys[:ssh][:host_ed25519_public] = file_read("/etc/ssh/ssh_host_ed25519_key.pub").split[1]
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
Ohai.plugin(:Train) do
|
19
|
+
provides "train"
|
20
|
+
|
21
|
+
collect_data do
|
22
|
+
if transport_connection
|
23
|
+
train Mash.new
|
24
|
+
train["family_hierarchy"] = transport_connection.platform.family_hierarchy
|
25
|
+
train["family"] = transport_connection.platform.family
|
26
|
+
train["platform"] = transport_connection.platform.platform
|
27
|
+
train["backend"] = transport_connection.backend_type
|
28
|
+
if transport_connection.respond_to?(:uri)
|
29
|
+
train["scheme"] = URI.parse(transport_connection.uri).scheme
|
30
|
+
train["uri"] = transport_connection.uri
|
31
|
+
else
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/ohai/plugins/uptime.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
6
6
|
# Author:: Kurt Yoder (<ktyopscode@yoderhome.com>)
|
7
7
|
# Author:: Paul Mooring (<paul@chef.io>)
|
8
|
-
# Copyright:: Copyright (c)
|
8
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
9
9
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
10
10
|
# Copyright:: Copyright (c) 2010 VMware, Inc.
|
11
11
|
# License:: Apache License, Version 2.0
|
@@ -54,7 +54,7 @@ Ohai.plugin(:Uptime) do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
collect_data(:linux) do
|
57
|
-
uptime, idletime =
|
57
|
+
uptime, idletime = file_open("/proc/uptime").gets.split(" ")
|
58
58
|
uptime_seconds uptime.to_i
|
59
59
|
uptime seconds_to_human(uptime.to_i)
|
60
60
|
idletime_seconds idletime.to_i
|