garrison-api 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d52efa6a09a8a881d20599de7d28e0122a1218d
4
- data.tar.gz: c83a8ab3ab6b15a84d985c699f368f7ec17452db
3
+ metadata.gz: 4cead380d4865c8837421eed9cd827c932176ef9
4
+ data.tar.gz: 92840e7011c346878af415469f4c5a7842d03977
5
5
  SHA512:
6
- metadata.gz: 794ba747e079161641e4b6130d1fa51d5a8576426163d0eede3cbcb8baac7c7a0253995c4c079c32492c004e5a08e060f044c2fb9fc1aeb51df6005daf9e8a6c
7
- data.tar.gz: d1ce95a143cecda8b3d13e5b95587c825d8a9e4c2185d33da54bdabd4aff8be9775e9752215bd7afbad2b4f8626a125ace3d620cc27ce526af58838796e819e3
6
+ metadata.gz: d788ed1f3ceae53b2b425f17f18103f41c5f993dbaa865e9f010492e6dc30c942ecce50c1760d2f32bc152480355b0a932e7f3ac82b35f326e5cefd8bdca0a2c
7
+ data.tar.gz: 69c6392fc90c1c2ed9c0da63b627a902b0df9eaf93a7803fdbd9e4085b383a9c105fc8cf4cf133b636c1bafb73bc2dd231240618a710513796bd6785726e4093
@@ -1,13 +1,15 @@
1
1
  module Garrison
2
- module Agents
2
+ module Checks
3
3
  class Check
4
4
 
5
+ attr_accessor :source
5
6
  attr_accessor :severity
6
7
  attr_accessor :family
7
8
  attr_accessor :type
8
9
  attr_accessor :options
9
10
 
10
11
  def initialize(options = {})
12
+ @source = ENV['GARRISON_ALERT_SOURCE']
11
13
  @severity = ENV['GARRISON_ALERT_SEVERITY']
12
14
  @type = ENV['GARRISON_ALERT_TYPE']
13
15
  @family = ENV['GARRISON_ALERT_FAMILY']
@@ -15,7 +17,7 @@ module Garrison
15
17
 
16
18
  Logging.info "Starting... #{self.class.name}"
17
19
  inherit_settings
18
- Logging.info "Agent Settings (severity=#{self.severity} type=#{self.type} family=#{self.family})"
20
+ Logging.info "Agent Settings (source=#{self.source} severity=#{self.severity} type=#{self.type} family=#{self.family})"
19
21
 
20
22
  options_log = options.map do |key, value|
21
23
  value = value.is_a?(Array) ? value.join(',') : value
@@ -25,7 +27,11 @@ module Garrison
25
27
  end
26
28
 
27
29
  def perform
28
- raise 'You must override this method'
30
+ raise 'You must provide a perform method in your check class'
31
+ end
32
+
33
+ def key_values
34
+ []
29
35
  end
30
36
 
31
37
  def alert(name:, target:, detail:, finding:, finding_id:, urls: [], key_values: [])
@@ -34,7 +40,7 @@ module Garrison
34
40
  alert = Api::Alert.new
35
41
  alert.type = type
36
42
  alert.family = family
37
- alert.source = 'aws-rds'
43
+ alert.source = source
38
44
 
39
45
  alert.name = name
40
46
  alert.target = target
@@ -46,11 +52,7 @@ module Garrison
46
52
  alert.detected_at = Time.now.utc
47
53
 
48
54
  alert.urls = urls
49
-
50
- alert.key_values = key_values
51
- alert.key_values << { key: 'datacenter', value: 'aws' }
52
- alert.key_values << { key: 'aws-service', value: 'rds' }
53
- alert.key_values << { key: 'aws-account', value: AwsHelper.whoami.account }
55
+ alert.key_values = (self.key_values + key_values).uniq { |h| h[:key] }
54
56
 
55
57
  alert.save
56
58
  end
@@ -1,5 +1,5 @@
1
1
  module Garrison
2
2
  module Api
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garrison-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Forward3D Developers