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.
- checksums.yaml +4 -4
- data/bin/smith-datadog +14 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41640d80038b9cb4159cd19eaec1ef8fef4e88ac
|
4
|
+
data.tar.gz: 0d9e37b306a27cb21b0a92df3b6fb64afc5bc6a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 = "
|
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 |
|
25
|
-
|
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 |
|
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
|
-
{
|
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}
|
112
|
+
"#{SERVICE_NAME.downcase}.#{name.to_s.underscore}"
|
106
113
|
end
|
107
114
|
|
108
115
|
def state(state)
|
109
|
-
{:timeout =>
|
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.
|
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
|
+
date: 2016-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: smith
|