sensu-plugins-eventstore 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/check-gossip.rb +38 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fed7594889235965a1b644d4e98a73fa6fa1c453
4
- data.tar.gz: 4a1bbc6a87744a2a98b2780f9f30ae98ee2469ef
3
+ metadata.gz: 38994ee87db4e297cdec9d70ef832775a29e1b33
4
+ data.tar.gz: 59436bc00a7b1e9bc17ad38bad1e398344a5bc75
5
5
  SHA512:
6
- metadata.gz: 75267c5e0d10958ba2a5ffdab23a4aba284adb8ce5092994733252eb92b3ca5894f8bf0331cd3e46efd1805473e63a444b91298ee86567b3fa1789021711e189
7
- data.tar.gz: 5300dcf48fa5a5aca75fe29e6eb0e9eec8626de0ec716db662232433ce18f875f6e17c917a34e505f097677885cb80bc5fdfc522a2d0da00c4d8458f04d29aba
6
+ metadata.gz: c5112ccfa0d8a846abc8c7d3181b136794d74f463726075c12c6db4c1665891f4aff7b17c6eb22ed894b8451ac2512dd695aba85df3a8d2d33130ee73cc1ce02
7
+ data.tar.gz: bfa6f88dcdf913849037905f1a4b38a8294877d8e86a3186bbb22e829412cdeb88ff80e8e1bfa7a870487b258566f32a7e899c9b083b8cce9ccfba20b17dd400
data/bin/check-gossip.rb CHANGED
@@ -73,6 +73,7 @@ class CheckGossip < Sensu::Plugin::Check::CLI
73
73
 
74
74
  current_machine_ips = get_current_machine_ipv4s
75
75
  event_store_ips = get_event_store_ips_from_dns cluster_dns
76
+ critical_failure_from_no_event_store_ips cluster_dns unless event_store_ips.any?
76
77
  gossip_address = get_matching_ips current_machine_ips, event_store_ips
77
78
  expected_nodes = event_store_ips.count
78
79
  end
@@ -84,7 +85,7 @@ class CheckGossip < Sensu::Plugin::Check::CLI
84
85
  matched_ips = machine_ips.select do |ip_to_look_for|
85
86
  event_store_ips.find { |ip_to_match| ip_to_look_for == ip_to_match }
86
87
  end
87
- critical "#{matched_ips.count} ips were found for this machine in the event store dns lookup, cannot figure out where to check gossip from" unless matched_ips.one?
88
+ critical_failure_from_no_matching_ips machine_ips, event_store_ips unless matched_ips.one?
88
89
  matched_ips[0]
89
90
  end
90
91
 
@@ -111,25 +112,52 @@ class CheckGossip < Sensu::Plugin::Check::CLI
111
112
 
112
113
  def nodes_all_alive?(document)
113
114
  nodes = get_is_alive_nodes document
114
- nodes.all? { |node| node.content == 'true' }
115
+ nodes.all? { |node| node_is_alive? node }
115
116
  end
116
117
 
117
118
  def check_node(gossip_address, gossip_port, expected_nodes)
118
119
  puts "\nchecking gossip at #{gossip_address}:#{gossip_port}"
119
- gossip = open("http://#{gossip_address}:#{gossip_port}/gossip?format=xml")
120
+
121
+ begin
122
+ connection_url = "http://#{gossip_address}:#{gossip_port}/gossip?format=xml";
123
+ gossip = open(connection_url)
124
+
125
+ rescue StandardError
126
+ critical "Could not connect to #{connection_url} to check gossip, has event store fallen over on this node? "
127
+ end
120
128
 
121
129
  xml_doc = Nokogiri::XML(gossip.readline)
122
130
 
123
- puts "\tchecking for #{expected_nodes} nodes"
124
- critical "\twrong number of nodes, was #{get_members(xml_doc).count} should be exactly #{expected_nodes}" unless node_count_is_correct? xml_doc, expected_nodes
131
+ puts "Checking for #{expected_nodes} nodes"
132
+ critical_failure_from_missing_nodes xml_doc, expected_nodes unless node_count_is_correct? xml_doc, expected_nodes
125
133
 
126
- puts "\tchecking nodes for IsAlive state"
127
- critical "\tat least 1 node is not alive" unless nodes_all_alive? xml_doc
134
+ puts "Checking nodes for IsAlive state"
135
+ critical_failure_from_dead_nodes xml_doc, expected_nodes unless nodes_all_alive? xml_doc
136
+
137
+ puts "Checking for exactly 1 master"
138
+ critical_failure_from_incorrect_master_count xml_doc unless only_one_master? xml_doc
139
+
140
+ ok "#{gossip_address} is gossiping with #{expected_nodes} nodes. All nodes are marked as alive and one master node was found."
141
+ end
128
142
 
129
- puts "\tchecking for exactly 1 master"
130
- critical "\twrong number of node masters, there should be exactly 1" unless only_one_master? xml_doc
143
+ def critical_failure_from_no_matching_ips(machine_ips, event_store_ips)
144
+ critical "this machine has ips of #{machine_ips}, event store (according to dns lookup) has ips of #{event_store_ips}. There should be exactly one match, but wasn't. "
145
+ end
146
+ def critical_failure_from_no_event_store_ips(dns_name)
147
+ critical "could not find any ips at dns name #{dns_name} so cannot check gossips"
148
+ end
149
+ def critical_failure_from_missing_nodes(xml_doc, expected_nodes)
150
+ critical "Wrong number of nodes, was #{get_members(xml_doc).count} should be exactly #{expected_nodes}"
151
+ end
152
+ def critical_failure_from_dead_nodes(xml_doc, expected_nodes)
153
+ critical "Only #{get_is_alive_nodes(xml_doc).count { |node| node_is_alive? node}} alive nodes, should be #{expected_nodes} alive"
154
+ end
155
+ def critical_failure_from_incorrect_master_count(xml_doc)
156
+ critical "Wrong number of node masters, there should be exactly 1 but there were #{get_masters(xml_doc)} masters"
157
+ end
131
158
 
132
- ok "Gossiping with #{expected_nodes} nodes, all of which alive and with one master node."
159
+ def node_is_alive?(node)
160
+ node.content == 'true'
133
161
  end
134
162
 
135
163
  def print_all(collection, type)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-eventstore
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
  - Jamie Wroe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard