sensu-plugins-eventstore 0.0.18 → 0.0.19
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/metrics-eventstore-stats-stream.rb +74 -41
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f59afdbc50e0e95fbc595615582987d47d6dca6
|
4
|
+
data.tar.gz: 615a56334db39ed7c1b80ab9ba11ae81b2f5a8a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 080dea02b3ceb5b850d636c8d5bd781b637cb2234b8280b429bb8b14c0d21425cca849b5e255e296a68a017de447ebba77fcb110c379054b44aa3f0fa5937901
|
7
|
+
data.tar.gz: a76409d78377d11ca11fb15f61fc89e5d11f455d0691babf5e012325ac1cde70d43f55e95c294c9b444fef01085c414cf4fa6476f4a3aff0304c836716037202
|
@@ -69,12 +69,18 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
69
69
|
long: '--auth_password auth_password',
|
70
70
|
default: 'changeit'
|
71
71
|
|
72
|
-
option :
|
73
|
-
description: 'What to prepend to output metrics (Default "<hostname>.eventstore")',
|
72
|
+
option :proc_scheme,
|
73
|
+
description: 'What to prepend to output proc metrics (Default "<hostname>.eventstore")',
|
74
74
|
short: '-s',
|
75
|
-
long: '--
|
75
|
+
long: '--proc_scheme proc_scheme',
|
76
76
|
default: "#{Socket.gethostname}.eventstore"
|
77
77
|
|
78
|
+
option :queue_scheme,
|
79
|
+
description: 'What to prepend to output queue metrics (Default "<cluster_dns>.eventstore")',
|
80
|
+
short: '-q',
|
81
|
+
long: '--queue_scheme queue_scheme',
|
82
|
+
default: "#{config[:cluster_dns]}.eventstore"
|
83
|
+
|
78
84
|
option :verbose,
|
79
85
|
description: 'output extra messaging (Default false)',
|
80
86
|
short: '-v',
|
@@ -95,11 +101,10 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
95
101
|
critical address unless helper.is_valid_v4_ip address
|
96
102
|
end
|
97
103
|
|
98
|
-
force_downloaded_files_to_be_temp_files
|
99
104
|
collect_metrics address, port
|
100
105
|
end
|
101
106
|
|
102
|
-
def
|
107
|
+
def force_web_requests_to_use_temp_files
|
103
108
|
# Don't allow downloaded files to be created as StringIO. Force a tempfile to be created.
|
104
109
|
OpenURI::Buffer.send :remove_const, 'StringMax' if OpenURI::Buffer.const_defined?('StringMax')
|
105
110
|
OpenURI::Buffer.const_set 'StringMax', -1
|
@@ -108,6 +113,7 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
108
113
|
def collect_metrics(address, port)
|
109
114
|
stream_url = "http://#{address}:#{port}/streams/$stats-#{address}:#{port}"
|
110
115
|
|
116
|
+
force_web_requests_to_use_temp_files
|
111
117
|
stream_temp_file = get_stream stream_url, "application/atom+xml"
|
112
118
|
|
113
119
|
namespace_regex = / xmlns="[A-Za-z:\/.0-9]+"/
|
@@ -131,9 +137,15 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
131
137
|
|
132
138
|
puts "json stats #{json_stats}" if config_is_true config[:verbose]
|
133
139
|
|
134
|
-
stats_dict =
|
140
|
+
stats_dict = add_standard_metrics json_stats
|
141
|
+
|
142
|
+
add_metrics_for_queues json_stats, stats_dict if are_we_master? address, port
|
143
|
+
|
144
|
+
stat_time = latest_entry.at_xpath('.//updated').content
|
145
|
+
|
146
|
+
parsed_date_time = DateTime.parse(stat_time)
|
135
147
|
|
136
|
-
stats_dict.each { |stat| output stat[0], stat[1]}
|
148
|
+
stats_dict.each { |stat| output stat[0], stat[1], parsed_date_time}
|
137
149
|
|
138
150
|
ok
|
139
151
|
end
|
@@ -144,14 +156,14 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
144
156
|
if config_is_true config[:use_authentication]
|
145
157
|
username = config[:auth_user]
|
146
158
|
password = config[:auth_password]
|
147
|
-
|
159
|
+
open stream_url, http_basic_authentication:[username, password], "Accept" => accept_type
|
148
160
|
else
|
149
|
-
|
161
|
+
open stream_url, "Accept" => accept_type
|
150
162
|
end
|
151
163
|
end
|
152
164
|
|
153
165
|
def config_is_true(config)
|
154
|
-
|
166
|
+
"true".casecmp(config) == 0
|
155
167
|
end
|
156
168
|
|
157
169
|
def add_metric(json_stats, stats_dict, stat_name_mapping)
|
@@ -159,44 +171,65 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
159
171
|
stats_dict[stat_name_mapping[:target_name]] = stat_value
|
160
172
|
end
|
161
173
|
|
162
|
-
def
|
163
|
-
|
174
|
+
def create_proc_mapping(source_name, target_name)
|
175
|
+
{
|
176
|
+
source_name: source_name,
|
177
|
+
target_name:"#{config[:proc_scheme]}.#{target_name}"
|
178
|
+
}
|
164
179
|
end
|
165
|
-
|
166
|
-
def create_metric_mapping(source_name, target_name)
|
180
|
+
def create_queue_mapping(source_name, target_name)
|
167
181
|
{
|
168
|
-
|
169
|
-
|
182
|
+
source_name: source_name,
|
183
|
+
target_name:"#{config[:queue_scheme]}.#{target_name}"
|
170
184
|
}
|
171
185
|
end
|
172
186
|
|
173
|
-
def
|
187
|
+
def add_standard_metrics(json_stats)
|
174
188
|
name_mappings = [
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
189
|
+
create_proc_mapping("proc-mem", "memory"),
|
190
|
+
create_proc_mapping("proc-cpu", "cpu"),
|
191
|
+
create_proc_mapping("proc-threadsCount", "threadsCount"),
|
192
|
+
create_proc_mapping("proc-contentionsRate", "contentionsRate"),
|
193
|
+
create_proc_mapping("proc-thrownExceptionsRate", "thrownExceptionsRate"),
|
194
|
+
create_proc_mapping("proc-diskIo-readBytes", "diskIo.readBytes"),
|
195
|
+
create_proc_mapping("proc-diskIo-writtenBytes", "diskIo.writtenBytes"),
|
196
|
+
create_proc_mapping("proc-diskIo-readOps", "diskIo.readOps"),
|
197
|
+
create_proc_mapping("proc-diskIo-writeOps", "diskIo.writeOps"),
|
198
|
+
create_proc_mapping("proc-tcp-receivingSpeed", "tcp.receivingSpeed"),
|
199
|
+
create_proc_mapping("proc-tcp-sendingSpeed", "tcp.sendingSpeed"),
|
200
|
+
create_proc_mapping("proc-tcp-inSend", "tcp.inSend"),
|
201
|
+
create_proc_mapping("proc-tcp-measureTime", "tcp.measureTime"),
|
202
|
+
create_proc_mapping("proc-tcp-receivedBytesSinceLastRun", "tcp.receivedBytesSinceLastRun"),
|
203
|
+
create_proc_mapping("proc-tcp-sentBytesSinceLastRun", "tcp.sentBytesSinceLastRun"),
|
204
|
+
create_proc_mapping("proc-gc-gen0Size", "gc.gen0Size"),
|
205
|
+
create_proc_mapping("proc-gc-gen1Size", "gc.gen1Size"),
|
206
|
+
create_proc_mapping("proc-gc-gen2Size", "gc.gen2Size"),
|
207
|
+
create_proc_mapping("proc-gc-largeHeapSize", "gc.largeHeapSize"),
|
208
|
+
create_proc_mapping("proc-gc-totalBytesInHeaps", "gc.totalBytesInHeaps")
|
195
209
|
]
|
196
210
|
stats_dict = Hash.new
|
197
|
-
|
198
|
-
|
199
|
-
|
211
|
+
name_mappings.each {|stat_mapping| add_metric json_stats, stats_dict, stat_mapping}
|
212
|
+
|
213
|
+
stats_dict
|
214
|
+
end
|
215
|
+
|
216
|
+
def are_we_master?(address, port)
|
217
|
+
begin
|
218
|
+
connection_url = "#{address}:#{port}/gossip?format=xml"
|
219
|
+
gossip = open(connection_url)
|
220
|
+
rescue StandardError
|
221
|
+
critical "Could not connect to #{connection_url} to check gossip, has event store fallen over on this node? "
|
222
|
+
end
|
223
|
+
|
224
|
+
xml_doc = Nokogiri::XML(gossip.readline)
|
225
|
+
|
226
|
+
members = xml_doc.xpath '//MemberInfoDto'
|
227
|
+
|
228
|
+
|
229
|
+
us = members.find { |member| member.xpath('.//ExternalHttpIp').content == address and
|
230
|
+
member.xpath('.//ExternalHttpPort').content == port}
|
231
|
+
|
232
|
+
us.xpath('.//state').content == 'Master'
|
200
233
|
end
|
201
234
|
|
202
235
|
def add_metrics_for_queues(json_stats, stats_dict)
|
@@ -216,7 +249,7 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
216
249
|
def add_metrics_for_queue(queue, json_stats, stats_dict)
|
217
250
|
queue_name = queue[0]
|
218
251
|
|
219
|
-
metric_mappings = queue[1].map { |metric_name|
|
252
|
+
metric_mappings = queue[1].map { |metric_name| create_queue_mapping "es-queue-#{queue_name}-#{metric_name}", "#{cleaned_name queue_name}.#{metric_name}" }
|
220
253
|
|
221
254
|
metric_mappings.each {|mapping| add_metric json_stats, stats_dict, mapping}
|
222
255
|
end
|
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.
|
4
|
+
version: 0.0.19
|
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-
|
11
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|