sensu-plugins-eventstore 0.0.4 → 0.0.5
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/bin/check-gossip.rb +54 -43
- 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: bdb16fcadb0f5c1ce1f91bc09a8f43f82d9650b0
|
4
|
+
data.tar.gz: 3924369e8a2e84752246717a2f74e4427b1a8494
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa8d641213093e20eef660428ff88985f3dc40192af60033871cbd177eed1baed8da29323cfd12eaa5ffe465024c537420123f7897db479d30c79612648e3443
|
7
|
+
data.tar.gz: 1f0c76a904c019f0145f80696ad50e4e160fd143c38fe2bedc5fd5544578a73fe39e0eea7d5a0d4e7cc5bf24739f85122e88132c6ee23412863d0d874fed96ef
|
data/bin/check-gossip.rb
CHANGED
@@ -73,7 +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
|
-
|
76
|
+
critical_no_event_store_ips cluster_dns unless event_store_ips.any?
|
77
77
|
gossip_address = get_matching_ips current_machine_ips, event_store_ips
|
78
78
|
expected_nodes = event_store_ips.count
|
79
79
|
end
|
@@ -85,13 +85,12 @@ class CheckGossip < Sensu::Plugin::Check::CLI
|
|
85
85
|
matched_ips = machine_ips.select do |ip_to_look_for|
|
86
86
|
event_store_ips.find { |ip_to_match| ip_to_look_for == ip_to_match }
|
87
87
|
end
|
88
|
-
|
88
|
+
critical_no_matching_ips machine_ips, event_store_ips unless matched_ips.one?
|
89
89
|
matched_ips[0]
|
90
90
|
end
|
91
91
|
|
92
|
-
def
|
93
|
-
|
94
|
-
states.count { |state| state.content == 'Master' }
|
92
|
+
def get_master_count(document)
|
93
|
+
get_states(document).count { |state| state.content == 'Master' }
|
95
94
|
end
|
96
95
|
|
97
96
|
def get_members(document)
|
@@ -102,8 +101,17 @@ class CheckGossip < Sensu::Plugin::Check::CLI
|
|
102
101
|
document.xpath '//IsAlive'
|
103
102
|
end
|
104
103
|
|
104
|
+
def get_states(document)
|
105
|
+
document.xpath '//State'
|
106
|
+
end
|
107
|
+
|
105
108
|
def only_one_master?(document)
|
106
|
-
|
109
|
+
get_master_count(document) == 1
|
110
|
+
end
|
111
|
+
|
112
|
+
def all_nodes_master_or_slave?(document)
|
113
|
+
states = get_states document
|
114
|
+
states.all? {|node| node.content == "Master" || node.content == "Slave"}
|
107
115
|
end
|
108
116
|
|
109
117
|
def node_count_is_correct?(document, expected_count)
|
@@ -115,56 +123,31 @@ class CheckGossip < Sensu::Plugin::Check::CLI
|
|
115
123
|
nodes.all? { |node| node_is_alive? node }
|
116
124
|
end
|
117
125
|
|
118
|
-
def
|
119
|
-
puts "\nchecking gossip at #{gossip_address}:#{gossip_port}"
|
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
|
128
|
-
|
129
|
-
xml_doc = Nokogiri::XML(gossip.readline)
|
130
|
-
|
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
|
133
|
-
|
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
|
142
|
-
|
143
|
-
def critical_failure_from_no_matching_ips(machine_ips, event_store_ips)
|
126
|
+
def critical_no_matching_ips(machine_ips, event_store_ips)
|
144
127
|
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
128
|
end
|
146
|
-
def
|
129
|
+
def critical_no_event_store_ips(dns_name)
|
147
130
|
critical "could not find any ips at dns name #{dns_name} so cannot check gossips"
|
148
131
|
end
|
149
|
-
def
|
150
|
-
critical "Wrong number of nodes, was #{get_members(xml_doc).count} should be
|
132
|
+
def critical_missing_nodes(xml_doc, expected_nodes)
|
133
|
+
critical "Wrong number of nodes, was #{get_members(xml_doc).count} should be #{expected_nodes}"
|
151
134
|
end
|
152
|
-
def
|
135
|
+
def critical_dead_nodes(xml_doc, expected_nodes)
|
153
136
|
critical "Only #{get_is_alive_nodes(xml_doc).count { |node| node_is_alive? node}} alive nodes, should be #{expected_nodes} alive"
|
154
137
|
end
|
155
|
-
def
|
156
|
-
critical "Wrong number of node masters, there should be
|
138
|
+
def critical_master_count(xml_doc)
|
139
|
+
critical "Wrong number of node masters, there should be 1 but there were #{get_master_count(xml_doc)} masters"
|
140
|
+
end
|
141
|
+
def warn_nodes_not_ready(xml_doc)
|
142
|
+
states = get_states xml_doc
|
143
|
+
states = states.find { |node| node.content != "Master" and node.content != "Slave"}
|
144
|
+
warn "nodes found with states: #{states} when expected Master or Slave."
|
157
145
|
end
|
158
146
|
|
159
147
|
def node_is_alive?(node)
|
160
148
|
node.content == 'true'
|
161
149
|
end
|
162
150
|
|
163
|
-
def print_all(collection, type)
|
164
|
-
puts "\nprinting #{type} collection"
|
165
|
-
collection.each { |item| p item }
|
166
|
-
end
|
167
|
-
|
168
151
|
def get_event_store_ips_from_dns(dns_name)
|
169
152
|
Resolv::DNS.open { |dns|
|
170
153
|
resources = dns.getresources dns_name, Resolv::DNS::Resource::IN::A
|
@@ -181,4 +164,32 @@ class CheckGossip < Sensu::Plugin::Check::CLI
|
|
181
164
|
|
182
165
|
potential_ips.select { |info| ipv4_regex.match(info)}
|
183
166
|
end
|
167
|
+
|
168
|
+
def check_node(gossip_address, gossip_port, expected_nodes)
|
169
|
+
puts "\nchecking gossip at #{gossip_address}:#{gossip_port}"
|
170
|
+
|
171
|
+
begin
|
172
|
+
connection_url = "http://#{gossip_address}:#{gossip_port}/gossip?format=xml"
|
173
|
+
gossip = open(connection_url)
|
174
|
+
|
175
|
+
rescue StandardError
|
176
|
+
critical "Could not connect to #{connection_url} to check gossip, has event store fallen over on this node? "
|
177
|
+
end
|
178
|
+
|
179
|
+
xml_doc = Nokogiri::XML(gossip.readline)
|
180
|
+
|
181
|
+
puts "Checking for #{expected_nodes} nodes"
|
182
|
+
critical_missing_nodes xml_doc, expected_nodes unless node_count_is_correct? xml_doc, expected_nodes
|
183
|
+
|
184
|
+
puts "Checking nodes for IsAlive state"
|
185
|
+
critical_dead_nodes xml_doc, expected_nodes unless nodes_all_alive? xml_doc
|
186
|
+
|
187
|
+
puts "Checking for exactly 1 master"
|
188
|
+
critical_master_count xml_doc unless only_one_master? xml_doc
|
189
|
+
|
190
|
+
puts "Checking node state"
|
191
|
+
warn_nodes_not_ready xml_doc unless all_nodes_master_or_slave? xml_doc
|
192
|
+
|
193
|
+
ok "#{gossip_address} is gossiping with #{expected_nodes} nodes, all nodes are alive, exactly one master node was found and all other nodes are in the 'Slave' state."
|
194
|
+
end
|
184
195
|
end
|