chef_knives 0.2 → 0.3
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.
- data/History.txt +5 -1
- data/Manifest.txt +1 -0
- data/bin/chef_node_find +73 -0
- data/chef_knives.gemspec +4 -4
- data/lib/chef/knives.rb +1 -1
- metadata +4 -2
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/bin/chef_node_find
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'couchrest'
|
4
|
+
require 'chef'
|
5
|
+
require 'choice'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
CHEF_DB_URL = 'http://localhost:5984/chef'
|
9
|
+
|
10
|
+
def humanize_bytes(bytes)
|
11
|
+
return "0 Bytes" if bytes == 0
|
12
|
+
m = bytes.to_i
|
13
|
+
units = %w[Bits Bytes MB GB TB PB]
|
14
|
+
while (m/1024.0) >= 1
|
15
|
+
m = m/1024.0
|
16
|
+
units.shift
|
17
|
+
end
|
18
|
+
return m.round.to_s + " #{units[0]}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def main
|
22
|
+
Choice.options do
|
23
|
+
header ''
|
24
|
+
header 'Available options:'
|
25
|
+
|
26
|
+
option :help do
|
27
|
+
long '--help'
|
28
|
+
short '-h'
|
29
|
+
desc 'Show this message'
|
30
|
+
action do
|
31
|
+
Choice.help
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
option :match do
|
37
|
+
default '.*'
|
38
|
+
long '--match'
|
39
|
+
short '-m'
|
40
|
+
desc 'Match only the nodes with an FQDN matching this value'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
db = CouchRest.database(CHEF_DB_URL)
|
45
|
+
|
46
|
+
db.documents['rows'].each do |doc|
|
47
|
+
if doc['id'] =~ /node_/
|
48
|
+
node = db.get(doc['id'])
|
49
|
+
next if node.fqdn !~ /#{Choice.choices[:match]}/
|
50
|
+
plat = node.platform+node.platform_version
|
51
|
+
fqdn = node.fqdn
|
52
|
+
puts fqdn
|
53
|
+
puts "-------------"
|
54
|
+
puts "Platform: " + plat
|
55
|
+
puts "Uptime: " + node.uptime
|
56
|
+
puts "Memory Total: " + humanize_bytes(node.memory.total.gsub('kB','').to_i * 1024)
|
57
|
+
puts "Memory Free: " + humanize_bytes(node.memory.free.gsub('kB','').to_i * 1024)
|
58
|
+
puts "Network Interfaces: "
|
59
|
+
puts "Is a Virtual Machine?: #{(node.virtualization.role == 'guest') rescue false}"
|
60
|
+
node.network.interfaces.each_key do |iface|
|
61
|
+
next unless node.network.interfaces[iface][:addresses]
|
62
|
+
puts " #{iface}"
|
63
|
+
node.network.interfaces[iface].addresses.each_key do |a|
|
64
|
+
print " #{a}".ljust(30)
|
65
|
+
puts " [#{node.network.interfaces[iface].addresses[a].family}]"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
puts
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
main
|
data/chef_knives.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{chef_knives}
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.3"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Sergio Rubio"]
|
7
|
-
s.date = %q{2009-09-
|
7
|
+
s.date = %q{2009-09-11}
|
8
8
|
s.description = %q{Unofficial Chef Server scripts and related stuff. http://wiki.opscode.com/display/chef}
|
9
9
|
s.email = ["sergio@rubio.name"]
|
10
|
-
s.executables = ["chef_node_fs_usage", "chef_node_mem_usage", "chef_node_stats"]
|
10
|
+
s.executables = ["chef_node_find", "chef_node_fs_usage", "chef_node_mem_usage", "chef_node_stats"]
|
11
11
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
|
12
|
-
s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/chef_node_fs_usage", "bin/chef_node_mem_usage", "bin/chef_node_stats", "chef_knives.gemspec", "lib/chef/knives.rb"]
|
12
|
+
s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/chef_node_find", "bin/chef_node_fs_usage", "bin/chef_node_mem_usage", "bin/chef_node_stats", "chef_knives.gemspec", "lib/chef/knives.rb"]
|
13
13
|
s.homepage = %q{http://github.com/rubiojr/chef-knives}
|
14
14
|
s.rdoc_options = ["--main", "README.txt"]
|
15
15
|
s.require_paths = ["lib"]
|
data/lib/chef/knives.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef_knives
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Rubio
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-11 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -26,6 +26,7 @@ description: Unofficial Chef Server scripts and related stuff. http://wiki.opsco
|
|
26
26
|
email:
|
27
27
|
- sergio@rubio.name
|
28
28
|
executables:
|
29
|
+
- chef_node_find
|
29
30
|
- chef_node_fs_usage
|
30
31
|
- chef_node_mem_usage
|
31
32
|
- chef_node_stats
|
@@ -40,6 +41,7 @@ files:
|
|
40
41
|
- Manifest.txt
|
41
42
|
- README.txt
|
42
43
|
- Rakefile
|
44
|
+
- bin/chef_node_find
|
43
45
|
- bin/chef_node_fs_usage
|
44
46
|
- bin/chef_node_mem_usage
|
45
47
|
- bin/chef_node_stats
|