knife-ohno 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.
Files changed (2) hide show
  1. data/lib/chef/knife/ohno.rb +51 -0
  2. metadata +63 -0
@@ -0,0 +1,51 @@
1
+ require 'chef/knife'
2
+
3
+ module Lnxchk
4
+ class Ohno < Chef::Knife
5
+
6
+ deps do
7
+ require 'chef/knife/status'
8
+ require 'chef/knife/search'
9
+ require 'chef/search/query'
10
+ require 'highline'
11
+ end
12
+
13
+ banner "knife ohno HOURS"
14
+
15
+ def run
16
+ unless hours = name_args.first
17
+ ui.error "You need to specify a number of hours behind the checkins are"
18
+ exit 1
19
+ end
20
+
21
+ if nocolor = name_args[1]
22
+ color = 0
23
+ else
24
+ color = 1
25
+ end
26
+
27
+ hours = hours.to_i
28
+
29
+ stdout_orig = $stdout
30
+ $stdout = File.open('/dev/null', 'w')
31
+ knife_status = Chef::Knife::Status.new
32
+ hitlist = knife_status.run
33
+ $stdout.close
34
+ $stdout = stdout_orig
35
+
36
+ print "\nLost cheep in need of chefherding for more than #{hours} hours: \n"
37
+ hitlist.each { |node|
38
+ hour, minutes, seconds = Chef::Knife::Status.new.time_difference_in_hms(node["ohai_time"])
39
+ if hour >= hours
40
+ x = hour.to_s()
41
+ if (color == 1)
42
+ ui.msg("#{node['fqdn']}:\t\t" + ui.color("#{x} hours", :red))
43
+ else
44
+ ui.msg("#{node['fqdn']}:\t\t#{x} hours")
45
+ end
46
+ end
47
+ }
48
+ #File.delete('/tmp/ohno')
49
+ end # close run
50
+ end # close class
51
+ end # close module
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: knife-ohno
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Mandi Walls
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2012-06-15 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: A messy client-status watcher plugin for Chef::Knife
22
+ email:
23
+ - mandi@opscode.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - lib/chef/knife/ohno.rb
32
+ has_rdoc: true
33
+ homepage: https://github.com/lnxchk/Ohno
34
+ licenses:
35
+ - ""
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.3.6
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: knife ohno
62
+ test_files: []
63
+