Skip to content

Commit

Permalink
[WIP] - converting sigar -> AIX commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimberman committed May 9, 2013
1 parent a824628 commit 2e91995
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 10 deletions.
35 changes: 32 additions & 3 deletions lib/ohai/plugins/aix/cpu.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Author:: Doug MacEachern <dougm@vmware.com>
# Copyright:: Copyright (c) 2010 VMware, Inc.
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2013, Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,4 +16,33 @@
# limitations under the License.
#

require_plugin "sigar::cpu"
provides "cpu"

cpu = Mash.new

# IBM is the only maker of CPUs for AIX systems.
cpu[:vendor_id] = "IBM"
# At least one CPU will be available, but we'll wait to increment this later.
cpu[:available] = 0
cpu[:total] = 0

cpudevs = from("lsdev -Cc processor").lines
cpudevs.each do |c|
cpu[:total] += 1
name, status, location = c.split
cpu[name] = Mash.new
cpu[name][:status] = status
cpu[name][:location] = location
if status =~ /Available/
cpu[:available] += 1
lsattr = from("lsattr -El #{name}").lines
lsattr.each do |attribute|
attrib, value = attribute.split
cpu[name][attrib] = value
end
end
end

# Every AIX system has proc0.
cpu[:model] = cpu[:proc0][:type]
cpu[:mhz] = cpu[:proc0][:frequency].to_i / 1024
4 changes: 3 additions & 1 deletion lib/ohai/plugins/aix/hostname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
# limitations under the License.
#

require_plugin "sigar::hostname"
provides "hostname"

hostname from("hostname")
27 changes: 27 additions & 0 deletions lib/ohai/plugins/aix/kernel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2013 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

provides "kernel"

kernel Mash.new

kernel[:name] = from("uname -s").downcase
kernel[:release] = from("uname -r")
kernel[:version] = from("uname -v")
kernel[:machine] = from("uname -p")
kernel[:modules] = Mash.new
11 changes: 8 additions & 3 deletions lib/ohai/plugins/aix/memory.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Author:: Doug MacEachern <dougm@vmware.com>
# Copyright:: Copyright (c) 2010 VMware, Inc.
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2013, Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,4 +16,9 @@
# limitations under the License.
#

require_plugin "sigar::memory"
provides "memory"

memory = Mash.new

meminfo = from("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'")
memory[:total], u, memory[:free] = meminfo.split
12 changes: 9 additions & 3 deletions lib/ohai/plugins/aix/platform.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Author:: Doug MacEachern <dougm@vmware.com>
# Copyright:: Copyright (c) 2010 VMware, Inc.
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2013, Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,4 +16,10 @@
# limitations under the License.
#

require_plugin "sigar::platform"
require_plugin "#{os}::kernel"

provides "platform", "platform_version", "platform_family"

platform kernel[:name]
platform_version [kernel[:version], kernel[:release]].join(".")
platform_family platform

0 comments on commit 2e91995

Please sign in to comment.