watchmonkey_cli 1.11.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47f837c69b183c6b2f6f1670358d1bd4eb6745afd4db2335e2f1c95749c17022
4
- data.tar.gz: bdc02ab27bbb69a4c15eb67c4bc310fbfc25493abb124684353ccddcf7a320e8
3
+ metadata.gz: 5d2615fa891c7ccb38541934fa918c33fa37a93cc3d3c52ece8db41a100e1d0b
4
+ data.tar.gz: 98f2a66da3fdc810c9b7fc1396ba12a605f3cd12d939585e9c9ed03d9f252fbf
5
5
  SHA512:
6
- metadata.gz: def716ff43830383dd7f095b5c502172ce9ac71f008a9cbee00cd18448aa8d893fdf306e717181e569e70a36facac814433b520674fc0957b27430e48857c6cf
7
- data.tar.gz: 1fc92b89105fd547344474405c276661f1383486c5cf0443bc8ee989c991b0fe1a46c003bc88bede5ca3d7e3c91cd0e651e97d82e51d6f984291a5015fe7a63d
6
+ metadata.gz: 23307a955c34627a32e0023df5dc40874eda5d72e80f152e2a57bcf12be767b34db53fc565ffbc8329060cbfe8e72871956123bf553f0ff409ed4468528bca0f
7
+ data.tar.gz: c671b5bac01cf8c423eef81ada024cd35a1c82f426c9fa80cee4cb90047aa242c579a39248ef349d2cc69d7be281037caac74afa410d59af633029f5b5860b52
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.11.0
1
+ 1.12.0
@@ -59,10 +59,11 @@ module WatchmonkeyCli
59
59
  end
60
60
  end
61
61
 
62
- def initialize app, file
62
+ def initialize app, file = nil, tags = []
63
63
  @app = app
64
64
  @file = file
65
- @tags = []
65
+ @tags = tags
66
+ return unless file
66
67
  begin
67
68
  eval File.read(file, encoding: "utf-8"), binding, file
68
69
  rescue
@@ -84,7 +85,21 @@ module WatchmonkeyCli
84
85
  opts = args.extract_options!
85
86
  only = @app.opts[:tag_only]
86
87
  except = @app.opts[:tag_except]
87
- tags = (@tags + (opts[:tags] || []).map(&:to_sym)).uniq
88
+
89
+ # build tags
90
+ tags = (@tags + (opts[:tags] || []).map(&:to_sym))
91
+ if @app.opts[:autotag]
92
+ tags << :"WMC-#{c.class.checker_name}" # checker name
93
+ if args[0].is_a?(Symbol)
94
+ tags << :"WMS-#{args[0]}" # ssh/local connection
95
+ elsif args[0].is_a?(String) && args[0].match(/\Ahttp(s)?:\/\//i)
96
+ uri = URI.parse(args[0]) rescue false
97
+ tags << :"WMH-#{uri.hostname.gsub(".", "_")}" if uri # hostname from URL
98
+ end
99
+ end
100
+ tags = tags.uniq
101
+ @app.tag_list.merge(tags)
102
+
88
103
  if only.any?
89
104
  if tags.any?{|t| only.include?(t) }
90
105
  if tags.any?{|t| except.include?(t) }
@@ -57,7 +57,7 @@ ssh_connection :my_server, host: "wheel@example.com", port: 23 # additional opti
57
57
  #
58
58
  # timeout Maximum time to wait for request (default: 20 seconds)
59
59
  # verify If enabled the peer will be verified (default: true)
60
- # threshold Minimum certificate lifetime before showing warnings (default: 1.month)
60
+ # threshold Minimum certificate lifetime before showing warnings (default: 28.days)
61
61
  #
62
62
  ssl_expiration "https://example.com", threshold: 3.months
63
63
 
@@ -1,6 +1,6 @@
1
1
  module WatchmonkeyCli
2
2
  class Application
3
- attr_reader :opts, :checkers, :connections, :threads, :queue, :hooks, :processed
3
+ attr_reader :opts, :checkers, :connections, :threads, :queue, :hooks, :processed, :tag_list
4
4
  include Helper
5
5
  include OutputHelper
6
6
  include Colorize
@@ -49,6 +49,7 @@ module WatchmonkeyCli
49
49
  @monitor = Monitor.new
50
50
  @threads = []
51
51
  @queue = Queue.new
52
+ @tag_list = Set.new
52
53
  @processed = 0
53
54
  @running = false
54
55
  @opts = {
@@ -62,6 +63,7 @@ module WatchmonkeyCli
62
63
  conclosewait: 10, # max seconds to wait for connections to be closed (may never if they got killed by maxrt)
63
64
  loop_forever: false, # (internal) loop forever (app mode)
64
65
  loop_wait_empty: 1, # (internal) time to wait in thread if queue is empty
66
+ autotag: true, # (internal) if true checkers will get auto tags for checker name and hostname/connection
65
67
  silent: false, # -s flag
66
68
  quiet: false, # -q flag
67
69
  stdout: STDOUT, # (internal) STDOUT redirect
@@ -163,6 +163,10 @@ module WatchmonkeyCli
163
163
  end
164
164
  end
165
165
 
166
+ def blank_config tags = []
167
+ Application::Configuration.new(app, nil, tags)
168
+ end
169
+
166
170
  # def to_s
167
171
  # string = "#<#{self.class.name}:#{self.object_id} "
168
172
  # fields = self.class.inspector_fields.map{|field| "#{field}: #{self.send(field)}"}
@@ -4,7 +4,7 @@ module WatchmonkeyCli
4
4
  self.checker_name = "ftp_availability"
5
5
 
6
6
  def enqueue host, opts = {}
7
- opts = { threshold: 1.months }.merge(opts)
7
+ opts = {}.merge(opts)
8
8
  app.enqueue(self, host, opts)
9
9
  end
10
10
 
@@ -4,7 +4,7 @@ module WatchmonkeyCli
4
4
  self.checker_name = "ssl_expiration"
5
5
 
6
6
  def enqueue page, opts = {}
7
- opts = { threshold: 1.months, verify: true, timeout: 20 }.merge(opts)
7
+ opts = { threshold: 28.days, verify: true, timeout: 20 }.merge(opts)
8
8
  app.enqueue(self, page, opts)
9
9
  end
10
10
 
@@ -35,7 +35,9 @@ module WatchmonkeyCli
35
35
  # sec.check!(result, host, opts[which])
36
36
  # end
37
37
  # app.enqueue_sub(self, which, host, opts[which]) if opts[which]
38
- spawn_sub(which, host, opts[which].is_a?(Hash) ? opts[which] : {}) unless opts[which] == false
38
+ #spawn_sub(which, host, (opts[which].is_a?(Hash) ? opts[which] : {}).merge(tags: result.tags)) unless opts[which] == false
39
+ stags = (opts[:tags] || []).reject{|t| t.to_s.start_with?("WMC-") }
40
+ blank_config(stags).send(which, host, (opts[which].is_a?(Hash) ? opts[which] : {})) unless opts[which] == false
39
41
  end
40
42
  end
41
43
  end
@@ -9,7 +9,8 @@ module WatchmonkeyCli
9
9
  # if available enable ssl_expiration support
10
10
  if page.start_with?("https://") && opts[:ssl_expiration] != false && !app.running?
11
11
  sopts = { timeout: opts[:timeout] }.merge(opts[:ssl_expiration].is_a?(Hash) ? opts[:ssl_expiration] : {})
12
- spawn_sub("ssl_expiration", page, sopts)
12
+ stags = (opts[:tags] || []).reject{|t| t.to_s.start_with?("WMC-") }
13
+ blank_config(stags).ssl_expiration(page, sopts)
13
14
  end
14
15
  end
15
16
 
@@ -418,7 +418,7 @@ module WatchmonkeyCli
418
418
  when "/start"
419
419
  if event.user_data
420
420
  event.reply [].tap{|m|
421
- m << "<b>Welcome!</b> I will tell you if something is wrong with bmonkeys infrastructure."
421
+ m << "<b>Welcome!</b> I will tell you if something is wrong with your infrastructure."
422
422
  m << "Your current tags are: #{event.user_data[1].join(", ")}"
423
423
  m << "<b>You have admin permissions!</b>" if event.user_admin?
424
424
  m << "\nInstead of muting me in Telegram you can silence me for a while with <code>/mute 6h 30m</code>."
@@ -1,4 +1,4 @@
1
1
  module WatchmonkeyCli
2
- VERSION = "1.11.0"
2
+ VERSION = "1.12.0"
3
3
  UPDATE_URL = "https://raw.githubusercontent.com/2called-chaos/watchmonkey_cli/master/VERSION"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watchmonkey_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Pachnit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-27 00:00:00.000000000 Z
11
+ date: 2021-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  requirements: []
168
- rubygems_version: 3.1.2
168
+ rubygems_version: 3.1.4
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Watchmonkey CLI - dead simple agentless monitoring via SSH, HTTP, FTP, etc.