knife-ohno2 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 (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/chef/knife/ohno2.rb +51 -0
  3. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4874b4c2c3630f5379542d59ce828b91535f6d07
4
+ data.tar.gz: d9c60f8737fb572e3a608fadebf67b7da4c4944d
5
+ SHA512:
6
+ metadata.gz: 6168b210ab9f4f369f570d3c2b14d540c4d4f62f0b3f0e3a2dbc31a30bb6b406f3cb8660af883d6c8c3f773bbcb24c946b167ad156efe273d9a1dd789ee7a995
7
+ data.tar.gz: 4fc134d5c5a4dcddf241c2e4e195fc2bb0498a3b6a00a6673c34579f9284a2ace2e4db6e1defb7688f2939d960c4a8671ca3b75bec90db116184c8cd62dcd71f
@@ -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 ohno2 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.name || node.hostname}\t(" + "#{node.ipaddress})\t: " + ui.color("#{x} hours", :red))
43
+ else
44
+ ui.msg("#{node.name || node.hostname}\t(" + "#{node.ipaddress})\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,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: knife-ohno2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jacob Sohn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A messy client-status watcher plugin for Chef::Knife
14
+ email:
15
+ - layer3switch@yahoo.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/chef/knife/ohno2.rb
21
+ homepage: https://github.com/layer3switch/Ohno.git
22
+ licenses:
23
+ - ''
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.2.2
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: rip off of knife-ohno with ipaddress and hostname as fallback attribute to
45
+ display
46
+ test_files: []