watchmonkey_cli 1.12.1 → 1.13.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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/checksums/watchmonkey_cli-1.12.1.gem.sha512 +1 -1
- data/doc/checker_example.rb +6 -0
- data/lib/watchmonkey_cli/application/core.rb +4 -2
- data/lib/watchmonkey_cli/application.rb +1 -0
- data/lib/watchmonkey_cli/checker.rb +32 -7
- data/lib/watchmonkey_cli/version.rb +1 -1
- data/watchmonkey_cli.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5bb6a637e71a9a3483a2b7b7a7b6dab90469b786c313f742e174743560afaa1b
|
|
4
|
+
data.tar.gz: 94c468d5e0fe0d8344c321584e78828ecf4b3a43872885b80eb30028eab5e15f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dce28700596ca2267765017a3ed23f862cd5cb36951e2d1371ed714cabb9c6d36a0550ad4835ffa1b24ed749a78f775a5c0123ab8d9f9799c1438f988d5f76b8
|
|
7
|
+
data.tar.gz: dc9afb99c806398ab45cb89dbdb38f6ac30db97b58a63e2012fbe940f33e29009c52af90515ed3267d021532f2edfb997f3957a1af7360b44b26bca4663527cc
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.13.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
55896784ac9e3bc3bfe0998cb907cd13721d773860429de292208dffb19bc34f44d9783cb68814842ceabf982531ee8e650560d882e6b0e90dbd52b59b4d18db
|
data/doc/checker_example.rb
CHANGED
|
@@ -20,6 +20,12 @@ module MyWatchmonkeyCheckers
|
|
|
20
20
|
#self.maxrt = 5.minutes
|
|
21
21
|
#self.maxrt = ->(app, checker, args){ app.opts[:maxrt] && app.opts[:maxrt] * 2 }
|
|
22
22
|
|
|
23
|
+
# Maximum amount of time this task may retry on error.
|
|
24
|
+
# Set to proc to evaluate at runtime
|
|
25
|
+
# Defaults to app.opts[:max_retry] if nil/unset
|
|
26
|
+
#self.max_retry = 1
|
|
27
|
+
#self.max_retry = ->(app, checker, args){ app.opts[:max_retry] && app.opts[:max_retry] * 2 }
|
|
28
|
+
|
|
23
29
|
# Called by configuration defining a check with all the arguments.
|
|
24
30
|
# e.g. my_checker "http://google.com", some_option: true
|
|
25
31
|
# Should invoke `app.enqueue` which will by default call `#check!` method with given arguments.
|
|
@@ -3,7 +3,7 @@ module WatchmonkeyCli
|
|
|
3
3
|
module Core
|
|
4
4
|
def filtered_threads
|
|
5
5
|
Thread.list.reject do |thr|
|
|
6
|
-
@opts[:filtered_threads].any?{ thr.backtrace
|
|
6
|
+
@opts[:filtered_threads].any?{ thr.backtrace.first&.include?(_1) }
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -136,7 +136,9 @@ module WatchmonkeyCli
|
|
|
136
136
|
a << taskopts
|
|
137
137
|
|
|
138
138
|
checker.debug(result.str_running)
|
|
139
|
-
checker.
|
|
139
|
+
max_retry = checker.class.max_retry.nil? ? @opts[:max_retry] : checker.class.max_retry
|
|
140
|
+
max_retry = max_retry.call(self, checker, a) if max_retry.respond_to?(:call)
|
|
141
|
+
checker.rsafe(result, max_retry: max_retry) {
|
|
140
142
|
timeout = checker.class.maxrt.nil? ? @opts[:maxrt] : checker.class.maxrt
|
|
141
143
|
timeout = timeout.call(self, checker, a) if timeout.respond_to?(:call)
|
|
142
144
|
begin
|
|
@@ -60,6 +60,7 @@ module WatchmonkeyCli
|
|
|
60
60
|
debug: false, # -d flag
|
|
61
61
|
threads: 10, # -t flag
|
|
62
62
|
maxrt: 120.seconds, # max runtime of a single task after which it will be terminated (may break SSH connection), 0/false to not limit runtime
|
|
63
|
+
max_retry: 3, # max retry on error for a single task
|
|
63
64
|
conclosewait: 10, # max seconds to wait for connections to be closed (may never if they got killed by maxrt)
|
|
64
65
|
loop_forever: false, # (internal) loop forever (app mode)
|
|
65
66
|
loop_wait_empty: 1, # (internal) time to wait in thread if queue is empty
|
|
@@ -25,6 +25,14 @@ module WatchmonkeyCli
|
|
|
25
25
|
@maxrt = seconds
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
def self.max_retry
|
|
29
|
+
@max_retry
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.max_retry= num
|
|
33
|
+
@max_retry = num
|
|
34
|
+
end
|
|
35
|
+
|
|
28
36
|
module AppHelper
|
|
29
37
|
def init_checkers!
|
|
30
38
|
@checkers = {}
|
|
@@ -118,6 +126,14 @@ module WatchmonkeyCli
|
|
|
118
126
|
sync { @type == meth }
|
|
119
127
|
end
|
|
120
128
|
end
|
|
129
|
+
|
|
130
|
+
def fatal! msg = nil
|
|
131
|
+
sync do
|
|
132
|
+
@spool[:error] << msg if msg
|
|
133
|
+
@type = :error
|
|
134
|
+
throw(:checker, :fatal)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
121
137
|
end
|
|
122
138
|
|
|
123
139
|
# -------------------
|
|
@@ -177,13 +193,13 @@ module WatchmonkeyCli
|
|
|
177
193
|
@app.fetch_connection(:loopback, :local)
|
|
178
194
|
end
|
|
179
195
|
|
|
180
|
-
def safe descriptor = nil, &block
|
|
196
|
+
def safe descriptor = nil, max_retry: 3, &block
|
|
181
197
|
tries = 0
|
|
182
198
|
begin
|
|
183
199
|
tries += 1
|
|
184
200
|
block.call
|
|
185
201
|
rescue StandardError => e
|
|
186
|
-
unless tries >
|
|
202
|
+
unless tries > max_retry
|
|
187
203
|
app.sync do
|
|
188
204
|
error "#{descriptor}retry #{tries} reason is `#{e.class}: #{e.message}'"
|
|
189
205
|
e.backtrace.each{|l| debug "\t\t#{l}" }
|
|
@@ -197,13 +213,21 @@ module WatchmonkeyCli
|
|
|
197
213
|
end
|
|
198
214
|
end
|
|
199
215
|
|
|
200
|
-
def rsafe resultobj, &block
|
|
216
|
+
def rsafe resultobj, max_retry: 3, &block
|
|
201
217
|
tries = 0
|
|
218
|
+
checker_ctrl = false
|
|
219
|
+
|
|
202
220
|
begin
|
|
203
221
|
tries += 1
|
|
204
|
-
block
|
|
222
|
+
checker_ctrl = catch(:checker, &block)
|
|
205
223
|
rescue StandardError => e
|
|
206
|
-
|
|
224
|
+
if checker_ctrl == :fatal
|
|
225
|
+
resultobj.sync do
|
|
226
|
+
resultobj.error! "fatal reason is `#{e.class}: #{e.message}'"
|
|
227
|
+
e.backtrace.each{|l| resultobj.debug "\t\t#{l}" }
|
|
228
|
+
resultobj.dump!
|
|
229
|
+
end
|
|
230
|
+
elsif tries <= max_retry
|
|
207
231
|
resultobj.sync do
|
|
208
232
|
resultobj.error! "retry #{tries} reason is `#{e.class}: #{e.message}'"
|
|
209
233
|
e.backtrace.each{|l| resultobj.debug "\t\t#{l}" }
|
|
@@ -213,9 +237,10 @@ module WatchmonkeyCli
|
|
|
213
237
|
sleep 1
|
|
214
238
|
retry
|
|
215
239
|
end
|
|
240
|
+
else
|
|
241
|
+
resultobj.error! "retries exceeded"
|
|
242
|
+
resultobj.dump!
|
|
216
243
|
end
|
|
217
|
-
resultobj.error! "retries exceeded"
|
|
218
|
-
resultobj.dump!
|
|
219
244
|
end
|
|
220
245
|
end
|
|
221
246
|
|
data/watchmonkey_cli.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.version = WatchmonkeyCli::VERSION
|
|
9
9
|
spec.authors = ["Sven Pachnit"]
|
|
10
10
|
spec.email = ["sven@bmonkeys.net"]
|
|
11
|
-
spec.summary = %q{Watchmonkey CLI - dead simple agentless monitoring via SSH, HTTP, FTP, etc}
|
|
11
|
+
spec.summary = %q{Watchmonkey CLI - dead simple agentless monitoring via SSH, HTTP, FTP, etc.}
|
|
12
12
|
spec.description = %q{If you want an easy way to monitor services without the need of installing agents let a monkey do the job by polling status information via transport protocols.}
|
|
13
13
|
spec.homepage = "https://github.com/2called-chaos/watchmonkey_cli"
|
|
14
14
|
spec.license = "MIT"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: watchmonkey_cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sven Pachnit
|
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
122
122
|
- !ruby/object:Gem::Version
|
|
123
123
|
version: '0'
|
|
124
124
|
requirements: []
|
|
125
|
-
rubygems_version: 4.0.
|
|
125
|
+
rubygems_version: 4.0.6
|
|
126
126
|
specification_version: 4
|
|
127
|
-
summary: Watchmonkey CLI - dead simple agentless monitoring via SSH, HTTP, FTP, etc
|
|
127
|
+
summary: Watchmonkey CLI - dead simple agentless monitoring via SSH, HTTP, FTP, etc.
|
|
128
128
|
test_files: []
|