backup 4.0.6 → 4.0.7

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: 92b075a8c0c4cd0cfb491b9eebe7a832a4bd4e0c
4
- data.tar.gz: 3f5d1f313497276ea43879502ad2729d74c417e9
3
+ metadata.gz: e7bc86c4dc89353c401df759462b0ba4348b707f
4
+ data.tar.gz: 3e08c40c56ec68a4dd60f7fa4f06f57d20f54965
5
5
  SHA512:
6
- metadata.gz: 43f674576dfddb1feefc4ffaf068b5994ac15949a12565c2c67e234383d2e6f8f946d9ffe70a6b5ccc9db75c7a94fe32aa508cf8e474b545be83f1e57a520203
7
- data.tar.gz: baffa3b4132cce710376518ae9e7af343077dbdadaf7eb1152aaefb870d9832b785c6c5da7d29c59879fb8fbee697529e74933c39e345e633d87ff93debcd4cc
6
+ metadata.gz: 3f2f379cfd4b36b326487b9688c15d9eafc2c99f3676482b7773a9c79bbbd123396bc44b4f2535bd4cf8a483b8ff07d20cbd7b16359485f12d805dbb435b1217
7
+ data.tar.gz: 97c930d5f9dc687948e85b3cd622b47763af7d4cb86eff7edecd4f59e52ed9a2c481f6659f261a8c755ffae83cb927cd35a8ee236b8bf91ce61f18e86b47b23e
data/README.md CHANGED
@@ -10,6 +10,8 @@ was built with modularity, extensibility and simplicity in mind.
10
10
 
11
11
  [Installation][] · [Release Notes][] · [Documentation][]
12
12
 
13
+ Please use the Backup features [issue tracker](https://github.com/meskyanichi/backup-features/issues) to suggest new features.
14
+ Only use the Backup gem [issue tracker](https://github.com/meskyanichi/backup/issues) for bugs and other issues.
13
15
 
14
16
  **Copyright (c) 2009-2014 [Michael van Rooijen][] ( [@meskyanichi][] )**
15
17
  Released under the **MIT** [License](LICENSE.md).
@@ -114,6 +114,7 @@ module Backup
114
114
  autoload :Nagios, File.join(NOTIFIER_PATH, 'nagios')
115
115
  autoload :FlowDock, File.join(NOTIFIER_PATH, 'flowdock')
116
116
  autoload :Zabbix, File.join(NOTIFIER_PATH, 'zabbix')
117
+ autoload :DataDog, File.join(NOTIFIER_PATH, 'datadog')
117
118
  end
118
119
 
119
120
  ##
@@ -0,0 +1,116 @@
1
+ # encoding: utf-8
2
+ require 'dogapi'
3
+
4
+ module Backup
5
+ module Notifier
6
+ class DataDog < Base
7
+
8
+ ##
9
+ # The DataDog API key
10
+ attr_accessor :api_key
11
+
12
+ ##
13
+ # The title of the event
14
+ attr_accessor :title
15
+
16
+ ##
17
+ # The text information for the event
18
+ attr_accessor :text
19
+
20
+ ##
21
+ # The timestamp for the event
22
+ attr_accessor :date_happened
23
+
24
+ ##
25
+ # The priority of the event (low/normal)
26
+ attr_accessor :priority
27
+
28
+ ##
29
+ # The host that generated the event
30
+ attr_accessor :host
31
+
32
+ ##
33
+ # The tags for this host (should be an array)
34
+ attr_accessor :tags
35
+
36
+ ##
37
+ # The alert_type of the event (error/warning/info/success)
38
+ attr_accessor :alert_type
39
+
40
+ ##
41
+ # The aggregation_key for the event
42
+ attr_accessor :aggregation_key
43
+
44
+ ##
45
+ # The source_type for the event (nagios, hudson, jenkins, user, my apps, feed, chef, puppet, git, bitbucket, fabric, capistrano)
46
+ attr_accessor :source_type_name
47
+
48
+ def initialize(model, &block)
49
+ super
50
+ instance_eval(&block) if block_given?
51
+
52
+ @title ||= default_title
53
+ @text ||= default_text
54
+ end
55
+
56
+ private
57
+
58
+ ##
59
+ # Notify the user of the backup operation results.
60
+ #
61
+ # `status` indicates one of the following:
62
+ #
63
+ # `:success`
64
+ # : The backup completed successfully.
65
+ # : Notification will be sent if `on_success` is `true`.
66
+ #
67
+ # `:warning`
68
+ # : The backup completed successfully, but warnings were logged.
69
+ # : Notification will be sent if `on_warning` or `on_success` is `true`.
70
+ #
71
+ # `:failure`
72
+ # : The backup operation failed.
73
+ # : Notification will be sent if `on_warning` or `on_success` is `true`.
74
+ #
75
+ def notify!(status)
76
+ hash = {alert_type: default_alert_type(status)}
77
+ hash.store(:msg_title, @title)
78
+ hash.store(:date_happened, @date_happened) if @date_happened
79
+ hash.store(:priority, @priority) if @priority
80
+ hash.store(:host, @host) if @host
81
+ hash.store(:tags, @tags) if @tags
82
+ hash.store(:aggregation_key, @aggregation_key) if @aggregation_key
83
+ hash.store(:source_type_name, @source_type_name) if @source_type_name
84
+ hash.store(:alert_type, @alert_type) if @alert_type
85
+ send_event(hash)
86
+ end
87
+
88
+ # Dogapi::Client will raise an error if unsuccessful.
89
+ def send_event(hash)
90
+ client = Dogapi::Client.new(@api_key)
91
+ event = Dogapi::Event.new(@text, hash)
92
+ client.emit_event(event)
93
+ end
94
+
95
+ # set alert type
96
+ def default_alert_type(status)
97
+ case status
98
+ when :success then 'success'
99
+ when :warning then 'warning'
100
+ when :failure then 'error'
101
+ end
102
+ end
103
+
104
+ # set default title
105
+ def default_title
106
+ "Backup #{ model.label }"
107
+ end
108
+
109
+ # set default text
110
+ def default_text
111
+ "Backup Notification for #{ model.label }"
112
+ end
113
+
114
+ end
115
+ end
116
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Backup
4
- VERSION = '4.0.6'
4
+ VERSION = '4.0.7'
5
5
  end
@@ -0,0 +1,57 @@
1
+ ##
2
+ # DataDog [Notifier]
3
+ #
4
+ notify_by DataDog do |datadog|
5
+ datadog.on_success = true
6
+ datadog.on_warning = true
7
+ datadog.on_failure = true
8
+
9
+ datadog.api_key = 'my_api_key'
10
+
11
+ ##
12
+ # Optional
13
+ #
14
+ # Override Default Title
15
+ # Default is: "Backup #{:label}"
16
+ # datadog.title = "Backup #{:status}"
17
+ #
18
+ # Override Default Text
19
+ # Default is "Backup Notification for #{:label}"
20
+ # datadog.text = "Backup #{:status} - #{:message}"
21
+ #
22
+ # Provide a hostname to associate this backup to
23
+ # Default is nil
24
+ # datadog.host = 'db.example.com'
25
+ #
26
+ # Add Tags to the Event
27
+ # Default is nil
28
+ # valid option is an Array
29
+ # datadog.tags = ['backup', 'env:production']
30
+ #
31
+ # Override the Alert Type
32
+ # Default is based on the :status of the backup:
33
+ # :success => 'success'
34
+ # :warning => 'warning'
35
+ # :failure => 'error'
36
+ # valid options are: 'info', 'success', 'warning', 'error'
37
+ # datadog.alert_type = 'info'
38
+ #
39
+ # Add a Source Type
40
+ # Default is nil
41
+ # see api docs for valid source_type_names
42
+ # datadog.source_type_name = 'my apps'
43
+ #
44
+ # Override the Priority Level
45
+ # Default is 'normal'
46
+ # valid options are: 'normal' or 'low'
47
+ # datadog.priority = 'low'
48
+ #
49
+ # Override the Event Time (must be a unix Timestamp)
50
+ # Default is Time.now.to_i
51
+ # datadog.date_happened = Time.now.to_i
52
+ #
53
+ # Add an Aggregation Key
54
+ # Default is nil
55
+ # max length allowed is 100 characters
56
+ # datadog.aggregation_key = 'my_aggregation'
57
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.6
4
+ version: 4.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van Rooijen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-13 00:00:00.000000000 Z
11
+ date: 2014-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.0.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: dogapi
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.11.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.11.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: dropbox-sdk
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -606,6 +620,7 @@ files:
606
620
  - lib/backup/model.rb
607
621
  - lib/backup/notifier/base.rb
608
622
  - lib/backup/notifier/campfire.rb
623
+ - lib/backup/notifier/datadog.rb
609
624
  - lib/backup/notifier/flowdock.rb
610
625
  - lib/backup/notifier/hipchat.rb
611
626
  - lib/backup/notifier/http_post.rb
@@ -661,6 +676,7 @@ files:
661
676
  - templates/cli/model
662
677
  - templates/cli/notifier/zabbix
663
678
  - templates/cli/notifiers/campfire
679
+ - templates/cli/notifiers/datadog
664
680
  - templates/cli/notifiers/flowdock
665
681
  - templates/cli/notifiers/hipchat
666
682
  - templates/cli/notifiers/http_post