sys_watchdog 0.0.3 → 0.0.4

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: 32e9ee338613c50e7292a0c82b04cf6259d54aa9
4
- data.tar.gz: 11f75ee6a5074a2e461dd683997900f03830491d
3
+ metadata.gz: 0221c538d8757310a166809ebfb18dc070d84c4b
4
+ data.tar.gz: eeae1dcf833a98af9fa9eba58777af26d96d7f11
5
5
  SHA512:
6
- metadata.gz: 9bc8050aa88024ddf1a4aa50a3938b9e85decce244ae02a52f38337eb30eddcbef50ce98388732071bf0616c0dc4132282d078b312e86a8d6a755383ec5a9f3e
7
- data.tar.gz: c434713b9e4f43bd271f27fa11814394697d0d872f70e475a13efca29fe4e0f819cdbf53219e035a445c78adc59d891498c5299432d18cc3272a1f17d7a2b74c
6
+ metadata.gz: 3778d095f69a8df419b1453d085e56f63695402a8e6499e508d856b0ce73307bfee2bd77f5bf9ac7229456a687a5b063644bf56cf48b31501749606bc232b617
7
+ data.tar.gz: 7b3662106dc6a97bdec532404166fd84d0ef6f077d0a3e38e7590d74843f71dc7cf498d7737336c30da20440dafee5476adc03d09bfb29b5e739e3c621a2bcfc
data/README.md CHANGED
@@ -66,14 +66,14 @@ mail_to | -
66
66
 
67
67
  setting | description
68
68
  ------------------|-------------------------------------------------------------------------------------------
69
- test_cmd | -
70
- test_url | -
71
- notify_on_change | -
72
- restore_cmd | -
73
- expected_regex | -
74
- expected_string | -
75
- expected_max | -
76
- expected_min | -
69
+ test_cmd | -
70
+ test_url | -
71
+ notify_on_output_change | -
72
+ restore_cmd | -
73
+ expected_regex | -
74
+ expected_string | -
75
+ expected_max | -
76
+ expected_min | -
77
77
 
78
78
  ## Create a Slack Token
79
79
 
@@ -6,8 +6,6 @@ class SysWatchdog
6
6
  log_file ||= DEFAULT_LOG_FILE
7
7
  conf_file ||= DEFAULT_CONF_FILE
8
8
 
9
- @trackers = {}
10
-
11
9
  @logger = WdLogger.new log_file
12
10
  parse_conf conf_file
13
11
 
@@ -52,14 +50,14 @@ class SysWatchdog
52
50
  end
53
51
 
54
52
  def run_test test, after_restore: false
55
- success, exitstatus, output = test.run
56
-
57
- notify_change test, output
53
+ new_status, exitstatus, output = test.run
58
54
 
59
- return if success == test.fail
55
+ notify_output_change test, output
60
56
 
61
- if success
62
- test.fail = false
57
+ return if new_status == test.status
58
+ test.status = new_status
59
+
60
+ if new_status
63
61
  notify "#{test.name} ok"
64
62
  else
65
63
  if test.restore_cmd and not after_restore
@@ -73,17 +71,14 @@ class SysWatchdog
73
71
  @logger.error e.desc
74
72
  end
75
73
 
76
- def notify_change test, output
77
- if test.notify_on_change
78
- if @trackers[test.name] != output
79
- notify "#{test.name} changed", "old: #{@trackers[test.name]}\nnew: #{output}"
80
- end
81
- @trackers[test.name] = output
74
+ def notify_output_change test, output
75
+ if test.notify_on_output_change and test.previous_output != output
76
+ notify "#{test.name} changed", "old: #{test.previous_output}\nnew: #{output}"
77
+ test.previous_output = output
82
78
  end
83
79
  end
84
80
 
85
81
  def fail test, exitstatus, output
86
- test.fail = true
87
82
  body = "exitstatus: #{exitstatus}"
88
83
  body += "\noutput: #{output}" if output and not output.empty?
89
84
  notify "#{test.name} fail", body
@@ -1,8 +1,8 @@
1
1
  class WdTest
2
2
  attr_accessor :name,
3
- :test_cmd, :test_url, :notify_on_change, :restore_cmd,
3
+ :test_cmd, :test_url, :notify_output_change, :restore_cmd,
4
4
  :expected_regex, :expected_string, :expected_max, :expected_min,
5
- :fail
5
+ :status, :previous_output
6
6
 
7
7
  def initialize name, params, logger
8
8
  @logger = logger
@@ -11,7 +11,7 @@ class WdTest
11
11
 
12
12
  @test_cmd = params[:test_cmd]
13
13
  @test_url = params[:test_url]
14
- @notify_on_change = params[:notify_on_change]
14
+ @notify_output_change = params[:notify_output_change]
15
15
  @restore_cmd = params[:restore_cmd]
16
16
 
17
17
  @expected_regex = params[:expected_regex]
@@ -19,7 +19,8 @@ class WdTest
19
19
  @expected_max = params[:expected_max]
20
20
  @expected_min = params[:expected_min]
21
21
 
22
- @fail = false
22
+ @status = true
23
+ @previous_output = nil
23
24
 
24
25
  setup
25
26
  end
@@ -69,8 +70,8 @@ class WdTest
69
70
  if @expected_regex
70
71
  @expected_regex = Regexp.new @expected_regex
71
72
  end
72
- if @notify_on_change
73
- @test_cmd = @notify_on_change
73
+ if @notify_on_output_change
74
+ @test_cmd = @notify_on_output_change
74
75
  end
75
76
  end
76
77
 
data/sys_watchdog.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "sys_watchdog"
3
- s.version = "0.0.3"
3
+ s.version = "0.0.4"
4
4
  s.authors = ["Tom Lobato"]
5
5
  s.email = "lobato@bettercall.io"
6
6
  s.homepage = "http://sys-watchdog.bettercall.io/"
@@ -17,7 +17,7 @@ config:
17
17
  tests:
18
18
  ## General
19
19
  boot_time:
20
- notify_on_change: uptime -s
20
+ notify_output_change: uptime -s
21
21
 
22
22
  ## URLs
23
23
  site_status:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys_watchdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Lobato