watchmonkey_cli 1.7.1 → 1.8
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/lib/watchmonkey_cli/application/configuration.tpl +32 -0
- data/lib/watchmonkey_cli/checkers/tcp_port.rb +29 -0
- data/lib/watchmonkey_cli/checkers/udp_port.rb +34 -0
- data/lib/watchmonkey_cli/ssh_connection.rb +2 -0
- data/lib/watchmonkey_cli/version.rb +1 -1
- data/lib/watchmonkey_cli.rb +3 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de4bbb8f369c58b63f3e11248e811022710f14de
|
4
|
+
data.tar.gz: 39ce0c2031cb3d488860479aa38bff212dcce525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43ad504c029ecd9418c2f8848d97b05727354ecc326316de649bf470b485e9f4e49c828f50218eccb5702f0e6df4dde90234d3b672bd29440c833f952630da94
|
7
|
+
data.tar.gz: dc61ff90fb7ffa71100c50876c157d208bc4019cdc0de3dd46e0822bd37657ecdef7bb5653f67b11060dc7900877812de7d607ee526871e9e6f91c5bf6a3ecee
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.8
|
@@ -59,6 +59,38 @@ www_availability "https://example.com", ssl_expiration: false
|
|
59
59
|
www_availability "https://example.com", ssl_expiration: { threshold: 4.weeks }
|
60
60
|
|
61
61
|
|
62
|
+
# -----
|
63
|
+
# TCP port
|
64
|
+
# -----
|
65
|
+
# Attempts to establish a TCP connection to a given port.
|
66
|
+
# Host might be :local/SSH connection/String(IP/DNS)
|
67
|
+
# Available options:
|
68
|
+
#
|
69
|
+
# message Error message when connection cannot be established
|
70
|
+
# timeout Timeout in seconds to wait for a connection (default = 2 seconds - false/nil = 1 hour)
|
71
|
+
#
|
72
|
+
tcp_port "ftp.example.com", 21, message: "FTP offline"
|
73
|
+
tcp_port :my_server, 21, message: "FTP offline"
|
74
|
+
|
75
|
+
|
76
|
+
# -----
|
77
|
+
# UDP port
|
78
|
+
# -----
|
79
|
+
# Attempts to establish a UDP connection to a given port.
|
80
|
+
# NOTE: We send a message and attempt to receive a response.
|
81
|
+
# If the port is closed we get an IO exception and assume the port to be unreachable.
|
82
|
+
# If the port is open we most likely don't get ANY response and when the timeout
|
83
|
+
# is reached we assume the port to be reachable. This is not an exact check.
|
84
|
+
# Host might be :local/SSH connection/String(IP/DNS)
|
85
|
+
# Available options:
|
86
|
+
#
|
87
|
+
# message Error message when connection cannot be established
|
88
|
+
# timeout Timeout in seconds to wait for a response (default = 2 seconds - false/nil = 1 hour)
|
89
|
+
#
|
90
|
+
udp_port "example.com", 9987, message: "Teamspeak offline"
|
91
|
+
udp_port :my_server, 9987, message: "Teamspeak offline"
|
92
|
+
|
93
|
+
|
62
94
|
# -----
|
63
95
|
# FTP availability
|
64
96
|
# -----
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module WatchmonkeyCli
|
2
|
+
module Checkers
|
3
|
+
class TcpPort < Checker
|
4
|
+
self.checker_name = "tcp_port"
|
5
|
+
|
6
|
+
def enqueue host, port, opts = {}
|
7
|
+
opts = { message: "Port #{port} (TCP) is not reachable!", timeout: 2 }.merge(opts)
|
8
|
+
host = app.fetch_connection(:loopback, :local) if !host || host == :local
|
9
|
+
host = app.fetch_connection(:ssh, host) if host.is_a?(Symbol)
|
10
|
+
app.enqueue(self, host, port, opts)
|
11
|
+
end
|
12
|
+
|
13
|
+
def check! result, host, port, opts = {}
|
14
|
+
result.result = port_open?(host.is_a?(String) ? host : host.is_a?(WatchmonkeyCli::LoopbackConnection) ? "127.0.0.1" : host.opts[:host_name] || host.opts[:host] || host.opts[:ip], port, opts)
|
15
|
+
result.error! "#{opts[:message]}" unless result.result
|
16
|
+
end
|
17
|
+
|
18
|
+
def port_open?(ip, port, opts = {})
|
19
|
+
Timeout::timeout(opts[:timeout] ? opts[:timeout] : 3600) do
|
20
|
+
s = TCPSocket.new(ip, port)
|
21
|
+
s.close
|
22
|
+
end
|
23
|
+
true
|
24
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Timeout::Error
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module WatchmonkeyCli
|
2
|
+
module Checkers
|
3
|
+
class UdpPort < Checker
|
4
|
+
self.checker_name = "udp_port"
|
5
|
+
|
6
|
+
def enqueue host, port, opts = {}
|
7
|
+
opts = { message: "Port #{port} (UDP) is not reachable!", timeout: 2 }.merge(opts)
|
8
|
+
host = app.fetch_connection(:loopback, :local) if !host || host == :local
|
9
|
+
host = app.fetch_connection(:ssh, host) if host.is_a?(Symbol)
|
10
|
+
app.enqueue(self, host, port, opts)
|
11
|
+
end
|
12
|
+
|
13
|
+
def check! result, host, port, opts = {}
|
14
|
+
result.result = port_open?(host.is_a?(String) ? host : host.is_a?(WatchmonkeyCli::LoopbackConnection) ? "127.0.0.1" : host.opts[:host_name] || host.opts[:host] || host.opts[:ip], port, opts)
|
15
|
+
result.error! "#{opts[:message]}" unless result.result
|
16
|
+
end
|
17
|
+
|
18
|
+
def port_open?(ip, port, opts = {})
|
19
|
+
Timeout::timeout(opts[:timeout] ? opts[:timeout] : 3600) do
|
20
|
+
s = UDPSocket.new
|
21
|
+
s.connect(ip, port)
|
22
|
+
s.send "aaa", 0
|
23
|
+
s.recv(1)
|
24
|
+
s.close
|
25
|
+
end
|
26
|
+
true
|
27
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
28
|
+
return false
|
29
|
+
rescue Timeout::Error
|
30
|
+
return true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/watchmonkey_cli.rb
CHANGED
@@ -35,11 +35,13 @@ require "watchmonkey_cli/application"
|
|
35
35
|
require "watchmonkey_cli/checkers/ftp_availability"
|
36
36
|
require "watchmonkey_cli/checkers/mysql_replication"
|
37
37
|
require "watchmonkey_cli/checkers/ssl_expiration"
|
38
|
+
require "watchmonkey_cli/checkers/tcp_port"
|
39
|
+
require "watchmonkey_cli/checkers/ts3_license"
|
40
|
+
require "watchmonkey_cli/checkers/udp_port"
|
38
41
|
require "watchmonkey_cli/checkers/unix_defaults"
|
39
42
|
require "watchmonkey_cli/checkers/unix_df"
|
40
43
|
require "watchmonkey_cli/checkers/unix_file_exists"
|
41
44
|
require "watchmonkey_cli/checkers/unix_load"
|
42
45
|
require "watchmonkey_cli/checkers/unix_mdadm"
|
43
46
|
require "watchmonkey_cli/checkers/unix_memory"
|
44
|
-
require "watchmonkey_cli/checkers/ts3_license"
|
45
47
|
require "watchmonkey_cli/checkers/www_availability"
|
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.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Pachnit
|
@@ -126,7 +126,9 @@ files:
|
|
126
126
|
- lib/watchmonkey_cli/checkers/ftp_availability.rb
|
127
127
|
- lib/watchmonkey_cli/checkers/mysql_replication.rb
|
128
128
|
- lib/watchmonkey_cli/checkers/ssl_expiration.rb
|
129
|
+
- lib/watchmonkey_cli/checkers/tcp_port.rb
|
129
130
|
- lib/watchmonkey_cli/checkers/ts3_license.rb
|
131
|
+
- lib/watchmonkey_cli/checkers/udp_port.rb
|
130
132
|
- lib/watchmonkey_cli/checkers/unix_defaults.rb
|
131
133
|
- lib/watchmonkey_cli/checkers/unix_df.rb
|
132
134
|
- lib/watchmonkey_cli/checkers/unix_file_exists.rb
|