huginn_netlify_status_agent 0.1 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/huginn_netlify_status_agent/netlify_status_agent.rb +41 -14
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e24159895b4a17f75bc5a7429562f75614ceed2e32da4a4c0d9e52ce3da8f34f
|
4
|
+
data.tar.gz: d7ec7c18ff500e5ae1f8566ef91b5d065b86e3321ad443d5e2a9940facc4955a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0da55ec0ce2dfb27cbfe44907fa02523243bd2586427923a53b20e795a46a887bc5dcb8101c1931baa0cb7f0cae3cd4ddb768c6e1c8ead60b080f7314fe3f5f3
|
7
|
+
data.tar.gz: 38a89eafadef56b39d9240befe5cf80e0205e9aa5e80e90cc93023afeed6ebd0dc5ece0a2bd5ea7288ea955373dcaf5e11ba419948a48dca1bb16a2aa60eaf4e
|
@@ -10,6 +10,10 @@ module Agents
|
|
10
10
|
The Netlify Agent fetches Netlify services status.
|
11
11
|
I added this agent because with website agent, when indicator is empty for "all ok status", no event was created.
|
12
12
|
|
13
|
+
The `debug` can add verbosity.
|
14
|
+
|
15
|
+
`changes_only` is only used to emit event about a currency's change.
|
16
|
+
|
13
17
|
`expected_receive_period_in_days` is used to determine if the Agent is working. Set it to the maximum number of days
|
14
18
|
that you anticipate passing without this Agent receiving an incoming Event.
|
15
19
|
MD
|
@@ -28,11 +32,13 @@ module Agents
|
|
28
32
|
|
29
33
|
def default_options
|
30
34
|
{
|
35
|
+
'debug' => 'false',
|
31
36
|
'expected_receive_period_in_days' => '2',
|
32
37
|
'changes_only' => 'true'
|
33
38
|
}
|
34
39
|
end
|
35
40
|
|
41
|
+
form_configurable :debug, type: :boolean
|
36
42
|
form_configurable :expected_receive_period_in_days, type: :string
|
37
43
|
form_configurable :changes_only, type: :boolean
|
38
44
|
|
@@ -42,6 +48,10 @@ module Agents
|
|
42
48
|
errors.add(:base, "if provided, changes_only must be true or false")
|
43
49
|
end
|
44
50
|
|
51
|
+
if options.has_key?('debug') && boolify(options['debug']).nil?
|
52
|
+
errors.add(:base, "if provided, debug must be true or false")
|
53
|
+
end
|
54
|
+
|
45
55
|
unless options['expected_receive_period_in_days'].present? && options['expected_receive_period_in_days'].to_i > 0
|
46
56
|
errors.add(:base, "Please provide 'expected_receive_period_in_days' to indicate how many days can pass before this Agent is considered to be not working")
|
47
57
|
end
|
@@ -57,26 +67,43 @@ module Agents
|
|
57
67
|
|
58
68
|
private
|
59
69
|
|
70
|
+
def log_curl_output(code,body)
|
71
|
+
|
72
|
+
log "request status : #{code}"
|
73
|
+
|
74
|
+
if interpolated['debug'] == 'true'
|
75
|
+
log "body"
|
76
|
+
log body
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
60
81
|
def check_status()
|
61
82
|
|
62
|
-
|
63
|
-
|
83
|
+
uri = URI.parse("https://www.netlifystatus.com/api/v2/status.json")
|
84
|
+
response = Net::HTTP.get_response(uri)
|
64
85
|
|
65
|
-
|
66
|
-
parsed_json = JSON.parse(response.body)
|
67
|
-
payload = { :status => { :indicator => "#{parsed_json['status']['indicator']}", :description => "#{parsed_json['status']['description']}" } }
|
86
|
+
log_curl_output(response.code,response.body)
|
68
87
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
88
|
+
payload = JSON.parse(response.body)
|
89
|
+
event = payload.dup
|
90
|
+
event = { :status => { :name => "#{payload['page']['name']}", :indicator => "#{payload['status']['indicator']}", :description => "#{payload['status']['description']}" } }
|
91
|
+
|
92
|
+
if interpolated['changes_only'] == 'true'
|
93
|
+
if payload != memory['last_status']
|
94
|
+
if memory['last_status'].nil?
|
95
|
+
create_event payload: event
|
96
|
+
elsif !memory['last_status']['status'].nil? and memory['last_status']['status'].present? and payload['status'] != memory['last_status']['status']
|
97
|
+
create_event payload: event
|
78
98
|
end
|
99
|
+
memory['last_status'] = payload
|
100
|
+
end
|
101
|
+
else
|
102
|
+
create_event payload: event
|
103
|
+
if payload != memory['last_status']
|
104
|
+
memory['last_status'] = payload
|
79
105
|
end
|
106
|
+
end
|
80
107
|
end
|
81
108
|
end
|
82
109
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huginn_netlify_status_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Germain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
|
-
rubygems_version: 3.
|
85
|
+
rubygems_version: 3.3.3
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Write a short summary, because Rubygems requires one.
|