deckard 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -15,10 +15,13 @@ Features:
15
15
  * Alert priorities (log, email, SMS and notifo)
16
16
  * Simple setup via cron
17
17
  * Basic scheduling to silence alerts
18
+ * Adjustable delay before firing check content requests
18
19
 
19
20
  Usage:
20
21
 
21
- $ deckard ./deckard.yml
22
+ $ deckard --all ./deckard.yml
23
+
24
+ You now have the option of running --all, --failover, --content, --replication if you only want to run a subset of checks
22
25
 
23
26
  Setup:
24
27
 
@@ -26,7 +29,7 @@ Setup:
26
29
  * Create a crontab entry
27
30
 
28
31
  $ crontab -e
29
- */5 * * * * deckard /path/deckard.yml &> /dev/null
32
+ */5 * * * * deckard --all /path/deckard.yml &> /dev/null
30
33
 
31
34
 
32
35
  Example documents:
@@ -0,0 +1,33 @@
1
+ defaults:
2
+ email_to: "joe@cloudant.com"
3
+ email_from: "joe@cloudant.com"
4
+ email_host: "localhost"
5
+ db_user:
6
+ db_password:
7
+ db_host: "localhost"
8
+ db_port: "5984"
9
+ on_call_db: "monitor_on_call"
10
+ on_call_doc: "on_call_person"
11
+ log_file: "./log"
12
+
13
+ content_check:
14
+ retry_count: 1
15
+ retry_interval: 5
16
+ db: "monitor_content_check"
17
+ delay: false
18
+ delay_upper_bound: 10
19
+
20
+ fo_check:
21
+ retry_count: 1
22
+ aws_key: "AKIAIZU26DXCWA2EHUSA"
23
+ aws_secret: "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"
24
+ db: "monitor_fo_check"
25
+
26
+ rep_check:
27
+ doc_behind_threshold: 5000
28
+ doc_ahead_threshold: -100
29
+ db: "monitor_rep_check"
30
+
31
+ notifo:
32
+ user: "username"
33
+ apikey: "password"
@@ -14,6 +14,8 @@ content_check:
14
14
  retry_count: 1
15
15
  retry_interval: 5
16
16
  db: "monitor_content_check"
17
+ delay: false
18
+ delay_upper_bound: 10
17
19
 
18
20
  fo_check:
19
21
  retry_count: 1
@@ -28,4 +30,4 @@ rep_check:
28
30
 
29
31
  notifo:
30
32
  user: "username"
31
- apikey: "password"
33
+ apikey: "password"
@@ -30,6 +30,8 @@ class Deckard
30
30
  def self.content_check
31
31
  retry_count = Deckard::Config.content_check_retry
32
32
  db_name = Deckard::Config.content_check_db
33
+ delay = Deckard::Config.content_check_delay
34
+ upper_bound = Deckard::Config.content_check_delay_upper_bound
33
35
  list = Array.new
34
36
 
35
37
  nodes = Deckard::Util.get_nodes(db_name)
@@ -38,6 +40,9 @@ class Deckard
38
40
  run = Thread.new {
39
41
  Deckard::Monitor.content_check(node["url"], node["content"], node["priority"], retry_count, node["schedule"])
40
42
  }
43
+ if delay
44
+ sleep(rand(upper_bound))
45
+ end
41
46
  list << run
42
47
  end
43
48
 
@@ -90,9 +95,18 @@ class Deckard
90
95
  def self.main
91
96
  list = Array.new
92
97
 
93
- list << Thread.new { content_check }
94
- list << Thread.new { rep_check }
95
- list << Thread.new { fo_check }
98
+ case ARGV[0]
99
+ when "--all"
100
+ list << Thread.new { content_check }
101
+ list << Thread.new { rep_check }
102
+ list << Thread.new { fo_check }
103
+ when "--content"
104
+ list << Thread.new { content_check }
105
+ when "--replication"
106
+ list << Thread.new { rep_check }
107
+ when "--failover"
108
+ list << Thread.new { fo_check }
109
+ end
96
110
 
97
111
  list.each { |x|
98
112
  x.join
@@ -1,6 +1,6 @@
1
1
  class Deckard
2
2
  class Config
3
- monitor_config = YAML.load(File.open(ARGV[0]))
3
+ monitor_config = YAML.load(File.open(ARGV[1]))
4
4
  extend Mixlib::Config
5
5
  configure do |c|
6
6
  c[:email_to] = monitor_config["defaults"]["email_to"]
@@ -17,6 +17,8 @@ class Deckard
17
17
  c[:content_check_retry] = monitor_config["content_check"]["retry_count"]
18
18
  c[:content_check_retry_interval] = monitor_config["content_check"]["retry_interval"]
19
19
  c[:content_check_db] = monitor_config["content_check"]["db"]
20
+ c[:content_check_delay] = monitor_config["content_check"]["delay"]
21
+ c[:content_check_delay_upper_bound] = monitor_config["content_check"]["delay_upper_bound"]
20
22
 
21
23
  c[:fo_check_retry] = monitor_config["fo_check"]["retry_count"]
22
24
  c[:aws_key] = monitor_config["fo_check"]["aws_key"]
@@ -66,16 +66,17 @@ class Deckard
66
66
  Deckard::Util.alert(priority, subject, body, log, schedule, "http://#{elastic_ip}")
67
67
 
68
68
  instance_id = Deckard::Ec2.get_association(region, elastic_ip)
69
-
70
- if Deckard::Ec2.disassociate_address(region, elastic_ip) == "true"
71
- Deckard::Log.info("ALERT :: Disassociated #{elastic_ip}")
72
- else
73
- Deckard::Log.info("ALERT :: Could not disassociate #{elastic_ip}")
74
- Deckard::Util.alert(priority, "ALERT :: Could not disassociate #{elastic_ip}", "ALERT :: Could not disassociate #{elastic_ip}", log, schedule, "http://#{elastic_ip}")
75
- end
69
+
70
+ if Deckard::Ec2.disassociate_address(region, elastic_ip)
71
+ Deckard::Log.info("ALERT :: Disassociated #{elastic_ip}")
72
+ else
73
+ Deckard::Log.info("ALERT :: Could not disassociate #{elastic_ip}")
74
+ Deckard::Util.alert(priority, "ALERT :: Could not disassociate #{elastic_ip}", "ALERT :: Could not disassoci
75
+ ate #{elastic_ip}", log, schedule, "http://#{elastic_ip}")
76
+ end
76
77
 
77
78
  if instance_id == primary_instance_id
78
- if Deckard::Ec2.associate_address(region, secondary_instance_id, elastic_ip) == "true"
79
+ if Deckard::Ec2.associate_address(region, secondary_instance_id, elastic_ip)
79
80
  info = "ALERT :: associated #{elastic_ip} to #{secondary_instance_id}"
80
81
  Deckard::Log.info("ALERT :: associated #{elastic_ip} to #{secondary_instance_id}")
81
82
  subject = "ALERT :: Failover Complete for #{elastic_ip} #{secondary_instance_id}"
@@ -88,7 +89,7 @@ class Deckard
88
89
  end
89
90
 
90
91
  elsif instance_id == secondary_instance_id
91
- if Deckard::Ec2.associate_address(region, primary_instance_id, elastic_ip) == "true"
92
+ if Deckard::Ec2.associate_address(region, primary_instance_id, elastic_ip)
92
93
  info = "ALERT :: associated #{elastic_ip} to #{secondary_instance_id}"
93
94
  Deckard::Log.info("ALERT :: associated #{elastic_ip} to #{secondary_instance_id}")
94
95
  subject = "ALERT :: Failover Complete for #{elastic_ip} #{secondary_instance_id}"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 7
9
- version: 0.5.7
8
+ - 8
9
+ version: 0.5.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - joe williams
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-05 00:00:00 -07:00
17
+ date: 2010-09-09 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -119,6 +119,7 @@ files:
119
119
  - lib/deckard/monitoring.rb
120
120
  - lib/deckard/util.rb
121
121
  - lib/deckard.rb
122
+ - config/deckard-test.yml
122
123
  - config/deckard.yml
123
124
  - README
124
125
  has_rdoc: true