watchmonkey_cli 1.7 → 1.7.1
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/checkers/ts3_license.rb +55 -53
- data/lib/watchmonkey_cli/version.rb +1 -1
- data/lib/watchmonkey_cli.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86ce6eed439d29ac6eef7d4d0813803b4d7b2beb
|
4
|
+
data.tar.gz: 9cd0a3af426a68459e11164b7df367f5f62264af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32a1fa7651b825530353a9c2f4946dc0b8a5da0e79f1db0e605e54720143341c26cfecb51e2cb97905b570c4491866079b405c26f94b291c8ae9cd28b8111c24
|
7
|
+
data.tar.gz: 0c4a6c26666917532d37aca96b3f02b5d1b9211f1b75c619ed55ce3508e17389bb4a9dc01933cd7f14cd0abc4269553afeed63618258b2b61955d942aa66910c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.7
|
1
|
+
1.7.1
|
@@ -1,66 +1,68 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
1
|
+
module WatchmonkeyCli
|
2
|
+
module Checkers
|
3
|
+
class Ts3License < Checker
|
4
|
+
self.checker_name = "ts3_license"
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
def enqueue host, file, opts = {}
|
7
|
+
opts = { threshold: 1.months }.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, file, opts)
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def check! result, host, file, opts = {}
|
14
|
+
result.command = "cat #{Shellwords.escape(file)}"
|
15
|
+
result.result = host.exec(result.command).force_encoding('UTF-8')
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
if result.result.downcase["no such file"]
|
18
|
+
result.error! "Failed to read file #{file} (#{result.result})"
|
19
|
+
else
|
20
|
+
result.data = _parse_response(result.result)
|
21
|
+
start_at = zone_parse "UTC", result.data["start date"]
|
22
|
+
end_at = zone_parse "UTC", result.data["end date"]
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
if start_at > Time.current
|
25
|
+
result.error! "TS3 license is not yet valid (will in #{human_seconds(start_at - Time.current)}, #{start_at})!"
|
26
|
+
return
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
if end_at <= Time.current
|
30
|
+
result.error! "TS3 license is EXPIRED (since #{human_seconds(end_at - Time.current)}, #{end_at})!"
|
31
|
+
return
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
if end_at <= Time.current + opts[:threshold]
|
35
|
+
result.error! "TS3 license is about to expire within threshold (in #{human_seconds(end_at - Time.current)}, #{end_at})!"
|
36
|
+
return
|
37
|
+
else
|
38
|
+
result.info! "TS3 license for `#{page}' expires in #{human_seconds(end_at - Time.current)} (#{end_at})!"
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
40
|
-
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
def zone_parse tz, date
|
44
|
+
tz_was = Time.zone
|
45
|
+
Time.zone = "UTC"
|
46
|
+
Time.zone.parse(date)
|
47
|
+
ensure
|
48
|
+
Time.zone = tz_was
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
51
|
+
def _parse_response res
|
52
|
+
{}.tap do |r|
|
53
|
+
lines = res.split("\n")
|
54
|
+
reached_key = false
|
55
|
+
lines.each do |l|
|
56
|
+
next if l.blank?
|
57
|
+
if l[":"]
|
58
|
+
c = l.split(":", 2)
|
59
|
+
r[c[0].strip] = c[1].strip
|
60
|
+
elsif l["==key=="]
|
61
|
+
reached_key = true
|
62
|
+
elsif reached_key
|
63
|
+
r["key"] ||= ""
|
64
|
+
r["key"] += l
|
65
|
+
end
|
64
66
|
end
|
65
67
|
end
|
66
68
|
end
|
data/lib/watchmonkey_cli.rb
CHANGED
@@ -41,4 +41,5 @@ require "watchmonkey_cli/checkers/unix_file_exists"
|
|
41
41
|
require "watchmonkey_cli/checkers/unix_load"
|
42
42
|
require "watchmonkey_cli/checkers/unix_mdadm"
|
43
43
|
require "watchmonkey_cli/checkers/unix_memory"
|
44
|
+
require "watchmonkey_cli/checkers/ts3_license"
|
44
45
|
require "watchmonkey_cli/checkers/www_availability"
|