ohai 16.4.12 → 16.7.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +11 -11
- data/bin/ohai +2 -1
- data/lib/ohai.rb +2 -1
- data/lib/ohai/application.rb +40 -0
- data/lib/ohai/common/dmi.rb +8 -3
- data/lib/ohai/config.rb +3 -3
- data/lib/ohai/dsl.rb +2 -1
- data/lib/ohai/dsl/plugin.rb +13 -5
- data/lib/ohai/dsl/plugin/versionvii.rb +29 -16
- data/lib/ohai/exception.rb +2 -1
- data/lib/ohai/hints.rb +2 -1
- data/lib/ohai/loader.rb +1 -1
- data/lib/ohai/log.rb +2 -1
- data/lib/ohai/mash.rb +1 -0
- data/lib/ohai/mixin/azure_metadata.rb +3 -2
- data/lib/ohai/mixin/chef_utils_wiring.rb +52 -0
- data/lib/ohai/mixin/command.rb +4 -54
- data/lib/ohai/mixin/constant_helper.rb +2 -1
- data/lib/ohai/mixin/dmi_decode.rb +2 -1
- data/lib/ohai/mixin/do_metadata.rb +4 -3
- data/lib/ohai/mixin/ec2_metadata.rb +5 -4
- data/lib/ohai/mixin/gce_metadata.rb +3 -2
- data/lib/ohai/mixin/http_helper.rb +2 -1
- data/lib/ohai/mixin/network_helper.rb +2 -1
- data/lib/ohai/mixin/os.rb +68 -2
- data/lib/ohai/mixin/scaleway_metadata.rb +4 -3
- data/lib/ohai/mixin/seconds_to_human.rb +2 -1
- data/lib/ohai/mixin/shell_out.rb +51 -0
- data/lib/ohai/mixin/softlayer_metadata.rb +2 -1
- data/lib/ohai/mixin/string.rb +2 -1
- data/lib/ohai/mixin/train_helpers.rb +36 -0
- data/lib/ohai/mixin/which.rb +39 -0
- data/lib/ohai/plugin_config.rb +2 -1
- data/lib/ohai/plugins/aix/kernel.rb +2 -1
- data/lib/ohai/plugins/aix/memory.rb +4 -3
- data/lib/ohai/plugins/aix/network.rb +3 -2
- data/lib/ohai/plugins/aix/platform.rb +2 -1
- data/lib/ohai/plugins/aix/uptime.rb +4 -3
- data/lib/ohai/plugins/aix/virtualization.rb +1 -1
- data/lib/ohai/plugins/azure.rb +26 -5
- data/lib/ohai/plugins/bsd/virtualization.rb +4 -3
- data/lib/ohai/plugins/c.rb +1 -0
- data/lib/ohai/plugins/chef.rb +2 -1
- data/lib/ohai/plugins/cloud.rb +2 -1
- data/lib/ohai/plugins/command.rb +2 -1
- data/lib/ohai/plugins/cpu.rb +8 -9
- data/lib/ohai/plugins/darwin/hardware.rb +1 -0
- data/lib/ohai/plugins/darwin/memory.rb +3 -4
- data/lib/ohai/plugins/darwin/network.rb +2 -1
- data/lib/ohai/plugins/darwin/platform.rb +3 -2
- data/lib/ohai/plugins/darwin/virtualization.rb +3 -2
- data/lib/ohai/plugins/digital_ocean.rb +1 -0
- data/lib/ohai/plugins/dmi.rb +2 -1
- data/lib/ohai/plugins/docker.rb +2 -1
- data/lib/ohai/plugins/dragonflybsd/memory.rb +1 -0
- data/lib/ohai/plugins/dragonflybsd/network.rb +1 -0
- data/lib/ohai/plugins/dragonflybsd/platform.rb +1 -0
- data/lib/ohai/plugins/ec2.rb +16 -9
- data/lib/ohai/plugins/elixir.rb +1 -1
- data/lib/ohai/plugins/erlang.rb +2 -1
- data/lib/ohai/plugins/eucalyptus.rb +5 -2
- data/lib/ohai/plugins/filesystem.rb +5 -5
- data/lib/ohai/plugins/fips.rb +2 -1
- data/lib/ohai/plugins/freebsd/memory.rb +1 -0
- data/lib/ohai/plugins/freebsd/network.rb +1 -0
- data/lib/ohai/plugins/freebsd/platform.rb +1 -0
- 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/haskell.rb +1 -0
- data/lib/ohai/plugins/hostname.rb +2 -1
- data/lib/ohai/plugins/init_package.rb +3 -2
- data/lib/ohai/plugins/java.rb +2 -1
- data/lib/ohai/plugins/joyent.rb +3 -2
- data/lib/ohai/plugins/kernel.rb +11 -6
- data/lib/ohai/plugins/keys.rb +2 -1
- data/lib/ohai/plugins/languages.rb +2 -1
- data/lib/ohai/plugins/libvirt.rb +2 -1
- data/lib/ohai/plugins/linode.rb +2 -1
- data/lib/ohai/plugins/linux/block_device.rb +10 -9
- 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 +8 -21
- data/lib/ohai/plugins/linux/lspci.rb +1 -0
- 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 +39 -38
- data/lib/ohai/plugins/linux/network.rb +14 -13
- data/lib/ohai/plugins/linux/platform.rb +32 -31
- 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 +25 -24
- 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 +1 -0
- 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 +3 -2
- 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 +1 -0
- data/lib/ohai/plugins/openstack.rb +2 -1
- data/lib/ohai/plugins/os.rb +6 -1
- data/lib/ohai/plugins/packages.rb +21 -0
- data/lib/ohai/plugins/passwd.rb +58 -1
- data/lib/ohai/plugins/perl.rb +2 -2
- data/lib/ohai/plugins/php.rb +1 -1
- data/lib/ohai/plugins/platform.rb +2 -1
- data/lib/ohai/plugins/powershell.rb +2 -2
- data/lib/ohai/plugins/ps.rb +2 -1
- data/lib/ohai/plugins/python.rb +2 -2
- data/lib/ohai/plugins/rackspace.rb +4 -3
- 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 +2 -1
- data/lib/ohai/plugins/scsi.rb +1 -0
- data/lib/ohai/plugins/shard.rb +2 -2
- data/lib/ohai/plugins/shells.rb +4 -3
- data/lib/ohai/plugins/softlayer.rb +2 -1
- 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 +7 -8
- data/lib/ohai/plugins/solaris2/platform.rb +9 -15
- data/lib/ohai/plugins/solaris2/virtualization.rb +4 -3
- data/lib/ohai/plugins/ssh_host_key.rb +14 -13
- data/lib/ohai/plugins/sysconf.rb +1 -0
- data/lib/ohai/plugins/timezone.rb +1 -0
- data/lib/ohai/plugins/train.rb +36 -0
- data/lib/ohai/plugins/uptime.rb +3 -2
- data/lib/ohai/plugins/virtualbox.rb +2 -1
- data/lib/ohai/plugins/vmware.rb +3 -2
- data/lib/ohai/plugins/windows/dmi.rb +1 -0
- data/lib/ohai/plugins/windows/drivers.rb +2 -1
- data/lib/ohai/plugins/windows/memory.rb +1 -0
- data/lib/ohai/plugins/windows/network.rb +3 -2
- data/lib/ohai/plugins/windows/platform.rb +2 -1
- data/lib/ohai/plugins/windows/system_enclosure.rb +2 -1
- data/lib/ohai/plugins/windows/virtualization.rb +2 -1
- data/lib/ohai/plugins/zpools.rb +6 -3
- data/lib/ohai/provides_map.rb +2 -1
- data/lib/ohai/runner.rb +8 -5
- data/lib/ohai/system.rb +35 -7
- data/lib/ohai/train_transport.rb +29 -0
- data/lib/ohai/util/file_helper.rb +5 -37
- data/lib/ohai/util/ip_helper.rb +1 -0
- data/lib/ohai/util/win32.rb +2 -1
- data/lib/ohai/version.rb +4 -3
- data/ohai.gemspec +8 -7
- metadata +80 -60
data/lib/ohai/plugins/elixir.rb
CHANGED
data/lib/ohai/plugins/erlang.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Joe Williams (<joe@joetify.com>)
|
3
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Tim Dysinger (<tim@dysinger.net>)
|
3
4
|
# Author:: Benjamin Black (<bb@chef.io>)
|
4
5
|
# Author:: Christopher Brown (<cb@chef.io>)
|
5
|
-
# Copyright:: Copyright (c)
|
6
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
7
|
# License:: Apache License, Version 2.0
|
7
8
|
#
|
8
9
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -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
|
@@ -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
|
#
|
@@ -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,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Matt Wrock (<matt@mattwrock.com>)
|
3
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
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
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>)
|
@@ -6,7 +7,7 @@
|
|
6
7
|
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
7
8
|
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
8
9
|
# Author:: Isa Farnik (<isa@chef.io>)
|
9
|
-
# Copyright:: Copyright (c)
|
10
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
10
11
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
11
12
|
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
12
13
|
# Copyright:: Copyright (c) 2010 VMware, Inc.
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Caleb Tennis (<caleb.tennis@gmail.com>)
|
3
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -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
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Benjamin Black (<bb@chef.io>)
|
3
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
data/lib/ohai/plugins/joyent.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author: sawanoboriyu@higanworks.com
|
3
4
|
# Copyright (C) 2014 HiganWorks LLC
|
@@ -25,7 +26,7 @@ Ohai.plugin(:Joyent) do
|
|
25
26
|
depends "os", "platform", "virtualization"
|
26
27
|
|
27
28
|
def collect_product_file
|
28
|
-
data =
|
29
|
+
data = file_read("/etc/product") rescue nil
|
29
30
|
if data
|
30
31
|
data.strip.split("\n")
|
31
32
|
else
|
@@ -34,7 +35,7 @@ Ohai.plugin(:Joyent) do
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def collect_pkgsrc
|
37
|
-
data =
|
38
|
+
data = file_read("/opt/local/etc/pkg_install.conf") rescue nil
|
38
39
|
if data
|
39
40
|
/PKG_PATH=(.*)/.match(data)[1] rescue nil
|
40
41
|
end
|
data/lib/ohai/plugins/kernel.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
4
|
# Author:: Benjamin Black (<nostromo@gmail.com>)
|
4
5
|
# Author:: Bryan McLellan (<btm@loftninjas.org>)
|
5
6
|
# Author:: Claire McQuin (<claire@chef.io>)
|
6
7
|
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
7
|
-
# Copyright:: Copyright (c) Chef Software
|
8
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
8
9
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
9
10
|
# License:: Apache License, Version 2.0
|
10
11
|
#
|
@@ -42,7 +43,7 @@ Ohai.plugin(:Kernel) do
|
|
42
43
|
# @return [Mash]
|
43
44
|
def bsd_modules(path)
|
44
45
|
modules = Mash.new
|
45
|
-
so = shell_out(
|
46
|
+
so = shell_out(Ohai.abs_path(path).to_s)
|
46
47
|
so.stdout.lines do |line|
|
47
48
|
# 1 7 0xc0400000 97f830 kernel
|
48
49
|
if line =~ /(\d+)\s+(\d+)\s+([0-9a-fx]+)\s+([0-9a-fx]+)\s+([a-zA-Z0-9\_]+)/
|
@@ -156,6 +157,10 @@ Ohai.plugin(:Kernel) do
|
|
156
157
|
].include?(name)
|
157
158
|
end
|
158
159
|
|
160
|
+
collect_data(:target) do
|
161
|
+
# intentionally left blank
|
162
|
+
end
|
163
|
+
|
159
164
|
collect_data(:default) do
|
160
165
|
kernel init_kernel
|
161
166
|
end
|
@@ -204,8 +209,8 @@ Ohai.plugin(:Kernel) do
|
|
204
209
|
if line =~ /([a-zA-Z0-9\_]+)\s+(\d+)\s+(\d+)/
|
205
210
|
modules[$1] = { size: $2, refcount: $3 }
|
206
211
|
# Making sure to get the module version that has been loaded
|
207
|
-
if
|
208
|
-
version =
|
212
|
+
if file_exist?("/sys/module/#{$1}/version")
|
213
|
+
version = file_read("/sys/module/#{$1}/version").chomp.strip
|
209
214
|
modules[$1]["version"] = version unless version.empty?
|
210
215
|
end
|
211
216
|
end
|
@@ -230,7 +235,7 @@ Ohai.plugin(:Kernel) do
|
|
230
235
|
so = shell_out("uname -s")
|
231
236
|
kernel[:os] = so.stdout.split($/)[0]
|
232
237
|
|
233
|
-
so =
|
238
|
+
so = file_open("/etc/release", &:gets)
|
234
239
|
md = /(?<update>\d.*\d)/.match(so)
|
235
240
|
kernel[:update] = md[:update] if md
|
236
241
|
|
@@ -240,7 +245,7 @@ Ohai.plugin(:Kernel) do
|
|
240
245
|
# EXAMPLE:
|
241
246
|
# Id Loadaddr Size Info Rev Module Name
|
242
247
|
# 6 1180000 4623 1 1 specfs (filesystem for specfs)
|
243
|
-
module_description =
|
248
|
+
module_description = /\s*(\d+)\s+([a-f\d]+)\s+([a-f\d]+)\s+(?:[\-\d]+)\s+(?:\d+)\s+(\S+)\s+\((.+)\)$/
|
244
249
|
so.stdout.lines do |line|
|
245
250
|
if ( mod = module_description.match(line) )
|
246
251
|
modules[mod[4]] = { id: mod[1].to_i, loadaddr: mod[2], size: mod[3].to_i(16), description: mod[5] }
|
data/lib/ohai/plugins/keys.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Cookbook Name:: apache2
|
3
4
|
# Recipe:: default
|
4
5
|
#
|
5
|
-
# Copyright
|
6
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
7
|
#
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
9
|
# you may not use this file except in compliance with the License.
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
data/lib/ohai/plugins/libvirt.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Benjamin Black (<bb@chef.io>)
|
3
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
data/lib/ohai/plugins/linode.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Aaron Kalin (<akalin@martinisoftware.com>)
|
3
4
|
# License:: Apache License, Version 2.0
|
@@ -25,7 +26,7 @@ Ohai.plugin(:Linode) do
|
|
25
26
|
# Returns true or false
|
26
27
|
def has_linode_kernel?
|
27
28
|
if ( kernel_data = kernel )
|
28
|
-
kernel_data[:release].split("-").last
|
29
|
+
kernel_data[:release].split("-").last.include?("linode")
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -20,24 +21,24 @@ Ohai.plugin(:BlockDevice) do
|
|
20
21
|
provides "block_device"
|
21
22
|
|
22
23
|
collect_data(:linux) do
|
23
|
-
if
|
24
|
+
if file_exist?("/sys/block")
|
24
25
|
block = Mash.new
|
25
|
-
|
26
|
+
dir_glob("/sys/block/*").each do |block_device_dir|
|
26
27
|
dir = File.basename(block_device_dir)
|
27
28
|
block[dir] = Mash.new
|
28
29
|
%w{size removable}.each do |check|
|
29
|
-
if
|
30
|
-
|
30
|
+
if file_exist?("/sys/block/#{dir}/#{check}")
|
31
|
+
file_open("/sys/block/#{dir}/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
|
31
32
|
end
|
32
33
|
end
|
33
34
|
%w{model rev state timeout vendor queue_depth}.each do |check|
|
34
|
-
if
|
35
|
-
|
35
|
+
if file_exist?("/sys/block/#{dir}/device/#{check}")
|
36
|
+
file_open("/sys/block/#{dir}/device/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
|
36
37
|
end
|
37
38
|
end
|
38
39
|
%w{rotational physical_block_size logical_block_size}.each do |check|
|
39
|
-
if
|
40
|
-
|
40
|
+
if file_exist?("/sys/block/#{dir}/queue/#{check}")
|
41
|
+
file_open("/sys/block/#{dir}/queue/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
|
41
42
|
end
|
42
43
|
end
|
43
44
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Davide Cavalca (<dcavalca@fb.com>)
|
3
4
|
# Copyright:: Copyright (c) 2016 Facebook
|
@@ -25,8 +26,8 @@ Ohai.plugin(:Hostnamectl) do
|
|
25
26
|
hostnamectl_path = which("hostnamectl")
|
26
27
|
if hostnamectl_path
|
27
28
|
shell_out(hostnamectl_path).stdout.split("\n").each do |line|
|
28
|
-
key, val = line.split(":")
|
29
|
-
hostnamectl[key.chomp.lstrip.tr(" ", "_").downcase] = val
|
29
|
+
key, val = line.split(": ", 2)
|
30
|
+
hostnamectl[key.chomp.lstrip.tr(" ", "_").downcase] = val
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Davide Cavalca <dcavalca@fb.com>
|
3
4
|
# Copyright:: Copyright (c) 2020 Facebook
|
@@ -25,7 +26,7 @@ Ohai.plugin(:Interrupts) do
|
|
25
26
|
# format: comma-separate list of 32bit bitmask in hex
|
26
27
|
# each bit is a CPU, right to left ordering (i.e. CPU0 is rightmost)
|
27
28
|
def parse_smp_affinity(path, cpus)
|
28
|
-
masks =
|
29
|
+
masks = file_read(path).strip
|
29
30
|
bit_masks = []
|
30
31
|
masks.split(",").each do |mask|
|
31
32
|
bit_masks << mask.rjust(8, "0").to_i(16).to_s(2)
|
@@ -47,7 +48,7 @@ Ohai.plugin(:Interrupts) do
|
|
47
48
|
parse_smp_affinity("/proc/irq/default_smp_affinity", cpus)
|
48
49
|
|
49
50
|
interrupts[:irq] = Mash.new
|
50
|
-
|
51
|
+
file_open("/proc/interrupts").each do |line|
|
51
52
|
# Documentation: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
|
52
53
|
# format is "{irqn}: {CPUn...} [type] [vector] [device]"
|
53
54
|
irqn, fields = line.split(":", 2)
|
@@ -70,7 +71,7 @@ Ohai.plugin(:Interrupts) do
|
|
70
71
|
interrupts[:irq][irqn][:vector],
|
71
72
|
interrupts[:irq][irqn][:device] =
|
72
73
|
fields[cpus].split
|
73
|
-
if
|
74
|
+
if file_exist?("/proc/irq/#{irqn}/smp_affinity")
|
74
75
|
interrupts[:irq][irqn][:smp_affinity_by_cpu] =
|
75
76
|
parse_smp_affinity("/proc/irq/#{irqn}/smp_affinity", cpus)
|
76
77
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Jay Vana <jsvana@fb.com>
|
3
4
|
# Author:: Davide Cavalca <dcavalca@fb.com>
|
@@ -41,7 +42,7 @@ Ohai.plugin(:IPC) do
|
|
41
42
|
"perms" => parts[3],
|
42
43
|
"bytes" => parts[4].to_i,
|
43
44
|
"nattch" => parts[5].to_i,
|
44
|
-
"status" => parts[6]
|
45
|
+
"status" => parts[6] || "",
|
45
46
|
}
|
46
47
|
|
47
48
|
ipc["shm"][parts[1].to_i] = segment
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -22,38 +23,24 @@ Ohai.plugin(:LSB) do
|
|
22
23
|
collect_data(:linux) do
|
23
24
|
lsb Mash.new
|
24
25
|
|
25
|
-
if
|
26
|
+
if file_exist?("/usr/bin/lsb_release")
|
26
27
|
# From package redhat-lsb on Fedora/Redhat, lsb-release on Debian/Ubuntu
|
27
28
|
shell_out("lsb_release -a").stdout.lines do |line|
|
28
29
|
case line
|
29
|
-
when /^Distributor ID:\s+(.+)
|
30
|
+
when /^Distributor ID:\s+(.+)/
|
30
31
|
lsb[:id] = $1
|
31
|
-
when /^Description:\s+(.+)
|
32
|
+
when /^Description:\s+(.+)/
|
32
33
|
lsb[:description] = $1
|
33
|
-
when /^Release:\s+(.+)
|
34
|
+
when /^Release:\s+(.+)/
|
34
35
|
lsb[:release] = $1
|
35
|
-
when /^Codename:\s+(.+)
|
36
|
+
when /^Codename:\s+(.+)/
|
36
37
|
lsb[:codename] = $1
|
37
38
|
else
|
38
39
|
lsb[:id] = line
|
39
40
|
end
|
40
41
|
end
|
41
|
-
elsif File.exist?("/etc/lsb-release")
|
42
|
-
# Old, non-standard Debian support
|
43
|
-
File.open("/etc/lsb-release").each do |line|
|
44
|
-
case line
|
45
|
-
when /^DISTRIB_ID=["']?(.+?)["']?$/
|
46
|
-
lsb[:id] = $1
|
47
|
-
when /^DISTRIB_RELEASE=["']?(.+?)["']?$/
|
48
|
-
lsb[:release] = $1
|
49
|
-
when /^DISTRIB_CODENAME=["']?(.+?)["']?$/
|
50
|
-
lsb[:codename] = $1
|
51
|
-
when /^DISTRIB_DESCRIPTION=["']?(.+?)["']?$/
|
52
|
-
lsb[:description] = $1
|
53
|
-
end
|
54
|
-
end
|
55
42
|
else
|
56
|
-
logger.trace("Plugin LSB: Skipping LSB, cannot find /
|
43
|
+
logger.trace("Plugin LSB: Skipping LSB, cannot find /usr/bin/lsb_release")
|
57
44
|
end
|
58
45
|
end
|
59
46
|
end
|