barkdog 0.1.3 → 0.1.4

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: 0df44e3dab1e9d1e2ca862e8cca4723d1f490712
4
- data.tar.gz: 342257b4f1e85fab2cb2b9460434883b8297c303
3
+ metadata.gz: c21615f347dced36cd4409fb53dc2df65166ee91
4
+ data.tar.gz: 08dae8f1e3eaab800c87fc5bae38068466b49193
5
5
  SHA512:
6
- metadata.gz: 36a699f5f4c5ba8b291f20dda35ced3a77e5c18ad68e08aab330f0078860f2a957c1859ac93dbbdec7aa2e7b59fc5e7a97e8a65a48353daf1dfa0385721f6dd5
7
- data.tar.gz: 24b1acc3d0598a33ee87e1652e698586daddb4ab471f0691a61b37e9fa6546d0c635d58785a1cf4891d05bb2f5253842805cf28f43c250cd834e60975126f0e5
6
+ metadata.gz: 979495548620024f79d5bebf457f6826d307479ac239d567c45db493ebe4a3de4384c6a851914d6107517425d17c07a8ee6e023580011a725dda93649e718287
7
+ data.tar.gz: ec08151e9f466f7b00ea6cc32ab94248233ad27967605a257f118fb20358b09398ab7b85a89f127cd7295d54b05205e0c32fa72b1635876c880799a4ce86ccbd
data/README.md CHANGED
@@ -62,6 +62,7 @@ monitor "Check load avg", :type=>"metric alert" do
62
62
  query "avg(last_5m):avg:ddstat.load_avg.1m{host:i-XXXXXXXX} > 1"
63
63
  message "@winebarrel@example.net"
64
64
  options do
65
+ locked false
65
66
  notify_no_data true
66
67
  no_data_timeframe 2
67
68
  notify_audit true
@@ -77,6 +78,7 @@ template "cpu template" do
77
78
  query "avg(last_5m):avg:#{context.target}.load_avg.1m{host:i-XXXXXXXX} > 1"
78
79
  message context.message
79
80
  options do
81
+ locked false
80
82
  notify_no_data true
81
83
  no_data_timeframe 2
82
84
  notify_audit true
@@ -90,7 +92,7 @@ monitor "Check load avg", :type=>"metric alert" do
90
92
  end
91
93
 
92
94
  template "basic monitor" do
93
- monitor "#{target} cpu" do
95
+ monitor "#{context.target} cpu" do
94
96
  query "avg(last_5m):avg:#{context.target}.load_avg.1m{host:i-XXXXXXXX} > 1"
95
97
  ...
96
98
  end
@@ -105,3 +107,6 @@ end
105
107
  ...
106
108
  end
107
109
  ```
110
+
111
+ ## Similar tools
112
+ * [Codenize.tools](http://codenize.tools/)
@@ -11,6 +11,10 @@ DEFAULT_FILENAME = 'Barkfile'
11
11
  mode = nil
12
12
  file = DEFAULT_FILENAME
13
13
  output_file = '-'
14
+ MAGIC_COMMENT = <<-EOS
15
+ # -*- mode: ruby -*-
16
+ # vi: set ft=ruby :
17
+ EOS
14
18
 
15
19
  options = {
16
20
  :api_key => ENV['BARKDOG_API_KEY'],
@@ -69,7 +73,10 @@ begin
69
73
  puts client.export
70
74
  else
71
75
  logger.info("Export Datadog monitors to `#{output_file}`")
72
- open(output_file, 'wb') {|f| f.puts client.export }
76
+ open(output_file, 'wb') do |f|
77
+ f.puts MAGIC_COMMENT
78
+ f.puts client.export
79
+ end
73
80
  end
74
81
  when :apply
75
82
  unless File.exist?(file)
@@ -15,7 +15,7 @@ class Barkdog::Driver
15
15
  end
16
16
 
17
17
  unless @options[:dry_run]
18
- @dog.monitor(
18
+ _, response = @dog.monitor(
19
19
  attrs['type'],
20
20
  attrs['query'],
21
21
  :name => name,
@@ -23,6 +23,7 @@ class Barkdog::Driver
23
23
  :options => attrs['options']
24
24
  )
25
25
 
26
+ validate_response(response)
26
27
  updated = true
27
28
  end
28
29
 
@@ -34,7 +35,8 @@ class Barkdog::Driver
34
35
  log(:info, "Delete Monitor: #{name}", :color => :red)
35
36
 
36
37
  unless @options[:dry_run]
37
- @dog.delete_monitor(attrs['id'])
38
+ _, response = @dog.delete_monitor(attrs['id'])
39
+ validate_response(response)
38
40
  updated = true
39
41
  end
40
42
 
@@ -60,17 +62,31 @@ class Barkdog::Driver
60
62
  log(:info, diffy.to_s(@options[:color] ? :color : :text), :color => false)
61
63
 
62
64
  unless @options[:dry_run]
63
- @dog.update_monitor(
65
+ _, response = @dog.update_monitor(
64
66
  expected['id'],
65
67
  expected['query'],
66
68
  :name => name,
67
69
  :message => expected['message'],
68
70
  :options => expected['options']
69
71
  )
72
+
73
+ validate_response(response)
70
74
  updated = true
71
75
  end
72
76
  end
73
77
 
74
78
  updated
75
79
  end
80
+
81
+ private
82
+
83
+ def validate_response(response)
84
+ if response['warnings']
85
+ log(:warn, response['warnings'].join("\n"), :color => :yellow)
86
+ end
87
+
88
+ if response['errors']
89
+ raise response['errors'].join("\n")
90
+ end
91
+ end
76
92
  end
@@ -1,3 +1,3 @@
1
1
  module Barkdog
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -7,6 +7,7 @@ monitor "my metric check", :type=>"metric alert" do
7
7
  query "avg(last_5m):avg:datadog.dogstatsd.packet.count{*} > 1"
8
8
  message "metric check message"
9
9
  options do
10
+ locked false
10
11
  no_data_timeframe 2
11
12
  notify_audit false
12
13
  notify_no_data false
@@ -18,6 +19,7 @@ monitor "my service check", :type=>"service check" do
18
19
  query "\"datadog.agent.up\".over(\"*\").last(2).count_by_status()"
19
20
  message "service check message"
20
21
  options do
22
+ locked false
21
23
  no_data_timeframe 2
22
24
  notify_audit false
23
25
  notify_no_data true
@@ -47,6 +49,7 @@ template 'my metric check' do
47
49
  query "avg(last_5m):avg:datadog.dogstatsd.packet.count{*} > 1"
48
50
  message "metric check message"
49
51
  options do
52
+ locked false
50
53
  no_data_timeframe context.no_data_timeframe
51
54
  notify_audit false
52
55
  notify_no_data false
@@ -55,6 +58,7 @@ template 'my metric check' do
55
58
  end
56
59
 
57
60
  template "my service check options" do
61
+ locked false
58
62
  no_data_timeframe 2
59
63
  notify_audit false
60
64
  notify_no_data true
@@ -96,6 +100,7 @@ monitor "my metric check", :type=>"metric alert" do
96
100
  query "avg(last_5m):avg:datadog.dogstatsd.packet.count{*} > 2"
97
101
  message "metric check message2"
98
102
  options do
103
+ locked false
99
104
  no_data_timeframe 3
100
105
  notify_audit true
101
106
  notify_no_data true
@@ -107,6 +112,7 @@ monitor "my service check", :type=>"service check" do
107
112
  query "\"datadog.agent.up\".over(\"*\").last(3).count_by_status()"
108
113
  message "service check message2"
109
114
  options do
115
+ locked false
110
116
  no_data_timeframe 3
111
117
  notify_audit true
112
118
  notify_no_data true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barkdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-18 00:00:00.000000000 Z
11
+ date: 2016-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dogapi
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  version: '0'
162
162
  requirements: []
163
163
  rubyforge_project:
164
- rubygems_version: 2.4.5
164
+ rubygems_version: 2.4.5.1
165
165
  signing_key:
166
166
  specification_version: 4
167
167
  summary: Barkdog is a tool to manage Datadog monitors.