sensu-plugins-sms 0.0.2 → 1.0.0
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 +4 -4
- data/CHANGELOG.md +14 -3
- data/README.md +103 -3
- data/bin/handler-freesmsalert.rb +6 -6
- data/bin/handler-playsms.rb +93 -0
- data/lib/sensu-plugins-sms/version.rb +2 -2
- metadata +29 -35
- checksums.yaml.gz.sig +0 -2
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb5abea8f9abae772f67d9e82de2a63afdf8203d
|
4
|
+
data.tar.gz: 1a546ab4bcc78e885dd10a6a13923ed03e8e6a71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcc853d7f3662e54970c6b7e65f843f45549ae31c2ed34b36897cef036d0970f4ffa8c62160c60a3afdcd91168134bdd9fc4eb938d884d148cf31826b621d7e7
|
7
|
+
data.tar.gz: b879d3db5fb247f7064f3a5409d986d9b85583bee6193f0f1192fd8344606b001f3bc888ccf5062a8fff26d227bcbc0f6efdc091f1ff3717ff2d0f4892bd0c43
|
data/CHANGELOG.md
CHANGED
@@ -3,14 +3,25 @@ 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
|
-
## Unreleased]
|
6
|
+
## [Unreleased]
|
7
|
+
|
8
|
+
## [1.0.0] - 2016-12-27
|
9
|
+
### Added
|
10
|
+
- added playSMS handler
|
11
|
+
- added client name to sms message
|
12
|
+
- Ruby 2.3.0 support
|
13
|
+
|
14
|
+
### Removed
|
15
|
+
- Ruby < 2.1 support
|
7
16
|
|
8
17
|
## [0.0.2] - 2015-07-14
|
9
18
|
### Changed
|
10
19
|
- updated sensu-plugin gem to 1.2.0
|
11
20
|
|
12
|
-
##
|
13
|
-
|
21
|
+
## 0.0.1 - 2015-07-04
|
14
22
|
### Added
|
15
23
|
- initial release
|
16
24
|
|
25
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-sms/compare/1.0.0...HEAD
|
26
|
+
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-sms/compare/0.0.2...1.0.0
|
27
|
+
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-sms/compare/0.0.1...0.0.2
|
data/README.md
CHANGED
@@ -1,24 +1,124 @@
|
|
1
1
|
## Sensu-Plugins-sms
|
2
2
|
|
3
|
-
[
|
3
|
+
[](https://travis-ci.org/sensu-plugins/sensu-plugins-sms)
|
4
4
|
[](http://badge.fury.io/rb/sensu-plugins-sms)
|
5
5
|
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-sms)
|
6
6
|
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-sms)
|
7
7
|
[](https://gemnasium.com/sensu-plugins/sensu-plugins-sms)
|
8
|
-
[ ](https://codeship.com/projects/84117)
|
9
8
|
|
10
9
|
## Functionality
|
11
10
|
|
12
11
|
## Files
|
13
12
|
* bin/check-sms
|
13
|
+
* bin/handler-playsms
|
14
14
|
* bin/metrics-sms-bulk
|
15
15
|
* bin/metrics-sms-if
|
16
16
|
* bin/metrics-sms
|
17
17
|
|
18
|
+
|
18
19
|
## Usage
|
19
20
|
|
21
|
+
### FreeSMS
|
22
|
+
|
23
|
+
```json
|
24
|
+
{
|
25
|
+
"free_sms_alert": {
|
26
|
+
"carrier_portal": {
|
27
|
+
// US carriers:
|
28
|
+
"att": "%number%@txt.att.net",
|
29
|
+
"verizon": "%number%@vtext.com",
|
30
|
+
"tmobile": "%number%@tmomail.net",
|
31
|
+
"sprint": "%number%@messaging.sprintpcs.com",
|
32
|
+
"virgin": "%number%@vmobl.com",
|
33
|
+
"uscellular": "%number%@email.uscc.net",
|
34
|
+
"nextel": "%number%@messaging.nextel.com",
|
35
|
+
"boost": "%number%@myboostmobile.com",
|
36
|
+
"alltel": "%number%@message.alltel.com",
|
37
|
+
// Canadian carriers:
|
38
|
+
"telus": "%number%@msg.telus.com",
|
39
|
+
"rogers": "%number%@pcs.rogers.com",
|
40
|
+
"fido": "%number%@fido.ca",
|
41
|
+
"bell": "%number%@txt.bell.ca",
|
42
|
+
"mts": "%number%@text.mtsmobility.com",
|
43
|
+
"kudo": "%number%@msg.koodomobile.com",
|
44
|
+
"presidentschoice": "%number%@txt.bell.ca",
|
45
|
+
"sasktel": "%number%@sms.sasktel.com",
|
46
|
+
"solo": "%number%@txt.bell.ca",
|
47
|
+
"virgincanada": "%number%@vmobile.ca",
|
48
|
+
// Dummy carrier (in case you actually want to send an email):
|
49
|
+
"email": "%number%"
|
50
|
+
},
|
51
|
+
"smtp_address": "localhost",
|
52
|
+
"smtp_domain": "localhost.localdomain",
|
53
|
+
"smtp_port": "25",
|
54
|
+
"mail_from": "sensu_alert@mydomain.com"
|
55
|
+
}
|
56
|
+
}
|
57
|
+
```
|
58
|
+
|
59
|
+
```json
|
60
|
+
{
|
61
|
+
"free_sms_alert": {
|
62
|
+
"alert_recipient_mappings": {
|
63
|
+
|
64
|
+
"ttutone": {
|
65
|
+
"name": "Tommy Tutone",
|
66
|
+
"carrier": "att",
|
67
|
+
"number": "800-867-5309"
|
68
|
+
},
|
69
|
+
|
70
|
+
"ghostbuster": {
|
71
|
+
"name": "Ghost Busters",
|
72
|
+
"carrier": "tmobile",
|
73
|
+
"number": "800-555-2368"
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
```
|
79
|
+
|
80
|
+
### playSMS
|
81
|
+
|
82
|
+
Create a json config file with your host, API user, and API secret.
|
83
|
+
|
84
|
+
```json
|
85
|
+
{
|
86
|
+
"playsms": {
|
87
|
+
"host": "http://playsms.example.com",
|
88
|
+
"api_user": "sensu",
|
89
|
+
"api_secret": "XXXXX"
|
90
|
+
}
|
91
|
+
}
|
92
|
+
```
|
93
|
+
|
94
|
+
Set your check to use the handler and define the playsms recipients.
|
95
|
+
|
96
|
+
```json
|
97
|
+
{
|
98
|
+
"checks": {
|
99
|
+
"check-disk-usage": {
|
100
|
+
"command": "check-disk-usage.rb -w :::disk.warning|80::: -c :::disk.critical|90:::",
|
101
|
+
"subscribers": [
|
102
|
+
"production"
|
103
|
+
],
|
104
|
+
"handlers": [
|
105
|
+
"playsms"
|
106
|
+
],
|
107
|
+
"playsms": {
|
108
|
+
"recipients": [
|
109
|
+
"1234567890",
|
110
|
+
"@joe_smith",
|
111
|
+
"#operations"
|
112
|
+
]
|
113
|
+
},
|
114
|
+
"interval": 60,
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
```
|
119
|
+
|
20
120
|
## Installation
|
21
121
|
|
22
|
-
[Installation and Setup](
|
122
|
+
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
23
123
|
|
24
124
|
## Notes
|
data/bin/handler-freesmsalert.rb
CHANGED
@@ -64,7 +64,7 @@ class FreeSMSAlert < Sensu::Handler
|
|
64
64
|
# This method sends the acutal email
|
65
65
|
#
|
66
66
|
def send_sms(user_id, mail_to, mail_from)
|
67
|
-
mail_subject = "Alert:#{@event['check']['name']}"
|
67
|
+
mail_subject = "Alert:#{@event['check']['name']} #{@event['client']['name']}"
|
68
68
|
mail_body = <<-BODY.gsub(/^\s+/, '')
|
69
69
|
#{@event['check']['output']}
|
70
70
|
BODY
|
@@ -105,11 +105,11 @@ class FreeSMSAlert < Sensu::Handler
|
|
105
105
|
mail_to = nil
|
106
106
|
number = nil
|
107
107
|
info = settings['free_sms_alert']['alert_recipient_mappings'][user_id]
|
108
|
-
if info['carrier'] == 'email'
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
108
|
+
number = if info['carrier'] == 'email'
|
109
|
+
info['number']
|
110
|
+
else
|
111
|
+
info['number'].gsub(/[^0-9]/, '')
|
112
|
+
end
|
113
113
|
settings['free_sms_alert']['carrier_portal'].each do |carrier, address|
|
114
114
|
mail_to = address.gsub(/%number%/, number) if info['carrier'] == carrier
|
115
115
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# handler-playsms.rb
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Sensu handler for sending SMS messages through a playSMS gateway.
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# None unless there is an error
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-handler
|
16
|
+
# gem: playsms
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
#
|
20
|
+
# Configure your playSMS host, user, and secret here:
|
21
|
+
# playsms.json
|
22
|
+
#
|
23
|
+
# Recipients can be a single phone number, or a playSMS #groupcode or @username defined in the
|
24
|
+
# playSMS "phonebook" of your API user. Recipients are listed in the checks as an array of
|
25
|
+
# one or more of the above.
|
26
|
+
# e.g. [ '1234567890', '@joe_smith', '#operations' ]
|
27
|
+
#
|
28
|
+
# NOTES:
|
29
|
+
#
|
30
|
+
# LICENSE:
|
31
|
+
# Matt Mencel mr-mencel@wiu.edu
|
32
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
33
|
+
# for details.
|
34
|
+
#
|
35
|
+
|
36
|
+
require 'date'
|
37
|
+
require 'playsms'
|
38
|
+
require 'sensu-handler'
|
39
|
+
require 'timeout'
|
40
|
+
|
41
|
+
# playSMS Handler
|
42
|
+
class PlaysmsAlert < Sensu::Handler
|
43
|
+
def send_sms(recipients, msg)
|
44
|
+
client = Playsms::Client.new(user: api_user, secret: api_secret, host: host)
|
45
|
+
client.send_message(to: recipients, msg: msg)
|
46
|
+
end
|
47
|
+
|
48
|
+
def api_user
|
49
|
+
settings['playsms']['api_user']
|
50
|
+
end
|
51
|
+
|
52
|
+
def api_secret
|
53
|
+
settings['playsms']['api_secret']
|
54
|
+
end
|
55
|
+
|
56
|
+
def action_to_string
|
57
|
+
@event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'
|
58
|
+
end
|
59
|
+
|
60
|
+
def executed_at
|
61
|
+
Time.at(@event['check']['executed']).to_datetime
|
62
|
+
end
|
63
|
+
|
64
|
+
def host
|
65
|
+
settings['playsms']['host']
|
66
|
+
end
|
67
|
+
|
68
|
+
def msg
|
69
|
+
"#{action_to_string} - #{short_name}: #{output} #{executed_at}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def output
|
73
|
+
@event['check']['output'].strip
|
74
|
+
end
|
75
|
+
|
76
|
+
def recipients
|
77
|
+
@event['check']['playsms']['recipients'].join ','
|
78
|
+
end
|
79
|
+
|
80
|
+
def short_name
|
81
|
+
@event['client']['name'] + '/' + @event['check']['name']
|
82
|
+
end
|
83
|
+
|
84
|
+
def handle
|
85
|
+
Timeout.timeout 10 do
|
86
|
+
send_sms(recipients, msg)
|
87
|
+
puts 'playsms -- sent alert for ' + short_name + ' to ' + recipients
|
88
|
+
end
|
89
|
+
rescue Timeout::Error
|
90
|
+
puts 'playsms -- timed out while attempting to ' + action_to_string + ' an incident -- '\
|
91
|
+
'(TO: ' + settings['playsms']['recipients'] + ' SUBJ: ' + subject + ')' + short_name
|
92
|
+
end
|
93
|
+
end
|
metadata
CHANGED
@@ -1,51 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIDgDCCAmigAwIBAgIBATAN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28
|
-
UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
|
29
|
-
JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
|
30
|
-
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
|
-
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
|
-
-----END CERTIFICATE-----
|
33
|
-
date: 2015-07-14 00:00:00.000000000 Z
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-28 00:00:00.000000000 Z
|
34
12
|
dependencies:
|
35
13
|
- !ruby/object:Gem::Dependency
|
36
14
|
name: sensu-plugin
|
37
15
|
requirement: !ruby/object:Gem::Requirement
|
38
16
|
requirements:
|
39
|
-
- -
|
17
|
+
- - "~>"
|
40
18
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.2
|
19
|
+
version: '1.2'
|
42
20
|
type: :runtime
|
43
21
|
prerelease: false
|
44
22
|
version_requirements: !ruby/object:Gem::Requirement
|
45
23
|
requirements:
|
46
|
-
- -
|
24
|
+
- - "~>"
|
47
25
|
- !ruby/object:Gem::Version
|
48
|
-
version: 1.2
|
26
|
+
version: '1.2'
|
49
27
|
- !ruby/object:Gem::Dependency
|
50
28
|
name: mail
|
51
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,6 +38,20 @@ dependencies:
|
|
60
38
|
- - '='
|
61
39
|
- !ruby/object:Gem::Version
|
62
40
|
version: 2.6.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: playsms
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.1
|
63
55
|
- !ruby/object:Gem::Dependency
|
64
56
|
name: bundler
|
65
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,16 +112,16 @@ dependencies:
|
|
120
112
|
name: rubocop
|
121
113
|
requirement: !ruby/object:Gem::Requirement
|
122
114
|
requirements:
|
123
|
-
- -
|
115
|
+
- - "~>"
|
124
116
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
117
|
+
version: 0.40.0
|
126
118
|
type: :development
|
127
119
|
prerelease: false
|
128
120
|
version_requirements: !ruby/object:Gem::Requirement
|
129
121
|
requirements:
|
130
|
-
- -
|
122
|
+
- - "~>"
|
131
123
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
124
|
+
version: 0.40.0
|
133
125
|
- !ruby/object:Gem::Dependency
|
134
126
|
name: rspec
|
135
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,6 +182,7 @@ description: Sensu sms plugins
|
|
190
182
|
email: "<sensu-users@googlegroups.com>"
|
191
183
|
executables:
|
192
184
|
- handler-freesmsalert.rb
|
185
|
+
- handler-playsms.rb
|
193
186
|
extensions: []
|
194
187
|
extra_rdoc_files: []
|
195
188
|
files:
|
@@ -197,6 +190,7 @@ files:
|
|
197
190
|
- LICENSE
|
198
191
|
- README.md
|
199
192
|
- bin/handler-freesmsalert.rb
|
193
|
+
- bin/handler-playsms.rb
|
200
194
|
- lib/sensu-plugins-sms.rb
|
201
195
|
- lib/sensu-plugins-sms/version.rb
|
202
196
|
homepage: https://github.com/sensu-plugins/sensu-plugins-sms
|
@@ -217,7 +211,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
211
|
requirements:
|
218
212
|
- - ">="
|
219
213
|
- !ruby/object:Gem::Version
|
220
|
-
version: 1.
|
214
|
+
version: 2.1.0
|
221
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
216
|
requirements:
|
223
217
|
- - ">="
|
@@ -225,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
219
|
version: '0'
|
226
220
|
requirements: []
|
227
221
|
rubyforge_project:
|
228
|
-
rubygems_version: 2.4.
|
222
|
+
rubygems_version: 2.4.5
|
229
223
|
signing_key:
|
230
224
|
specification_version: 4
|
231
225
|
summary: Sensu plugins for sms
|
checksums.yaml.gz.sig
DELETED
data.tar.gz.sig
DELETED
Binary file
|
metadata.gz.sig
DELETED
Binary file
|