sumo-check-es 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 565a1f2419bf63b4e1300e3797e7b41663a2ada8
4
- data.tar.gz: 5f666397568acb8859b5a958c19e2c9466bd9db1
3
+ metadata.gz: 3be4b11753d361124d09b96b3e0245ed9053d101
4
+ data.tar.gz: fbdf58a12828f262a877a7bef5204edc87279893
5
5
  SHA512:
6
- metadata.gz: 40e802aae3cbaafe04bc449c362aaac6254e1291c29331fe11a6f845ebf67cc836e16d91706907a7e5e5fe130d09f6e8936e0f172f25e2b75b98175e240ba264
7
- data.tar.gz: ad753d19bc315d42f545f1645fc979db13ad5217d041ff277f2d3d23d8631fe33168362047251849d772a4b2beb58e1f78bafd4c1a7edf29c1244b01e4bb653d
6
+ metadata.gz: f4af5cf889c3b8533894844ab92ab5d5bfa2e3b990f75be254a907c712fb17082ccad0a223b0a4d4062d59e167cfa97d917d67fccdfef433b09d6766d97395db
7
+ data.tar.gz: 0c72e763ef1ad3d96c92454387fecf7aebca1d2283237deb0975d688b3678f5ceca7978957deb16aba3b07188646365dc0f18176a1a1abf32d5e39c0b81372f2
File without changes
@@ -0,0 +1,70 @@
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 SensuCheckEventsRate < Sensu::Plugin::Check::CLI
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 :min_per_min,
16
+ short: '-r 15',
17
+ description: 'Mininum subscribers per min',
18
+ default: 15
19
+
20
+ option :aws_access_key_id,
21
+ short: '-i homer',
22
+ description: 'aws access key id',
23
+ default: nil
24
+
25
+ option :aws_secret_access_key,
26
+ short: '-v simpson',
27
+ description: 'aws secret access key',
28
+ default: nil
29
+
30
+ def run
31
+ uri = URI(config[:server].strip)
32
+ if config[:aws_access_key_id] != nil && config[:aws_secret_access_key] != nil
33
+ signing_options = {
34
+ credentials: Aws::Credentials.new(config[:aws_access_key_id], config[:aws_secret_access_key]),
35
+ service_name: 'es',
36
+ region: 'us-west-2'
37
+ }
38
+ client = Elasticsearch::Client.new log:false, url: uri do |f|
39
+ f.use FaradayMiddleware::Gzip
40
+ f.request :aws_signers_v4, signing_options
41
+ end
42
+ else
43
+ client = Elasticsearch::Client.new log:false, url: uri
44
+ end
45
+
46
+ query = {
47
+ :query => {
48
+ :range => {
49
+ :created_at => {
50
+ :gt => "now-15m"
51
+ }
52
+ }
53
+ }
54
+ }
55
+
56
+ result = client.count index: 'events-*', type: 'event' , body: query.to_json
57
+ if result["_shards"]["failed"] == 0
58
+ events_per_min = (result["count"] / 15).to_i
59
+ if events_per_min > config[:min_per_min].to_i
60
+ ok("events/min: #{events_per_min}")
61
+ else
62
+ critical("events rate is to low...: #{events_per_min}")
63
+ end
64
+ else
65
+ critical("oops, there was an issue with the query: #{result.to_s}")
66
+ end
67
+
68
+ end
69
+
70
+ 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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr. Ogg
@@ -71,11 +71,13 @@ email:
71
71
  executables:
72
72
  - sumo-check-es_subscriber_rate.rb
73
73
  - sumo-check-es_subscriber_status.rb
74
+ - sumo-check-events_rate.rb
74
75
  extensions: []
75
76
  extra_rdoc_files: []
76
77
  files:
77
78
  - bin/sumo-check-es_subscriber_rate.rb
78
79
  - bin/sumo-check-es_subscriber_status.rb
80
+ - bin/sumo-check-events_rate.rb
79
81
  homepage:
80
82
  licenses: []
81
83
  metadata: {}