sensu-plugins-eventstore 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 333339c77111196383ca1ef8c087d10bf48d9dad
4
- data.tar.gz: 3d5c1dd690a1d4cb9050425986157bceaff2d1db
3
+ metadata.gz: 30289602da4bc203c72500ac66fddcb192b3accd
4
+ data.tar.gz: ce128c99260de932b2af913e6e3f35c4934e21cc
5
5
  SHA512:
6
- metadata.gz: d0c0d2fea45b9375180342b2377b3c2602cdebe71237b9ef060417854525e7959a26da0494457c64259468dc6faebcf5987343b3e084710df223faca8f260411
7
- data.tar.gz: d7a8181db6d29de9678d2daa01609ceac1f58c26c18c92ef98dd9b05830703518de19c4dd4d632faa98e2b9e3351efb9b9e3048d02f4a846b6880281a80032d9
6
+ metadata.gz: 560349cfc128cfb95df04630805a7c64177bcc4411f1d785ffb08fabc9bf32f2d1d51860f8cbb8ada2b0f0ebb9dcbc0f756cdb896d203952c6b3319f2bf33b9e
7
+ data.tar.gz: 59db0795947bf561b35a739ef98a1f52055cfd9ea514a39fb097d088e56b8d0ce4730b300495409784c30289d16295629d3f9d40065e452b8dbbf26673aa7193
@@ -29,7 +29,7 @@ require 'json'
29
29
  class Stats < Sensu::Plugin::Metric::CLI::Graphite
30
30
  option :discover_via_dns,
31
31
  description: 'Whether to use DNS lookup to discover other cluster nodes. (Default: true)',
32
- short: '-v',
32
+ short: '-k',
33
33
  long: '--discover_via_dns discover_via_dns',
34
34
  default: 'true'
35
35
 
@@ -69,6 +69,18 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
69
69
  long: '--auth_password auth_password',
70
70
  default: 'changeit'
71
71
 
72
+ option :scheme,
73
+ description: 'What to prepend to output metrics (Default "<hostname>.eventstore")',
74
+ short: '-s',
75
+ long: '--scheme scheme',
76
+ default: "#{Socket.gethostname}.eventstore"
77
+
78
+ option :verbose,
79
+ description: 'output extra messaging (Default false)',
80
+ short: '-v',
81
+ long: '--verbose verbose',
82
+ default: 'false'
83
+
72
84
  def run
73
85
  discover_via_dns = config[:discover_via_dns]
74
86
  address = config[:address]
@@ -105,7 +117,7 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
105
117
 
106
118
  xml_doc = Nokogiri::XML xml_stream_without_namespace
107
119
 
108
- puts xml_doc
120
+ puts xml_doc if config_is_true config[:verbose]
109
121
 
110
122
  latest_entry = xml_doc.xpath('.//entry')
111
123
  .sort { |node| DateTime.parse node.xpath('.//updated').text }
@@ -117,21 +129,19 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
117
129
 
118
130
  json_stats = JSON.parse element_temp_file.read
119
131
 
120
- puts "json stats #{json_stats}"
132
+ puts "json stats #{json_stats}" if config_is_true config[:verbose]
121
133
 
122
134
  stats_dict = parse_json_stats json_stats
123
135
 
124
136
  stats_dict.each { |stat| output stat[0], stat[1]}
125
137
 
126
- ok
138
+ ok "metrics collected successfully"
127
139
  end
128
140
 
129
141
  def get_stream(stream_url, accept_type)
130
- puts "opening stream @ url #{stream_url}"
131
-
132
- use_auth = config[:use_authentication]
142
+ puts "opening stream @ url #{stream_url}" if config_is_true config[:verbose]
133
143
 
134
- if "true".casecmp(use_auth) == 0
144
+ if config_is_true config[:use_authentication]
135
145
  username = config[:auth_user]
136
146
  password = config[:auth_password]
137
147
  return open stream_url, http_basic_authentication:[username, password], "Accept" => accept_type
@@ -140,6 +150,10 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
140
150
  end
141
151
  end
142
152
 
153
+ def config_is_true(config)
154
+ return "true".casecmp(config) == 0
155
+ end
156
+
143
157
  def add_metric(json_stats, stats_dict, stat_name_mapping)
144
158
  stat_value = json_stats[stat_name_mapping[:source_name]]
145
159
  stats_dict[stat_name_mapping[:target_name]] = stat_value
@@ -152,7 +166,7 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
152
166
  def create_metric_mapping(source_name, target_name)
153
167
  {
154
168
  source_name: source_name,
155
- target_name:"#{Socket.gethostname}.eventstore.#{target_name}"
169
+ target_name:"#{config[:scheme]}.#{target_name}"
156
170
  }
157
171
  end
158
172
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-eventstore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Wroe