sensu-plugins-eventstore 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/metrics-eventstore-stats-stream.rb +18 -6
- 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: 44ce8ee38b05a664487437ab2a4189d98d00cb00
|
4
|
+
data.tar.gz: b1218bfc2002119abc86a77bdcb1dfd3873fc424
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83c33f31f05742991bfaf64477844f4dfd465e2782418e78b923120079d64af33fda27e5c17e1cc0272f16d236f97b8f82bbe21e0c03856ddfdfdaf729b78252
|
7
|
+
data.tar.gz: 93c55fa469ce20a031eac3a6c59af23a6a121577ff80e50b3b8669dfda021ceddd0a6c7af8bda13be8d6a577067b81c378fed68b19f0a59463e2a439566dfc67
|
@@ -21,6 +21,7 @@
|
|
21
21
|
# for details.
|
22
22
|
#
|
23
23
|
|
24
|
+
require 'date'
|
24
25
|
require 'nokogiri'
|
25
26
|
require 'sensu-plugin/metric/cli'
|
26
27
|
require 'ip-helper.rb'
|
@@ -79,7 +80,7 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
79
80
|
description: 'What to prepend to output queue metrics (Default "<cluster_dns>.eventstore")',
|
80
81
|
short: '-q',
|
81
82
|
long: '--queue_scheme queue_scheme',
|
82
|
-
default: "
|
83
|
+
default: ""
|
83
84
|
|
84
85
|
option :verbose,
|
85
86
|
description: 'output extra messaging (Default false)',
|
@@ -87,6 +88,11 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
87
88
|
long: '--verbose verbose',
|
88
89
|
default: 'false'
|
89
90
|
|
91
|
+
def get_queue_scheme
|
92
|
+
return config[:queue_scheme] unless config[:queue_scheme].empty?
|
93
|
+
"#{config[:cluster_dns]}.eventstore"
|
94
|
+
end
|
95
|
+
|
90
96
|
def run
|
91
97
|
discover_via_dns = config[:discover_via_dns]
|
92
98
|
address = config[:address]
|
@@ -123,7 +129,7 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
123
129
|
|
124
130
|
xml_doc = Nokogiri::XML xml_stream_without_namespace
|
125
131
|
|
126
|
-
puts xml_doc
|
132
|
+
puts xml_doc if verbose?
|
127
133
|
|
128
134
|
latest_entry = xml_doc.xpath('.//entry')
|
129
135
|
.sort { |node| DateTime.parse node.xpath('.//updated').text }
|
@@ -135,7 +141,7 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
135
141
|
|
136
142
|
json_stats = JSON.parse element_temp_file.read
|
137
143
|
|
138
|
-
puts "json stats #{json_stats}"
|
144
|
+
puts "json stats #{json_stats}" if verbose?
|
139
145
|
|
140
146
|
stats_dict = add_standard_metrics json_stats
|
141
147
|
|
@@ -143,15 +149,21 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
143
149
|
|
144
150
|
stat_time = latest_entry.at_xpath('.//updated').content
|
145
151
|
|
152
|
+
puts "stat retrived for time #{stat_time}" if verbose?
|
153
|
+
|
146
154
|
parsed_date_time = DateTime.parse(stat_time)
|
147
155
|
|
148
|
-
stats_dict.each { |stat| output stat[0], stat[1], parsed_date_time}
|
156
|
+
stats_dict.each { |stat| output stat[0], stat[1], parsed_date_time.strftime('%s')}
|
149
157
|
|
150
158
|
ok
|
151
159
|
end
|
152
160
|
|
161
|
+
def verbose?
|
162
|
+
config_is_true config[:verbose]
|
163
|
+
end
|
164
|
+
|
153
165
|
def get_stream(stream_url, accept_type)
|
154
|
-
puts "opening stream @ url #{stream_url}" if
|
166
|
+
puts "opening stream @ url #{stream_url}" if verbose?
|
155
167
|
|
156
168
|
if config_is_true config[:use_authentication]
|
157
169
|
username = config[:auth_user]
|
@@ -180,7 +192,7 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
180
192
|
def create_queue_mapping(source_name, target_name)
|
181
193
|
{
|
182
194
|
source_name: source_name,
|
183
|
-
target_name:"#{
|
195
|
+
target_name:"#{get_queue_scheme}.#{target_name}"
|
184
196
|
}
|
185
197
|
end
|
186
198
|
|