Top Level Namespace
Defined Under Namespace
Modules: Ohai
Instance Method Summary collapse
-
#_seconds_to_human(seconds) ⇒ Object
- Author
- Adam Jacob (<[email protected]>) Copyright
-
Copyright © 2008 Opscode, Inc.
-
#encaps_lookup(ifname) ⇒ Object
- Author
- Adam Jacob (<[email protected]>) Copyright
-
Copyright © 2008 Opscode, Inc.
- #excluded_setting?(setting) ⇒ Boolean
- #find_ip_and_mac(addresses) ⇒ Object
- #metadata(id = '') ⇒ Object
- #parse_media(media_string) ⇒ Object
- #scope_lookup(scope) ⇒ Object
Instance Method Details
#_seconds_to_human(seconds) ⇒ Object
- Author
-
Adam Jacob (<[email protected]>)
- Copyright
-
Copyright © 2008 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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ohai/plugins/uptime.rb', line 19 def _seconds_to_human(seconds) days = seconds.to_i / 86400 seconds -= 86400 * days hours = seconds.to_i / 3600 seconds -= 3600 * hours minutes = seconds.to_i / 60 seconds -= 60 * minutes if days > 1 return sprintf("%d days %02d hours %02d minutes %02d seconds", days, hours, minutes, seconds) elsif days == 1 return sprintf("%d day %02d hours %02d minutes %02d seconds", days, hours, minutes, seconds) elsif hours > 0 return sprintf("%d hours %02d minutes %02d seconds", hours, minutes, seconds) elsif minutes > 0 return sprintf("%d minutes %02d seconds", minutes, seconds) else return sprintf("%02d seconds", seconds) end end |
#encaps_lookup(ifname) ⇒ Object
- Author
-
Adam Jacob (<[email protected]>)
- Copyright
-
Copyright © 2008 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.
19 20 21 22 23 24 25 26 27 |
# File 'lib/ohai/plugins/linux/network.rb', line 19 def encaps_lookup(encap) return "Loopback" if encap.eql?("Local Loopback") return "PPP" if encap.eql?("Point-to-Point Protocol") return "SLIP" if encap.eql?("Serial Line IP") return "VJSLIP" if encap.eql?("VJ Serial Line IP") return "IPIP" if encap.eql?("IPIP Tunnel") return "6to4" if encap.eql?("IPv6-in-IPv4") encap end |
#excluded_setting?(setting) ⇒ Boolean
55 56 57 |
# File 'lib/ohai/plugins/darwin/network.rb', line 55 def excluded_setting?(setting) setting.match('_sw_cksum') end |
#find_ip_and_mac(addresses) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/ohai/plugins/network.rb', line 25 def find_ip_and_mac(addresses) ip = nil; mac = nil addresses.each do |addr| ip = addr["address"] if addr["family"].eql?("inet") mac = addr["address"] if addr["family"].eql?("lladdr") break if (ip and mac) end [ip, mac] end |
#metadata(id = '') ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ohai/plugins/ec2.rb', line 24 def (id='') OpenURI.open_uri("http://169.254.169.254/2008-02-01/meta-data/#{id}"). read.split("\n").each do |o| key = "#{id}#{o.gsub(/\=.*$/, '/')}" if key[-1..-1] != '/' ec2[key.gsub(/\-|\//, '_').to_sym] = OpenURI.open_uri("http://169.254.169.254/2008-02-01" + "/meta-data/#{key}").gets else (key) end end end |
#parse_media(media_string) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ohai/plugins/darwin/network.rb', line 21 def parse_media(media_string) media = Array.new line_array = media_string.split(' ') 0.upto(line_array.length - 1) do |i| unless line_array[i].eql?("none") if line_array[i + 1] =~ /^\<([a-zA-Z\-\,]+)\>$/ media << { line_array[i] => { "options" => $1.split(',') }} else media << { "autoselect" => { "options" => [] } } if line_array[i].eql?("autoselect") end else media << { "none" => { "options" => [] } } end end media end |
#scope_lookup(scope) ⇒ Object
49 50 51 52 53 |
# File 'lib/ohai/plugins/darwin/network.rb', line 49 def scope_lookup(scope) return "Link" if scope.match(/^fe80\:/) return "Site" if scope.match(/^fec0\:/) "Global" end |