ohai 0.6.10 → 0.6.12.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ohai/plugins/linux/filesystem.rb +39 -13
- data/lib/ohai/plugins/linux/network.rb +193 -69
- data/lib/ohai/plugins/linux/platform.rb +36 -8
- data/lib/ohai/plugins/openbsd/uptime.rb +3 -3
- data/lib/ohai/plugins/os.rb +4 -4
- data/lib/ohai/plugins/platform.rb +6 -3
- data/lib/ohai/plugins/sigar/network_route.rb +5 -2
- data/lib/ohai/plugins/windows/platform.rb +1 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/ohai/plugins/linux/filesystem_spec.rb +289 -0
- data/spec/ohai/plugins/linux/network_spec.rb +285 -0
- data/spec/ohai/plugins/linux/platform_spec.rb +164 -9
- data/spec/ohai/plugins/os_spec.rb +5 -5
- data/spec/ohai/plugins/platform_spec.rb +17 -2
- data/spec/ohai/plugins/ruby_spec.rb +11 -5
- data/spec/ohai/plugins/sigar/network_route_spec.rb +120 -106
- metadata +16 -10
@@ -40,7 +40,7 @@ popen4("df -P") do |pid, stdin, stdout, stderr|
|
|
40
40
|
end
|
41
41
|
|
42
42
|
# Grab mount information from /bin/mount
|
43
|
-
popen4("mount
|
43
|
+
popen4("mount") do |pid, stdin, stdout, stderr|
|
44
44
|
stdin.close
|
45
45
|
stdout.each do |line|
|
46
46
|
if line =~ /^(.+?) on (.+?) type (.+?) \((.+?)\)$/
|
@@ -53,27 +53,53 @@ popen4("mount -l") do |pid, stdin, stdout, stderr|
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
#
|
57
|
-
popen4("
|
56
|
+
# Gather more filesystem types via libuuid, even devices that's aren't mounted
|
57
|
+
popen4("blkid -s TYPE") do |pid, stdin, stdout, stderr|
|
58
58
|
stdin.close
|
59
59
|
stdout.each do |line|
|
60
|
-
if line =~ /^
|
61
|
-
filesystem =
|
60
|
+
if line =~ /^(\S+): TYPE="(\S+)"/
|
61
|
+
filesystem = $1
|
62
|
+
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
|
63
|
+
fs[filesystem][:fs_type] = $2
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Gather device UUIDs via libuuid
|
69
|
+
popen4("blkid -s UUID") do |pid, stdin, stdout, stderr|
|
70
|
+
stdin.close
|
71
|
+
stdout.each do |line|
|
72
|
+
if line =~ /^(\S+): UUID="(\S+)"/
|
73
|
+
filesystem = $1
|
62
74
|
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
|
63
75
|
fs[filesystem][:uuid] = $2
|
64
76
|
end
|
65
77
|
end
|
66
78
|
end
|
67
79
|
|
80
|
+
# Gather device labels via libuuid
|
81
|
+
popen4("blkid -s LABEL") do |pid, stdin, stdout, stderr|
|
82
|
+
stdin.close
|
83
|
+
stdout.each do |line|
|
84
|
+
if line =~ /^(\S+): LABEL="(\S+)"/
|
85
|
+
filesystem = $1
|
86
|
+
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
|
87
|
+
fs[filesystem][:label] = $2
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
68
92
|
# Grab any missing mount information from /proc/mounts
|
69
|
-
File.
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
93
|
+
if File.exists?('/proc/mounts')
|
94
|
+
File.open('/proc/mounts').read_nonblock(4096).each_line do |line|
|
95
|
+
if line =~ /^(\S+) (\S+) (\S+) (\S+) \S+ \S+$/
|
96
|
+
filesystem = $1
|
97
|
+
next if fs.has_key?(filesystem)
|
98
|
+
fs[filesystem] = Mash.new
|
99
|
+
fs[filesystem][:mount] = $2
|
100
|
+
fs[filesystem][:fs_type] = $3
|
101
|
+
fs[filesystem][:mount_options] = $4.split(",")
|
102
|
+
end
|
77
103
|
end
|
78
104
|
end
|
79
105
|
|
@@ -16,12 +16,13 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
+
require 'ipaddr'
|
19
20
|
provides "network", "counters/network"
|
20
21
|
|
21
22
|
begin
|
22
23
|
route_result = from("route -n \| grep -m 1 ^0.0.0.0").split(/[ \t]+/)
|
23
24
|
if route_result.last =~ /(venet\d+)/
|
24
|
-
network[:default_interface] = from("ip addr show dev #{$1} | grep -v 127.0.0.
|
25
|
+
network[:default_interface] = from("ip addr show dev #{$1} | grep -v 127.0.0. | grep -m 1 inet").split(/[ \t]+/).last
|
25
26
|
network[:default_gateway] = route_result[1]
|
26
27
|
else
|
27
28
|
network[:default_gateway], network[:default_interface] = route_result.values_at(1,7)
|
@@ -31,95 +32,218 @@ rescue Ohai::Exceptions::Exec
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def encaps_lookup(encap)
|
34
|
-
return "Loopback" if encap.eql?("Local Loopback")
|
35
|
+
return "Loopback" if encap.eql?("Local Loopback") || encap.eql?("loopback")
|
35
36
|
return "PPP" if encap.eql?("Point-to-Point Protocol")
|
36
37
|
return "SLIP" if encap.eql?("Serial Line IP")
|
37
38
|
return "VJSLIP" if encap.eql?("VJ Serial Line IP")
|
38
39
|
return "IPIP" if encap.eql?("IPIP Tunnel")
|
39
40
|
return "6to4" if encap.eql?("IPv6-in-IPv4")
|
41
|
+
return "Ethernet" if encap.eql?("ether")
|
40
42
|
encap
|
41
43
|
end
|
42
44
|
|
43
45
|
iface = Mash.new
|
44
46
|
net_counters = Mash.new
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
|
48
|
+
if File.exist?("/sbin/ip")
|
49
|
+
|
50
|
+
begin
|
51
|
+
route_result = from("ip route show exact 0.0.0.0/0").chomp.split(/[ \t]+/)
|
52
|
+
|
53
|
+
if route_result[4] =~ /(venet\d+)/
|
54
|
+
network[:default_interface] = from("ip addr show dev #{$1} | grep -v 127.0.0.1 | grep -m 1 inet").split(/[ \t]+/).last
|
55
|
+
network[:default_gateway] = route_result[1]
|
56
|
+
else
|
57
|
+
network[:default_gateway], network[:default_interface] = route_result.values_at(2,4)
|
58
|
+
end
|
59
|
+
rescue Ohai::Exceptions::Exec
|
60
|
+
Ohai::Log.debug("Unable to determine default interface")
|
61
|
+
end
|
62
|
+
|
63
|
+
popen4("ip addr") do |pid, stdin, stdout, stderr|
|
64
|
+
stdin.close
|
65
|
+
cint = nil
|
66
|
+
stdout.each do |line|
|
67
|
+
if line =~ /^(\d+): ([0-9a-zA-Z\.\-_]+):\s/
|
68
|
+
cint = $2
|
69
|
+
iface[cint] = Mash.new
|
70
|
+
if cint =~ /^(\w+)(\d+.*)/
|
71
|
+
iface[cint][:type] = $1
|
72
|
+
iface[cint][:number] = $2
|
73
|
+
end
|
74
|
+
|
75
|
+
if line =~ /mtu (\d+)/
|
76
|
+
iface[cint][:mtu] = $1
|
77
|
+
end
|
78
|
+
|
79
|
+
flags = line.scan(/(UP|BROADCAST|DEBUG|LOOPBACK|POINTTOPOINT|NOTRAILERS|LOWER_UP|NOARP|PROMISC|ALLMULTI|SLAVE|MASTER|MULTICAST|DYNAMIC)/)
|
80
|
+
if flags.length > 1
|
81
|
+
iface[cint][:flags] = flags.flatten.uniq
|
82
|
+
end
|
83
|
+
end
|
84
|
+
if line =~ /link\/(\w+) ([\da-f\:]+) /
|
85
|
+
iface[cint][:encapsulation] = encaps_lookup($1)
|
86
|
+
unless $2 == "00:00:00:00:00:00"
|
87
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
88
|
+
iface[cint][:addresses][$2.upcase] = { "family" => "lladdr" }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
if line =~ /inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\/(\d{1,2})/
|
92
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
93
|
+
tmp_addr = $1
|
94
|
+
iface[cint][:addresses][tmp_addr] = { "family" => "inet" }
|
95
|
+
iface[cint][:addresses][tmp_addr][:netmask] = IPAddr.new("255.255.255.255").mask($2.to_i).to_s
|
96
|
+
|
97
|
+
if line =~ /brd (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
98
|
+
iface[cint][:addresses][tmp_addr][:broadcast] = $1
|
99
|
+
end
|
100
|
+
end
|
101
|
+
if line =~ /inet6 ([a-f0-9\:]+)\/(\d+) scope (\w+)/
|
102
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
103
|
+
tmp_addr = $1
|
104
|
+
iface[cint][:addresses][tmp_addr] = { "family" => "inet6", "prefixlen" => $2, "scope" => ($3.eql?("host") ? "Node" : $3.capitalize) }
|
56
105
|
end
|
57
106
|
end
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
net_counters[cint][:rx] = { "packets" => $1, "errors" => $2, "drop" => $3, "overrun" => $4, "frame" => $5 }
|
93
|
-
end
|
94
|
-
if line =~ /TX packets:(\d+) errors:(\d+) dropped:(\d+) overruns:(\d+) carrier:(\d+)/
|
95
|
-
net_counters[cint][:tx] = { "packets" => $1, "errors" => $2, "drop" => $3, "overrun" => $4, "carrier" => $5 }
|
96
|
-
end
|
97
|
-
if line =~ /collisions:(\d+)/
|
98
|
-
net_counters[cint][:tx]["collisions"] = $1
|
99
|
-
end
|
100
|
-
if line =~ /txqueuelen:(\d+)/
|
101
|
-
net_counters[cint][:tx]["queuelen"] = $1
|
107
|
+
end
|
108
|
+
|
109
|
+
popen4("ip link -s") do |pid, stdin, stdout, stderr|
|
110
|
+
stdin.close
|
111
|
+
tmp_int = nil
|
112
|
+
on_rx = true
|
113
|
+
stdout.each do |line|
|
114
|
+
if line =~ /^(\d+): ([0-9a-zA-Z\.\-_]+):\s/
|
115
|
+
tmp_int = $2
|
116
|
+
net_counters[tmp_int] = Mash.new unless net_counters[tmp_int]
|
117
|
+
end
|
118
|
+
|
119
|
+
if line =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
|
120
|
+
int = on_rx ? :rx : :tx
|
121
|
+
net_counters[tmp_int][int] = Mash.new unless net_counters[tmp_int][int]
|
122
|
+
net_counters[tmp_int][int][:bytes] = $1
|
123
|
+
net_counters[tmp_int][int][:packets] = $2
|
124
|
+
net_counters[tmp_int][int][:errors] = $3
|
125
|
+
net_counters[tmp_int][int][:drop] = $4
|
126
|
+
if(int == :rx)
|
127
|
+
net_counters[tmp_int][int][:overrun] = $5
|
128
|
+
else
|
129
|
+
net_counters[tmp_int][int][:carrier] = $5
|
130
|
+
net_counters[tmp_int][int][:collisions] = $6
|
131
|
+
end
|
132
|
+
|
133
|
+
on_rx = !on_rx
|
134
|
+
end
|
135
|
+
|
136
|
+
if line =~ /qlen (\d+)/
|
137
|
+
net_counters[tmp_int][:tx] = Mash.new unless net_counters[tmp_int][:tx]
|
138
|
+
net_counters[tmp_int][:tx][:queuelen] = $1
|
139
|
+
end
|
140
|
+
|
102
141
|
end
|
103
|
-
|
104
|
-
|
142
|
+
end
|
143
|
+
|
144
|
+
popen4("ip neighbor show") do |pid, stdin, stdout, stderr|
|
145
|
+
stdin.close
|
146
|
+
stdout.each do |line|
|
147
|
+
if line =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) dev ([0-9a-zA-Z\.\:\-]+) lladdr ([a-fA-F0-9\:]+)/
|
148
|
+
next unless iface[$2]
|
149
|
+
iface[$2][:arp] = Mash.new unless iface[$2][:arp]
|
150
|
+
iface[$2][:arp][$1] = $3.downcase
|
151
|
+
end
|
105
152
|
end
|
106
|
-
|
107
|
-
|
153
|
+
end
|
154
|
+
|
155
|
+
else
|
156
|
+
|
157
|
+
begin
|
158
|
+
route_result = from("route -n \| grep -m 1 ^0.0.0.0").split(/[ \t]+/)
|
159
|
+
network[:default_gateway], network[:default_interface] = route_result.values_at(1,7)
|
160
|
+
rescue Ohai::Exceptions::Exec
|
161
|
+
Ohai::Log.debug("Unable to determine default interface")
|
162
|
+
end
|
163
|
+
|
164
|
+
popen4("ifconfig -a") do |pid, stdin, stdout, stderr|
|
165
|
+
stdin.close
|
166
|
+
cint = nil
|
167
|
+
stdout.each do |line|
|
168
|
+
tmp_addr = nil
|
169
|
+
if line =~ /^([0-9a-zA-Z\.\:\-_]+)\s+/
|
170
|
+
cint = $1
|
171
|
+
iface[cint] = Mash.new
|
172
|
+
if cint =~ /^(\w+)(\d+.*)/
|
173
|
+
iface[cint][:type] = $1
|
174
|
+
iface[cint][:number] = $2
|
175
|
+
end
|
176
|
+
end
|
177
|
+
if line =~ /Link encap:(Local Loopback)/ || line =~ /Link encap:(.+?)\s/
|
178
|
+
iface[cint][:encapsulation] = encaps_lookup($1)
|
179
|
+
end
|
180
|
+
if line =~ /HWaddr (.+?)\s/
|
181
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
182
|
+
iface[cint][:addresses][$1] = { "family" => "lladdr" }
|
183
|
+
end
|
184
|
+
if line =~ /inet addr:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
185
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
186
|
+
iface[cint][:addresses][$1] = { "family" => "inet" }
|
187
|
+
tmp_addr = $1
|
188
|
+
end
|
189
|
+
if line =~ /inet6 addr: ([a-f0-9\:]+)\/(\d+) Scope:(\w+)/
|
190
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
191
|
+
iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $2, "scope" => ($3.eql?("Host") ? "Node" : $3) }
|
192
|
+
end
|
193
|
+
if line =~ /Bcast:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
194
|
+
iface[cint][:addresses][tmp_addr]["broadcast"] = $1
|
195
|
+
end
|
196
|
+
if line =~ /Mask:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
197
|
+
iface[cint][:addresses][tmp_addr]["netmask"] = $1
|
198
|
+
end
|
199
|
+
flags = line.scan(/(UP|BROADCAST|DEBUG|LOOPBACK|POINTTOPOINT|NOTRAILERS|RUNNING|NOARP|PROMISC|ALLMULTI|SLAVE|MASTER|MULTICAST|DYNAMIC)\s/)
|
200
|
+
if flags.length > 1
|
201
|
+
iface[cint][:flags] = flags.flatten
|
202
|
+
end
|
203
|
+
if line =~ /MTU:(\d+)/
|
204
|
+
iface[cint][:mtu] = $1
|
205
|
+
end
|
206
|
+
if line =~ /P-t-P:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
207
|
+
iface[cint][:peer] = $1
|
208
|
+
end
|
209
|
+
if line =~ /RX packets:(\d+) errors:(\d+) dropped:(\d+) overruns:(\d+) frame:(\d+)/
|
210
|
+
net_counters[cint] = Mash.new unless net_counters[cint]
|
211
|
+
net_counters[cint][:rx] = { "packets" => $1, "errors" => $2, "drop" => $3, "overrun" => $4, "frame" => $5 }
|
212
|
+
end
|
213
|
+
if line =~ /TX packets:(\d+) errors:(\d+) dropped:(\d+) overruns:(\d+) carrier:(\d+)/
|
214
|
+
net_counters[cint][:tx] = { "packets" => $1, "errors" => $2, "drop" => $3, "overrun" => $4, "carrier" => $5 }
|
215
|
+
end
|
216
|
+
if line =~ /collisions:(\d+)/
|
217
|
+
net_counters[cint][:tx]["collisions"] = $1
|
218
|
+
end
|
219
|
+
if line =~ /txqueuelen:(\d+)/
|
220
|
+
net_counters[cint][:tx]["queuelen"] = $1
|
221
|
+
end
|
222
|
+
if line =~ /RX bytes:(\d+) \((\d+?\.\d+ .+?)\)/
|
223
|
+
net_counters[cint][:rx]["bytes"] = $1
|
224
|
+
end
|
225
|
+
if line =~ /TX bytes:(\d+) \((\d+?\.\d+ .+?)\)/
|
226
|
+
net_counters[cint][:tx]["bytes"] = $1
|
227
|
+
end
|
108
228
|
end
|
109
229
|
end
|
110
|
-
end
|
111
230
|
|
112
|
-
|
113
|
-
stdin
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
231
|
+
|
232
|
+
popen4("arp -an") do |pid, stdin, stdout, stderr|
|
233
|
+
stdin.close
|
234
|
+
stdout.each do |line|
|
235
|
+
if line =~ /^\S+ \((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) \[(\w+)\] on ([0-9a-zA-Z\.\:\-]+)/
|
236
|
+
next unless iface[$4] # this should never happen
|
237
|
+
iface[$4][:arp] = Mash.new unless iface[$4][:arp]
|
238
|
+
iface[$4][:arp][$1] = $2.downcase
|
239
|
+
end
|
119
240
|
end
|
120
241
|
end
|
242
|
+
|
121
243
|
end
|
122
244
|
|
245
|
+
|
123
246
|
counters[:network][:interfaces] = net_counters
|
124
247
|
|
125
248
|
network["interfaces"] = iface
|
249
|
+
|
@@ -24,19 +24,29 @@ def get_redhatish_version(contents)
|
|
24
24
|
contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/release ([\d\.]+)/, 1]
|
25
25
|
end
|
26
26
|
|
27
|
-
provides "platform", "platform_version"
|
27
|
+
provides "platform", "platform_version", "platform_family"
|
28
28
|
|
29
29
|
require_plugin 'linux::lsb'
|
30
|
-
|
31
|
-
# platform [ and platform_version ? ] should be lower case to avoid dealing with RedHat/Redhat/redhat matching
|
32
30
|
|
33
|
-
|
31
|
+
# platform [ and platform_version ? ] should be lower case to avoid dealing with RedHat/Redhat/redhat matching
|
32
|
+
if File.exists?("/etc/oracle-release")
|
33
|
+
contents = File.read("/etc/oracle-release").chomp
|
34
|
+
platform "oracle"
|
35
|
+
platform_version get_redhatish_version(contents)
|
36
|
+
elsif File.exists?("/etc/enterprise-release")
|
37
|
+
contents = File.read("/etc/enterprise-release").chomp
|
38
|
+
platform "oracle"
|
39
|
+
platform_version get_redhatish_version(contents)
|
40
|
+
elsif lsb[:id] =~ /RedHat/i
|
34
41
|
platform "redhat"
|
35
42
|
platform_version lsb[:release]
|
36
43
|
elsif lsb[:id] =~ /Amazon/i
|
37
|
-
|
38
|
-
|
39
|
-
elsif lsb[:id]
|
44
|
+
platform "amazon"
|
45
|
+
platform_version lsb[:release]
|
46
|
+
elsif lsb[:id] =~ /ScientificSL/i
|
47
|
+
platform "scientific"
|
48
|
+
platform_version lsb[:release]
|
49
|
+
elsif lsb[:id]
|
40
50
|
platform lsb[:id].downcase
|
41
51
|
platform_version lsb[:release]
|
42
52
|
elsif File.exists?("/etc/debian_version")
|
@@ -52,7 +62,7 @@ elsif File.exists?("/etc/system-release")
|
|
52
62
|
platform_version get_redhatish_version(contents)
|
53
63
|
elsif File.exists?('/etc/gentoo-release')
|
54
64
|
platform "gentoo"
|
55
|
-
platform_version
|
65
|
+
platform_version File.read('/etc/gentoo-release').scan(/(\d+|\.+)/).join
|
56
66
|
elsif File.exists?('/etc/SuSE-release')
|
57
67
|
platform "suse"
|
58
68
|
platform_version File.read("/etc/SuSE-release").scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
|
@@ -65,3 +75,21 @@ elsif File.exists?('/etc/arch-release')
|
|
65
75
|
# no way to determine platform_version in a rolling release distribution
|
66
76
|
# kernel release will be used - ex. 2.6.32-ARCH
|
67
77
|
end
|
78
|
+
|
79
|
+
|
80
|
+
case platform
|
81
|
+
when /debian/, /ubuntu/, /mint/
|
82
|
+
platform_family "debian"
|
83
|
+
when /fedora/, /amazon/
|
84
|
+
platform_family "fedora"
|
85
|
+
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/
|
86
|
+
platform_family "rhel"
|
87
|
+
when /suse/
|
88
|
+
platform_family "suse"
|
89
|
+
when /gentoo/
|
90
|
+
platform_family "gentoo"
|
91
|
+
when /slackware/
|
92
|
+
platform_family "slackware"
|
93
|
+
when /arch/
|
94
|
+
platform_family "arch"
|
95
|
+
end
|
@@ -18,13 +18,13 @@
|
|
18
18
|
|
19
19
|
provides "uptime", "uptime_seconds"
|
20
20
|
|
21
|
-
# kern.boottime
|
21
|
+
# kern.boottime=Tue Nov 1 14:45:52 2011
|
22
22
|
|
23
23
|
popen4("/sbin/sysctl kern.boottime") do |pid, stdin, stdout, stderr|
|
24
24
|
stdin.close
|
25
25
|
stdout.each do |line|
|
26
|
-
if line =~ /kern.boottime
|
27
|
-
uptime_seconds Time.new.to_i - $1.to_i
|
26
|
+
if line =~ /kern.boottime=(.+)/
|
27
|
+
uptime_seconds Time.new.to_i - Time.parse($1).to_i
|
28
28
|
uptime self._seconds_to_human(uptime_seconds)
|
29
29
|
end
|
30
30
|
end
|