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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 312311aaf04df5cc1d42249ec5202c0e01a35ef6
4
- data.tar.gz: b1e0f912c416b626a876d16663fa466e75bb9b7d
3
+ metadata.gz: 86ce6eed439d29ac6eef7d4d0813803b4d7b2beb
4
+ data.tar.gz: 9cd0a3af426a68459e11164b7df367f5f62264af
5
5
  SHA512:
6
- metadata.gz: 1fb4acc683cbe5fc57b3bc37034f0c5f8e2b339aad8d21e226d2adefe07c1e560f7484d69073fb3e951ab09d61f58f502a3b0b37607a1ec0158ca7195df315d8
7
- data.tar.gz: 3f9b86d3acb7956be9b9cef6dceddbf2d2aa63c730139f4d7e1b760e8a39837e54bbf009e45a19f04a3ac297983a816dc35a9519396993835cfe3f8d39cb3c14
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 WatchmonkeyCliCustom
2
- class Ts3License < WatchmonkeyCli::Checker
3
- self.checker_name = "ts3_license"
1
+ module WatchmonkeyCli
2
+ module Checkers
3
+ class Ts3License < Checker
4
+ self.checker_name = "ts3_license"
4
5
 
5
- def enqueue host, file, opts = {}
6
- opts = { threshold: 1.months }.merge(opts)
7
- host = app.fetch_connection(:loopback, :local) if !host || host == :local
8
- host = app.fetch_connection(:ssh, host) if host.is_a?(Symbol)
9
- app.enqueue(self, host, file, opts)
10
- end
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
- def check! result, host, file, opts = {}
13
- result.command = "cat #{Shellwords.escape(file)}"
14
- result.result = host.exec(result.command).force_encoding('UTF-8')
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
- if result.result.downcase["no such file"]
17
- result.error! "Failed to read file #{file} (#{result.result})"
18
- else
19
- result.data = _parse_response(result.result)
20
- start_at = zone_parse "UTC", result.data["start date"]
21
- end_at = zone_parse "UTC", result.data["end date"]
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
- if start_at > Time.current
24
- result.error! "TS3 license is not yet valid (will in #{human_seconds(start_at - Time.current)}, #{start_at})!"
25
- return
26
- end
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
- if end_at <= Time.current
29
- result.error! "TS3 license is EXPIRED (since #{human_seconds(end_at - Time.current)}, #{end_at})!"
30
- return
31
- end
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
- if end_at <= Time.current + opts[:threshold]
34
- result.error! "TS3 license is about to expire within threshold (in #{human_seconds(end_at - Time.current)}, #{end_at})!"
35
- return
36
- else
37
- result.info! "TS3 license for `#{page}' expires in #{human_seconds(end_at - Time.current)} (#{end_at})!"
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
- def zone_parse tz, date
43
- tz_was = Time.zone
44
- Time.zone = "UTC"
45
- Time.zone.parse(date)
46
- ensure
47
- Time.zone = tz_was
48
- end
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
- def _parse_response res
51
- {}.tap do |r|
52
- lines = res.split("\n")
53
- reached_key = false
54
- lines.each do |l|
55
- next if l.blank?
56
- if l[":"]
57
- c = l.split(":", 2)
58
- r[c[0].strip] = c[1].strip
59
- elsif l["==key=="]
60
- reached_key = true
61
- elsif reached_key
62
- r["key"] ||= ""
63
- r["key"] += l
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
@@ -1,4 +1,4 @@
1
1
  module WatchmonkeyCli
2
- VERSION = "1.7"
2
+ VERSION = "1.7.1"
3
3
  UPDATE_URL = "https://raw.githubusercontent.com/2called-chaos/watchmonkey_cli/master/VERSION"
4
4
  end
@@ -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"
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.7'
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Pachnit