chef_knives 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,6 +1,7 @@
1
- === 1.0.0 / 2009-09-09
1
+ === 0.2 / 2009-09-09
2
2
 
3
- * 1 major enhancement
3
+ * chef_node_stats script added
4
4
 
5
- * Birthday!
5
+ === 0.1 / 2009-09-09
6
6
 
7
+ * initial release
data/Manifest.txt CHANGED
@@ -4,4 +4,6 @@ README.txt
4
4
  Rakefile
5
5
  bin/chef_node_fs_usage
6
6
  bin/chef_node_mem_usage
7
+ bin/chef_node_stats
8
+ chef_knives.gemspec
7
9
  lib/chef/knives.rb
@@ -0,0 +1,72 @@
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 main
11
+ Choice.options do
12
+ header ''
13
+ header 'Available options:'
14
+
15
+ option :help do
16
+ long '--help'
17
+ short '-h'
18
+ desc 'Show this message'
19
+ action do
20
+ Choice.help
21
+ exit
22
+ end
23
+ end
24
+
25
+ option :match do
26
+ default '.*'
27
+ long '--match'
28
+ short '-m'
29
+ desc 'Match only the nodes with an FQDN matching this value'
30
+ end
31
+ end
32
+
33
+ db = CouchRest.database(CHEF_DB_URL)
34
+
35
+ counter = 0
36
+ platforms = {}
37
+ vguests = 0
38
+ phynodes = 0
39
+ virt_hosts = 0
40
+ db.documents['rows'].each do |doc|
41
+ if doc['id'] =~ /node_/
42
+ node = db.get(doc['id'])
43
+ next if node.fqdn !~ /#{Choice.choices[:match]}/
44
+ plat = node.platform+node.platform_version
45
+ platforms[plat] = 0 if platforms[plat].nil?
46
+ platforms[plat] += 1
47
+ if node.virtualization and node.virtualization['role'] == 'guest'
48
+ vguests += 1
49
+ end
50
+ if node.virtualization['role'] == 'host'
51
+ virt_hosts += 1
52
+ end
53
+ if node.virtualization.empty?
54
+ phynodes += 1
55
+ end
56
+ counter += 1
57
+ end
58
+ end
59
+ puts "Chef Server Stats"
60
+ puts "------------------"
61
+ puts "Registered Nodes:".ljust(30) + counter.to_s
62
+ puts " Virtual Nodes (Guests):".ljust(30) + vguests.to_s
63
+ puts " Host Nodes:".ljust(30) + virt_hosts.to_s
64
+ puts " Physical Nodes:".ljust(30) + phynodes.to_s
65
+ puts "Nodes by platform:"
66
+ platforms.each do |p,count|
67
+ puts " #{p}: #{count}"
68
+ end
69
+
70
+ end
71
+
72
+ main
@@ -0,0 +1,32 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{chef_knives}
3
+ s.version = "0.2"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Sergio Rubio"]
7
+ s.date = %q{2009-09-10}
8
+ s.description = %q{Unofficial Chef Server scripts and related stuff. http://wiki.opscode.com/display/chef}
9
+ s.email = ["sergio@rubio.name"]
10
+ s.executables = ["chef_node_fs_usage", "chef_node_mem_usage", "chef_node_stats"]
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"]
13
+ s.homepage = %q{http://github.com/rubiojr/chef-knives}
14
+ s.rdoc_options = ["--main", "README.txt"]
15
+ s.require_paths = ["lib"]
16
+ s.rubyforge_project = %q{chef_knives}
17
+ s.rubygems_version = %q{1.3.3}
18
+ s.summary = %q{Chef addons to become a cooking master!}
19
+
20
+ if s.respond_to? :specification_version then
21
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
22
+ s.specification_version = 3
23
+
24
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
25
+ s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
26
+ else
27
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
28
+ end
29
+ else
30
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
31
+ end
32
+ end
data/lib/chef/knives.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Chef
2
2
  module Knives
3
- VERSION = '0.1'
3
+ VERSION = '0.2'
4
4
  end
5
5
  end
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.1"
4
+ version: "0.2"
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-09 00:00:00 +02:00
12
+ date: 2009-09-10 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -28,6 +28,7 @@ email:
28
28
  executables:
29
29
  - chef_node_fs_usage
30
30
  - chef_node_mem_usage
31
+ - chef_node_stats
31
32
  extensions: []
32
33
 
33
34
  extra_rdoc_files:
@@ -41,6 +42,8 @@ files:
41
42
  - Rakefile
42
43
  - bin/chef_node_fs_usage
43
44
  - bin/chef_node_mem_usage
45
+ - bin/chef_node_stats
46
+ - chef_knives.gemspec
44
47
  - lib/chef/knives.rb
45
48
  has_rdoc: true
46
49
  homepage: http://github.com/rubiojr/chef-knives