barkdog 0.0.1 → 0.1.0

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: 9b638cff71a732aae5f42cbd4f60f30e4e674d36
4
- data.tar.gz: 89044b32af12f4aee82413d5d8848132582e5479
3
+ metadata.gz: 8eb8ef495351e01eb4686bbc1d73c68529267ae0
4
+ data.tar.gz: 69eeda438a1769ddce356e142ff224397b3830b9
5
5
  SHA512:
6
- metadata.gz: b2577c9e00dc2e8758a315bc74cfd25457d395b581c9ec404d6fc388476b44fb2f82d8bf554589eb002c0599b052e9fcda2f1fcbc7a21c86760b24b1250a2c03
7
- data.tar.gz: a6bc116e8fc6bffdd0003658713ce24359564959147e71a993768125e77374ad41c1f802713117c916bf31253089c780aa0e017c2eab8e0f2a0fda23a48f5ae6
6
+ metadata.gz: 912452f325a9a745879cb0ca115494967d73cea9c1a460e16101b7fcfc12990d21b7436126206c9575a655769b1936122088fac701bb556bd5a6cf9ed3dfaa59
7
+ data.tar.gz: 8fb714af798b001fee0d23ca4c7ea63237b86fd39ffdd3bfc7f615d5ad60712526d6d42869336d2f027a3dc547fcdfa16891d0a0d2e8f550d0fcc86a187ba9c5
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --require spec_helper
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script:
5
+ - bundle install
6
+ - bundle exec rake
7
+ env:
8
+ global:
9
+ - secure: "isrR0KYg4po5oZNWV3X6eSIryA7BdcMdyztIJPILZR0gRVd0IQLbe/0npvxFKzn7Y4mwQ/4N3oLnd1Jv/okuIC+zvMim+ZDyZP6uK0mDg9AFY718BVBhDcXjp85aW2KXki7dpUZ6G+cbsAtYbomEh/Soi3y47m+Ov/1odz7qylXBnwEZKbsxsoGd9iwb/DmFOCQeXvit+pQa4lPkTynu2etUxJtrzUPCxEBjcDXOB08GuDOQlAbnokiqN2pMwq60HC1U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PkUh6+QJtjoeOcEewl6EDheKVw07CmaFbR1tS2DDiUlGk="
data/README.md CHANGED
@@ -4,6 +4,9 @@ Barkdog is a tool to manage [Datadog monitors](http://docs.datadoghq.com/guides/
4
4
 
5
5
  It defines Datadog monitors using Ruby DSL, and updates monitors according to DSL.
6
6
 
7
+ [![Gem Version](https://badge.fury.io/rb/barkdog.svg)](http://badge.fury.io/rb/barkdog)
8
+ [![Build Status](https://travis-ci.org/winebarrel/barkdog.svg?branch=master)](https://travis-ci.org/winebarrel/barkdog)
9
+
7
10
  ## Installation
8
11
 
9
12
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,2 +1,5 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
2
3
 
4
+ RSpec::Core::RakeTask.new('spec')
5
+ task :default => :spec
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency 'bundler'
25
25
  spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec', '>= 0.3.0'
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module Barkdog
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -0,0 +1,80 @@
1
+ describe Barkdog::Client do
2
+ subject { barkdog_client.export }
3
+
4
+ let(:actual_dsl) do
5
+ <<-'RUBY'
6
+ monitor "my metric check", :type=>"metric alert" do
7
+ query "avg(last_5m):avg:datadog.dogstatsd.packet.count{*} > 1"
8
+ message "metric check message"
9
+ options do
10
+ notify_no_data false
11
+ no_data_timeframe 2
12
+ notify_audit false
13
+ silenced({})
14
+ end
15
+ end
16
+
17
+ monitor "my service check", :type=>"service check" do
18
+ query "\"datadog.agent.up\".over(\"*\").last(2).count_by_status()"
19
+ message "service check message"
20
+ options do
21
+ notify_audit false
22
+ timeout_h 0
23
+ silenced({})
24
+ thresholds "warning"=>1, "ok"=>1, "critical"=>1
25
+ period 15
26
+ notify_no_data true
27
+ renotify_interval 0
28
+ no_data_timeframe 2
29
+ end
30
+ end
31
+ RUBY
32
+ end
33
+
34
+ before { barkdog { actual_dsl } }
35
+
36
+ context 'when create monitors' do
37
+ it { is_expected.to eq actual_dsl }
38
+ end
39
+
40
+ context 'when delete monitors' do
41
+ let(:expected_dsl) { '' }
42
+ before { barkdog { expected_dsl } }
43
+ it { is_expected.to eq expected_dsl }
44
+ end
45
+
46
+ context 'when update monitors' do
47
+ let(:expected_dsl) do
48
+ <<-'RUBY'
49
+ monitor "my metric check", :type=>"metric alert" do
50
+ query "avg(last_5m):avg:datadog.dogstatsd.packet.count{*} > 2"
51
+ message "metric check message2"
52
+ options do
53
+ notify_no_data true
54
+ no_data_timeframe 3
55
+ notify_audit true
56
+ silenced "*"=>nil
57
+ end
58
+ end
59
+
60
+ monitor "my service check", :type=>"service check" do
61
+ query "\"datadog.agent.up\".over(\"*\").last(3).count_by_status()"
62
+ message "service check message2"
63
+ options do
64
+ notify_audit true
65
+ timeout_h 1
66
+ silenced "*"=>nil
67
+ thresholds "warning"=>2, "ok"=>2, "critical"=>2
68
+ period 30
69
+ notify_no_data true
70
+ renotify_interval 1
71
+ no_data_timeframe 3
72
+ end
73
+ end
74
+ RUBY
75
+ end
76
+
77
+ before { barkdog { expected_dsl } }
78
+ it { is_expected.to eq expected_dsl }
79
+ end
80
+ end
@@ -0,0 +1,50 @@
1
+ require 'barkdog'
2
+ require 'tempfile'
3
+
4
+ BARKDOG_TEST_API_KEY = ENV['BARKDOG_TEST_API_KEY']
5
+ BARKDOG_TEST_APP_KEY = ENV['BARKDOG_TEST_APP_KEY']
6
+
7
+ RSpec.configure do |config|
8
+ config.before(:each) do
9
+ barkdog { '' }
10
+ end
11
+
12
+ config.after(:all) do
13
+ barkdog { '' }
14
+ end
15
+ end
16
+
17
+ def barkdog_client(options = {})
18
+ options = {
19
+ api_key: BARKDOG_TEST_API_KEY,
20
+ application_key: BARKDOG_TEST_APP_KEY,
21
+ }.merge(options)
22
+
23
+ if ENV['DEBUG'] == '1'
24
+ options[:debug] = true
25
+ else
26
+ options[:logger] = Logger.new('/dev/null')
27
+ end
28
+
29
+ Barkdog::Client.new(options)
30
+ end
31
+
32
+ def barkdog(options = {})
33
+ client = barkdog_client(options)
34
+
35
+ tempfile(yield) do |f|
36
+ client.apply(f.path)
37
+ end
38
+ end
39
+
40
+ def tempfile(content, options = {})
41
+ basename = "#{File.basename __FILE__}.#{$$}"
42
+ basename = [basename, options[:ext]] if options[:ext]
43
+
44
+ Tempfile.open(basename) do |f|
45
+ f.puts(content)
46
+ f.flush
47
+ f.rewind
48
+ yield(f)
49
+ end
50
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barkdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.3.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.3.0
69
83
  description: Barkdog is a tool to manage Datadog monitors.
70
84
  email:
71
85
  - sgwr_dts@yahoo.co.jp
@@ -75,6 +89,8 @@ extensions: []
75
89
  extra_rdoc_files: []
76
90
  files:
77
91
  - .gitignore
92
+ - .rspec
93
+ - .travis.yml
78
94
  - Gemfile
79
95
  - LICENSE.txt
80
96
  - README.md
@@ -94,6 +110,8 @@ files:
94
110
  - lib/barkdog/ext/string_ext.rb
95
111
  - lib/barkdog/logger.rb
96
112
  - lib/barkdog/version.rb
113
+ - spec/barkdog_spec.rb
114
+ - spec/spec_helper.rb
97
115
  homepage: https://github.com/winebarrel/barkdog
98
116
  licenses:
99
117
  - MIT
@@ -118,4 +136,6 @@ rubygems_version: 2.0.14
118
136
  signing_key:
119
137
  specification_version: 4
120
138
  summary: Barkdog is a tool to manage Datadog monitors.
121
- test_files: []
139
+ test_files:
140
+ - spec/barkdog_spec.rb
141
+ - spec/spec_helper.rb