riemann-smith 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/riemann-smith +23 -14
- 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: 4e513e2a5d743c3065f035c53b2206b0aa30b7f1
|
4
|
+
data.tar.gz: 8d76647517a2059142b7308845903d40575bd2ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e9be2c0b8cb1e011ca50d82922fbe0c1227569da4b7c9875542e7c7aec213af57411700f7c256ab457b73dba2625705b41485acc0b7b026f1d9d8bd789ebd9f
|
7
|
+
data.tar.gz: a93f19496d1acc391622179a638fb303f0f9c20ea79f2137c194b3a98f866afe4477d9f9d33f56bd9abfbb0d4c706f94b93ab4bff1f5d30a6c994e905dd15955
|
data/bin/riemann-smith
CHANGED
@@ -13,7 +13,7 @@ class Smith::Riemann
|
|
13
13
|
include Smith::Commands::Common
|
14
14
|
include Smith::Logger
|
15
15
|
|
16
|
-
RIEMANN_SERVICE_NAME = "smith"
|
16
|
+
RIEMANN_SERVICE_NAME = "smith-agent"
|
17
17
|
|
18
18
|
def initialize
|
19
19
|
log_level :info
|
@@ -55,15 +55,24 @@ class Smith::Riemann
|
|
55
55
|
# Checks that the list of agents return from the list command matches
|
56
56
|
# the list of know agents and composes an appropriate alert.
|
57
57
|
def check(response)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
58
|
+
options[:group].map do |group|
|
59
|
+
begin
|
60
|
+
group_agents = options[:agents] + agent_group(group)
|
61
|
+
running_agents = parse_response(response)
|
62
|
+
|
63
|
+
group_agents.map do |agent_name|
|
64
|
+
if running_agents.has_key?(agent_name) && running_agents[agent_name].any? { |a| a[:state] == "running" && running?(a[:pid]) }
|
65
|
+
alert(agent_name, :running, "Agent running")
|
66
|
+
else
|
67
|
+
alert(agent_name, :critical, "Agent not running")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
rescue RuntimeError => e
|
71
|
+
pp e
|
72
|
+
alert("group #{group}", :critical, e.message)
|
73
|
+
options[:agents]
|
65
74
|
end
|
66
|
-
end
|
75
|
+
end.flatten
|
67
76
|
end
|
68
77
|
|
69
78
|
# Returns a Nested hash representing the running agents.
|
@@ -77,7 +86,7 @@ class Smith::Riemann
|
|
77
86
|
|
78
87
|
# Construct an alert messages
|
79
88
|
def alert(service, state, description)
|
80
|
-
{:tags => options[:tags], :service => service(service), :state => state(state), :description => description}.tap { |a| puts "#{a[:service]}: #{state(state)}" }
|
89
|
+
{:tags => options[:tags], :ttl => options[:ttl], :service => service(service), :state => state(state), :description => description}.tap { |a| puts "#{a[:service]}: #{state(state)}" }
|
81
90
|
end
|
82
91
|
|
83
92
|
# Return true if the given pid exists in the process table.
|
@@ -98,7 +107,7 @@ class Smith::Riemann
|
|
98
107
|
@options ||= begin
|
99
108
|
OptionParser.accept(Pathname) {|p,| Pathname.new(p) if p}
|
100
109
|
|
101
|
-
defaults = {:interval => 30, :timeout =>
|
110
|
+
defaults = {:interval => 30, :ttl => nil, :timeout => 11, :agents => [], :group => [], :tags => [], :host => 'localhost', :port => 5555, :agency_timeout => 60}
|
102
111
|
defaults.tap do |options|
|
103
112
|
parser = OptionParser.new do |opts|
|
104
113
|
opts.separator "\n"
|
@@ -107,15 +116,15 @@ class Smith::Riemann
|
|
107
116
|
opts.banner = "\nUsage: #{opts.program_name} OPTIONS"
|
108
117
|
opts.on_head "\n Periodically lists the running agents and sends the result to riemann."
|
109
118
|
|
119
|
+
opts.on("--ttl <i>", Integer, "TTL for events") { |t| options[:ttl] = t }
|
110
120
|
opts.on("--interval <i>", Integer, "Polling interval in seconds (default #{options[:interval]})") { |t| options[:interval] = t }
|
111
121
|
opts.on("--timeout <i>", Integer, "Agency timeout (default #{options[:timeout]})") { |t| options[:interval] = t }
|
112
122
|
opts.on("--host <s>", String, "Riemann host (default #{options[:host]})") { |v| options[:host] = v }
|
113
123
|
opts.on("--port <i>", Integer, "Riemann port (default #{options[:port]})") { |v| options[:port] = v }
|
114
124
|
opts.on("--tags <tag1,tag1,...>", Array, "Tags to add to the alert") { |t| options[:tags] = t }
|
125
|
+
|
115
126
|
opts.on("--agents <agent1,agent2,...>", Array, "Agents to monitor") { |v| options[:agents] + v }
|
116
|
-
opts.on("--agent-group <group name>>", Array, "The name of an 'agent group' to monitor")
|
117
|
-
options[:agents] += g.map { |g| agent_group(g) }.flatten
|
118
|
-
end
|
127
|
+
opts.on("--agent-group <group name>>", Array, "The name of an 'agent group' to monitor") { |g| options[:group] += g }
|
119
128
|
|
120
129
|
opts.separator "\n"
|
121
130
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riemann-smith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Heycock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smith
|