sumo-check-es 0.0.2 → 0.0.3

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: 3be4b11753d361124d09b96b3e0245ed9053d101
4
- data.tar.gz: fbdf58a12828f262a877a7bef5204edc87279893
3
+ metadata.gz: 4361d720ed2d5ea56629ff64b836c322b9326a14
4
+ data.tar.gz: ff5567e09dca2a67393ec43c8f1137201e24abdd
5
5
  SHA512:
6
- metadata.gz: f4af5cf889c3b8533894844ab92ab5d5bfa2e3b990f75be254a907c712fb17082ccad0a223b0a4d4062d59e167cfa97d917d67fccdfef433b09d6766d97395db
7
- data.tar.gz: 0c72e763ef1ad3d96c92454387fecf7aebca1d2283237deb0975d688b3678f5ceca7978957deb16aba3b07188646365dc0f18176a1a1abf32d5e39c0b81372f2
6
+ metadata.gz: b0f997d69ff77a57d162bd6554b524e6bc0f6559a14121609c76efc8bf73aa1edc6cbe1701e0813e8674434b2c688f29a06b2be120188a3eeb7777f6141f1693
7
+ data.tar.gz: 0c66d133216509e5849a3995424e202b61482652209db3f279d0e31d58e5e90792d06d1debe6860dc52a5aad11ca39c11877d2dc2ae048a866fe712c0dcce25c
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ require 'elasticsearch'
3
+ require 'faraday_middleware'
4
+ require 'faraday_middleware/aws_signers_v4'
5
+ require 'sensu-plugin/check/cli'
6
+ require 'uri'
7
+
8
+ class SensuMetricEsSubscriberRate < Sensu::Plugin::Metric::CLI::Graphite
9
+ option :server,
10
+ short: '-s http://localhost:9200',
11
+ long: '--server',
12
+ description: 'Hostname of Elastic Search Cluster',
13
+ default: 'http://localhost:9200'
14
+
15
+ option :aws_access_key_id,
16
+ short: '-i sdfsdfsfs',
17
+ description: 'aws access key id',
18
+ default: nil
19
+
20
+ option :aws_secret_access_key,
21
+ short: '-v sdfsfsdfdsfs',
22
+ description: 'aws secret access key',
23
+ default: nil
24
+
25
+ def run
26
+ uri = URI(config[:server].strip)
27
+ if config[:aws_access_key_id] != nil && config[:aws_secret_access_key] != nil
28
+ signing_options = {
29
+ credentials: Aws::Credentials.new(config[:aws_access_key_id], config[:aws_secret_access_key]),
30
+ service_name: 'es',
31
+ region: 'us-west-2'
32
+ }
33
+ client = Elasticsearch::Client.new log:false, url: uri do |f|
34
+ f.use FaradayMiddleware::Gzip
35
+ f.request :aws_signers_v4, signing_options
36
+ end
37
+ else
38
+ client = Elasticsearch::Client.new log:false, url: uri
39
+ end
40
+
41
+ query = {
42
+ :query => {
43
+ :range => {
44
+ :created_at => {
45
+ :gt => "now-15m"
46
+ }
47
+ }
48
+ }
49
+ }
50
+
51
+ result = client.count index: 'subscribers', type: 'subscriber' , body: query.to_json
52
+ subscribers_per_min = (result["count"] / 15).to_i
53
+ ok "subscribers_per_min", subscribers_per_min
54
+
55
+ end
56
+
57
+ end
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ require 'elasticsearch'
3
+ require 'faraday_middleware'
4
+ require 'faraday_middleware/aws_signers_v4'
5
+ require 'sensu-plugin/check/cli'
6
+ require 'uri'
7
+
8
+ class SensuMetricEventsRate < Sensu::Plugin::Metric::CLI::Graphite
9
+ option :server,
10
+ short: '-s http://localhost:9200',
11
+ long: '--server',
12
+ description: 'Hostname of Elastic Search Cluster',
13
+ default: 'http://localhost:9200'
14
+
15
+ option :aws_access_key_id,
16
+ short: '-i homer',
17
+ description: 'aws access key id',
18
+ default: nil
19
+
20
+ option :aws_secret_access_key,
21
+ short: '-v simpson',
22
+ description: 'aws secret access key',
23
+ default: nil
24
+
25
+ def run
26
+ uri = URI(config[:server].strip)
27
+ if config[:aws_access_key_id] != nil && config[:aws_secret_access_key] != nil
28
+ signing_options = {
29
+ credentials: Aws::Credentials.new(config[:aws_access_key_id], config[:aws_secret_access_key]),
30
+ service_name: 'es',
31
+ region: 'us-west-2'
32
+ }
33
+ client = Elasticsearch::Client.new log:false, url: uri do |f|
34
+ f.use FaradayMiddleware::Gzip
35
+ f.request :aws_signers_v4, signing_options
36
+ end
37
+ else
38
+ client = Elasticsearch::Client.new log:false, url: uri
39
+ end
40
+
41
+ query = {
42
+ :query => {
43
+ :range => {
44
+ :created_at => {
45
+ :gt => "now-15m"
46
+ }
47
+ }
48
+ }
49
+ }
50
+
51
+ result = client.count index: 'events-*', type: 'event' , body: query.to_json
52
+ events_per_min = (result["count"] / 15).to_i
53
+ ok "events_per_min", events_per_min
54
+
55
+ end
56
+
57
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sumo-check-es
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr. Ogg
@@ -72,12 +72,16 @@ executables:
72
72
  - sumo-check-es_subscriber_rate.rb
73
73
  - sumo-check-es_subscriber_status.rb
74
74
  - sumo-check-events_rate.rb
75
+ - sumo-metric-es_subscriber_rate.rb
76
+ - sumo-metric-events_rate.rb
75
77
  extensions: []
76
78
  extra_rdoc_files: []
77
79
  files:
78
80
  - bin/sumo-check-es_subscriber_rate.rb
79
81
  - bin/sumo-check-es_subscriber_status.rb
80
82
  - bin/sumo-check-events_rate.rb
83
+ - bin/sumo-metric-es_subscriber_rate.rb
84
+ - bin/sumo-metric-events_rate.rb
81
85
  homepage:
82
86
  licenses: []
83
87
  metadata: {}