ohai 15.1.5 → 15.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/ohai/common/dmi.rb +3 -0
- data/lib/ohai/dsl/plugin.rb +3 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +4 -2
- data/lib/ohai/hints.rb +3 -1
- data/lib/ohai/loader.rb +7 -4
- data/lib/ohai/mash.rb +1 -1
- data/lib/ohai/mixin/constant_helper.rb +1 -0
- data/lib/ohai/mixin/ec2_metadata.rb +4 -3
- data/lib/ohai/mixin/gce_metadata.rb +2 -3
- data/lib/ohai/plugins/aix/kernel.rb +1 -1
- data/lib/ohai/plugins/aix/network.rb +3 -3
- data/lib/ohai/plugins/aix/virtualization.rb +4 -0
- data/lib/ohai/plugins/azure.rb +1 -0
- data/lib/ohai/plugins/cloud.rb +7 -4
- data/lib/ohai/plugins/cpu.rb +6 -6
- data/lib/ohai/plugins/darwin/network.rb +9 -4
- data/lib/ohai/plugins/digital_ocean.rb +2 -0
- data/lib/ohai/plugins/dmi.rb +1 -0
- data/lib/ohai/plugins/dragonflybsd/memory.rb +1 -1
- data/lib/ohai/plugins/dragonflybsd/network.rb +1 -0
- data/lib/ohai/plugins/ec2.rb +1 -0
- data/lib/ohai/plugins/eucalyptus.rb +1 -0
- data/lib/ohai/plugins/filesystem.rb +12 -2
- data/lib/ohai/plugins/freebsd/memory.rb +1 -1
- data/lib/ohai/plugins/freebsd/network.rb +1 -0
- data/lib/ohai/plugins/haskell.rb +4 -4
- data/lib/ohai/plugins/hostname.rb +2 -1
- data/lib/ohai/plugins/java.rb +1 -0
- data/lib/ohai/plugins/kernel.rb +10 -5
- data/lib/ohai/plugins/linode.rb +1 -1
- data/lib/ohai/plugins/linux/lspci.rb +3 -2
- data/lib/ohai/plugins/linux/network.rb +18 -7
- data/lib/ohai/plugins/linux/platform.rb +4 -8
- data/lib/ohai/plugins/netbsd/memory.rb +1 -1
- data/lib/ohai/plugins/netbsd/network.rb +1 -0
- data/lib/ohai/plugins/network.rb +2 -0
- data/lib/ohai/plugins/openbsd/memory.rb +1 -1
- data/lib/ohai/plugins/openbsd/network.rb +1 -0
- data/lib/ohai/plugins/openstack.rb +8 -14
- data/lib/ohai/plugins/packages.rb +29 -1
- data/lib/ohai/plugins/rackspace.rb +1 -0
- data/lib/ohai/plugins/scaleway.rb +1 -0
- data/lib/ohai/plugins/shard.rb +1 -1
- data/lib/ohai/plugins/solaris2/network.rb +3 -1
- data/lib/ohai/plugins/virtualbox.rb +5 -3
- data/lib/ohai/plugins/windows/network.rb +6 -0
- data/lib/ohai/provides_map.rb +26 -3
- data/lib/ohai/runner.rb +18 -5
- data/lib/ohai/system.rb +8 -0
- data/lib/ohai/util/win32.rb +4 -4
- data/lib/ohai/version.rb +1 -1
- data/spec/data/plugins/rpmquery.output +2 -0
- data/spec/functional/application_spec.rb +1 -1
- data/spec/functional/loader_spec.rb +1 -1
- data/spec/unit/dsl/plugin_spec.rb +15 -15
- data/spec/unit/plugin_config_spec.rb +3 -3
- data/spec/unit/plugins/docker_spec.rb +11 -11
- data/spec/unit/plugins/ec2_spec.rb +4 -2
- data/spec/unit/plugins/erlang_spec.rb +2 -2
- data/spec/unit/plugins/hostname_spec.rb +14 -10
- data/spec/unit/plugins/linux/filesystem_spec.rb +1 -0
- data/spec/unit/plugins/linux/lspci_spec.rb +2 -1
- data/spec/unit/plugins/linux/platform_spec.rb +5 -0
- data/spec/unit/plugins/network_spec.rb +3 -2
- data/spec/unit/plugins/openstack_spec.rb +31 -30
- data/spec/unit/plugins/packages_spec.rb +20 -0
- data/spec/unit/plugins/ruby_spec.rb +1 -1
- data/spec/unit/plugins/scsi_spec.rb +2 -1
- data/spec/unit/plugins/shard_spec.rb +1 -1
- data/spec/unit/plugins/windows/filesystem_spec.rb +2 -2
- data/spec/unit/plugins/windows/kernel_spec.rb +2 -2
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/system_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98f79af3f1e5744de5e63178fcc9acf038c0d8cc7f684064dac8aabc2d34cbad
|
4
|
+
data.tar.gz: e3a2b907da4cb97b5218b3d9013688c14cce257ef594f3bc47f43ecc84dc1526
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cdc8ca66bdd032d58ddce52f9a99c2a29189b7cdc95aa727ea84cd0b525cb84d8121cd161ab1681a9b0a46309679c46f07a396bfa055847a570cc63edf455ae
|
7
|
+
data.tar.gz: 9fa787535d3ae2229647cb4e589f8a3bded19e25d2457b7858290555ff777258de6d8559bcdd1b8ce31767fd77c8d3f2fdac6c78249ea308350c5ff63dda7fe9
|
data/Rakefile
CHANGED
data/lib/ohai/common/dmi.rb
CHANGED
@@ -119,12 +119,14 @@ module Ohai
|
|
119
119
|
in_common = Mash.new
|
120
120
|
next unless records.class.to_s == "Mash"
|
121
121
|
next unless records.key?("all_records")
|
122
|
+
|
122
123
|
records[:all_records].each do |record|
|
123
124
|
record.each do |field, value|
|
124
125
|
next if value.class.to_s == "Mash"
|
125
126
|
next if field.to_s == "application_identifier"
|
126
127
|
next if field.to_s == "size"
|
127
128
|
next if field.to_s == "record_id"
|
129
|
+
|
128
130
|
translated = field.downcase.gsub(/[^a-z0-9]/, "_")
|
129
131
|
value = value.strip
|
130
132
|
if in_common.key?(translated)
|
@@ -136,6 +138,7 @@ module Ohai
|
|
136
138
|
end
|
137
139
|
in_common.each do |field, value|
|
138
140
|
next if value.nil?
|
141
|
+
|
139
142
|
dmi[type][field] = value.strip
|
140
143
|
end
|
141
144
|
end
|
data/lib/ohai/dsl/plugin.rb
CHANGED
@@ -145,6 +145,7 @@ module Ohai
|
|
145
145
|
def from(cmd)
|
146
146
|
_status, stdout, _stderr = run_command(command: cmd)
|
147
147
|
return "" if stdout.nil? || stdout.empty?
|
148
|
+
|
148
149
|
stdout.strip
|
149
150
|
end
|
150
151
|
|
@@ -155,6 +156,7 @@ module Ohai
|
|
155
156
|
regex_list.flatten.each do |regex|
|
156
157
|
_status, stdout, _stderr = run_command(command: cmd)
|
157
158
|
return "" if stdout.nil? || stdout.empty?
|
159
|
+
|
158
160
|
stdout.chomp!.strip
|
159
161
|
md = stdout.match(regex)
|
160
162
|
return md[1]
|
@@ -210,6 +212,7 @@ module Ohai
|
|
210
212
|
unless attrs.nil? || attrs.is_a?(Array) || attrs.is_a?(Hash)
|
211
213
|
raise TypeError.new("Expected Hash but got #{attrs.class}.")
|
212
214
|
end
|
215
|
+
|
213
216
|
attrs[key]
|
214
217
|
end
|
215
218
|
rescue NoMethodError
|
@@ -145,9 +145,11 @@ module Ohai
|
|
145
145
|
|
146
146
|
def configuration(option, *options)
|
147
147
|
return nil if plugin_config.nil? || !plugin_config.key?(option)
|
148
|
+
|
148
149
|
value = plugin_config[option]
|
149
150
|
options.each do |opt|
|
150
151
|
return nil unless value.key?(opt)
|
152
|
+
|
151
153
|
value = value[opt]
|
152
154
|
end
|
153
155
|
value
|
@@ -169,12 +171,12 @@ module Ohai
|
|
169
171
|
# ["", "Memory"] => ["Memory"]
|
170
172
|
# ["", "Network", "", "Listeners"] => ["Network", "Listeners"]
|
171
173
|
# ["SSH", "Host", "", "Key"] => ["SSH", "Host", "Key"]
|
172
|
-
parts.delete_if
|
174
|
+
parts.delete_if(&:empty?)
|
173
175
|
# ["DMI"] => :dmi
|
174
176
|
# ["Memory"] => :memory
|
175
177
|
# ["Network", "Listeners"] => :network_listeners
|
176
178
|
# ["SSH", "Host", "Key"] => :ssh_host_key
|
177
|
-
snake_case_name = parts.map
|
179
|
+
snake_case_name = parts.map(&:downcase).join("_").to_sym
|
178
180
|
|
179
181
|
# Plugin names in config hashes are auto-vivified, so we check with
|
180
182
|
# key? to avoid falsely instantiating a configuration hash.
|
data/lib/ohai/hints.rb
CHANGED
@@ -51,14 +51,16 @@ module Ohai
|
|
51
51
|
def self.hint?(name)
|
52
52
|
@hints ||= {}
|
53
53
|
return @hints[name] if @hints[name]
|
54
|
+
|
54
55
|
Ohai.config[:hints_path].each do |path|
|
55
56
|
filename = File.join(path, "#{name}.json")
|
56
57
|
next unless File.exist?(filename)
|
58
|
+
|
57
59
|
Ohai::Log.trace("Found hint #{name}.json at #{filename}")
|
58
60
|
@hints[name] = parse_hint_file(filename)
|
59
61
|
end
|
60
62
|
|
61
|
-
Ohai::Log.trace("Did not find hint #{name}.json in the hint path(s): #{Ohai.config[:hints_path].join(
|
63
|
+
Ohai::Log.trace("Did not find hint #{name}.json in the hint path(s): #{Ohai.config[:hints_path].join(", ")} ") unless @hints.key?(name)
|
62
64
|
@hints[name]
|
63
65
|
end
|
64
66
|
end
|
data/lib/ohai/loader.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Claire McQuin (<claire@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2013-
|
3
|
+
# Copyright:: Copyright (c) 2013-2019, 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");
|
@@ -83,7 +83,8 @@ module Ohai
|
|
83
83
|
# @param plugin_path [String]
|
84
84
|
def load_plugin(plugin_path)
|
85
85
|
plugin_class = load_plugin_class(plugin_path)
|
86
|
-
return nil unless plugin_class.
|
86
|
+
return nil unless plugin_class.is_a?(Class)
|
87
|
+
|
87
88
|
if plugin_class < Ohai::DSL::Plugin::VersionVII
|
88
89
|
load_v7_plugin(plugin_class)
|
89
90
|
else
|
@@ -137,9 +138,10 @@ module Ohai
|
|
137
138
|
# @return [Ohai::DSL::Plugin::VersionVII] Ohai plugin object
|
138
139
|
def load_v7_plugin_class(contents, plugin_path)
|
139
140
|
plugin_class = eval(contents, TOPLEVEL_BINDING, plugin_path) # rubocop: disable Security/Eval
|
140
|
-
unless plugin_class.
|
141
|
+
unless plugin_class.is_a?(Class) && plugin_class < Ohai::DSL::Plugin
|
141
142
|
raise Ohai::Exceptions::IllegalPluginDefinition, "Plugin file cannot contain any statements after the plugin definition"
|
142
143
|
end
|
144
|
+
|
143
145
|
plugin_class.sources << plugin_path
|
144
146
|
@v7_plugin_classes << plugin_class unless @v7_plugin_classes.include?(plugin_class)
|
145
147
|
plugin_class
|
@@ -159,9 +161,10 @@ module Ohai
|
|
159
161
|
parts = e.message.split(/<.*>[:[0-9]+]*: syntax error, /)
|
160
162
|
parts.each do |part|
|
161
163
|
next if part.length == 0
|
164
|
+
|
162
165
|
logger.warn("Plugin Syntax Error: <#{plugin_path}>: #{part}")
|
163
166
|
end
|
164
|
-
rescue Exception
|
167
|
+
rescue Exception => e
|
165
168
|
logger.warn("Plugin Error: <#{plugin_path}>: #{e.message}")
|
166
169
|
logger.trace("Plugin Error: <#{plugin_path}>: #{e.inspect}, #{e.backtrace.join('\n')}")
|
167
170
|
end
|
data/lib/ohai/mash.rb
CHANGED
@@ -68,6 +68,7 @@ module Ohai
|
|
68
68
|
if versions.empty?
|
69
69
|
raise "Mixin EC2: Unable to determine EC2 metadata version (no supported entries found)"
|
70
70
|
end
|
71
|
+
|
71
72
|
versions.last
|
72
73
|
end
|
73
74
|
end
|
@@ -134,7 +135,7 @@ module Ohai
|
|
134
135
|
end
|
135
136
|
|
136
137
|
def fetch_dir_metadata(id, api_version)
|
137
|
-
metadata =
|
138
|
+
metadata = {}
|
138
139
|
retrieved_metadata = metadata_get(id, api_version)
|
139
140
|
if retrieved_metadata
|
140
141
|
retrieved_metadata.split("\n").each do |o|
|
@@ -195,11 +196,11 @@ module Ohai
|
|
195
196
|
# ignore "./" and "../"
|
196
197
|
path.gsub(%r{/\.\.?(?:/|$)}, "/")
|
197
198
|
.sub(%r{^\.\.?(?:/|$)}, "")
|
198
|
-
.sub(
|
199
|
+
.sub(/^$/, "/")
|
199
200
|
end
|
200
201
|
|
201
202
|
def metadata_key(key)
|
202
|
-
key.gsub(
|
203
|
+
key.gsub(%r{\-|/}, "_")
|
203
204
|
end
|
204
205
|
|
205
206
|
end
|
@@ -31,8 +31,7 @@ module Ohai
|
|
31
31
|
conn.get(uri, {
|
32
32
|
"Metadata-Flavor" => "Google",
|
33
33
|
"User-Agent" => "chef-ohai/#{Ohai::VERSION}",
|
34
|
-
}
|
35
|
-
)
|
34
|
+
})
|
36
35
|
end
|
37
36
|
|
38
37
|
def fetch_metadata(id = "")
|
@@ -76,7 +75,7 @@ module Ohai
|
|
76
75
|
end
|
77
76
|
|
78
77
|
def sanitize_key(key)
|
79
|
-
key.gsub(
|
78
|
+
key.gsub(%r{\-|/}, "_")
|
80
79
|
end
|
81
80
|
end
|
82
81
|
end
|
@@ -37,7 +37,7 @@ Ohai.plugin(:Kernel) do
|
|
37
37
|
# 6390000 20000 63a0000 ba8 /usr/lib/drivers/if_en
|
38
38
|
# f1000000c0318000 20000 f1000000c0320000 17138 /usr/lib/drivers/random
|
39
39
|
so.stdout.lines do |line|
|
40
|
-
if line =~
|
40
|
+
if line =~ %r{\s*([0-9a-f]+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+([a-zA-Z0-9/\._]+)}
|
41
41
|
modules[$5] = { text: { address: $1, size: $2 }, data: { address: $3, size: $4 } }
|
42
42
|
end
|
43
43
|
end
|
@@ -77,7 +77,7 @@ Ohai.plugin(:Network) do
|
|
77
77
|
iface[interface][:metric] = $1 if lin =~ /metric\s(\S+)/
|
78
78
|
else
|
79
79
|
# We have key value pairs.
|
80
|
-
if lin =~
|
80
|
+
if lin =~ %r{inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(/(\d{1,2}))?}
|
81
81
|
tmp_addr, tmp_prefix = $1, $3
|
82
82
|
if tmp_prefix.nil?
|
83
83
|
netmask = hex_to_dec_netmask($1) if lin =~ /netmask\s(\S+)\s/
|
@@ -96,7 +96,7 @@ Ohai.plugin(:Network) do
|
|
96
96
|
if lin =~ /broadcast\s(\S+)\s/
|
97
97
|
iface[interface][:addresses][tmp_addr][:broadcast] = $1
|
98
98
|
end
|
99
|
-
elsif lin =~
|
99
|
+
elsif lin =~ %r{inet6 ([a-f0-9\:]+)%?([\d]*)/?(\d*)?}
|
100
100
|
# TODO do we have more properties on inet6 in aix? broadcast
|
101
101
|
iface[interface][:addresses] ||= Mash.new
|
102
102
|
iface[interface][:addresses][$1] = { "family" => "inet6", "zone_index" => $2, "prefixlen" => $3 }
|
@@ -128,7 +128,7 @@ Ohai.plugin(:Network) do
|
|
128
128
|
so_n.stdout.lines.each do |line|
|
129
129
|
if line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\S+)/
|
130
130
|
interface = $6
|
131
|
-
iface[interface][:routes] =
|
131
|
+
iface[interface][:routes] = [] unless iface[interface][:routes]
|
132
132
|
iface[interface][:routes] << Mash.new( destination: $1, family: family,
|
133
133
|
via: $2, flags: $3)
|
134
134
|
end
|
@@ -58,6 +58,7 @@ Ohai.plugin(:Virtualization) do
|
|
58
58
|
case title
|
59
59
|
when "network"
|
60
60
|
next if line =~ /^Interface|^---/
|
61
|
+
|
61
62
|
splat = line.strip.split
|
62
63
|
key = splat[0].downcase
|
63
64
|
value = {
|
@@ -68,6 +69,7 @@ Ohai.plugin(:Virtualization) do
|
|
68
69
|
wpars[wpar_name][title][key] = value
|
69
70
|
when "user-specified routes"
|
70
71
|
next if line =~ /^Type|^---/
|
72
|
+
|
71
73
|
splat = line.strip.split
|
72
74
|
key = splat[2].downcase
|
73
75
|
value = {
|
@@ -77,6 +79,7 @@ Ohai.plugin(:Virtualization) do
|
|
77
79
|
wpars[wpar_name][title][key] = value
|
78
80
|
when "file systems"
|
79
81
|
next if line =~ /^MountPoint|^---/
|
82
|
+
|
80
83
|
splat = line.strip.split
|
81
84
|
key = splat[1].downcase
|
82
85
|
value = {
|
@@ -99,6 +102,7 @@ Ohai.plugin(:Virtualization) do
|
|
99
102
|
wpars[wpar_name][title]["Privileges"] += privileges.split(",")
|
100
103
|
when "device exports"
|
101
104
|
next if line =~ /^Name|^---/
|
105
|
+
|
102
106
|
splat = line.strip.split
|
103
107
|
key = splat[0].downcase
|
104
108
|
value = {
|
data/lib/ohai/plugins/azure.rb
CHANGED
data/lib/ohai/plugins/cloud.rb
CHANGED
@@ -53,14 +53,15 @@ Ohai.plugin(:Cloud) do
|
|
53
53
|
|
54
54
|
def add_ipv4_addr(ip, accessibility)
|
55
55
|
return if ip.nil? # just skip if ip is nil
|
56
|
+
|
56
57
|
ipaddr = validate_ip_addr(ip, :ipv4)
|
57
58
|
|
58
59
|
case accessibility
|
59
60
|
when :public
|
60
|
-
@cloud[:public_ipv4_addrs] ||=
|
61
|
+
@cloud[:public_ipv4_addrs] ||= []
|
61
62
|
@cloud[:public_ipv4_addrs] << ipaddr.to_s
|
62
63
|
when :private
|
63
|
-
@cloud[:local_ipv4_addrs] ||=
|
64
|
+
@cloud[:local_ipv4_addrs] ||= []
|
64
65
|
@cloud[:local_ipv4_addrs] << ipaddr.to_s
|
65
66
|
else
|
66
67
|
raise "ERROR: invalid accessibility param of '#{accessibility}'. must be :public or :private."
|
@@ -69,15 +70,17 @@ Ohai.plugin(:Cloud) do
|
|
69
70
|
|
70
71
|
def add_ipv6_addr(ip, accessibility)
|
71
72
|
return if ip.nil? # just skip if ip is nil
|
73
|
+
|
72
74
|
ipaddr = validate_ip_addr(ip, :ipv6)
|
73
75
|
|
74
76
|
raise "ERROR: invalid ipv6 address of '#{ip}' detected. " unless ipaddr.ipv6?
|
77
|
+
|
75
78
|
case accessibility
|
76
79
|
when :public
|
77
|
-
@cloud[:public_ipv6_addrs] ||=
|
80
|
+
@cloud[:public_ipv6_addrs] ||= []
|
78
81
|
@cloud[:public_ipv6_addrs] << ipaddr.to_s
|
79
82
|
when :private
|
80
|
-
@cloud[:local_ipv6_addrs] ||=
|
83
|
+
@cloud[:local_ipv6_addrs] ||= []
|
81
84
|
@cloud[:local_ipv6_addrs] << ipaddr.to_s
|
82
85
|
else
|
83
86
|
raise "ERROR: invalid accessibility param of '#{accessibility}'. must be :public or :private."
|
data/lib/ohai/plugins/cpu.rb
CHANGED
@@ -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 =~ (%r{IBM/S390})
|
65
65
|
cpuinfo["vendor_id"] = vendor_id
|
66
66
|
else
|
67
67
|
cpuinfo[current_cpu]["vendor_id"] = vendor_id
|
@@ -173,9 +173,9 @@ Ohai.plugin(:CPU) do
|
|
173
173
|
cpuinfo["model"] = $3.to_i(16).to_s
|
174
174
|
cpuinfo["stepping"] = $4
|
175
175
|
# These _should_ match /AMD Features2?/ lines as well
|
176
|
-
when /
|
176
|
+
when %r{FreeBSD/SMP: Multiprocessor System Detected: (\d*) CPUs}
|
177
177
|
cpuinfo["total"] = $1.to_i
|
178
|
-
when /
|
178
|
+
when %r{FreeBSD/SMP: (\d*) package\(s\) x (\d*) core\(s\)}
|
179
179
|
cpuinfo["real"] = $1.to_i
|
180
180
|
cpuinfo["cores"] = $1.to_i * $2.to_i
|
181
181
|
end
|
@@ -336,8 +336,8 @@ Ohai.plugin(:CPU) do
|
|
336
336
|
cpu["cpustates"] = Mash.new
|
337
337
|
|
338
338
|
currentcpu = 0
|
339
|
-
cpucores =
|
340
|
-
cpusockets =
|
339
|
+
cpucores = []
|
340
|
+
cpusockets = []
|
341
341
|
processor_info.each do |processor|
|
342
342
|
_desc, instance, _record, keyvalue = processor.split(":")
|
343
343
|
cpu[instance] ||= Mash.new
|
@@ -406,7 +406,7 @@ Ohai.plugin(:CPU) do
|
|
406
406
|
cpu[current_cpu]["model_name"] = processor["name"]
|
407
407
|
cpu[current_cpu]["description"] = processor["description"]
|
408
408
|
cpu[current_cpu]["mhz"] = processor["maxclockspeed"].to_s
|
409
|
-
cpu[current_cpu]["cache_size"] = "#{processor[
|
409
|
+
cpu[current_cpu]["cache_size"] = "#{processor["l2cachesize"]} KB"
|
410
410
|
end
|
411
411
|
|
412
412
|
cpu[:total] = logical_processors
|
@@ -21,14 +21,14 @@ Ohai.plugin(:Network) do
|
|
21
21
|
provides "counters/network", "counters/network/interfaces"
|
22
22
|
|
23
23
|
def parse_media(media_string)
|
24
|
-
media =
|
24
|
+
media = {}
|
25
25
|
line_array = media_string.split(" ")
|
26
26
|
|
27
27
|
0.upto(line_array.length - 1) do |i|
|
28
28
|
unless line_array[i].eql?("none")
|
29
29
|
|
30
30
|
if line_array[i + 1] =~ /^\<([a-zA-Z\-\,]+)\>$/
|
31
|
-
media[line_array[i]] =
|
31
|
+
media[line_array[i]] = {} unless media.key?(line_array[i])
|
32
32
|
if media[line_array[i]].key?("options")
|
33
33
|
$1.split(",").each do |opt|
|
34
34
|
media[line_array[i]]["options"] << opt unless media[line_array[i]]["options"].include?(opt)
|
@@ -38,7 +38,7 @@ Ohai.plugin(:Network) do
|
|
38
38
|
end
|
39
39
|
else
|
40
40
|
if line_array[i].eql?("autoselect")
|
41
|
-
media["autoselect"] =
|
41
|
+
media["autoselect"] = {} unless media.key?("autoselect")
|
42
42
|
media["autoselect"]["options"] = []
|
43
43
|
end
|
44
44
|
end
|
@@ -56,6 +56,7 @@ Ohai.plugin(:Network) do
|
|
56
56
|
return "IPIP" if ifname.eql?("gif")
|
57
57
|
return "6to4" if ifname.eql?("stf")
|
58
58
|
return "dot1q" if ifname.eql?("vlan")
|
59
|
+
|
59
60
|
"Unknown"
|
60
61
|
end
|
61
62
|
|
@@ -63,6 +64,7 @@ Ohai.plugin(:Network) do
|
|
63
64
|
return "Node" if scope.eql?("::1")
|
64
65
|
return "Link" if scope =~ /^fe80\:/
|
65
66
|
return "Site" if scope =~ /^fec0\:/
|
67
|
+
|
66
68
|
"Global"
|
67
69
|
end
|
68
70
|
|
@@ -74,6 +76,7 @@ Ohai.plugin(:Network) do
|
|
74
76
|
return ifname unless ifaces[ifname].nil?
|
75
77
|
# oh well, time to go hunting!
|
76
78
|
return ifname.chop if ifname =~ /\*$/
|
79
|
+
|
77
80
|
ifaces.each_key do |ifc|
|
78
81
|
ifaces[ifc][:addresses].each_key do |addr|
|
79
82
|
return ifc if addr.eql? mac
|
@@ -115,7 +118,7 @@ Ohai.plugin(:Network) do
|
|
115
118
|
if line =~ /\sflags\=\d+\<((UP|BROADCAST|DEBUG|SMART|SIMPLEX|LOOPBACK|POINTOPOINT|NOTRAILERS|RUNNING|NOARP|PROMISC|ALLMULTI|SLAVE|MASTER|MULTICAST|DYNAMIC|,)+)\>\s/
|
116
119
|
flags = $1.split(",")
|
117
120
|
else
|
118
|
-
flags =
|
121
|
+
flags = []
|
119
122
|
end
|
120
123
|
iface[cint][:flags] = flags.flatten
|
121
124
|
if cint =~ /^(\w+)(\d+.*)/
|
@@ -165,6 +168,7 @@ Ohai.plugin(:Network) do
|
|
165
168
|
if line =~ /^\S+ \((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([a-zA-Z0-9\.\:\-]+).*\[(\w+)\]/
|
166
169
|
# MAC addr really should be normalized to include all the zeroes.
|
167
170
|
next if iface[$3].nil? # this should never happen
|
171
|
+
|
168
172
|
iface[$3][:arp] ||= Mash.new
|
169
173
|
iface[$3][:arp][$1] = $2
|
170
174
|
end
|
@@ -189,6 +193,7 @@ Ohai.plugin(:Network) do
|
|
189
193
|
line =~ /^([a-zA-Z0-9\.\:\-\*]+)\s+\d+\s+\<[a-zA-Z0-9\#]+\>(\s+)(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
|
190
194
|
ifname = locate_interface(iface, $1, $2)
|
191
195
|
next if iface[ifname].nil? # this shouldn't happen, but just in case
|
196
|
+
|
192
197
|
net_counters[ifname] ||= Mash.new
|
193
198
|
net_counters[ifname] = { rx: { bytes: $5, packets: $3, errors: $4, drop: 0, overrun: 0, frame: 0, compressed: 0, multicast: 0 },
|
194
199
|
tx: { bytes: $8, packets: $6, errors: $7, drop: 0, overrun: 0, collisions: $9, carrier: 0, compressed: 0 },
|