sensu-plugins-couchdb 0.0.1 → 1.0.0

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDZjNzA5M2I3OTM0MWU5ZjYyMmQzNmYyOTRmZmE1OTgzNDUxOGM4Yw==
5
- data.tar.gz: !binary |-
6
- MzZjMzAwZTg4YTQyZmY1MzRjZGI4ZDQyMGUxYTVmZjdiZTM4ZjZhYw==
2
+ SHA1:
3
+ metadata.gz: da677d71f37c46470338fc35b9c20a9b949d67a3
4
+ data.tar.gz: e28dbff3ce2dfe10e568a0a5f176183dcd1e5eab
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MTVjMzk2MzFlMWIxN2RjM2YzZDY0MzYyYTZmMGY2N2EzNmQ2YjBhZTgxMGU5
10
- NDY4N2ViMjEzNzAxNDc3MTg0ZWMzYTQ5OThiN2U0OGFlNjk0OWU2ZThjODhj
11
- YWRmMzEyMDQwYjk1ZTdiMDFjYzg2MTNjNDA1NDc0YTU3NjRjMjM=
12
- data.tar.gz: !binary |-
13
- NjcyYmY2Mzk3MzM2NjNiMjU0ZmU5MDk0NDUwODNlMzMxMjk3MzA5MjczYmUz
14
- YjljNTIzZGVlNDc3ODk4M2MxZjFmNWFlZjBmNzQ2NzVlZjQ4M2E5NTUwZGYy
15
- YWRhODAyNGQxYjFiNTQ1M2FkMzEzYTFmNTMxOTlhNWU0MTM5OWU=
6
+ metadata.gz: 3d43e3ac82c33ab0b0a1ab5dae69f38d0b07010d8d146bd4439f667fc82f29bfe7628613ff46d4f3b187f449a8752fbe10475aceb175a424ceecae57b6396d7d
7
+ data.tar.gz: 1102bda7b8290101996e7a570f464b5b0ec814d45dd79642289fbffdc44f44630bb94a1caadcd4e6cec6f31e16014b76b337da96a14e8887099d4279bf745e69
data/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ###[Unreleased]
7
7
 
8
+ ## 1.0.0 - 2017-07-8
9
+ ### No-op
10
+ - no code change bumping to 1.0 to prep for breaking changes in 2.x. Leave no user without a reasonable upgrade path (@majormoses)
11
+
12
+ ### Fix
13
+ - misc fixes in changelog and pr templates (@majormoses)
14
+ - ensured all checks are exectuable (@majormoses)
15
+
16
+ ## 0.0.2 - 2016-11-01
17
+ ### Added
18
+ - check-couchdb-alive.rb
19
+
8
20
  ## 0.0.1 - 2016-02-04
9
21
  ### Changed
10
22
  - adjusted dependencies
@@ -15,4 +27,7 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
15
27
  - update certs
16
28
  - metrics-couchdb.rb
17
29
 
18
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-couchdb/compare/0.0.1...HEAD
30
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-couchdb/compare/1.0.0...HEAD
31
+ [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-couchdb/compare/0.0.2...1.0.0
32
+ [0.0.2]: https://github.com/sensu-plugins/sensu-plugins-couchdb/compare/v0.0.1...0.0.2
33
+ [0.0.1]: https://github.com/sensu-plugins/sensu-plugins-couchdb/compare/7b922f558627beab911eb1113a184ac66a2a212b...v0.0.1
@@ -0,0 +1,82 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-couchdb-alive.rb
4
+ #
5
+ # DESCRIPTION:
6
+ # Check if a CouchDB server is alive and optionally if a database exists
7
+ #
8
+ # PLATFORMS:
9
+ # Linux
10
+ #
11
+ # DEPENDENCIES:
12
+ # gem: sensu-plugin
13
+ # gem: json
14
+ # gem: rest-client
15
+ #
16
+ # NOTES
17
+ # Based on:
18
+ # https://github.com/sensu-plugins/sensu-plugins-rabbitmq/blob/master/bin/check-rabbitmq-alive.rb
19
+ #
20
+ # LICENSE:
21
+ # Copyright 2016 Alex Enachioaie github.com/thisisjaid
22
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
23
+ # for details.
24
+ #
25
+
26
+ require 'sensu-plugin/check/cli'
27
+ require 'json'
28
+ require 'rest_client'
29
+
30
+ # main plugin class
31
+
32
+ class CouchDBAlive < Sensu::Plugin::Check::CLI
33
+ option :host,
34
+ description: 'CouchDB host',
35
+ long: '--host HOST',
36
+ default: 'localhost'
37
+
38
+ option :port,
39
+ description: 'CouchDB port',
40
+ long: '--port PORT',
41
+ default: 5984
42
+
43
+ option :database,
44
+ description: 'CouchDB database',
45
+ long: '--database DATABASE',
46
+ default: ''
47
+
48
+ def run
49
+ res = couchdb_alive?
50
+
51
+ if res['status'] == 'ok'
52
+ ok res['message']
53
+ elsif res['status'] == 'critical'
54
+ critical res['message']
55
+ else
56
+ unknown res['message']
57
+ end
58
+ end
59
+
60
+ def couchdb_alive?
61
+ host = config[:host]
62
+ port = config[:port]
63
+ database = config[:database]
64
+
65
+ begin
66
+ if database.nil? || database.empty?
67
+ resource = RestClient::Resource.new("http://#{host}:#{port}/")
68
+ # Attempt to parse response (just to trigger parse exception)
69
+ _response = JSON.parse(resource.get) == { 'couchdb' => 'Welcome' }
70
+ { 'status' => 'ok', 'message' => 'CouchDB server is alive' }
71
+ else
72
+ resource = RestClient::Resource.new("http://#{host}:#{port}/#{database}")
73
+ _response = JSON.parse(resource.get) == { 'db_name' => "#{database}.to_s" }
74
+ { 'status' => 'ok', 'message' => 'CouchDB server is alive and database exists' }
75
+ end
76
+ rescue Errno::ECONNREFUSED => e
77
+ { 'status' => 'critical', 'message' => e.message }
78
+ rescue => e
79
+ { 'status' => 'unknown', 'message' => e.message }
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # metrics-couchdb-database.rb
4
+ #
5
+ # DESCRIPTION:
6
+ #
7
+ # OUTPUT:
8
+ # metrics from a database
9
+ #
10
+ # PLATFORMS:
11
+ # Linux
12
+ #
13
+ # DEPENDENCIES:
14
+ # gem: sensu-plugin
15
+ # gem: json
16
+ # gem: net
17
+ #
18
+ # USAGE:
19
+ # #YELLOW
20
+ #
21
+ # NOTES:
22
+ # Based on:
23
+ # https://github.com/sensu-plugins/sensu-plugins-couchdb/blob/master/bin/metrics-couchdb.rb
24
+ #
25
+ # LICENSE:
26
+ # Copyright 2016 Florin Andrei github.com/FlorinAndrei
27
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
28
+ # for details.
29
+ #
30
+
31
+ require 'sensu-plugin/metric/cli'
32
+ require 'json'
33
+ require 'net/http'
34
+
35
+ #
36
+ # CouchDB
37
+ #
38
+
39
+ class CouchDB < Sensu::Plugin::Metric::CLI::Graphite
40
+ option :host,
41
+ description: 'CouchDB host',
42
+ long: '--host HOST',
43
+ default: 'localhost'
44
+
45
+ option :port,
46
+ description: 'CouchDB port',
47
+ long: '--port PORT',
48
+ default: 5984
49
+
50
+ option :scheme,
51
+ description: 'Metric naming scheme',
52
+ long: '--scheme SCHEME',
53
+ short: '-s SCHEME',
54
+ default: "#{Socket.gethostname}.couchdb"
55
+
56
+ option :database,
57
+ description: 'Database name',
58
+ long: '--database DATABASE',
59
+ short: '-d DATABASE'
60
+
61
+ def run
62
+ http = Net::HTTP.new(config[:host], config[:port])
63
+ req = Net::HTTP::Get.new('/' + config[:database])
64
+
65
+ begin
66
+ metrics = {}
67
+ res = http.request(req)
68
+ json = JSON.parse(res.body)
69
+
70
+ metrics.update(dot_it(json))
71
+ timestamp = Time.now.to_i
72
+ metrics.each do |k, v|
73
+ if v.nil?
74
+ next
75
+ end
76
+ unless v.is_a? Numeric
77
+ next
78
+ end
79
+ output [config[:scheme] + '.databases.' + config[:database], k].join('.'), v, timestamp
80
+ end
81
+ ok
82
+ rescue
83
+ exit(1)
84
+ end
85
+ end
86
+
87
+ def dot_it(object, prefix = nil)
88
+ if object.is_a? Hash
89
+ object.map do |key, value|
90
+ if prefix
91
+ dot_it value, "#{prefix}.#{key}"
92
+ else
93
+ dot_it value, key.to_s
94
+ end
95
+ end.reduce(&:merge)
96
+ else
97
+ { prefix => object }
98
+ end
99
+ end
100
+ end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsCouchdb
2
2
  module Version
3
- MAJOR = 0
3
+ MAJOR = 1
4
4
  MINOR = 0
5
- PATCH = 1
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,189 +1,160 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-couchdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - !binary |-
12
- LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURuakNDQW9hZ0F3SUJB
13
- Z0lCQVRBTkJna3Foa2lHOXcwQkFRVUZBREJLTVJVd0V3WURWUVFEREF4elpX
14
- NXoKZFMxd2JIVm5hVzR4SFRBYkJnb0praWFKay9Jc1pBRVpGZzF6Wlc1emRT
15
- MXdiSFZuYVc1ek1SSXdFQVlLQ1pJbQppWlB5TEdRQkdSWUNhVzh3SGhjTk1U
16
- WXdNakEwTWpNeU1qRTNXaGNOTVRjd01qQXpNak15TWpFM1dqQktNUlV3CkV3
17
- WURWUVFEREF4elpXNXpkUzF3YkhWbmFXNHhIVEFiQmdvSmtpYUprL0lzWkFF
18
- WkZnMXpaVzV6ZFMxd2JIVm4KYVc1ek1SSXdFQVlLQ1pJbWlaUHlMR1FCR1JZ
19
- Q2FXOHdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCRHdBdwpnZ0VLQW9J
20
- QkFRQy9VUzNmdEkyUmQrOWQzS3JIQUw0bERsOGxhN2s2ZHA3K1RPY210VHd3
21
- YzRiMUwzV0NyeEFoClpDWms1Q3k2aUpvWUd4VHVoN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Cbk5TaVd2WGIrSUttSkFWTzF1VzRrClFOODNielZXU1d1bFk4Qlk2
39
- a1grSVFNd1lhelpBbEIvMTNkN2E4VTBoN0NyYjM2Sm5TUGF0aHVSemU0cUtY
40
- RlEKM2YzVFVaV3d2UmZ0Y1N1K3Z0Y0JSa00wCi0tLS0tRU5EIENFUlRJRklD
41
- QVRFLS0tLS0K
42
- date: 2016-02-05 00:00:00.000000000 Z
10
+ cert_chain: []
11
+ date: 2017-07-08 00:00:00.000000000 Z
43
12
  dependencies:
44
13
  - !ruby/object:Gem::Dependency
45
14
  name: sensu-plugin
46
15
  requirement: !ruby/object:Gem::Requirement
47
16
  requirements:
48
- - - ~>
17
+ - - "~>"
49
18
  - !ruby/object:Gem::Version
50
19
  version: '1.2'
51
20
  type: :runtime
52
21
  prerelease: false
53
22
  version_requirements: !ruby/object:Gem::Requirement
54
23
  requirements:
55
- - - ~>
24
+ - - "~>"
56
25
  - !ruby/object:Gem::Version
57
26
  version: '1.2'
58
27
  - !ruby/object:Gem::Dependency
59
28
  name: bundler
60
29
  requirement: !ruby/object:Gem::Requirement
61
30
  requirements:
62
- - - ~>
31
+ - - "~>"
63
32
  - !ruby/object:Gem::Version
64
33
  version: '1.7'
65
34
  type: :development
66
35
  prerelease: false
67
36
  version_requirements: !ruby/object:Gem::Requirement
68
37
  requirements:
69
- - - ~>
38
+ - - "~>"
70
39
  - !ruby/object:Gem::Version
71
40
  version: '1.7'
72
41
  - !ruby/object:Gem::Dependency
73
42
  name: codeclimate-test-reporter
74
43
  requirement: !ruby/object:Gem::Requirement
75
44
  requirements:
76
- - - ~>
45
+ - - "~>"
77
46
  - !ruby/object:Gem::Version
78
47
  version: '0.4'
79
48
  type: :development
80
49
  prerelease: false
81
50
  version_requirements: !ruby/object:Gem::Requirement
82
51
  requirements:
83
- - - ~>
52
+ - - "~>"
84
53
  - !ruby/object:Gem::Version
85
54
  version: '0.4'
86
55
  - !ruby/object:Gem::Dependency
87
56
  name: github-markup
88
57
  requirement: !ruby/object:Gem::Requirement
89
58
  requirements:
90
- - - ~>
59
+ - - "~>"
91
60
  - !ruby/object:Gem::Version
92
61
  version: '1.3'
93
62
  type: :development
94
63
  prerelease: false
95
64
  version_requirements: !ruby/object:Gem::Requirement
96
65
  requirements:
97
- - - ~>
66
+ - - "~>"
98
67
  - !ruby/object:Gem::Version
99
68
  version: '1.3'
100
69
  - !ruby/object:Gem::Dependency
101
70
  name: pry
102
71
  requirement: !ruby/object:Gem::Requirement
103
72
  requirements:
104
- - - ~>
73
+ - - "~>"
105
74
  - !ruby/object:Gem::Version
106
75
  version: '0.10'
107
76
  type: :development
108
77
  prerelease: false
109
78
  version_requirements: !ruby/object:Gem::Requirement
110
79
  requirements:
111
- - - ~>
80
+ - - "~>"
112
81
  - !ruby/object:Gem::Version
113
82
  version: '0.10'
114
83
  - !ruby/object:Gem::Dependency
115
84
  name: rake
116
85
  requirement: !ruby/object:Gem::Requirement
117
86
  requirements:
118
- - - ~>
87
+ - - "~>"
119
88
  - !ruby/object:Gem::Version
120
89
  version: '10.5'
121
90
  type: :development
122
91
  prerelease: false
123
92
  version_requirements: !ruby/object:Gem::Requirement
124
93
  requirements:
125
- - - ~>
94
+ - - "~>"
126
95
  - !ruby/object:Gem::Version
127
96
  version: '10.5'
128
97
  - !ruby/object:Gem::Dependency
129
98
  name: redcarpet
130
99
  requirement: !ruby/object:Gem::Requirement
131
100
  requirements:
132
- - - ~>
101
+ - - "~>"
133
102
  - !ruby/object:Gem::Version
134
103
  version: '3.2'
135
104
  type: :development
136
105
  prerelease: false
137
106
  version_requirements: !ruby/object:Gem::Requirement
138
107
  requirements:
139
- - - ~>
108
+ - - "~>"
140
109
  - !ruby/object:Gem::Version
141
110
  version: '3.2'
142
111
  - !ruby/object:Gem::Dependency
143
112
  name: rubocop
144
113
  requirement: !ruby/object:Gem::Requirement
145
114
  requirements:
146
- - - ~>
115
+ - - "~>"
147
116
  - !ruby/object:Gem::Version
148
- version: '0.37'
117
+ version: 0.40.0
149
118
  type: :development
150
119
  prerelease: false
151
120
  version_requirements: !ruby/object:Gem::Requirement
152
121
  requirements:
153
- - - ~>
122
+ - - "~>"
154
123
  - !ruby/object:Gem::Version
155
- version: '0.37'
124
+ version: 0.40.0
156
125
  - !ruby/object:Gem::Dependency
157
126
  name: rspec
158
127
  requirement: !ruby/object:Gem::Requirement
159
128
  requirements:
160
- - - ~>
129
+ - - "~>"
161
130
  - !ruby/object:Gem::Version
162
131
  version: '3.4'
163
132
  type: :development
164
133
  prerelease: false
165
134
  version_requirements: !ruby/object:Gem::Requirement
166
135
  requirements:
167
- - - ~>
136
+ - - "~>"
168
137
  - !ruby/object:Gem::Version
169
138
  version: '3.4'
170
139
  - !ruby/object:Gem::Dependency
171
140
  name: yard
172
141
  requirement: !ruby/object:Gem::Requirement
173
142
  requirements:
174
- - - ~>
143
+ - - "~>"
175
144
  - !ruby/object:Gem::Version
176
145
  version: '0.8'
177
146
  type: :development
178
147
  prerelease: false
179
148
  version_requirements: !ruby/object:Gem::Requirement
180
149
  requirements:
181
- - - ~>
150
+ - - "~>"
182
151
  - !ruby/object:Gem::Version
183
152
  version: '0.8'
184
153
  description: Sensu couchdb plugins
185
- email: <sensu-users@googlegroups.com>
154
+ email: "<sensu-users@googlegroups.com>"
186
155
  executables:
156
+ - check-couchdb-alive.rb
157
+ - metrics-couchdb-database.rb
187
158
  - metrics-couchdb.rb
188
159
  extensions: []
189
160
  extra_rdoc_files: []
@@ -191,6 +162,8 @@ files:
191
162
  - CHANGELOG.md
192
163
  - LICENSE
193
164
  - README.md
165
+ - bin/check-couchdb-alive.rb
166
+ - bin/metrics-couchdb-database.rb
194
167
  - bin/metrics-couchdb.rb
195
168
  - lib/sensu-plugins-couchdb.rb
196
169
  - lib/sensu-plugins-couchdb/version.rb
@@ -210,12 +183,12 @@ require_paths:
210
183
  - lib
211
184
  required_ruby_version: !ruby/object:Gem::Requirement
212
185
  requirements:
213
- - - ! '>='
186
+ - - ">="
214
187
  - !ruby/object:Gem::Version
215
188
  version: 1.9.3
216
189
  required_rubygems_version: !ruby/object:Gem::Requirement
217
190
  requirements:
218
- - - ! '>='
191
+ - - ">="
219
192
  - !ruby/object:Gem::Version
220
193
  version: '0'
221
194
  requirements: []
checksums.yaml.gz.sig DELETED
Binary file
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
Binary file