hotdog 0.6.6 → 0.7.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/Rakefile +4 -0
- data/lib/hotdog/commands.rb +4 -3
- data/lib/hotdog/commands/down.rb +1 -1
- data/lib/hotdog/commands/pssh.rb +10 -1
- data/lib/hotdog/commands/ssh.rb +11 -9
- data/lib/hotdog/commands/up.rb +1 -1
- data/lib/hotdog/version.rb +1 -1
- 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: 5d906ae40a16258f5ad595603dd51cf64b503e46
|
4
|
+
data.tar.gz: 50186c1878f0de3534a4e7b8a502ce4380bbe2df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84a3883786cf631e1874fb39ed08c6475ee4ca293c8bca4d80ca6852191b8e59facfdbb7bcd3ca5ff3ed41632dae89620776986e6e03e9868e029ac796ec003c
|
7
|
+
data.tar.gz: ee613ad02480b125061011cbd80e05e60ca1716abd48242659552b8b3865ee083fcafca7733bf75eceaf2d2281f2b96403fa6d9e3c63f4a8c24c18b7407365f3
|
data/Rakefile
CHANGED
data/lib/hotdog/commands.rb
CHANGED
@@ -277,7 +277,7 @@ module Hotdog
|
|
277
277
|
logger.debug("execute: #{q} -- #{args.inspect}")
|
278
278
|
prepare(db, q).execute(args)
|
279
279
|
rescue
|
280
|
-
logger.
|
280
|
+
logger.warn("failed: #{q} -- #{args.inspect}")
|
281
281
|
raise
|
282
282
|
end
|
283
283
|
end
|
@@ -287,7 +287,8 @@ module Hotdog
|
|
287
287
|
requests = {all_downtime: "/api/v1/downtime", all_tags: "/api/v1/tags/hosts"}
|
288
288
|
query = URI.encode_www_form(api_key: options[:api_key], application_key: options[:application_key])
|
289
289
|
begin
|
290
|
-
|
290
|
+
parallelism = Parallel.processor_count
|
291
|
+
responses = Hash[Parallel.map(requests, in_threads: parallelism) { |name, request_path|
|
291
292
|
uri = URI.join(endpoint, "#{request_path}?#{query}")
|
292
293
|
begin
|
293
294
|
response = uri.open("User-Agent" => "hotdog/#{Hotdog::VERSION}") { |fp| fp.read }
|
@@ -304,7 +305,7 @@ module Hotdog
|
|
304
305
|
now = Time.new.to_i
|
305
306
|
downtimes = responses.fetch(:all_downtime, []).select { |downtime|
|
306
307
|
# active downtimes
|
307
|
-
downtime["active"] and ( downtime["start"].nil? or downtime["start"] < now ) and ( downtime["end"].nil? or now <= downtime["end"] )
|
308
|
+
downtime["active"] and ( downtime["start"].nil? or downtime["start"] < now ) and ( downtime["end"].nil? or now <= downtime["end"] ) and downtime["monitor_id"].nil?
|
308
309
|
}.flat_map { |downtime|
|
309
310
|
# find host scopes
|
310
311
|
downtime["scope"].select { |scope| scope.start_with?("host:") }.map { |scope| scope.sub(/\Ahost:/, "") }
|
data/lib/hotdog/commands/down.rb
CHANGED
@@ -33,8 +33,8 @@ module Hotdog
|
|
33
33
|
# Remove persistent.db to schedule update on next invocation
|
34
34
|
if @db
|
35
35
|
close_db(@db)
|
36
|
-
FileUtils.rm_f(File.join(options[:confdir], PERSISTENT_DB))
|
37
36
|
end
|
37
|
+
FileUtils.rm_f(File.join(options[:confdir], PERSISTENT_DB))
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/lib/hotdog/commands/pssh.rb
CHANGED
@@ -9,11 +9,20 @@ require "hotdog/commands/ssh"
|
|
9
9
|
module Hotdog
|
10
10
|
module Commands
|
11
11
|
class Pssh < SshAlike
|
12
|
+
def define_options(optparse, options={})
|
13
|
+
super
|
14
|
+
options[:show_identifier] = true
|
15
|
+
optparse.on("--[no-]identifier", "Each output line will be prepended with identifier.") do |identifier|
|
16
|
+
options[:show_identifier] = identifier
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
12
20
|
private
|
13
21
|
def run_main(hosts, options={})
|
14
22
|
stats = Parallel.map(hosts.each_with_index.to_a, in_threads: parallelism(hosts)) { |host, i|
|
15
23
|
cmdline = build_command_string(host, @remote_command, options)
|
16
|
-
|
24
|
+
identifier = options[:show_identifier] ? host : nil
|
25
|
+
exec_command(identifier, cmdline, index: i, output: true)
|
17
26
|
}
|
18
27
|
if stats.all?
|
19
28
|
exit(0)
|
data/lib/hotdog/commands/ssh.rb
CHANGED
@@ -162,15 +162,17 @@ module Hotdog
|
|
162
162
|
IO.popen(cmdline, in: :close, err: [:child, :out]) do |io|
|
163
163
|
io.each_with_index do |s, i|
|
164
164
|
if output
|
165
|
-
if
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
165
|
+
if identifier
|
166
|
+
if color
|
167
|
+
STDOUT.write("\e[0;#{color}m")
|
168
|
+
end
|
169
|
+
STDOUT.write(identifier)
|
170
|
+
STDOUT.write(":")
|
171
|
+
STDOUT.write(i.to_s)
|
172
|
+
STDOUT.write(":")
|
173
|
+
if color
|
174
|
+
STDOUT.write("\e[0m")
|
175
|
+
end
|
174
176
|
end
|
175
177
|
STDOUT.puts(s)
|
176
178
|
end
|
data/lib/hotdog/commands/up.rb
CHANGED
@@ -32,8 +32,8 @@ module Hotdog
|
|
32
32
|
# Remove persistent.db to schedule update on next invocation
|
33
33
|
if @db
|
34
34
|
close_db(@db)
|
35
|
-
FileUtils.rm_f(File.join(options[:confdir], PERSISTENT_DB))
|
36
35
|
end
|
36
|
+
FileUtils.rm_f(File.join(options[:confdir], PERSISTENT_DB))
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/hotdog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotdog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yamashita Yuu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|