Permalink
Browse files

Merge pull request #271 from opscode/merge-6-stable

Merge 6 stable
  • Loading branch information...
2 parents b9ec0bd + 594f2e0 commit 8890c7f6ac94bc50875726971a6ecc420811e8f7 Serdar Sutay committed Jan 13, 2014
View
@@ -3,3 +3,4 @@ Gemfile.lock
pkg/
tmp/
coverage/
+.DS_Store
View
@@ -1,23 +1,91 @@
-.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
-.TH OHAI "1" "April 2009" "ohai" "User Commands"
+.TH "OHAI" "1" "Ohai 6.20.0" "" "ohai"
.SH NAME
-ohai \- collect system information
-.SH SYNOPSIS
-.B ohai
-[\fIOPTION\fR]...
-.SH DESCRIPTION
-Information about your system is collected and returned as multidimensional
-attributes in a JSON format.
+ohai \- The man page for the ohai command line tool.
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.\" Man page generated from reStructuredText.
+.
+.sp
+Ohai is a tool that is used to detect attributes on a node, and then provide these attributes to the chef\-client at the start of every chef\-client run. Ohai is required by the chef\-client and must be present on a node. The types of attributes Ohai collects include:
+.INDENT 0.0
+.IP \(bu 2
+Platform details
+.IP \(bu 2
+Networking usage
+.IP \(bu 2
+Memory usage
+.IP \(bu 2
+Processor usage
+.IP \(bu 2
+Kernel data
+.IP \(bu 2
+Host names
+.IP \(bu 2
+Fully qualified domain names
+.IP \(bu 2
+Other configuration details
+.UNINDENT
+.sp
+Attributes that are collected by Ohai are automatic attributes, in that these attributes are used by the chef\-client to ensure that these attributes remain unchanged after the chef\-client is done configuring the node.
+.sp
+ohai is the command\-line interface for Ohai, a tool that is used to detect attributes on a node, and then provide these attributes to the chef\-client at the start of every chef\-client run.
+.SH OPTIONS
+.sp
+This command has the following syntax:
+.sp
+.nf
+.ft C
+ohai OPTION
+.ft P
+.fi
+.sp
+This tool has the following options:
+.INDENT 0.0
.TP
-\fB\-d\fR, \fB\-\-directory\fR NAME
-A directory to add to the Ohai search path
+.B \fB\-d PATH\fP, \fB\-\-directory PATH\fP
+The directory in which Ohai plugins are located. For example: \fB/etc/ohai/plugins\fP.
.TP
-\fB\-f\fR, \fB\-\-file\fR NAME
-A file to run Ohai against
+.B \fB\-f FILE_NAME\fP, \fB\-\-file FILE_NAME\fP
+The file against which Ohai will run.
.TP
-\fB\-l\fR, \fB\-\-loglevel\fR NAME
-Set log level for Ohai
+.B \fB\-h\fP, \fB\-\-help\fP
+Shows help for the command.
.TP
-\fB\-h\fR, \fB\-\-help\fR
-Show this message
-.IP
+.B \fB\-l LEVEL\fP, \fB\-\-log_level LEVEL\fP
+The level of logging that will be stored in a log file: \fBdebug\fP, \fBinfo\fP, \fBwarn\fP, \fBerror\fP, or \fBfatal\fP.
+.TP
+.B \fB\-L LOGLOCATION\fP, \fB\-\-logfile c\fP
+The location in which log file output files will be saved. If this location is set to something other than \fBSTDOUT\fP, standard output logging will still be performed (otherwise there would be no output other than to a file).
+.TP
+.B \fB\-v\fP, \fB\-\-version\fP
+The version of Ohai.
+.UNINDENT
+.SH AUTHOR
+Opscode
+.\" Generated by docutils manpage writer.
+.
@@ -124,12 +124,12 @@ def run_command_windows(command, timeout)
#
# Thanks Ara!
def popen4(cmd, args={}, &b)
-
+
## Disable garbage collection to work around possible bug in MRI
# Ruby 1.8 suffers from intermittent segfaults believed to be due to GC while IO.select
# See OHAI-330 / CHEF-2916 / CHEF-1305
GC.disable
-
+
# Waitlast - this is magic.
#
# Do we wait for the child process to die before we yield
@@ -325,9 +325,10 @@ def popen4(cmd, args={}, &b)
# have encoding methods.
if "".respond_to?(:force_encoding) && defined?(Encoding)
o.string.force_encoding(Encoding.default_external)
+ o.string.encode!('UTF-8', :invalid => :replace, :undef => :replace, :replace => '?')
e.string.force_encoding(Encoding.default_external)
+ e.string.encode!('UTF-8', :invalid => :replace, :undef => :replace, :replace => '?')
end
-
b[cid, pi[0], o, e]
results.last
end
@@ -22,7 +22,7 @@ module Mixin
module GCEMetadata
GCE_METADATA_ADDR = "metadata.google.internal" unless defined?(GCE_METADATA_ADDR)
- GCE_METADATA_URL = "/0.1/meta-data" unless defined?(GCE_METADATA_URL)
+ GCE_METADATA_URL = "/computeMetadata/v1beta1/?recursive=true" unless defined?(GCE_METADATA_URL)
def can_metadata_connect?(addr, port, timeout=2)
t = Socket.new(Socket::Constants::AF_INET, Socket::Constants::SOCK_STREAM, 0)
@@ -0,0 +1,53 @@
+#
+# Author:: Joshua Timberman <joshua@opscode.com>
+# Author:: Prabhu Das (<prabhu.das@clogeny.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.
+#
+
+Ohai.plugin(:CPU) do
+ provides "cpu"
+
+ collect_data(:aix) do
+ 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 = shell_out("lsdev -Cc processor").stdout.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 = shell_out("lsattr -El #{name}").stdout.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
+ end
+end
@@ -0,0 +1,72 @@
+#
+# Author:: Deepali Jagtap (<deepali.jagtap@clogeny.com>)
+# Author:: Prabhu Das (<prabhu.das@clogeny.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.
+#
+
+Ohai.plugin(:Filesystem) do
+ provides "filesystem"
+
+ collect_data(:aix) do
+ fs = Mash.new
+
+ # Grab filesystem data from df
+ so = shell_out("df -P")
+ so.stdout.lines.each do |line|
+ case line
+ when /^Filesystem\s+1024-blocks/
+ next
+ when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
+ filesystem = $1
+ fs[filesystem] = Mash.new
+ fs[filesystem][:kb_size] = $2
+ fs[filesystem][:kb_used] = $3
+ fs[filesystem][:kb_available] = $4
+ fs[filesystem][:percent_used] = $5
+ fs[filesystem][:mount] = $6
+ end
+ end
+
+ # Grab mount information from /bin/mount
+ so = shell_out("mount")
+ so.stdout.lines.each do |line|
+ case line
+ when /^\s*node/
+ next
+ when /^\s*---/
+ next
+ when /^\s*\/\w/
+ fields = line.split
+ filesystem = fields[0]
+ fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
+ fs[filesystem][:mount] = fields[1]
+ fs[filesystem][:fs_type] = fields[2]
+ fs[filesystem][:mount_options] = fields[6]
+ else
+ fields = line.split
+ filesystem = fields[0] + ":" + fields[1]
+ fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
+ fs[filesystem][:mount] = fields[2]
+ fs[filesystem][:fs_type] = fields[3]
+ fs[filesystem][:mount_options] = fields[7]
+ end
+ end
+
+ # Set the filesystem data
+ filesystem fs
+ end
+end
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+Ohai.plugin(:Kernel) do
+ provides "kernel", "kernel/modules"
+
+ collect_data(:aix) do
+ kernel Mash.new
+
+ kernel[:name] = shell_out("uname -s").stdout.downcase
+ kernel[:release] = shell_out("uname -r").stdout
+ kernel[:version] = shell_out("uname -v").stdout
+ kernel[:machine] = shell_out("uname -p").stdout
+ kernel[:modules] = Mash.new
+ end
+end
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+
+Ohai.plugin(:Memory) do
+ provides "memory"
+
+ collect_data(:aix) do
+ memory = Mash.new
+
+ meminfo = shell_out("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").stdout
+ memory[:total], u, memory[:free] = meminfo.split
+ end
+end
Oops, something went wrong.

0 comments on commit 8890c7f

Please sign in to comment.