enterprise-ohai 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'enterprise/ohai'
5
+
6
+ Enterprise::Ohai.run
@@ -0,0 +1,21 @@
1
+ require 'ohai'
2
+ require 'json'
3
+
4
+ Ohai::Config[:plugin_path] << File.dirname(__FILE__) + '/ohai/plugins'
5
+
6
+ module Enterprise
7
+ module Ohai
8
+
9
+ def self.run
10
+ puts JSON.pretty_generate(system_data)
11
+ end
12
+
13
+ def self.system_data
14
+ system = ::Ohai::System.new
15
+
16
+ system.all_plugins
17
+
18
+ system.data
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,48 @@
1
+ provides 'disk'
2
+
3
+ require_plugin 'linux::block_device'
4
+ require_plugin 'linux::filesystem'
5
+
6
+ def disk_path(link)
7
+ dir = File.dirname(link)
8
+ path = File.readlink(link)
9
+
10
+ File.expand_path(File.join(dir, path))
11
+ end
12
+
13
+ disks = Mash.new
14
+
15
+ by_path_root = '/dev/disk/by-path'
16
+ by_label_root = '/dev/disk/by-label'
17
+ by_uuid_root = '/dev/disk/by-uuid'
18
+
19
+ Dir.glob(File.join(by_path_root, '*')).each do |disk_name_link|
20
+ disk_name = File.basename(disk_name_link)
21
+ path = disk_path(disk_name_link)
22
+
23
+ disks[path] ||= Mash.new
24
+ disks[path][:name] = disk_name
25
+ end
26
+
27
+ Dir.glob(File.join(by_label_root, '*')).each do |disk_label_link|
28
+ disk_label = File.basename(disk_label_link)
29
+ path = disk_path(File.join(by_label_root, disk_label))
30
+
31
+ disks[path] ||= Mash.new
32
+ disks[path][:label] = disk_label
33
+ end
34
+
35
+ Dir.glob(File.join(by_uuid_root, '*')).each do |disk_uuid_link|
36
+ disk_uuid = File.basename(disk_uuid_link)
37
+ path = disk_path(File.join(by_uuid_root, disk_uuid))
38
+
39
+ disks[path] ||= Mash.new
40
+ disks[path][:uuid] = disk_uuid
41
+ end
42
+
43
+ disks.keys.each do |device|
44
+ disks[device].update(filesystem[device]) if filesystem[device]
45
+ disks[device].update(:swap => true) if swap[device]
46
+ end
47
+
48
+ disk disks
@@ -0,0 +1,17 @@
1
+ provides 'swap'
2
+
3
+ swaps = Mash.new
4
+
5
+ File.open('/proc/swaps').read_nonblock(4096).each_line do |line|
6
+ next if line =~ /^Filename/
7
+
8
+ parts = line.split
9
+ device = parts[0]
10
+ swaps[device] = Mash.new
11
+ swaps[device][:type] = parts[1]
12
+ swaps[device][:size] = parts[2].to_i
13
+ swaps[device][:used] = parts[3].to_i
14
+ swaps[device][:priority] = parts[4].to_i
15
+ end
16
+
17
+ swap swaps
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: enterprise-ohai
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - GitHub
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-09 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: ohai
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: json
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ description: Ohai plugins for enterprise.
50
+ email:
51
+ executables:
52
+ - enterprise-ohai
53
+ extensions: []
54
+
55
+ extra_rdoc_files: []
56
+
57
+ files:
58
+ - ./lib/enterprise/ohai/plugins/linux/disk.rb
59
+ - ./lib/enterprise/ohai/plugins/linux/swap.rb
60
+ - ./lib/enterprise/ohai.rb
61
+ - bin/enterprise-ohai
62
+ has_rdoc: true
63
+ homepage:
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ requirements: []
90
+
91
+ rubyforge_project:
92
+ rubygems_version: 1.6.2
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: Ohai plugins for enterprise.
96
+ test_files: []
97
+