sensu-plugins-telegram 0.2.0 → 2.0.0

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: b27c66b68f1ee795b6aa43157a5fd6f41d215582
4
- data.tar.gz: d5819eb9b5e000459f20265a4e4e60461ccee9da
3
+ metadata.gz: 09754171b52d9639979e84af89669724a25b2201
4
+ data.tar.gz: cb6efb45c3df09c5e6b00c1282727392090219b8
5
5
  SHA512:
6
- metadata.gz: 7a27771ac2da30b8a25a711777c6450d605876c73c8cd586af2ed7b99d469f433744fa5caf98cc78ed6b40d866e337357f93e4ead52937c328b53242aa19b36a
7
- data.tar.gz: c104cab7aa44ec827173e55fe3f087a8820637519824f88973057da4dc576a8f3a51a9798ff67037b8c16a6b1918ccf20376b968e2d889e1a18ca9d03e9c9c42
6
+ metadata.gz: 3e2309858f57f29e237eefef9b7faf04431afc84b24f594ac44baad1925740577ef9b839371fc2efe9d13e3d561fba1c001b2bae61f4e353cabfaebed4e032c0
7
+ data.tar.gz: 0a4a10e1eb1a52481d7591b6548c28dd9c43ebbe0e45019955df67dd8722b584238ed6528c234de148b17491403c14f99446c2cf8d1c43385fc98b1e166fc61b
@@ -1,9 +1,48 @@
1
- #Change Log
1
+ # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
6
  ## [Unreleased]
7
+ ## [2.0.0] - 2017-05-30
8
+ ### Breaking Change
9
+ - removed ruby 1.9x support
10
+
11
+ ### Changed
12
+ - updated authors, email, homepage in .gemspec
13
+ - misc repo cleanup
14
+
15
+ ## [1.0.1] - 2017-05-29
16
+ ### Changed
17
+ - just fixing the ruby api key in .travis.yml for rubygems
18
+
19
+ ## [1.0.0] - 2017-05-29
20
+ ### Added
21
+ - Support for custom message erb templates
22
+
23
+ ## [0.2.0] - 2016-03-23
24
+ ### Added
25
+ - Emojis!
26
+ - The json_config command line option, which lets you specify custom configs
27
+ for different handlers.
28
+ - the bot_token and error_file_location settings can also be specified
29
+ directly in the event data.
30
+
31
+ ### Fixed
32
+ - Correctly escape HTML entities, so that the TG API doesn't barf at invalid
33
+ HTML.
34
+
35
+ ## [0.1.1] - 2016-03-18
36
+ ### Changed
37
+ - Depend on sensu-plugin ~> 1.1 instead of ~> 1.2.
38
+
7
39
  ## 0.1.0 - 2016-03-18
8
40
  ### Added
9
41
  - Initial release
42
+
43
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-telegram/compare/2.0.0...HEAD
44
+ [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-telegram/compare/1.0.1...2.0.0
45
+ [1.0.1]: https://github.com/sensu-plugins/sensu-plugins-telegram/compare/1.0.0...1.0.1
46
+ [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-telegram/compare/v0.2.0...1.0.0
47
+ [0.2.0]: https://github.com/sensu-plugins/sensu-plugins-telegram/compare/v0.1.1...v0.2.0
48
+ [0.1.1]: https://github.com/sensu-plugins/sensu-plugins-telegram/compare/v0.1.0...v0.1.1
data/README.md CHANGED
@@ -1,10 +1,8 @@
1
1
  ## Sensu-Plugins-telegram
2
2
 
3
- <!-- [ ![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-campfire.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-campfire)
4
- [![Gem Version](https://badge.fury.io/rb/sensu-plugins-campfire.svg)](http://badge.fury.io/rb/sensu-plugins-campfire)
5
- [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-campfire/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-campfire)
6
- [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-campfire/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-campfire)
7
- [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-campfire.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-campfire) -->
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-telegram.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-telegram)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-telegram.svg)](http://badge.fury.io/rb/sensu-plugins-telegram)
5
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-telegram.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-telegram)
8
6
 
9
7
  ## Functionality
10
8
 
@@ -51,6 +49,18 @@ This gem also expects a JSON configuration file with the following contents:
51
49
  message to Telegram (ie. connectivity issues), the exception mesage will
52
50
  be written to a file in this location. You can then monitor this
53
51
  location to detect any errors with the Telegram handler.
52
+ - `message_template` (optional): An ERB template to use to format messages
53
+ instead of the default. Supports the following variables:
54
+ - `action_name`
55
+ - `action_icon`
56
+ - `client_name`
57
+ - `check_name`
58
+ - `status`
59
+ - `status_icon`
60
+ - `output`
61
+ - `message_template_file` (optional): A file to read an ERB template from to
62
+ format messages. Supports the same variables as `message_template`.
63
+
54
64
 
55
65
  ### Advanced configuration
56
66
 
@@ -39,6 +39,7 @@ require 'rubygems' if RUBY_VERSION < '1.9.0'
39
39
  require 'sensu-handler'
40
40
  require 'restclient'
41
41
  require 'cgi'
42
+ require 'erb'
42
43
 
43
44
  class TelegramHandler < Sensu::Handler
44
45
  option :json_config,
@@ -110,12 +111,26 @@ class TelegramHandler < Sensu::Handler
110
111
  end
111
112
 
112
113
  def build_message
114
+ template_file = fetch_setting 'message_template_file'
115
+ if !template_file.nil?
116
+ template = File.read(template_file)
117
+ else
118
+ template = fetch_setting 'message_template'
119
+ template ||= default_message
120
+ end
121
+
122
+ message = ERB.new(template).result(binding)
123
+
124
+ message
125
+ end
126
+
127
+ def default_message
113
128
  [
114
- "<b>Alert #{action_name}</b> #{action_icon}",
115
- "<b>Host:</b> #{client_name}",
116
- "<b>Check:</b> #{check_name}",
117
- "<b>Status:</b> #{status} #{status_icon}",
118
- "<b>Output:</b> <code>#{output}</code>"
129
+ '<b>Alert <%= action_name %></b> <%= action_icon %>',
130
+ '<b>Host:</b> <%= client_name %>',
131
+ '<b>Check:</b> <%= check_name %>',
132
+ '<b>Status:</b> <%= status %> <%= status_icon %>',
133
+ '<b>Output:</b> <code><%= output %></code>'
119
134
  ].join("\n")
120
135
  end
121
136
 
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsTelegram
2
2
  module Version
3
- MAJOR = 0
4
- MINOR = 2
3
+ MAJOR = 2
4
+ MINOR = 0
5
5
  PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-telegram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hernan Schmidt
8
+ - Sensu-Plugins and contributors
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-03-22 00:00:00.000000000 Z
12
+ date: 2017-05-31 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: sensu-plugin
@@ -100,14 +101,14 @@ dependencies:
100
101
  requirements:
101
102
  - - "~>"
102
103
  - !ruby/object:Gem::Version
103
- version: '10.0'
104
+ version: '10.5'
104
105
  type: :development
105
106
  prerelease: false
106
107
  version_requirements: !ruby/object:Gem::Requirement
107
108
  requirements:
108
109
  - - "~>"
109
110
  - !ruby/object:Gem::Version
110
- version: '10.0'
111
+ version: '10.5'
111
112
  - !ruby/object:Gem::Dependency
112
113
  name: redcarpet
113
114
  requirement: !ruby/object:Gem::Requirement
@@ -126,30 +127,30 @@ dependencies:
126
127
  name: rubocop
127
128
  requirement: !ruby/object:Gem::Requirement
128
129
  requirements:
129
- - - '='
130
+ - - "~>"
130
131
  - !ruby/object:Gem::Version
131
- version: 0.37.0
132
+ version: 0.40.0
132
133
  type: :development
133
134
  prerelease: false
134
135
  version_requirements: !ruby/object:Gem::Requirement
135
136
  requirements:
136
- - - '='
137
+ - - "~>"
137
138
  - !ruby/object:Gem::Version
138
- version: 0.37.0
139
+ version: 0.40.0
139
140
  - !ruby/object:Gem::Dependency
140
141
  name: rspec
141
142
  requirement: !ruby/object:Gem::Requirement
142
143
  requirements:
143
144
  - - "~>"
144
145
  - !ruby/object:Gem::Version
145
- version: '3.1'
146
+ version: '3.4'
146
147
  type: :development
147
148
  prerelease: false
148
149
  version_requirements: !ruby/object:Gem::Requirement
149
150
  requirements:
150
151
  - - "~>"
151
152
  - !ruby/object:Gem::Version
152
- version: '3.1'
153
+ version: '3.4'
153
154
  - !ruby/object:Gem::Dependency
154
155
  name: yard
155
156
  requirement: !ruby/object:Gem::Requirement
@@ -165,7 +166,9 @@ dependencies:
165
166
  - !ruby/object:Gem::Version
166
167
  version: '0.8'
167
168
  description: Sensu plugins for interfacing with Telegram messenger
168
- email: "<hschmidt@suse.de>"
169
+ email:
170
+ - hschmidt@suse.de
171
+ - sensu-users@googlegroups.com
169
172
  executables:
170
173
  - handler-telegram.rb
171
174
  extensions: []
@@ -177,7 +180,7 @@ files:
177
180
  - bin/handler-telegram.rb
178
181
  - lib/sensu-plugins-telegram.rb
179
182
  - lib/sensu-plugins-telegram/version.rb
180
- homepage: https://github.com/lagartoflojo/sensu-plugins-telegram
183
+ homepage: https://github.com/sensu-plugins/sensu-plugins-telegram
181
184
  licenses:
182
185
  - MIT
183
186
  metadata:
@@ -195,7 +198,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
198
  requirements:
196
199
  - - ">="
197
200
  - !ruby/object:Gem::Version
198
- version: 1.9.3
201
+ version: 2.0.0
199
202
  required_rubygems_version: !ruby/object:Gem::Requirement
200
203
  requirements:
201
204
  - - ">="
@@ -203,9 +206,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
206
  version: '0'
204
207
  requirements: []
205
208
  rubyforge_project:
206
- rubygems_version: 2.4.8
209
+ rubygems_version: 2.4.5
207
210
  signing_key:
208
211
  specification_version: 4
209
212
  summary: Sensu plugins for interfacing with Telegram messenger
210
213
  test_files: []
211
- has_rdoc: