singularity_task_history 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/singularity_task_history +78 -0
- data/lib/singularity_task_history/version.rb +3 -0
- data/lib/singularity_task_history.rb +5 -0
- data/singularity_task_history.gemspec +31 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 766ec5aea62dcff93dd7159f0947bc4f5bc43fe1
|
4
|
+
data.tar.gz: c163150f3ed28e115d77e523c43eabffb118fdf6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1082edfc6dbb86c8a671670e36fe8631017bb62d34798a500cbc7f40a9a8c1019dbfdb7df600537dfa437176ddf126941fb4365212b24a28ef7161d23cd057f9
|
7
|
+
data.tar.gz: 3e1a7afd835967af005a903074201400163fba5c1d0942e037740fef90aab18488352348c01e56160ccfe6dae0fc88611a8daacd88bb533eebb8306e70713b8a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Carl Flippin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# SingularityTaskHistory
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/singularity_task_history`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'singularity_task_history'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install singularity_task_history
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/singularity_task_history.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "singularity_task_history"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'zookeeper'
|
5
|
+
require 'sensu-plugin/check/cli'
|
6
|
+
|
7
|
+
class SingularityTaskHistory < Sensu::Plugin::Check::CLI
|
8
|
+
check_name 'singularity_task_history'
|
9
|
+
option :warn,
|
10
|
+
short: '-w WARN',
|
11
|
+
required: true,
|
12
|
+
description: 'Warning level for task history length',
|
13
|
+
proc: proc { |n| n.to_i }
|
14
|
+
option :critical,
|
15
|
+
short: '-c CRIT',
|
16
|
+
required: true,
|
17
|
+
description: 'Critical level for task history length',
|
18
|
+
proc: proc { |n| n.to_i }
|
19
|
+
option :host,
|
20
|
+
short: '-h HOST',
|
21
|
+
required: true,
|
22
|
+
description: 'ZooKeeper host to check'
|
23
|
+
option :port,
|
24
|
+
short: '-p PORT',
|
25
|
+
default: 2181,
|
26
|
+
description: 'ZooKeeper port',
|
27
|
+
proc: proc { |n| n.to_i }
|
28
|
+
|
29
|
+
def run
|
30
|
+
warn_list = {}
|
31
|
+
crit_list = {}
|
32
|
+
task_list.each do |task|
|
33
|
+
count = history_count(task)
|
34
|
+
crit_list[task] = count if count >= config[:critical]
|
35
|
+
warn_list[task] = count if count >= config[:warn]
|
36
|
+
end
|
37
|
+
report(crit_list, warn_list)
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize
|
41
|
+
super()
|
42
|
+
@z = Zookeeper.new("#{config[:host]}:#{config[:port]}")
|
43
|
+
@history_node = '/singularity/tasks/history'
|
44
|
+
end
|
45
|
+
|
46
|
+
def child_list(znode)
|
47
|
+
children = @z.get_children(path: znode)
|
48
|
+
children[:children]
|
49
|
+
end
|
50
|
+
|
51
|
+
def task_list
|
52
|
+
child_list(@history_node)
|
53
|
+
end
|
54
|
+
|
55
|
+
def history_count(task)
|
56
|
+
child_list(@history_node + '/' + task).count
|
57
|
+
end
|
58
|
+
|
59
|
+
def task_output(task_list)
|
60
|
+
if task_list.length == 0
|
61
|
+
''
|
62
|
+
else
|
63
|
+
task_list.map { |k, v| "#{k}: #{v}" }.join("\n") + "\n"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def report(crit_list, warn_list)
|
68
|
+
warn_list.delete_if { |k, _v| crit_list.key?(k) }
|
69
|
+
detail = task_output(crit_list) + task_output(warn_list)
|
70
|
+
if crit_list.length > 0
|
71
|
+
critical "Excessive task history:\n#{detail}"
|
72
|
+
elsif warn_list.length > 0
|
73
|
+
warn "Excessive task history:\n#{detail}"
|
74
|
+
else
|
75
|
+
ok 'All task history within limits'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'singularity_task_history/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'singularity_task_history'
|
8
|
+
spec.version = SingularityTaskHistory::VERSION
|
9
|
+
spec.authors = ['Carl Flippin']
|
10
|
+
spec.email = ['cflippin@opentable.com']
|
11
|
+
|
12
|
+
spec.summary = 'Sensu check for singularity task history'
|
13
|
+
spec.homepage = 'http://github.com/carlf/singularity_task_history'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
if spec.respond_to?(:metadata)
|
17
|
+
spec.metadata['allowed_push_host'] = 'http://artifactory.otenv.com'
|
18
|
+
else
|
19
|
+
fail 'RubyGems 2.0 or newer is required.'
|
20
|
+
end
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_dependency('zookeeper')
|
28
|
+
spec.add_dependency('sensu-plugin')
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: singularity_task_history
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carl Flippin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: zookeeper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sensu-plugin
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- cflippin@opentable.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- bin/console
|
82
|
+
- bin/setup
|
83
|
+
- bin/singularity_task_history
|
84
|
+
- lib/singularity_task_history.rb
|
85
|
+
- lib/singularity_task_history/version.rb
|
86
|
+
- singularity_task_history.gemspec
|
87
|
+
homepage: http://github.com/carlf/singularity_task_history
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata:
|
91
|
+
allowed_push_host: http://artifactory.otenv.com
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.0.14.1
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Sensu check for singularity task history
|
112
|
+
test_files: []
|