Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit.

  • Loading branch information...
commit 0c0689e25cdb0065c9bd0eadfc601e7436d2ebe8 0 parents
@benburkert benburkert authored
5 Gemfile
@@ -0,0 +1,5 @@
+source "http://rubygems.org"
+
+gemspec
+
+gem 'enterprise-ohai', :path => '.'
28 Gemfile.lock
@@ -0,0 +1,28 @@
+PATH
+ remote: .
+ specs:
+ enterprise-ohai (0.0.0)
+ json
+ ohai
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ json (1.6.1)
+ mixlib-cli (1.2.2)
+ mixlib-config (1.1.2)
+ mixlib-log (1.3.0)
+ ohai (0.6.10)
+ mixlib-cli
+ mixlib-config
+ mixlib-log
+ systemu (~> 2.2.0)
+ yajl-ruby
+ systemu (2.2.0)
+ yajl-ruby (1.0.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ enterprise-ohai!
6 bin/enterprise-ohai
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'enterprise/ohai'
+
+Enterprise::Ohai.run
BIN  enterprise-ohai-0.0.0.gem
Binary file not shown
17 enterprise-ohai.gemspec
@@ -0,0 +1,17 @@
+dir = File.dirname(__FILE__)
+
+Gem::Specification.new do |s|
+ s.name = 'enterprise-ohai'
+ s.version = '0.0.0'
+ s.summary = s.description = 'Ohai plugins for enterprise.'
+ s.authors = %w[GitHub]
+
+ s.files = Dir[File.join(dir, 'lib', '**', '*')]
+ s.require_paths = %w[lib]
+
+ s.bindir = 'bin'
+ s.executables = %w[enterprise-ohai]
+
+ s.add_dependency 'ohai'
+ s.add_dependency 'json'
+end
26 lib/enterprise/ohai.rb
@@ -0,0 +1,26 @@
+require 'ohai'
+require 'json'
+
+Ohai::Config[:plugin_path] << File.dirname(__FILE__) + '/enterprise/ohai/plugins'
+
+module Enterprise
+ module Ohai
+
+ def self.run
+ puts JSON.pretty_generate(system_data)
+ end
+
+ def self.system_data
+ system = ::Ohai::System.new
+
+ system.require_plugin('linux/block_device')
+ system.require_plugin('linux/filesystem')
+ system.require_plugin('linux/memory')
+ system.require_plugin('network')
+
+ system.require_plugin('swap')
+
+ system.data
+ end
+ end
+end
17 lib/enterprise/ohai/plugins/swap.rb
@@ -0,0 +1,17 @@
+provides "swap"
+
+swaps = Mash.new
+
+File.open('/proc/swaps').read_nonblock(4096).each_line do |line|
+ next if line =~ /^Filename/
+
+ parts = line.split
+ device = parts[0]
+ swaps[device] = Mash.new
+ swaps[device][:type] = parts[1]
+ swaps[device][:size] = parts[2].to_i
+ swaps[device][:used] = parts[3].to_i
+ swaps[device][:priority] = parts[4].to_i
+end
+
+swap swaps
Please sign in to comment.
Something went wrong with that request. Please try again.