sumo-check-es 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sumo-check-snapshots.rb +87 -0
  3. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28969abac2c5f21303f872e6cae763aad696d5dd
4
- data.tar.gz: c14ee5a2d677094c2e03b3bb5d1b4a3413d5b12d
3
+ metadata.gz: eb6002b7bb543c0248f347773c5eda54b1c6a624
4
+ data.tar.gz: 3c4dac0d25bd9bf13531b7272445955554ff4fae
5
5
  SHA512:
6
- metadata.gz: 6ebace470348392989f122d1c7c2ab9415b3190169b06c37a182ed5799cd3fb2546f16c609fd7e005caa69d903ef4bb249d3116b306beb82fb1df177889e7c41
7
- data.tar.gz: '09f13ec4e24ac82c236a3ae51fd4e0b25fb18e86ff1dd2e0e0193e8951584b90f52a39abf2c4107c4464c989dad4562c44da4fab5d10b1f854e5b051856f49f3'
6
+ metadata.gz: 1b1af89486529f39e8e97cff779cbb5274efb100405dd8329696106af144651ec5617d838c01c6fcb107f4823925f11a94fea696a43b122ece8e11a392a3cad1
7
+ data.tar.gz: 18c7912fe574103cc5e0d0ebace3a78827b9d239e16e3cef511cfd2d7acd5a1d48c9e4e9c7bf980347ebb9610aa6080760a546cb88f492667e10526d3c670ed6
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+ require 'net/http'
3
+ require 'json'
4
+ require 'uri'
5
+ require 'sensu-plugin/check/cli'
6
+
7
+ # IN_PROGRESS
8
+ # The snapshot is currently running.
9
+ #
10
+ # SUCCESS
11
+ # The snapshot finished and all shards were stored successfully.
12
+ #
13
+ # FAILED
14
+ # The snapshot finished with an error and failed to store any data.
15
+ #
16
+ # PARTIAL
17
+ # The global cluster state was stored, but data of at least one
18
+ # shard wasn’t stored successfully. The failure section in this
19
+ # case should contain more detailed information about shards
20
+ # that were not processed correctly.
21
+ #
22
+ # INCOMPATIBLE
23
+ # The snapshot was created with an old version of Elasticsearch
24
+ # and therefore is incompatible with the current version of the cluster.
25
+
26
+
27
+
28
+ class SensuCheckSnapshotStatus < Sensu::Plugin::Check::CLI
29
+
30
+ @@es_ok_status_list =["IN_PROGRESS","SUCCESS","STARTED"]
31
+ @@es_failed_status_list =["FAILED","PARTIAL","INCOMPATIBLE","ABORTED"]
32
+
33
+ option :server,
34
+ short: '-s http://localhost:9200',
35
+ description: 'Hostname of Elastic Search Cluster',
36
+ default: 'http://localhost:9200'
37
+
38
+ option :snapshot_location,
39
+ short: '-d junk_snapshot_name',
40
+ description: 'Name of snapshot location',
41
+ default: 'junk_snapshot_name'
42
+
43
+ option :min_num_snapshots,
44
+ short: '-n 7',
45
+ description: 'Mininum number of snapshots allowed',
46
+ default: 7
47
+
48
+ option :max_num_snapshots,
49
+ short: '-m 9',
50
+ description: 'Maximum number of snapshots allowed',
51
+ default: 9
52
+
53
+ def get_snapshots()
54
+ uri = URI(config[:server].strip)
55
+ uri.path = "/_snapshot/#{config[:snapshot_location]}/_all"
56
+ result={}
57
+ http = Net::HTTP.new(uri.host, uri.port)
58
+ req = Net::HTTP::Get.new(uri)
59
+ res = http.request(req)
60
+ result["status"]= res.code
61
+ result["body"]= JSON.parse(res.body)
62
+ return result
63
+ end
64
+
65
+ def run
66
+ error_msgs=[]
67
+ data = get_snapshots
68
+
69
+ data["body"]["snapshots"].each do |snap|
70
+ if @@es_failed_status_list.include? snap["state"]
71
+ error_msgs.push({:snapshot=>snap["snapshot"],:state=>snap["state"],:failures=>snap["failures"]})
72
+ end
73
+ end
74
+
75
+ if !data["body"]["snapshots"].length.between?(config[:min_num_snapshots],config[:max_num_snapshots])
76
+ error_msgs.push("snapshot count at #{data["body"]["snapshots"].length} is outside of allowed range of #{config[:min_num_snapshots]} to #{config[:max_num_snapshots]}")
77
+ end
78
+
79
+ if error_msgs.length == 0
80
+ ok("snapshot status is ok")
81
+ else
82
+ critical(error_msgs.to_s)
83
+ end
84
+
85
+ end
86
+
87
+ 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.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr. Ogg
@@ -115,12 +115,14 @@ executables:
115
115
  - sumo-metric-es_subscriber_rate.rb
116
116
  - sumo-metric-events_rate.rb
117
117
  - sumo-metric-es_thread_pool.rb
118
+ - sumo-check-snapshots.rb
118
119
  extensions: []
119
120
  extra_rdoc_files: []
120
121
  files:
121
122
  - bin/sumo-check-es_subscriber_rate.rb
122
123
  - bin/sumo-check-es_subscriber_status.rb
123
124
  - bin/sumo-check-events_rate.rb
125
+ - bin/sumo-check-snapshots.rb
124
126
  - bin/sumo-metric-es_subscriber_rate.rb
125
127
  - bin/sumo-metric-es_thread_pool.rb
126
128
  - bin/sumo-metric-events_rate.rb