smith-datadog 0.7.2 → 0.7.3

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/smith-datadog +14 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba11bf20d379770b3c2e176d83a0d1257c6a3ca7
4
- data.tar.gz: 5fa91ac9777e6ba7488a6dcfc5e2a5a1a67f28b6
3
+ metadata.gz: 41640d80038b9cb4159cd19eaec1ef8fef4e88ac
4
+ data.tar.gz: 0d9e37b306a27cb21b0a92df3b6fb64afc5bc6a5
5
5
  SHA512:
6
- metadata.gz: 26aa348d8a9f8b79c46497852f4af48b742e287f139626cd5881d9b581d159e9bd1cd0e72624d74de3e12d70dc3874e99ac3a2cadc98cbb89cc50d1a49b39de8
7
- data.tar.gz: 0f50cce864a9bfb3e26cafc0b14639c66064416486e3e7ec19de6b73fead962e7bf82577f6431cafea9cf387dc3609c5505cfbaf64e0d4fba9661b47d4e72c32
6
+ metadata.gz: f0bc4064523666f54ec42fa0d9f464d22f56db3d95f1cdbd59300f1263af6db713e150b7f6b32611db1ecd906c1aa3649fdf4824fdb37bc0e6bb60a786bb9f86
7
+ data.tar.gz: 0be95ccd1e844c223c1e6bcf84e6fd1f29e2a6887c745aa4e0910ab2865eb0a8d2a99889b12498ac64934c1763062497e905af6f672972c0bcb1224794cf6d58
data/bin/smith-datadog CHANGED
@@ -4,6 +4,7 @@ require 'pp'
4
4
  require 'dogapi'
5
5
  require 'sys/proctable'
6
6
 
7
+ require 'active_support/inflector'
7
8
  require 'smith'
8
9
  require 'smith/commands/common'
9
10
 
@@ -12,7 +13,7 @@ class Smith::Datadog
12
13
  include Smith::Commands::Common
13
14
  include Smith::Logger
14
15
 
15
- SERVICE_NAME = "Smith"
16
+ SERVICE_NAME = "smith.agent"
16
17
  API_KEY = ENV.fetch('DATADOG_API_KEY')
17
18
 
18
19
  def initialize
@@ -21,11 +22,13 @@ class Smith::Datadog
21
22
 
22
23
  def run
23
24
  Smith::Messaging::Sender.new(Smith::QueueDefinitions::Agency_control.call) do |queue|
24
- on_check do |check|
25
- @datadog.emit_event(Dogapi::Event.new(check[:description], check))
25
+ on_check do |c|
26
+ logger.debug { options.inspect }
27
+ logger.debug { c.inspect }
28
+ @datadog.service_check(SERVICE_NAME, options[:host], c[:alert_type], :message => c[:description], :tags => ["agent:#{c[:service]}"])
26
29
  end
27
30
 
28
- queue.on_error do |channel, channel_close|
31
+ queue.on_error do |_, channel_close|
29
32
  logger.fatal { "Channel error: #{channel_close.reply_code}: #{channel_close.reply_text}." }
30
33
  Smith.stop
31
34
  end
@@ -92,7 +95,11 @@ class Smith::Datadog
92
95
 
93
96
  # Construct an alert messages
94
97
  def alert(service, state, description, extra={})
95
- {:source_type_name => 'name', :description => description, :alert_type => 'info', :source_type_name => SERVICE_NAME, :msg_title => "#{service} #{description}", :aggregation_key => service(service)}.merge(extra).tap { |a| logger.info { "#{a[:service]}: #{state(state)}" } }
98
+ {
99
+ :service => service(service),
100
+ :description => description,
101
+ :alert_type => state(state),
102
+ }.merge(extra).tap { |a| logger.info { "#{a[:service]}: #{state(state)}" } }
96
103
  end
97
104
 
98
105
  # Return true if the given pid exists in the process table.
@@ -102,11 +109,11 @@ class Smith::Datadog
102
109
 
103
110
  # Return the service name
104
111
  def service(name)
105
- "#{SERVICE_NAME} #{name}"
112
+ "#{SERVICE_NAME.downcase}.#{name.to_s.underscore}"
106
113
  end
107
114
 
108
115
  def state(state)
109
- {:timeout => "warning", :running => "info", :critical => "error"}[state]
116
+ {:timeout => 1, :running => 0, :critical => 2}[state]
110
117
  end
111
118
 
112
119
  def options
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smith-datadog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Heycock
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-12 00:00:00.000000000 Z
12
+ date: 2016-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: smith