hotdog 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/hotdog +5 -2
- data/lib/hotdog/commands.rb +27 -5
- 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: c48e9eaacb1f78de73ba7c6cf882f1ab10a90929
|
4
|
+
data.tar.gz: 4b88ef42188785724daf2b04d0b414c1e2786753
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4527eb314f0021df8cb192a8a2073e04faf2bca3a469812b2d9b9858194144d097090fd5d5bba360486bb3b7f3aff159e810e2e5a3aa9e64ac11bc72a1901abe
|
7
|
+
data.tar.gz: 37acf83100cc8832714a19ce4c004cad21e095502b88295ba56faa64a2e8a6b06e83ba5fbf5c1b51fd96384321b7b3fc707f561011407279055238b19ff63d43
|
data/README.md
CHANGED
data/bin/hotdog
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
## bundler/setup doesn't work expectedly when installed via gem
|
5
|
+
#ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
|
6
|
+
#require "bundler/setup"
|
7
|
+
|
5
8
|
require "hotdog/application"
|
6
9
|
dog = Hotdog::Application.new
|
7
10
|
dog.main(ARGV.dup)
|
data/lib/hotdog/commands.rb
CHANGED
@@ -125,19 +125,41 @@ module Hotdog
|
|
125
125
|
create_table_hosts_tags(memory_db)
|
126
126
|
create_index_hosts_tags(memory_db)
|
127
127
|
|
128
|
-
code,
|
128
|
+
code, all_tags = @dog.all_tags()
|
129
129
|
logger.debug("dog.all_tags() #==> [%s, ...]" % [code.inspect])
|
130
130
|
if code.to_i / 100 != 2
|
131
|
-
raise("dog.all_tags() returns
|
131
|
+
raise("dog.all_tags() returns [%s, ...]" % [code.inspect])
|
132
132
|
end
|
133
133
|
|
134
|
-
|
134
|
+
code, all_downtimes = @dog.get_all_downtimes()
|
135
|
+
logger.debug("dog.get_all_downtimes() #==> [%s, ...]" % [code.inspect])
|
136
|
+
if code.to_i / 100 != 2
|
137
|
+
raise("dog.get_all_downtimes() returns [%s, ...]" % [code.inspect])
|
138
|
+
end
|
139
|
+
|
140
|
+
now = Time.new.to_i
|
141
|
+
downs = all_downtimes.select { |downtime|
|
142
|
+
# active downtimes
|
143
|
+
downtime["active"] and ( downtime["start"].nil? or downtime["start"] < now ) and ( downtime["end"].nil? or now <= downtime["end"] )
|
144
|
+
}.map { |downtime|
|
145
|
+
# find host scopes
|
146
|
+
downtime["scope"].select { |scope| scope.start_with?("host:") }.map { |scope| scope.sub(/\Ahost:/, "") }
|
147
|
+
}.reduce(:+)
|
148
|
+
downs ||= []
|
149
|
+
|
150
|
+
if not downs.empty?
|
151
|
+
logger.info("ignore host(s) with scheduled downtimes: #{downs.inspect}")
|
152
|
+
end
|
153
|
+
|
154
|
+
all_tags["tags"].each do |tag, hosts|
|
135
155
|
tag_name, tag_value = tag.split(":", 2)
|
136
156
|
tag_value ||= ""
|
137
157
|
insert_or_ignore_into_tags(memory_db, tag_name, tag_value)
|
138
158
|
hosts.each do |host_name|
|
139
|
-
|
140
|
-
|
159
|
+
if not downs.include?(host_name)
|
160
|
+
insert_or_ignore_into_hosts(memory_db, host_name)
|
161
|
+
insert_or_replace_into_hosts_tags(memory_db, host_name, tag_name, tag_value)
|
162
|
+
end
|
141
163
|
end
|
142
164
|
end
|
143
165
|
|
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.1.
|
4
|
+
version: 0.1.1
|
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-01-
|
11
|
+
date: 2015-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|