sensu-plugins-green-dragon 0.1.5 → 0.1.6

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: 252b67797eaaa1f86418c0ef34f18c972b0b2316
4
- data.tar.gz: e39101826ffcfebaf99330daa47a644fbe8a332c
3
+ metadata.gz: 7c0b2a4d16fab60b5edb1a6cc76d7030d2a5ee39
4
+ data.tar.gz: 6a5771deee2da610746d02de712d4d2d9905c683
5
5
  SHA512:
6
- metadata.gz: 1db85d486eaec16e339211ae79b1c32032ed856f1ae8261f1fabbec3d74499277ede2b6da1c31481410928e9cf254c5f0b255d9120d6fb63c40416f5e48d20b2
7
- data.tar.gz: 92808f53153f3a911a7f07e669864f8e1d3bc4a357d93e616eea86b032536bacdd28de93916bae99ac55ba0892621cc0c8b5cad933e2a344ddf338bced58c888
6
+ metadata.gz: 293479178a5306eaaefa83b17d4ef919d5848693a156c0df87a3f40d953f5713cfdac6d09c9507e7022914d3a08ae9e9d2f2c70926d08ea646b1bd4dfd70d638
7
+ data.tar.gz: b5a36574dea24b3552f2bc6a5ddbb9b6c30eb67ed676ea29d162f91f1bec711661696fb6091dab75a74817cc1875e17d9e5780591966fab2aa0c4c097beeba80
data/README.md CHANGED
@@ -1,35 +1,23 @@
1
- # Green::Dragon::Plugins
1
+ A single gem for custom Sensu checks developed by Team Green Dragon. At the time of writing there's only one such check:
2
+ * [check-non-success-ratio.rb](bin/check-non-success-ratio.rb) - checks whether the ratio between successful (200)
3
+ and unsuccessful (non-200) requests to the API matches specified criteria (see code comments for example usage).
2
4
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/green/dragon/plugins`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'green-dragon-plugins'
5
+ ## Setup
6
+ To install necessary dependencies on your local computer:
7
+ ```
8
+ bundle install
13
9
  ```
14
10
 
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install green-dragon-plugins
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
11
+ ## Build
12
+ To build the gem:
13
+ ```
14
+ gem build sensu-plugins-green-dragon.gemspec
15
+ ```
34
16
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/green-dragon-plugins.
17
+ ## Publish
18
+ To publish the gem to RubyGems:
19
+ 1. Ask Grzegorz to give you necessary rights.
20
+ 2. Execute:
21
+ ```
22
+ gem push sensu-plugins-green-dragon-VERSION.gem
23
+ ```
@@ -123,20 +123,18 @@ class CheckNonSuccessRatio < Sensu::Plugin::Check::CLI
123
123
  username: config[:username],
124
124
  password: config[:password]
125
125
 
126
- success_responses_result = influxdb.query "select sum(value) from counter_httpResponseCode where httpStatus = '200' and application = '#{config[:app]}' and time > now() - 2h"
127
- non_success_responses_result = influxdb.query "select sum(value) from counter_httpResponseCode where httpStatus != '200' and application = '#{config[:app]}' and time > now() - 2h"
126
+ success_responses_result = influxdb.query "select sum(value) from counter_httpResponseCode where httpStatus = '200' and application = '#{config[:app]}' and time > now() - 15m"
127
+ non_success_responses_result = influxdb.query "select sum(value) from counter_httpResponseCode where httpStatus != '200' and application = '#{config[:app]}' and time > now() - 15m"
128
128
 
129
- if success_responses_result.empty?
130
- critical 'No result for success query'
131
- elsif non_success_responses_result.empty?
132
- critical 'No result for non-success query'
133
- end
134
-
135
- result_json_path = JsonPath.new('$..values[0].sum')
129
+ result_json_path = JsonPath.new '$..values[0].sum'
136
130
 
137
131
  success_responses_value = get_single_value(result_json_path, success_responses_result)
138
132
  non_success_responses_value = get_single_value(result_json_path, non_success_responses_result)
139
133
 
134
+ if success_responses_value + non_success_responses_value == 0
135
+ ok 'No requests in the past 15 minutes'
136
+ end
137
+
140
138
  ratio = non_success_responses_value.to_f / (success_responses_value + non_success_responses_value)
141
139
 
142
140
  calc = Dentaku::Calculator.new
@@ -1,3 +1,3 @@
1
1
  module GreenDragonPlugins
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-green-dragon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grzegorz Ziemonski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-17 00:00:00.000000000 Z
11
+ date: 2017-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin