rightscale-ohai 0.3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +201 -0
- data/README.rdoc +98 -0
- data/Rakefile +59 -0
- data/bin/ohai +78 -0
- data/lib/ohai/config.rb +118 -0
- data/lib/ohai/exception.rb +23 -0
- data/lib/ohai/log/formatter.rb +57 -0
- data/lib/ohai/log.rb +89 -0
- data/lib/ohai/mixin/command.rb +203 -0
- data/lib/ohai/mixin/from_file.rb +36 -0
- data/lib/ohai/mixin/string.rb +29 -0
- data/lib/ohai/plugins/cloud.rb +35 -0
- data/lib/ohai/plugins/command.rb +21 -0
- data/lib/ohai/plugins/darwin/filesystem.rb +57 -0
- data/lib/ohai/plugins/darwin/hostname.rb +22 -0
- data/lib/ohai/plugins/darwin/kernel.rb +37 -0
- data/lib/ohai/plugins/darwin/network.rb +187 -0
- data/lib/ohai/plugins/darwin/platform.rb +36 -0
- data/lib/ohai/plugins/darwin/ps.rb +23 -0
- data/lib/ohai/plugins/darwin/ssh_host_key.rb +25 -0
- data/lib/ohai/plugins/darwin/system_profiler.rb +33 -0
- data/lib/ohai/plugins/darwin/uptime.rb +32 -0
- data/lib/ohai/plugins/dmi.rb +59 -0
- data/lib/ohai/plugins/ec2.rb +100 -0
- data/lib/ohai/plugins/erlang.rb +40 -0
- data/lib/ohai/plugins/freebsd/cpu.rb +52 -0
- data/lib/ohai/plugins/freebsd/filesystem.rb +57 -0
- data/lib/ohai/plugins/freebsd/hostname.rb +22 -0
- data/lib/ohai/plugins/freebsd/kernel.rb +37 -0
- data/lib/ohai/plugins/freebsd/memory.rb +50 -0
- data/lib/ohai/plugins/freebsd/network.rb +112 -0
- data/lib/ohai/plugins/freebsd/platform.rb +23 -0
- data/lib/ohai/plugins/freebsd/ps.rb +24 -0
- data/lib/ohai/plugins/freebsd/ssh_host_key.rb +26 -0
- data/lib/ohai/plugins/freebsd/uptime.rb +32 -0
- data/lib/ohai/plugins/freebsd/virtualization.rb +66 -0
- data/lib/ohai/plugins/hostname.rb +27 -0
- data/lib/ohai/plugins/java.rb +36 -0
- data/lib/ohai/plugins/kernel.rb +33 -0
- data/lib/ohai/plugins/keys.rb +22 -0
- data/lib/ohai/plugins/languages.rb +21 -0
- data/lib/ohai/plugins/linux/block_device.rb +38 -0
- data/lib/ohai/plugins/linux/cpu.rb +60 -0
- data/lib/ohai/plugins/linux/filesystem.rb +57 -0
- data/lib/ohai/plugins/linux/hostname.rb +26 -0
- data/lib/ohai/plugins/linux/kernel.rb +33 -0
- data/lib/ohai/plugins/linux/lsb.rb +38 -0
- data/lib/ohai/plugins/linux/memory.rb +83 -0
- data/lib/ohai/plugins/linux/network.rb +112 -0
- data/lib/ohai/plugins/linux/platform.rb +43 -0
- data/lib/ohai/plugins/linux/ps.rb +23 -0
- data/lib/ohai/plugins/linux/ssh_host_key.rb +26 -0
- data/lib/ohai/plugins/linux/uptime.rb +28 -0
- data/lib/ohai/plugins/linux/virtualization.rb +77 -0
- data/lib/ohai/plugins/network.rb +52 -0
- data/lib/ohai/plugins/ohai_time.rb +21 -0
- data/lib/ohai/plugins/os.rb +43 -0
- data/lib/ohai/plugins/perl.rb +37 -0
- data/lib/ohai/plugins/platform.rb +25 -0
- data/lib/ohai/plugins/python.rb +37 -0
- data/lib/ohai/plugins/rightscale.rb +53 -0
- data/lib/ohai/plugins/ruby.rb +37 -0
- data/lib/ohai/plugins/solaris2/cpu.rb +33 -0
- data/lib/ohai/plugins/solaris2/hostname.rb +22 -0
- data/lib/ohai/plugins/solaris2/kernel.rb +21 -0
- data/lib/ohai/plugins/solaris2/network.rb +141 -0
- data/lib/ohai/plugins/solaris2/platform.rb +33 -0
- data/lib/ohai/plugins/solaris2/ps.rb +23 -0
- data/lib/ohai/plugins/solaris2/ssh_host_key.rb +26 -0
- data/lib/ohai/plugins/uptime.rb +42 -0
- data/lib/ohai/plugins/virtualization.rb +86 -0
- data/lib/ohai/plugins/windows/filesystem.rb +44 -0
- data/lib/ohai/plugins/windows/hostname.rb +25 -0
- data/lib/ohai/plugins/windows/kernel.rb +75 -0
- data/lib/ohai/plugins/windows/network.rb +114 -0
- data/lib/ohai/plugins/windows/platform.rb +26 -0
- data/lib/ohai/system.rb +226 -0
- data/lib/ohai.rb +27 -0
- data/spec/ohai/log/log_formatter_spec.rb +50 -0
- data/spec/ohai/log_spec.rb +63 -0
- data/spec/ohai/mixin/from_file_spec.rb +53 -0
- data/spec/ohai/plugins/cloud_spec.rb +64 -0
- data/spec/ohai/plugins/darwin/hostname_spec.rb +34 -0
- data/spec/ohai/plugins/darwin/kernel_spec.rb +46 -0
- data/spec/ohai/plugins/darwin/platform_spec.rb +67 -0
- data/spec/ohai/plugins/dmi_spec.rb +73 -0
- data/spec/ohai/plugins/ec2_spec.rb +77 -0
- data/spec/ohai/plugins/erlang_spec.rb +63 -0
- data/spec/ohai/plugins/freebsd/hostname_spec.rb +34 -0
- data/spec/ohai/plugins/freebsd/kernel_spec.rb +37 -0
- data/spec/ohai/plugins/freebsd/platform_spec.rb +40 -0
- data/spec/ohai/plugins/hostname_spec.rb +39 -0
- data/spec/ohai/plugins/java_spec.rb +70 -0
- data/spec/ohai/plugins/kernel_spec.rb +43 -0
- data/spec/ohai/plugins/linux/cpu_spec.rb +128 -0
- data/spec/ohai/plugins/linux/hostname_spec.rb +52 -0
- data/spec/ohai/plugins/linux/kernel_spec.rb +31 -0
- data/spec/ohai/plugins/linux/lsb_spec.rb +60 -0
- data/spec/ohai/plugins/linux/platform_spec.rb +81 -0
- data/spec/ohai/plugins/linux/uptime_spec.rb +61 -0
- data/spec/ohai/plugins/linux/virtualization_spec.rb +131 -0
- data/spec/ohai/plugins/ohai_time_spec.rb +46 -0
- data/spec/ohai/plugins/os_spec.rb +58 -0
- data/spec/ohai/plugins/perl_spec.rb +89 -0
- data/spec/ohai/plugins/platform_spec.rb +56 -0
- data/spec/ohai/plugins/python_spec.rb +53 -0
- data/spec/ohai/plugins/rightscale_spec.rb +71 -0
- data/spec/ohai/plugins/ruby_spec.rb +51 -0
- data/spec/ohai/system_spec.rb +130 -0
- data/spec/ohai_spec.rb +27 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +66 -0
- metadata +209 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "uptime", "uptime_seconds"
|
20
|
+
|
21
|
+
# kern.boottime: { sec = 1232765114, usec = 823118 } Fri Jan 23 18:45:14 2009
|
22
|
+
|
23
|
+
popen4("/usr/sbin/sysctl kern.boottime") do |pid, stdin, stdout, stderr|
|
24
|
+
stdin.close
|
25
|
+
stdout.each do |line|
|
26
|
+
if line =~ /kern.boottime:\D+(\d+)/
|
27
|
+
uptime_seconds Time.new.to_i - $1.to_i
|
28
|
+
uptime self._seconds_to_human(uptime_seconds)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "dmi"
|
20
|
+
|
21
|
+
# dmidecode does not return data without access to /dev/mem (or its equivalent)
|
22
|
+
|
23
|
+
dmi Mash.new
|
24
|
+
dmi[:version] = from("dmidecode --version")
|
25
|
+
|
26
|
+
dmi[:bios] = Mash.new
|
27
|
+
dmi[:bios][:vendor] = from("dmidecode -s bios-vendor")
|
28
|
+
dmi[:bios][:version] = from("dmidecode -s bios-version")
|
29
|
+
dmi[:bios][:release_date] = from("dmidecode -s bios-release-date")
|
30
|
+
|
31
|
+
dmi[:system] = Mash.new
|
32
|
+
dmi[:system][:manufacturer] = from("dmidecode -s system-manufacturer")
|
33
|
+
dmi[:system][:product_name] = from("dmidecode -s system-product-name")
|
34
|
+
dmi[:system][:version] = from("dmidecode -s system-version")
|
35
|
+
dmi[:system][:serial_number] = from("dmidecode -s system-serial-number")
|
36
|
+
|
37
|
+
dmi[:baseboard] = Mash.new
|
38
|
+
dmi[:baseboard][:manufacturer] = from("dmidecode -s baseboard-manufacturer")
|
39
|
+
dmi[:baseboard][:product_name] = from("dmidecode -s baseboard-product-name")
|
40
|
+
dmi[:baseboard][:version] = from("dmidecode -s baseboard-version")
|
41
|
+
dmi[:baseboard][:serial_number] = from("dmidecode -s baseboard-serial-number")
|
42
|
+
dmi[:baseboard][:asset_tag] = from("dmidecode -s baseboard-asset-tag")
|
43
|
+
|
44
|
+
dmi[:chassis] = Mash.new
|
45
|
+
dmi[:chassis][:manufacturer] = from("dmidecode -s chassis-manufacturer")
|
46
|
+
dmi[:chassis][:version] = from("dmidecode -s chassis-version")
|
47
|
+
dmi[:chassis][:serial_number] = from("dmidecode -s chassis-serial-number")
|
48
|
+
dmi[:chassis][:asset_tag] = from("dmidecode -s chassis-asset-tag")
|
49
|
+
|
50
|
+
dmi[:processor] = Mash.new
|
51
|
+
dmi[:processor][:manufacturer] = from("dmidecode -s processor-manufacturer")
|
52
|
+
dmi[:processor][:version] = from("dmidecode -s processor-version")
|
53
|
+
|
54
|
+
if dmi[:version].to_f >= 2.8
|
55
|
+
dmi[:chassis][:type] = from("dmidecode -s chassis-type")
|
56
|
+
dmi[:system][:uuid] = from("dmidecode -s system-uuid")
|
57
|
+
dmi[:processor][:family] = from("dmidecode -s processor-family")
|
58
|
+
dmi[:processor][:frequency] = from("dmidecode -s processor-frequency")
|
59
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Tim Dysinger (<tim@dysinger.net>)
|
3
|
+
# Author:: Benjamin Black (<bb@opscode.com>)
|
4
|
+
# Author:: Christopher Brown (<cb@opscode.com>)
|
5
|
+
# Copyright:: Copyright (c) 2009 Opscode, Inc.
|
6
|
+
# License:: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
|
20
|
+
provides "ec2"
|
21
|
+
|
22
|
+
require 'open-uri'
|
23
|
+
require 'socket'
|
24
|
+
|
25
|
+
require_plugin "hostname"
|
26
|
+
require_plugin "kernel"
|
27
|
+
require_plugin "network"
|
28
|
+
|
29
|
+
EC2_METADATA_ADDR = "169.254.169.254" unless defined?(EC2_METADATA_ADDR)
|
30
|
+
EC2_METADATA_URL = "http://#{EC2_METADATA_ADDR}/2008-02-01/meta-data" unless defined?(EC2_METADATA_URL)
|
31
|
+
EC2_USERDATA_URL = "http://#{EC2_METADATA_ADDR}/2008-02-01/user-data" unless defined?(EC2_USERDATA_URL)
|
32
|
+
|
33
|
+
def can_metadata_connect?(addr, port, timeout=2)
|
34
|
+
t = Socket.new(Socket::Constants::AF_INET, Socket::Constants::SOCK_STREAM, 0)
|
35
|
+
saddr = Socket.pack_sockaddr_in(port, addr)
|
36
|
+
connected = false
|
37
|
+
|
38
|
+
begin
|
39
|
+
t.connect_nonblock(saddr)
|
40
|
+
rescue Errno::EINPROGRESS
|
41
|
+
r,w,e = IO::select(nil,[t],nil,timeout)
|
42
|
+
if !w.nil?
|
43
|
+
connected = true
|
44
|
+
else
|
45
|
+
begin
|
46
|
+
t.connect_nonblock(saddr)
|
47
|
+
rescue Errno::EISCONN
|
48
|
+
t.close
|
49
|
+
connected = true
|
50
|
+
rescue SystemCallError
|
51
|
+
end
|
52
|
+
end
|
53
|
+
rescue SystemCallError
|
54
|
+
end
|
55
|
+
|
56
|
+
connected
|
57
|
+
end
|
58
|
+
|
59
|
+
def has_ec2_mac?
|
60
|
+
network[:interfaces].values.each do |iface|
|
61
|
+
unless iface[:arp].nil?
|
62
|
+
return true if iface[:arp].value?("fe:ff:ff:ff:ff:ff")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
false
|
66
|
+
end
|
67
|
+
|
68
|
+
def metadata(id='')
|
69
|
+
OpenURI.open_uri("#{EC2_METADATA_URL}/#{id}").read.split("\n").each do |o|
|
70
|
+
key = "#{id}#{o.gsub(/\=.*$/, '/')}"
|
71
|
+
if key[-1..-1] != '/'
|
72
|
+
ec2[key.gsub(/\-|\//, '_').to_sym] =
|
73
|
+
OpenURI.open_uri("#{EC2_METADATA_URL}/#{key}").gets
|
74
|
+
else
|
75
|
+
metadata(key)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def userdata()
|
81
|
+
ec2[:userdata] = nil
|
82
|
+
# assumes the only expected error is the 404 if there's no user-data
|
83
|
+
begin
|
84
|
+
ec2[:userdata] = OpenURI.open_uri("#{EC2_USERDATA_URL}/").gets
|
85
|
+
rescue OpenURI::HTTPError
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def looks_like_ec2?
|
90
|
+
# Try non-blocking connect so we don't "block" if
|
91
|
+
# the Xen environment is *not* EC2
|
92
|
+
has_ec2_mac? && can_metadata_connect?(EC2_METADATA_ADDR,80)
|
93
|
+
end
|
94
|
+
|
95
|
+
if looks_like_ec2?
|
96
|
+
ec2 Mash.new
|
97
|
+
self.metadata
|
98
|
+
self.userdata
|
99
|
+
end
|
100
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Joe Williams (<joe@joetify.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "languages/erlang"
|
20
|
+
|
21
|
+
require_plugin "languages"
|
22
|
+
|
23
|
+
output = nil
|
24
|
+
|
25
|
+
erlang = Mash.new
|
26
|
+
status, stdout, stderr = run_command(:no_status_check => true, :command => "erl +V")
|
27
|
+
|
28
|
+
if status == 0
|
29
|
+
output = stderr.split
|
30
|
+
if output.length >= 6
|
31
|
+
options = output[1]
|
32
|
+
options.gsub!(/(\(|\))/, '')
|
33
|
+
erlang[:version] = output[5]
|
34
|
+
erlang[:options] = options.split(',')
|
35
|
+
erlang[:emulator] = output[2].gsub!(/(\(|\))/, '')
|
36
|
+
if erlang[:version] and erlang[:options] and erlang[:emulator]
|
37
|
+
languages[:erlang] = erlang
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2008 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "cpu"
|
20
|
+
|
21
|
+
# all dmesg output for smp I can find only provides info about a single processor
|
22
|
+
# identical processors is probably a hardware requirement so we'll duplicate data for each cpu
|
23
|
+
# old examples: http://www.bnv-bamberg.de/home/ba3294/smp/rbuild/index.htm
|
24
|
+
cpuinfo = Mash.new
|
25
|
+
|
26
|
+
# /var/run/dmesg.boot
|
27
|
+
#CPU: QEMU Virtual CPU version 0.9.1 (1862.02-MHz 686-class CPU)
|
28
|
+
# Origin = "GenuineIntel" Id = 0x623 Stepping = 3
|
29
|
+
# Features=0x78bfbfd<FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2>
|
30
|
+
# Features2=0x80000001<SSE3,<b31>>
|
31
|
+
|
32
|
+
File.open("/var/run/dmesg.boot").each do |line|
|
33
|
+
case line
|
34
|
+
when /CPU:\s+(.+) \(([\d.]+).+\)/
|
35
|
+
cpuinfo["model_name"] = $1
|
36
|
+
cpuinfo["mhz"] = $2
|
37
|
+
when /Origin = "(.+)"\s+Id = (.+)\s+Stepping = (.+)/
|
38
|
+
cpuinfo["vendor_id"] = $1
|
39
|
+
cpuinfo["stepping"] = $3
|
40
|
+
# These _should_ match /AMD Features2?/ lines as well
|
41
|
+
when /Features=.+<(.+)>/
|
42
|
+
cpuinfo["flags"] = $1.downcase.split(',')
|
43
|
+
# Features2=0x80000001<SSE3,<b31>>
|
44
|
+
when /Features2=[a-f\dx]+<(.+)>/
|
45
|
+
cpuinfo["flags"].concat($1.downcase.split(','))
|
46
|
+
when /Logical CPUs per core: (\d+)/
|
47
|
+
cpuinfo["cores"] = $1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
cpu cpuinfo
|
52
|
+
cpu[:total] = from("sysctl -n hw.ncpu")
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "filesystem"
|
20
|
+
|
21
|
+
fs = Mash.new
|
22
|
+
|
23
|
+
# Grab filesystem data from df
|
24
|
+
popen4("df") do |pid, stdin, stdout, stderr|
|
25
|
+
stdin.close
|
26
|
+
stdout.each do |line|
|
27
|
+
case line
|
28
|
+
when /^Filesystem/
|
29
|
+
next
|
30
|
+
when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
|
31
|
+
filesystem = $1
|
32
|
+
fs[filesystem] = Mash.new
|
33
|
+
fs[filesystem][:kb_size] = $2
|
34
|
+
fs[filesystem][:kb_used] = $3
|
35
|
+
fs[filesystem][:kb_available] = $4
|
36
|
+
fs[filesystem][:percent_used] = $5
|
37
|
+
fs[filesystem][:mount] = $6
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Grab mount information from mount
|
43
|
+
popen4("mount -l") do |pid, stdin, stdout, stderr|
|
44
|
+
stdin.close
|
45
|
+
stdout.each do |line|
|
46
|
+
if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
|
47
|
+
filesystem = $1
|
48
|
+
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
|
49
|
+
fs[filesystem][:mount] = $2
|
50
|
+
fs[filesystem][:fs_type] = $3
|
51
|
+
fs[filesystem][:mount_options] = $4.split(/,\s*/)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Set the filesystem data
|
57
|
+
filesystem fs
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "hostname", "fqdn"
|
20
|
+
|
21
|
+
hostname from("hostname -s")
|
22
|
+
fqdn from("hostname -f")
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "kernel"
|
20
|
+
|
21
|
+
kernel[:os] = kernel[:name]
|
22
|
+
kernel[:ident] = from("uname -i")
|
23
|
+
kernel[:securelevel] = from_with_regex("sysctl kern.securelevel", /kern.securelevel: (.+)$/)
|
24
|
+
|
25
|
+
kld = Mash.new
|
26
|
+
popen4("/sbin/kldstat") do |pid, stdin, stdout, stderr|
|
27
|
+
stdin.close
|
28
|
+
stdout.each do |line|
|
29
|
+
# 1 7 0xc0400000 97f830 kernel
|
30
|
+
if line =~ /(\d+)\s+(\d+)\s+([0-9a-fx]+)\s+([0-9a-fx]+)\s+([a-zA-Z0-9\_]+)/
|
31
|
+
kld[$5] = { :size => $4, :refcount => $2 }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
kernel[:modules] = kld
|
37
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "memory"
|
20
|
+
|
21
|
+
memory Mash.new
|
22
|
+
memory[:swap] = Mash.new
|
23
|
+
|
24
|
+
# /usr/src/sys/sys/vmmeter.h
|
25
|
+
memory[:page_size] = from("sysctl -n vm.stats.vm.v_page_size")
|
26
|
+
memory[:page_count] = from("sysctl -n vm.stats.vm.v_page_count")
|
27
|
+
memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
|
28
|
+
memory[:free] = memory[:page_size].to_i * from("sysctl -n vm.stats.vm.v_free_count").to_i
|
29
|
+
memory[:active] = memory[:page_size].to_i * from("sysctl -n vm.stats.vm.v_active_count").to_i
|
30
|
+
memory[:inactive] = memory[:page_size].to_i * from("sysctl -n vm.stats.vm.v_inactive_count").to_i
|
31
|
+
memory[:cache] = memory[:page_size].to_i * from("sysctl -n vm.stats.vm.v_cache_count").to_i
|
32
|
+
memory[:wired] = memory[:page_size].to_i * from("sysctl -n vm.stats.vm.v_wire_count").to_i
|
33
|
+
memory[:buffers] = from("sysctl -n vfs.bufspace")
|
34
|
+
|
35
|
+
popen4("swapinfo") do |pid, stdin, stdout, stderr|
|
36
|
+
stdin.close
|
37
|
+
stdout.each do |line|
|
38
|
+
# Device 1K-blocks Used Avail Capacity
|
39
|
+
# /dev/ad0s1b 253648 0 253648 0%
|
40
|
+
if line =~ /^([\d\w\/]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\d\%]+)/
|
41
|
+
mdev = $1
|
42
|
+
memory[:swap][mdev] = Mash.new
|
43
|
+
memory[:swap][mdev][:total] = $2
|
44
|
+
memory[:swap][mdev][:used] = $3
|
45
|
+
memory[:swap][mdev][:free] = $4
|
46
|
+
memory[:swap][mdev][:percent_free] = $5
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|