hotdog 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c02920ad489cbbbf48668151aa47add9a237cc07
4
- data.tar.gz: 135a3312a19650537706eac8d00e7ec27fe503bc
3
+ metadata.gz: c48e9eaacb1f78de73ba7c6cf882f1ab10a90929
4
+ data.tar.gz: 4b88ef42188785724daf2b04d0b414c1e2786753
5
5
  SHA512:
6
- metadata.gz: ad15864f8d0cb38904e9e377c8c416aa28432ab032d8c109161bffa578e165bb572165658f260a10f6eb50dee59ed950f5b647aec165767eace829c03f80d0f9
7
- data.tar.gz: 0b452f257046f22a261deada1cba9e53e6e7aec8ef60dcbdc43991c4dabcf567a38888a72215d7d50a5cd1d7dd838f45723f017a978991b75f8e7add94f99668
6
+ metadata.gz: 4527eb314f0021df8cb192a8a2073e04faf2bca3a469812b2d9b9858194144d097090fd5d5bba360486bb3b7f3aff159e810e2e5a3aa9e64ac11bc72a1901abe
7
+ data.tar.gz: 37acf83100cc8832714a19ce4c004cad21e095502b88295ba56faa64a2e8a6b06e83ba5fbf5c1b51fd96384321b7b3fc707f561011407279055238b19ff63d43
data/README.md CHANGED
@@ -33,7 +33,7 @@ Or,
33
33
 
34
34
  ```
35
35
  $ mkdir ~/.hotdog
36
- $ cat <<EOF
36
+ $ cat <<EOF > ~/.hotdog/config.yml
37
37
  ---
38
38
  api_key: abcdefghijklmnopqrstuvwxyzabcdef
39
39
  application_key: abcdefghijklmnopqrstuvwxyzabcdefghijklmn
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
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
4
- require "bundler/setup"
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)
@@ -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, result = @dog.all_tags()
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 (%s: ...)" % [code.inspect])
131
+ raise("dog.all_tags() returns [%s, ...]" % [code.inspect])
132
132
  end
133
133
 
134
- result["tags"].each do |tag, hosts|
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
- insert_or_ignore_into_hosts(memory_db, host_name)
140
- insert_or_replace_into_hosts_tags(memory_db, host_name, tag_name, tag_value)
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
 
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-12 00:00:00.000000000 Z
11
+ date: 2015-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler