chef_knives 0.4.1 → 0.5
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 +4 -0
- data/Manifest.txt +1 -0
- data/bin/chef_node_last_checkin +71 -0
- data/chef_knives.gemspec +7 -4
- data/lib/chef/knives.rb +1 -1
- metadata +4 -2
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -0,0 +1,71 @@
|
|
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 last_check_in_time(last_check_in)
|
11
|
+
status_msg = ''
|
12
|
+
hours, minutes, seconds, frac = DateTime.day_fraction_to_time(DateTime.now - last_check_in)
|
13
|
+
hours_text = "#{hours} hour#{hours == 1 ? '' : 's'}"
|
14
|
+
minutes_text = "#{minutes} minute#{minutes == 1 ? '' : 's'}"
|
15
|
+
if hours > 48
|
16
|
+
status_msg = "> #{hours/24} days ago"
|
17
|
+
elsif hours > 0
|
18
|
+
status_msg = "> #{hours_text} ago"
|
19
|
+
elsif minutes < 1
|
20
|
+
status_msg = "< 1 minute ago"
|
21
|
+
else
|
22
|
+
status_msg = "#{minutes_text} ago"
|
23
|
+
end
|
24
|
+
status_msg
|
25
|
+
end
|
26
|
+
|
27
|
+
def main
|
28
|
+
Choice.options do
|
29
|
+
header ''
|
30
|
+
header 'Available options:'
|
31
|
+
|
32
|
+
option :help do
|
33
|
+
long '--help'
|
34
|
+
short '-h'
|
35
|
+
desc 'Show this message'
|
36
|
+
action do
|
37
|
+
Choice.help
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
option :threshold do
|
43
|
+
long '--threshold=MINUTES'
|
44
|
+
short '-t'
|
45
|
+
desc 'Print only the nodes with last check-in time greater than than this value'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
db = CouchRest.database(CHEF_DB_URL)
|
50
|
+
|
51
|
+
db.documents['rows'].each do |doc|
|
52
|
+
if doc['id'] =~ /node_/
|
53
|
+
node = db.get(doc['id'])
|
54
|
+
next if node.fqdn !~ /#{Choice.choices[:match]}/
|
55
|
+
last_check_in = DateTime.parse(Time.at(node.ohai_time).to_s)
|
56
|
+
hours, minutes, seconds, frac = DateTime.day_fraction_to_time(DateTime.now - last_check_in)
|
57
|
+
if Choice.choices[:threshold]
|
58
|
+
if ((hours * 60) + minutes) >= Choice.choices[:threshold].to_i
|
59
|
+
print "#{node.fqdn}: ".ljust(40)
|
60
|
+
puts last_check_in_time(last_check_in)
|
61
|
+
end
|
62
|
+
else
|
63
|
+
print "#{node.fqdn}: ".ljust(50)
|
64
|
+
puts last_check_in_time(last_check_in)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
main
|
data/chef_knives.gemspec
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
+
(in /Users/rubiojr/Work/github/chef_knives)
|
2
|
+
# -*- encoding: utf-8 -*-
|
3
|
+
|
1
4
|
Gem::Specification.new do |s|
|
2
5
|
s.name = %q{chef_knives}
|
3
|
-
s.version = "0.
|
6
|
+
s.version = "0.5"
|
4
7
|
|
5
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
9
|
s.authors = ["Sergio Rubio"]
|
7
|
-
s.date = %q{2009-09-
|
10
|
+
s.date = %q{2009-09-15}
|
8
11
|
s.description = %q{Unofficial Chef Server scripts and related stuff. http://wiki.opscode.com/display/chef}
|
9
12
|
s.email = ["sergio@rubio.name"]
|
10
|
-
s.executables = ["chef_node_find", "chef_node_fs_usage", "chef_node_mem_usage", "chef_node_stats", "chef_vlan_stats"]
|
13
|
+
s.executables = ["chef_node_find", "chef_node_fs_usage", "chef_node_last_checkin", "chef_node_mem_usage", "chef_node_stats", "chef_vlan_stats"]
|
11
14
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
|
12
|
-
s.files = ["AUTHORS", "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", "bin/chef_vlan_stats", "chef_knives.gemspec", "lib/chef/knives.rb"]
|
15
|
+
s.files = ["AUTHORS", "History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/chef_node_find", "bin/chef_node_fs_usage", "bin/chef_node_last_checkin", "bin/chef_node_mem_usage", "bin/chef_node_stats", "bin/chef_vlan_stats", "chef_knives.gemspec", "lib/chef/knives.rb"]
|
13
16
|
s.homepage = %q{http://github.com/rubiojr/chef-knives}
|
14
17
|
s.rdoc_options = ["--main", "README.txt"]
|
15
18
|
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.5"
|
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-15 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -78,6 +78,7 @@ email:
|
|
78
78
|
executables:
|
79
79
|
- chef_node_find
|
80
80
|
- chef_node_fs_usage
|
81
|
+
- chef_node_last_checkin
|
81
82
|
- chef_node_mem_usage
|
82
83
|
- chef_node_stats
|
83
84
|
- chef_vlan_stats
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- Rakefile
|
96
97
|
- bin/chef_node_find
|
97
98
|
- bin/chef_node_fs_usage
|
99
|
+
- bin/chef_node_last_checkin
|
98
100
|
- bin/chef_node_mem_usage
|
99
101
|
- bin/chef_node_stats
|
100
102
|
- bin/chef_vlan_stats
|