nat-monitor 1.1.0 → 2.0.0

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: 39809faab717e9222a32e1520359264a4834b6b4
4
- data.tar.gz: 6035485c770176b543d8d05cf61a71967e494ac2
3
+ metadata.gz: 3974f14b7e72be030eeb18f106c75cb253108ca9
4
+ data.tar.gz: 78bce4f038843212f57028f8dc7f2650191ac030
5
5
  SHA512:
6
- metadata.gz: 50c4559ab357e3709eb4c38a7d78948d98334fc49ccd1fa419de097c295bd7375db66becea3444d919ad4b7f994001f9b464864aa0a7c20c03c059a70e40edc4
7
- data.tar.gz: 03d4a9b94634733abb3685dd59a1923509de74872e727a630a43af92ac2b3115a423f55e612a323af0b3ad07f716ecd4911d2eb963da7700ed5a08a237f98bd0
6
+ metadata.gz: d18a2e90c2f7a0dfcfae9ce8a807feacd31531bb908e52a18224d8c851118654d7910ba6938e9d81974483d0daae8bce7747bad63a4789ad918f4a19e79978e9
7
+ data.tar.gz: beccbe7e6d3ae70c45e2d79dfb47ebab6774ad0fa03e8370f249facdd2fcd7d86e9ed78be38a3abb4b6b6678734f2835fbba061ff1ab0e3eb3e27a8dc854c2f4
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/nat-monitor.svg)](http://badge.fury.io/rb/nat-monitor)
2
+
1
3
  # nat-monitor
2
4
 
3
5
  Monitors a quorum of NAT servers for an outage and reassigns the specified EC2 route table to point to a working server.
@@ -69,7 +71,7 @@ The NAT Monitor has the ability to report out, via a simple URL request, its sta
69
71
  Requisite configuration needed:
70
72
 
71
73
  ```yaml
72
- monitor:
74
+ monitor_urls:
73
75
  begin: your.url/run
74
76
  success: your.url/complete
75
77
  fail: your.url/fail
data/lib/nat-monitor.rb CHANGED
@@ -21,24 +21,22 @@ module EtTools
21
21
  end
22
22
 
23
23
  def validate!
24
- exit_code = false
25
-
26
- case
27
- when !@conf['route_table_id']
28
- msg = 'route_table_id not specified'
29
- exit_code = 1
30
- when !route_exists?(@conf['route_table_id'])
31
- msg = "Route #{@conf['route_table_id']} not found"
32
- exit_code = 2
33
- when @conf['nodes'].count < 3
34
- msg = '3 or more nodes are required to create a quorum'
35
- exit_code = 3
36
- end
24
+ exit_code =
25
+ case
26
+ when !@conf['route_table_id']
27
+ msg = 'route_table_id not specified'
28
+ 1
29
+ when !route_exists?(@conf['route_table_id'])
30
+ msg = "Route #{@conf['route_table_id']} not found"
31
+ 2
32
+ when @conf['nodes'].count < 3
33
+ msg = '3 or more nodes are required to create a quorum'
34
+ 3
35
+ end
37
36
 
38
37
  return unless exit_code
39
38
 
40
39
  notify_monitor 'fail', msg
41
- output msg
42
40
  exit exit_code
43
41
  end
44
42
 
@@ -58,7 +56,6 @@ module EtTools
58
56
  rescue => e
59
57
  msg = "Caught #{e.class} exception: #{e.message}"
60
58
  notify_monitor 'fail', msg
61
- output msg
62
59
  output e.backtrace
63
60
  end
64
61
  sleep @conf['heartbeat_interval']
@@ -160,10 +157,13 @@ module EtTools
160
157
  end
161
158
 
162
159
  def notify_monitor(status, msg = nil)
160
+ output msg
163
161
  return unless @conf['monitor_enabled']
164
- url = monitor_url status
162
+ url = @conf['monitor_urls'][status]
165
163
  url += "?msg=#{msg}" if status == 'fail' && !msg.nil?
166
164
 
165
+ output 'Notifying external heartbeat monitor'
166
+
167
167
  Net::HTTP.get(URI url)
168
168
  end
169
169
 
@@ -179,9 +179,5 @@ module EtTools
179
179
  s.send(level, message)
180
180
  end
181
181
  end
182
-
183
- def monitor_url(status)
184
- @conf['monitor'][status]
185
- end
186
182
  end
187
183
  end
@@ -1,5 +1,5 @@
1
1
  module EtTools
2
2
  class NatMonitor
3
- VERSION = '1.1.0'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
@@ -13,7 +13,7 @@ describe EtTools::NatMonitor do
13
13
  @yaml_conf = { 'route_table_id' => @route_table_id,
14
14
  'aws_access_key_id' => 'AWS_ACCESS_KEY_ID',
15
15
  'aws_secret_access_key' => 'AWS_SECRET_ACCESS_KEY',
16
- 'monitor' => {
16
+ 'monitor_urls' => {
17
17
  'begin' => 'run',
18
18
  'success' => 'complete',
19
19
  'fail' => 'fail'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nat-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Herot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-25 00:00:00.000000000 Z
11
+ date: 2015-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec