ohai 18.0.14 → 18.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +28 -28
- data/LICENSE +201 -201
- data/bin/ohai +25 -25
- data/lib/ohai/application.rb +189 -189
- data/lib/ohai/common/dmi.rb +167 -163
- data/lib/ohai/config.rb +51 -51
- data/lib/ohai/dsl/plugin/versionvii.rb +203 -203
- data/lib/ohai/dsl/plugin.rb +232 -232
- data/lib/ohai/dsl.rb +22 -22
- data/lib/ohai/exception.rb +36 -36
- data/lib/ohai/hints.rb +68 -68
- data/lib/ohai/loader.rb +178 -178
- data/lib/ohai/log.rb +34 -34
- data/lib/ohai/mash.rb +22 -22
- data/lib/ohai/mixin/alibaba_metadata.rb +86 -86
- data/lib/ohai/mixin/azure_metadata.rb +111 -111
- data/lib/ohai/mixin/chef_utils_wiring.rb +52 -52
- data/lib/ohai/mixin/command.rb +4 -4
- data/lib/ohai/mixin/constant_helper.rb +55 -55
- data/lib/ohai/mixin/dmi_decode.rb +54 -54
- data/lib/ohai/mixin/do_metadata.rb +48 -48
- data/lib/ohai/mixin/ec2_metadata.rb +256 -256
- data/lib/ohai/mixin/gce_metadata.rb +83 -83
- data/lib/ohai/mixin/http_helper.rb +64 -64
- data/lib/ohai/mixin/network_helper.rb +65 -63
- data/lib/ohai/mixin/os.rb +128 -128
- data/lib/ohai/mixin/scaleway_metadata.rb +51 -51
- data/lib/ohai/mixin/seconds_to_human.rb +52 -52
- data/lib/ohai/mixin/shell_out.rb +51 -51
- data/lib/ohai/mixin/softlayer_metadata.rb +74 -74
- data/lib/ohai/mixin/string.rb +31 -31
- data/lib/ohai/mixin/train_helpers.rb +36 -36
- data/lib/ohai/mixin/which.rb +39 -39
- data/lib/ohai/plugin_config.rb +47 -47
- data/lib/ohai/plugins/aix/kernel.rb +50 -50
- data/lib/ohai/plugins/aix/memory.rb +37 -37
- data/lib/ohai/plugins/aix/network.rb +142 -142
- data/lib/ohai/plugins/aix/platform.rb +30 -30
- data/lib/ohai/plugins/aix/uptime.rb +54 -54
- data/lib/ohai/plugins/aix/virtualization.rb +154 -154
- data/lib/ohai/plugins/alibaba.rb +72 -72
- data/lib/ohai/plugins/azure.rb +154 -154
- data/lib/ohai/plugins/bsd/virtualization.rb +121 -121
- data/lib/ohai/plugins/c.rb +178 -178
- data/lib/ohai/plugins/chef.rb +50 -50
- data/lib/ohai/plugins/cloud.rb +357 -357
- data/lib/ohai/plugins/command.rb +26 -26
- data/lib/ohai/plugins/cpu.rb +635 -626
- data/lib/ohai/plugins/darwin/hardware.rb +99 -99
- data/lib/ohai/plugins/darwin/memory.rb +62 -62
- data/lib/ohai/plugins/darwin/network.rb +207 -207
- data/lib/ohai/plugins/darwin/platform.rb +38 -38
- data/lib/ohai/plugins/darwin/virtualization.rb +93 -93
- data/lib/ohai/plugins/digital_ocean.rb +67 -67
- data/lib/ohai/plugins/dmi.rb +134 -134
- data/lib/ohai/plugins/docker.rb +58 -58
- data/lib/ohai/plugins/dragonflybsd/memory.rb +60 -60
- data/lib/ohai/plugins/dragonflybsd/network.rb +128 -128
- data/lib/ohai/plugins/dragonflybsd/platform.rb +28 -28
- data/lib/ohai/plugins/ec2.rb +148 -155
- data/lib/ohai/plugins/elixir.rb +36 -36
- data/lib/ohai/plugins/erlang.rb +60 -60
- data/lib/ohai/plugins/eucalyptus.rb +86 -86
- data/lib/ohai/plugins/filesystem.rb +751 -751
- data/lib/ohai/plugins/fips.rb +36 -35
- data/lib/ohai/plugins/freebsd/memory.rb +60 -60
- data/lib/ohai/plugins/freebsd/network.rb +128 -128
- data/lib/ohai/plugins/freebsd/platform.rb +28 -28
- data/lib/ohai/plugins/gce.rb +89 -89
- data/lib/ohai/plugins/go.rb +34 -34
- data/lib/ohai/plugins/groovy.rb +38 -38
- data/lib/ohai/plugins/grub2.rb +40 -40
- data/lib/ohai/plugins/habitat.rb +73 -73
- data/lib/ohai/plugins/haskell.rb +96 -96
- data/lib/ohai/plugins/hostname.rb +133 -133
- data/lib/ohai/plugins/init_package.rb +26 -26
- data/lib/ohai/plugins/java.rb +78 -78
- data/lib/ohai/plugins/kernel.rb +292 -292
- data/lib/ohai/plugins/keys.rb +27 -27
- data/lib/ohai/plugins/languages.rb +26 -26
- data/lib/ohai/plugins/libvirt.rb +114 -114
- data/lib/ohai/plugins/linode.rb +73 -73
- data/lib/ohai/plugins/linux/block_device.rb +48 -48
- data/lib/ohai/plugins/linux/hostnamectl.rb +34 -34
- data/lib/ohai/plugins/linux/interrupts.rb +84 -84
- data/lib/ohai/plugins/linux/ipc.rb +52 -52
- data/lib/ohai/plugins/linux/livepatch.rb +38 -38
- data/lib/ohai/plugins/linux/lsb.rb +46 -46
- data/lib/ohai/plugins/linux/lspci.rb +76 -76
- data/lib/ohai/plugins/linux/machineid.rb +36 -36
- data/lib/ohai/plugins/linux/mdadm.rb +120 -120
- data/lib/ohai/plugins/linux/memory.rb +106 -106
- data/lib/ohai/plugins/linux/network.rb +879 -879
- data/lib/ohai/plugins/linux/os_release.rb +38 -38
- data/lib/ohai/plugins/linux/platform.rb +314 -313
- data/lib/ohai/plugins/linux/selinux.rb +69 -69
- data/lib/ohai/plugins/linux/sessions.rb +54 -54
- data/lib/ohai/plugins/linux/sysctl.rb +39 -39
- data/lib/ohai/plugins/linux/systemd_paths.rb +36 -36
- data/lib/ohai/plugins/linux/tc.rb +61 -61
- data/lib/ohai/plugins/linux/virtualization.rb +300 -300
- data/lib/ohai/plugins/lua.rb +39 -39
- data/lib/ohai/plugins/mono.rb +50 -50
- data/lib/ohai/plugins/netbsd/memory.rb +99 -99
- data/lib/ohai/plugins/netbsd/network.rb +122 -122
- data/lib/ohai/plugins/netbsd/platform.rb +28 -28
- data/lib/ohai/plugins/network.rb +186 -186
- data/lib/ohai/plugins/nodejs.rb +40 -40
- data/lib/ohai/plugins/ohai.rb +29 -29
- data/lib/ohai/plugins/ohai_time.rb +26 -26
- data/lib/ohai/plugins/openbsd/memory.rb +99 -99
- data/lib/ohai/plugins/openbsd/network.rb +122 -122
- data/lib/ohai/plugins/openbsd/platform.rb +28 -28
- data/lib/ohai/plugins/openstack.rb +84 -84
- data/lib/ohai/plugins/os.rb +55 -55
- data/lib/ohai/plugins/packages.rb +234 -234
- data/lib/ohai/plugins/passwd.rb +104 -104
- data/lib/ohai/plugins/perl.rb +45 -45
- data/lib/ohai/plugins/php.rb +52 -52
- data/lib/ohai/plugins/platform.rb +29 -29
- data/lib/ohai/plugins/powershell.rb +82 -82
- data/lib/ohai/plugins/ps.rb +35 -35
- data/lib/ohai/plugins/python.rb +43 -43
- data/lib/ohai/plugins/rackspace.rb +177 -177
- data/lib/ohai/plugins/root_group.rb +41 -41
- data/lib/ohai/plugins/rpm.rb +121 -119
- data/lib/ohai/plugins/ruby.rb +66 -66
- data/lib/ohai/plugins/rust.rb +34 -34
- data/lib/ohai/plugins/scala.rb +38 -38
- data/lib/ohai/plugins/scaleway.rb +58 -58
- data/lib/ohai/plugins/scsi.rb +52 -52
- data/lib/ohai/plugins/shard.rb +142 -142
- data/lib/ohai/plugins/shells.rb +32 -32
- data/lib/ohai/plugins/softlayer.rb +48 -48
- data/lib/ohai/plugins/solaris2/dmi.rb +191 -191
- data/lib/ohai/plugins/solaris2/memory.rb +32 -32
- data/lib/ohai/plugins/solaris2/network.rb +192 -192
- data/lib/ohai/plugins/solaris2/platform.rb +58 -58
- data/lib/ohai/plugins/solaris2/virtualization.rb +90 -90
- data/lib/ohai/plugins/ssh_host_key.rb +84 -84
- data/lib/ohai/plugins/sysconf.rb +46 -46
- data/lib/ohai/plugins/timezone.rb +25 -25
- data/lib/ohai/plugins/train.rb +35 -35
- data/lib/ohai/plugins/uptime.rb +95 -95
- data/lib/ohai/plugins/virtualbox.rb +197 -197
- data/lib/ohai/plugins/vmware.rb +94 -94
- data/lib/ohai/plugins/windows/dmi.rb +95 -95
- data/lib/ohai/plugins/windows/drivers.rb +52 -52
- data/lib/ohai/plugins/windows/memory.rb +39 -39
- data/lib/ohai/plugins/windows/network.rb +222 -222
- data/lib/ohai/plugins/windows/platform.rb +34 -34
- data/lib/ohai/plugins/windows/system_enclosure.rb +29 -29
- data/lib/ohai/plugins/windows/virtualization.rb +45 -45
- data/lib/ohai/plugins/zpools.rb +94 -94
- data/lib/ohai/provides_map.rb +208 -208
- data/lib/ohai/runner.rb +128 -128
- data/lib/ohai/system.rb +258 -258
- data/lib/ohai/train_transport.rb +29 -29
- data/lib/ohai/util/file_helper.rb +6 -6
- data/lib/ohai/util/ip_helper.rb +56 -56
- data/lib/ohai/util/win32.rb +47 -47
- data/lib/ohai/version.rb +23 -23
- data/lib/ohai.rb +23 -23
- data/ohai.gemspec +35 -35
- metadata +3 -3
@@ -1,192 +1,192 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Benjamin Black (<nostromo@gmail.com>)
|
4
|
-
# Copyright:: Copyright (c) Chef Software Inc.
|
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
|
-
# EXAMPLE SOLARIS IFCONFIG OUTPUT; CURRENTLY, ONLY SIMPLE STUFF IS SUPPORTED (E.G., NO TUNNELS)
|
21
|
-
# DEAR SUN: YOU GET AN F FOR YOUR IFCONFIG
|
22
|
-
# lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
|
23
|
-
# inet 127.0.0.1 netmask ff000000
|
24
|
-
# e1000g0:3: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 3
|
25
|
-
# inet 72.2.115.28 netmask ffffff80 broadcast 72.2.115.127
|
26
|
-
# e1000g2:1: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 4
|
27
|
-
# inet 10.2.115.28 netmask ffffff80 broadcast 10.2.115.127
|
28
|
-
# inet6 2001:0db8:3c4d:55:a00:20ff:fe8e:f3ad/64
|
29
|
-
# ip.tun0: flags=2200851<UP,POINTOPOINT,RUNNING,MULTICAST,NONUD,IPv6> mtu 1480 index 3
|
30
|
-
# inet tunnel src 109.146.85.57 tunnel dst 109.146.85.212
|
31
|
-
# tunnel security settings --> use 'ipsecconf -ln -i ip.tun1'
|
32
|
-
# tunnel hop limit 60
|
33
|
-
# inet6 fe80::6d92:5539/10 --> fe80::6d92:55d4
|
34
|
-
# ip.tun0:1: flags=2200851<UP,POINTOPOINT,RUNNING,MULTICAST,NONUD,IPv6> mtu 1480 index 3
|
35
|
-
# inet6 2::45/128 --> 2::46
|
36
|
-
# lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
|
37
|
-
# inet 127.0.0.1 netmask ff000000
|
38
|
-
# eri0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 \
|
39
|
-
# index 2
|
40
|
-
# inet 172.17.128.208 netmask ffffff00 broadcast 172.17.128.255
|
41
|
-
# ip6.tun0: flags=10008d1<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4> \
|
42
|
-
# mtu 1460
|
43
|
-
# index 3
|
44
|
-
# inet6 tunnel src fe80::1 tunnel dst fe80::2
|
45
|
-
# tunnel security settings --> use 'ipsecconf -ln -i ip.tun1'
|
46
|
-
# tunnel hop limit 60 tunnel encapsulation limit 4
|
47
|
-
# inet 10.0.0.208 --> 10.0.0.210 netmask ff000000
|
48
|
-
# qfe1: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 3
|
49
|
-
# usesrc vni0
|
50
|
-
# inet6 fe80::203:baff:fe17:4be0/10
|
51
|
-
# ether 0:3:ba:17:4b:e0
|
52
|
-
# vni0: flags=2002210041<UP,RUNNING,NOXMIT,NONUD,IPv6,VIRTUAL> mtu 0
|
53
|
-
# index 5
|
54
|
-
# srcof qfe1
|
55
|
-
# inet6 fe80::203:baff:fe17:4444/128
|
56
|
-
|
57
|
-
# Extracted from http://illumos.org/hcl/
|
58
|
-
ETHERNET_ENCAPS ||= %w{ afe amd8111s arn atge ath bfe bge bnx bnxe ce cxgbe
|
59
|
-
dmfe e1000g efe elxl emlxs eri hermon hme hxge igb
|
60
|
-
iprb ipw iwh iwi iwk iwp ixgb ixgbe mwl mxfe myri10ge
|
61
|
-
nge ntxn nxge pcn platform qfe qlc ral rge rtls rtw rwd
|
62
|
-
rwn sfe tavor vr wpi xge yge aggr}.freeze
|
63
|
-
|
64
|
-
Ohai.plugin(:Network) do
|
65
|
-
require_relative "../../mixin/network_helper"
|
66
|
-
|
67
|
-
provides "network", "network/interfaces"
|
68
|
-
provides "counters/network", "counters/network/interfaces"
|
69
|
-
|
70
|
-
include Ohai::Mixin::NetworkHelper
|
71
|
-
|
72
|
-
def solaris_encaps_lookup(ifname)
|
73
|
-
return "Ethernet" if ETHERNET_ENCAPS.include?(ifname)
|
74
|
-
return "Ethernet" if ifname.eql?("net")
|
75
|
-
return "Loopback" if ifname.eql?("lo")
|
76
|
-
|
77
|
-
"Unknown"
|
78
|
-
end
|
79
|
-
|
80
|
-
def arpname_to_ifname(iface, arpname)
|
81
|
-
iface.each_key do |ifn|
|
82
|
-
return ifn if ifn.split(":")[0].eql?(arpname)
|
83
|
-
end
|
84
|
-
|
85
|
-
nil
|
86
|
-
end
|
87
|
-
|
88
|
-
def full_interface_name(iface, part_name, index)
|
89
|
-
iface.each do |name, attrs|
|
90
|
-
next unless attrs.respond_to?(:[])
|
91
|
-
return name if /^#{part_name}($|:)/.match(name) && attrs[:index] == index
|
92
|
-
end
|
93
|
-
|
94
|
-
nil
|
95
|
-
end
|
96
|
-
|
97
|
-
collect_data(:solaris2) do
|
98
|
-
iface = Mash.new
|
99
|
-
network Mash.new unless network
|
100
|
-
network[:interfaces] ||= Mash.new
|
101
|
-
counters Mash.new unless counters
|
102
|
-
counters[:network] ||= Mash.new
|
103
|
-
|
104
|
-
cint = nil
|
105
|
-
shell_out("ifconfig -a").stdout.lines do |line|
|
106
|
-
# regex: https://rubular.com/r/ZiIHbsnfiWPW1p
|
107
|
-
if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+)(?: index (\d+))?/
|
108
|
-
cint = $1
|
109
|
-
iface[cint] ||= Mash.new
|
110
|
-
iface[cint][:mtu] = $2
|
111
|
-
iface[cint][:index] = $3
|
112
|
-
if line =~ / flags\=\d+\<((ADDRCONF|ANYCAST|BROADCAST|CoS|DEPRECATED|DHCP|DUPLICATE|FAILED|FIXEDMTU|INACTIVE|L3PROTECT|LOOPBACK|MIP|MULTI_BCAST|MULTICAST|NOARP|NOFAILOVER|NOLOCAL|NONUD|NORTEXCH|NOXMIT|OFFLINE|PHYSRUNNING|POINTOPOINT|PREFERRED|PRIVATE|ROUTER|RUNNING|STANDBY|TEMPORARY|UNNUMBERED|UP|VIRTUAL|XRESOLV|IPv4|IPv6|,)+)\>\s/
|
113
|
-
flags = $1.split(",")
|
114
|
-
else
|
115
|
-
flags = []
|
116
|
-
end
|
117
|
-
iface[cint][:flags] = flags.flatten
|
118
|
-
if cint =~ /^(\w+)(\d+.*)/
|
119
|
-
iface[cint][:type] = $1
|
120
|
-
iface[cint][:number] = $2
|
121
|
-
iface[cint][:encapsulation] = solaris_encaps_lookup($1)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask (([0-9a-f]){1,8})\s*$/
|
125
|
-
iface[cint][:addresses] ||= Mash.new
|
126
|
-
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2) }
|
127
|
-
end
|
128
|
-
if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask (([0-9a-f]){1,8}) broadcast (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
129
|
-
iface[cint][:addresses] ||= Mash.new
|
130
|
-
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2), "broadcast" => $4 }
|
131
|
-
end
|
132
|
-
if line =~ %r{\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*)/(\d+)\s*$}
|
133
|
-
iface[cint][:addresses] ||= Mash.new
|
134
|
-
iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4 }
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
# Device IP Address Mask Flags Phys Addr
|
139
|
-
# bge1 172.16.0.129 255.255.255.255 SPLA 00:03:ba:xx:xx:xx
|
140
|
-
so = shell_out("arp -an")
|
141
|
-
so.stdout.lines do |line|
|
142
|
-
if line =~ /([0-9a-zA-Z]+)\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\w+)?\s+([a-zA-Z0-9\.\:\-]+)/
|
143
|
-
next unless iface[arpname_to_ifname(iface, $1)] # this should never happen, except on solaris because sun hates you.
|
144
|
-
|
145
|
-
iface[arpname_to_ifname(iface, $1)][:arp] ||= Mash.new
|
146
|
-
iface[arpname_to_ifname(iface, $1)][:arp][$2] = $5
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
iface.each_key do |ifn|
|
151
|
-
iaddr = nil
|
152
|
-
if iface[ifn][:encapsulation].eql?("Ethernet")
|
153
|
-
iface[ifn][:addresses].each_key do |addr|
|
154
|
-
if iface[ifn][:addresses][addr]["family"].eql?("inet")
|
155
|
-
iaddr = addr
|
156
|
-
break
|
157
|
-
end
|
158
|
-
end
|
159
|
-
iface[ifn][:arp]&.each_key do |addr|
|
160
|
-
if addr.eql?(iaddr)
|
161
|
-
iface[ifn][:addresses][iface[ifn][:arp][iaddr]] = { "family" => "lladdr" }
|
162
|
-
break
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
network[:interfaces] = iface
|
169
|
-
|
170
|
-
so = shell_out("route -v -n get default")
|
171
|
-
so.stdout.lines do |line|
|
172
|
-
matches = /interface: (?<name>\S+)\s+index\s+(?<index>\d+)/.match(line)
|
173
|
-
if matches
|
174
|
-
network[:default_interface] =
|
175
|
-
case
|
176
|
-
when iface[matches[:name]]
|
177
|
-
matches[:name]
|
178
|
-
when int_name = full_interface_name(iface, matches[:name], matches[:index])
|
179
|
-
int_name
|
180
|
-
else
|
181
|
-
matches[:name]
|
182
|
-
end
|
183
|
-
logger.trace("Plugin Network: found interface device: #{network[:default_interface]} #{matches[:name]}")
|
184
|
-
end
|
185
|
-
matches = /gateway: (\S+)/.match(line)
|
186
|
-
if matches
|
187
|
-
logger.trace("Plugin Network: found gateway: #{matches[1]}")
|
188
|
-
network[:default_gateway] = matches[1]
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Benjamin Black (<nostromo@gmail.com>)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
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
|
+
# EXAMPLE SOLARIS IFCONFIG OUTPUT; CURRENTLY, ONLY SIMPLE STUFF IS SUPPORTED (E.G., NO TUNNELS)
|
21
|
+
# DEAR SUN: YOU GET AN F FOR YOUR IFCONFIG
|
22
|
+
# lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
|
23
|
+
# inet 127.0.0.1 netmask ff000000
|
24
|
+
# e1000g0:3: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 3
|
25
|
+
# inet 72.2.115.28 netmask ffffff80 broadcast 72.2.115.127
|
26
|
+
# e1000g2:1: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 4
|
27
|
+
# inet 10.2.115.28 netmask ffffff80 broadcast 10.2.115.127
|
28
|
+
# inet6 2001:0db8:3c4d:55:a00:20ff:fe8e:f3ad/64
|
29
|
+
# ip.tun0: flags=2200851<UP,POINTOPOINT,RUNNING,MULTICAST,NONUD,IPv6> mtu 1480 index 3
|
30
|
+
# inet tunnel src 109.146.85.57 tunnel dst 109.146.85.212
|
31
|
+
# tunnel security settings --> use 'ipsecconf -ln -i ip.tun1'
|
32
|
+
# tunnel hop limit 60
|
33
|
+
# inet6 fe80::6d92:5539/10 --> fe80::6d92:55d4
|
34
|
+
# ip.tun0:1: flags=2200851<UP,POINTOPOINT,RUNNING,MULTICAST,NONUD,IPv6> mtu 1480 index 3
|
35
|
+
# inet6 2::45/128 --> 2::46
|
36
|
+
# lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
|
37
|
+
# inet 127.0.0.1 netmask ff000000
|
38
|
+
# eri0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 \
|
39
|
+
# index 2
|
40
|
+
# inet 172.17.128.208 netmask ffffff00 broadcast 172.17.128.255
|
41
|
+
# ip6.tun0: flags=10008d1<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4> \
|
42
|
+
# mtu 1460
|
43
|
+
# index 3
|
44
|
+
# inet6 tunnel src fe80::1 tunnel dst fe80::2
|
45
|
+
# tunnel security settings --> use 'ipsecconf -ln -i ip.tun1'
|
46
|
+
# tunnel hop limit 60 tunnel encapsulation limit 4
|
47
|
+
# inet 10.0.0.208 --> 10.0.0.210 netmask ff000000
|
48
|
+
# qfe1: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 3
|
49
|
+
# usesrc vni0
|
50
|
+
# inet6 fe80::203:baff:fe17:4be0/10
|
51
|
+
# ether 0:3:ba:17:4b:e0
|
52
|
+
# vni0: flags=2002210041<UP,RUNNING,NOXMIT,NONUD,IPv6,VIRTUAL> mtu 0
|
53
|
+
# index 5
|
54
|
+
# srcof qfe1
|
55
|
+
# inet6 fe80::203:baff:fe17:4444/128
|
56
|
+
|
57
|
+
# Extracted from http://illumos.org/hcl/
|
58
|
+
ETHERNET_ENCAPS ||= %w{ afe amd8111s arn atge ath bfe bge bnx bnxe ce cxgbe
|
59
|
+
dmfe e1000g efe elxl emlxs eri hermon hme hxge igb
|
60
|
+
iprb ipw iwh iwi iwk iwp ixgb ixgbe mwl mxfe myri10ge
|
61
|
+
nge ntxn nxge pcn platform qfe qlc ral rge rtls rtw rwd
|
62
|
+
rwn sfe tavor vr wpi xge yge aggr}.freeze
|
63
|
+
|
64
|
+
Ohai.plugin(:Network) do
|
65
|
+
require_relative "../../mixin/network_helper"
|
66
|
+
|
67
|
+
provides "network", "network/interfaces"
|
68
|
+
provides "counters/network", "counters/network/interfaces"
|
69
|
+
|
70
|
+
include Ohai::Mixin::NetworkHelper
|
71
|
+
|
72
|
+
def solaris_encaps_lookup(ifname)
|
73
|
+
return "Ethernet" if ETHERNET_ENCAPS.include?(ifname)
|
74
|
+
return "Ethernet" if ifname.eql?("net")
|
75
|
+
return "Loopback" if ifname.eql?("lo")
|
76
|
+
|
77
|
+
"Unknown"
|
78
|
+
end
|
79
|
+
|
80
|
+
def arpname_to_ifname(iface, arpname)
|
81
|
+
iface.each_key do |ifn|
|
82
|
+
return ifn if ifn.split(":")[0].eql?(arpname)
|
83
|
+
end
|
84
|
+
|
85
|
+
nil
|
86
|
+
end
|
87
|
+
|
88
|
+
def full_interface_name(iface, part_name, index)
|
89
|
+
iface.each do |name, attrs|
|
90
|
+
next unless attrs.respond_to?(:[])
|
91
|
+
return name if /^#{part_name}($|:)/.match(name) && attrs[:index] == index
|
92
|
+
end
|
93
|
+
|
94
|
+
nil
|
95
|
+
end
|
96
|
+
|
97
|
+
collect_data(:solaris2) do
|
98
|
+
iface = Mash.new
|
99
|
+
network Mash.new unless network
|
100
|
+
network[:interfaces] ||= Mash.new
|
101
|
+
counters Mash.new unless counters
|
102
|
+
counters[:network] ||= Mash.new
|
103
|
+
|
104
|
+
cint = nil
|
105
|
+
shell_out("ifconfig -a").stdout.lines do |line|
|
106
|
+
# regex: https://rubular.com/r/ZiIHbsnfiWPW1p
|
107
|
+
if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+)(?: index (\d+))?/
|
108
|
+
cint = $1
|
109
|
+
iface[cint] ||= Mash.new
|
110
|
+
iface[cint][:mtu] = $2
|
111
|
+
iface[cint][:index] = $3
|
112
|
+
if line =~ / flags\=\d+\<((ADDRCONF|ANYCAST|BROADCAST|CoS|DEPRECATED|DHCP|DUPLICATE|FAILED|FIXEDMTU|INACTIVE|L3PROTECT|LOOPBACK|MIP|MULTI_BCAST|MULTICAST|NOARP|NOFAILOVER|NOLOCAL|NONUD|NORTEXCH|NOXMIT|OFFLINE|PHYSRUNNING|POINTOPOINT|PREFERRED|PRIVATE|ROUTER|RUNNING|STANDBY|TEMPORARY|UNNUMBERED|UP|VIRTUAL|XRESOLV|IPv4|IPv6|,)+)\>\s/
|
113
|
+
flags = $1.split(",")
|
114
|
+
else
|
115
|
+
flags = []
|
116
|
+
end
|
117
|
+
iface[cint][:flags] = flags.flatten
|
118
|
+
if cint =~ /^(\w+)(\d+.*)/
|
119
|
+
iface[cint][:type] = $1
|
120
|
+
iface[cint][:number] = $2
|
121
|
+
iface[cint][:encapsulation] = solaris_encaps_lookup($1)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask (([0-9a-f]){1,8})\s*$/
|
125
|
+
iface[cint][:addresses] ||= Mash.new
|
126
|
+
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2) }
|
127
|
+
end
|
128
|
+
if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask (([0-9a-f]){1,8}) broadcast (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
129
|
+
iface[cint][:addresses] ||= Mash.new
|
130
|
+
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2), "broadcast" => $4 }
|
131
|
+
end
|
132
|
+
if line =~ %r{\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*)/(\d+)\s*$}
|
133
|
+
iface[cint][:addresses] ||= Mash.new
|
134
|
+
iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4 }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# Device IP Address Mask Flags Phys Addr
|
139
|
+
# bge1 172.16.0.129 255.255.255.255 SPLA 00:03:ba:xx:xx:xx
|
140
|
+
so = shell_out("arp -an")
|
141
|
+
so.stdout.lines do |line|
|
142
|
+
if line =~ /([0-9a-zA-Z]+)\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\w+)?\s+([a-zA-Z0-9\.\:\-]+)/
|
143
|
+
next unless iface[arpname_to_ifname(iface, $1)] # this should never happen, except on solaris because sun hates you.
|
144
|
+
|
145
|
+
iface[arpname_to_ifname(iface, $1)][:arp] ||= Mash.new
|
146
|
+
iface[arpname_to_ifname(iface, $1)][:arp][$2] = $5
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
iface.each_key do |ifn|
|
151
|
+
iaddr = nil
|
152
|
+
if iface[ifn][:encapsulation].eql?("Ethernet")
|
153
|
+
iface[ifn][:addresses].each_key do |addr|
|
154
|
+
if iface[ifn][:addresses][addr]["family"].eql?("inet")
|
155
|
+
iaddr = addr
|
156
|
+
break
|
157
|
+
end
|
158
|
+
end
|
159
|
+
iface[ifn][:arp]&.each_key do |addr|
|
160
|
+
if addr.eql?(iaddr)
|
161
|
+
iface[ifn][:addresses][iface[ifn][:arp][iaddr]] = { "family" => "lladdr" }
|
162
|
+
break
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
network[:interfaces] = iface
|
169
|
+
|
170
|
+
so = shell_out("route -v -n get default")
|
171
|
+
so.stdout.lines do |line|
|
172
|
+
matches = /interface: (?<name>\S+)\s+index\s+(?<index>\d+)/.match(line)
|
173
|
+
if matches
|
174
|
+
network[:default_interface] =
|
175
|
+
case
|
176
|
+
when iface[matches[:name]]
|
177
|
+
matches[:name]
|
178
|
+
when int_name = full_interface_name(iface, matches[:name], matches[:index])
|
179
|
+
int_name
|
180
|
+
else
|
181
|
+
matches[:name]
|
182
|
+
end
|
183
|
+
logger.trace("Plugin Network: found interface device: #{network[:default_interface]} #{matches[:name]}")
|
184
|
+
end
|
185
|
+
matches = /gateway: (\S+)/.match(line)
|
186
|
+
if matches
|
187
|
+
logger.trace("Plugin Network: found gateway: #{matches[1]}")
|
188
|
+
network[:default_gateway] = matches[1]
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -1,58 +1,58 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Benjamin Black (<nostromo@gmail.com>)
|
4
|
-
# Copyright:: Copyright (c) Chef Software Inc.
|
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(:Platform) do
|
21
|
-
provides "platform", "platform_version", "platform_build", "platform_family"
|
22
|
-
|
23
|
-
collect_data(:solaris2) do
|
24
|
-
if file_exist?("/sbin/uname")
|
25
|
-
uname_exec = "/sbin/uname"
|
26
|
-
else
|
27
|
-
uname_exec = "uname"
|
28
|
-
end
|
29
|
-
|
30
|
-
shell_out("#{uname_exec} -X").stdout.lines do |line|
|
31
|
-
case line
|
32
|
-
when /^Release =\s+(.+)$/
|
33
|
-
platform_version $1
|
34
|
-
when /^KernelID =\s+(.+)$/
|
35
|
-
platform_build $1
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
file_open("/etc/release") do |file|
|
40
|
-
while ( line = file.gets )
|
41
|
-
case line
|
42
|
-
when /.*SmartOS.*/
|
43
|
-
platform "smartos"
|
44
|
-
when /^\s*OmniOS.*r(\d+).*$/
|
45
|
-
platform "omnios"
|
46
|
-
platform_version $1
|
47
|
-
when /^\s*OpenIndiana.*(Development oi_|Hipster )(\d\S*)/ # https://rubular.com/r/iMtOBwbnyqDz7u
|
48
|
-
platform "openindiana"
|
49
|
-
platform_version $2
|
50
|
-
when /^\s*(Oracle Solaris|Solaris)/
|
51
|
-
platform "solaris2"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
platform_family platform
|
57
|
-
end
|
58
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Benjamin Black (<nostromo@gmail.com>)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
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(:Platform) do
|
21
|
+
provides "platform", "platform_version", "platform_build", "platform_family"
|
22
|
+
|
23
|
+
collect_data(:solaris2) do
|
24
|
+
if file_exist?("/sbin/uname")
|
25
|
+
uname_exec = "/sbin/uname"
|
26
|
+
else
|
27
|
+
uname_exec = "uname"
|
28
|
+
end
|
29
|
+
|
30
|
+
shell_out("#{uname_exec} -X").stdout.lines do |line|
|
31
|
+
case line
|
32
|
+
when /^Release =\s+(.+)$/
|
33
|
+
platform_version $1
|
34
|
+
when /^KernelID =\s+(.+)$/
|
35
|
+
platform_build $1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
file_open("/etc/release") do |file|
|
40
|
+
while ( line = file.gets )
|
41
|
+
case line
|
42
|
+
when /.*SmartOS.*/
|
43
|
+
platform "smartos"
|
44
|
+
when /^\s*OmniOS.*r(\d+).*$/
|
45
|
+
platform "omnios"
|
46
|
+
platform_version $1
|
47
|
+
when /^\s*OpenIndiana.*(Development oi_|Hipster )(\d\S*)/ # https://rubular.com/r/iMtOBwbnyqDz7u
|
48
|
+
platform "openindiana"
|
49
|
+
platform_version $2
|
50
|
+
when /^\s*(Oracle Solaris|Solaris)/
|
51
|
+
platform "solaris2"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
platform_family platform
|
57
|
+
end
|
58
|
+
end
|