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 +4 -4
- data/README.md +8 -8
- data/lib/sys_watchdog/main.rb +10 -15
- data/lib/sys_watchdog/wd_test.rb +7 -6
- data/sys_watchdog.gemspec +1 -1
- data/util/sys_watchdog_sample.yml +1 -1
- 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: 0221c538d8757310a166809ebfb18dc070d84c4b
|
4
|
+
data.tar.gz: eeae1dcf833a98af9fa9eba58777af26d96d7f11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
|
data/lib/sys_watchdog/main.rb
CHANGED
@@ -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
|
-
|
56
|
-
|
57
|
-
notify_change test, output
|
53
|
+
new_status, exitstatus, output = test.run
|
58
54
|
|
59
|
-
|
55
|
+
notify_output_change test, output
|
60
56
|
|
61
|
-
if
|
62
|
-
|
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
|
77
|
-
if test.
|
78
|
-
|
79
|
-
|
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
|
data/lib/sys_watchdog/wd_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
class WdTest
|
2
2
|
attr_accessor :name,
|
3
|
-
:test_cmd, :test_url, :
|
3
|
+
:test_cmd, :test_url, :notify_output_change, :restore_cmd,
|
4
4
|
:expected_regex, :expected_string, :expected_max, :expected_min,
|
5
|
-
:
|
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
|
-
@
|
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
|
-
@
|
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 @
|
73
|
-
@test_cmd = @
|
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