singularity_task_history 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/bin/singularity_task_history +27 -24
- data/lib/singularity_task_history/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed91835a8a8bec80d1e81db362b434f154025712
|
4
|
+
data.tar.gz: 6a287813b126a21a169731d306b2b1561695f858
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4939b891c7c27e572f86d8c32910419e68cae990fbbef51fed6eaf77470f418ec6d460d7d27e283e02a8b029ca944b0fd9840f52d6149fe10ee64149dde81811
|
7
|
+
data.tar.gz: ada94f025c3cdaaa934635ef0fa03677a86979eeaf7cd9063d93c81ff57dcce8cda133f9ad474432b5fd6134e797329ec4746e578cc99198ec2314a6b524ead9
|
@@ -27,14 +27,14 @@ class SingularityTaskHistory < Sensu::Plugin::Check::CLI
|
|
27
27
|
proc: proc { |n| n.to_i }
|
28
28
|
|
29
29
|
def run
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
alert_list = gen_alert_list(config[:warn], config[:critical])
|
31
|
+
if !alert_list[:crit].empty?
|
32
|
+
critical "Excessive task history\n#{report(alert_list)}"
|
33
|
+
elsif !alert_list[:warn].empty?
|
34
|
+
warning "Excessive task history\n#{report(alert_list)}"
|
35
|
+
else
|
36
|
+
ok 'Task history is fine'
|
36
37
|
end
|
37
|
-
report(crit_list, warn_list)
|
38
38
|
end
|
39
39
|
|
40
40
|
def initialize
|
@@ -43,6 +43,19 @@ class SingularityTaskHistory < Sensu::Plugin::Check::CLI
|
|
43
43
|
@history_node = '/singularity/tasks/history'
|
44
44
|
end
|
45
45
|
|
46
|
+
def gen_alert_list(warn, crit)
|
47
|
+
alerts = { crit: {}, warn: {} }
|
48
|
+
task_list.each do |task|
|
49
|
+
count = history_count(task)
|
50
|
+
if count > crit
|
51
|
+
alerts[:crit][task] = count
|
52
|
+
elsif count > warn
|
53
|
+
alerts[:warn][task] = count
|
54
|
+
end
|
55
|
+
end
|
56
|
+
alerts
|
57
|
+
end
|
58
|
+
|
46
59
|
def child_list(znode)
|
47
60
|
children = @z.get_children(path: znode)
|
48
61
|
children[:children]
|
@@ -56,23 +69,13 @@ class SingularityTaskHistory < Sensu::Plugin::Check::CLI
|
|
56
69
|
child_list(@history_node + '/' + task).count
|
57
70
|
end
|
58
71
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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'
|
72
|
+
def report(task_list)
|
73
|
+
output = ''
|
74
|
+
task_list.keys.each do |key|
|
75
|
+
task_list[key].keys.each do |task|
|
76
|
+
output += "#{task}: #{task_list[key][task]}\n"
|
77
|
+
end
|
76
78
|
end
|
79
|
+
output
|
77
80
|
end
|
78
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singularity_task_history
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carl Flippin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zookeeper
|