sensu-plugins-chatwork 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 496998f3f3ee685e077c75a5b61281df2e2cf665
4
+ data.tar.gz: 03067e8e4b9b477e5b4981aa9c492fc273181d5d
5
+ SHA512:
6
+ metadata.gz: eec377f8683b1a07be68aa6b0e07895ee9d8ec9c44a89f0fa990dbf3dfa8876f033088732babe60f209bf836268c2aec90f6b3bb1e89b8ca8ba125ebe36521a8
7
+ data.tar.gz: 1d4dceea60357748a8152ee68da51360870331e24beb777b2b7fddf3e2d7c3a9cdca5d0a686a113d896807f93e41e64ce586bc753ed1d9d48dbdcac15decea4e
@@ -0,0 +1,17 @@
1
+ # Change Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [1.0.0]
9
+ ### Added
10
+ - Ruby 2.3.0 testing
11
+ - Ruby 2.4.1 testing
12
+
13
+ ### Removed
14
+ - Cleanup redundant Ruby pre-2.0 testing code
15
+
16
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-chatwork/compare/1.0.0...HEAD
17
+ [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-chatwork/compare/02e90eaff26ec7eff03891c9f0fe8a00db64210e...1.0.0
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Sensu-Plugins
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,30 @@
1
+ ## Sensu-Plugins-chatwork
2
+
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-chatwork.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-chatwork)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-chatwork.svg)](http://badge.fury.io/rb/sensu-plugins-chatwork)
5
+ [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-chatwork/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-chatwork)
6
+ [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-chatwork/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-chatwork)
7
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-chatwork.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-chatwork)
8
+
9
+ ## Functionality
10
+
11
+ ## Files
12
+ * bin/handler-chatwork.rb
13
+
14
+ ## Usage
15
+ ```
16
+ {
17
+ "chatwork": {
18
+ "serverurl": "https://api.chatwork.com/",
19
+ "apitoken": "123456789abcdefghijklmnopqrstuvw",
20
+ "apiversion": "v1",
21
+ "roomid": "12345678"
22
+ }
23
+ }
24
+ ```
25
+
26
+ ## Installation
27
+
28
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
29
+
30
+ ## Notes
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ # chatwork
4
+ #
5
+ # DESCRIPTION:
6
+ # This handler sends Sensu event to ChatWork via HTTPS request. You can
7
+ # change the handler settings using the chatwork.json configuration file,
8
+ # located by default in /etc/sensu/conf.d directory.
9
+ #
10
+ # PLATFORMS:
11
+ # Linux
12
+ #
13
+ # DEPENDENCIES:
14
+ # gem: sensu-handler
15
+ #
16
+ # USAGE:
17
+ # {
18
+ # "chatwork": {
19
+ # "serverurl": "https://api.chatwork.com/",
20
+ # "apitoken": "123456789abcdefghijklmnopqrstuvw",
21
+ # "apiversion": "v1",
22
+ # "roomid": "12345678"
23
+ # }
24
+ # }
25
+ # NOTES:
26
+ #
27
+ # LICENSE:
28
+ # Tsubasa Hirota tsubasa1173@gmail.com
29
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
30
+ # for details.
31
+ #
32
+
33
+ require 'sensu-handler'
34
+ require 'net/http'
35
+ require 'net/https'
36
+ require 'uri'
37
+ require 'timeout'
38
+
39
+ class ChatWkNotif < Sensu::Handler
40
+ def server_url
41
+ settings['chatwork']['serverurl'] || 'https://api.chatwork.com'
42
+ end
43
+
44
+ def api_token
45
+ settings['chatwork']['apitoken']
46
+ end
47
+
48
+ def api_version
49
+ settings['chatwork']['apiversion'] || 'v1'
50
+ end
51
+
52
+ def room_id
53
+ settings['chatwork']['roomid']
54
+ end
55
+
56
+ def access_uri
57
+ URI.parse("#{server_url}#{api_version}/rooms/#{room_id}/messages")
58
+ end
59
+
60
+ def access_header
61
+ { 'X-ChatWorkToken' => api_token.to_s }
62
+ end
63
+
64
+ def action_to_string
65
+ @event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'
66
+ end
67
+
68
+ def sensu_output
69
+ @event['check']['notification'] || @event['check']['output']
70
+ end
71
+
72
+ def sensu_message
73
+ "\s\s\s***#{action_to_string}***\s\s\s" + "\r\n" \
74
+ 'Time: ' + Time.at(@event['check']['issued']).to_s + "\r\n" \
75
+ 'Client: ' + @event['client']['name'] + "\r\n" \
76
+ 'Address: ' + @event['client']['address'] + "\r\n" \
77
+ 'Subscriptions: ' + @event['client']['subscriptions'].join(', ') + "\r\n" \
78
+ 'Check: ' + @event['check']['name'] + "\r\n" \
79
+ 'Output: ' + "#{sensu_output}" \
80
+ ' ***by Sensu*** '
81
+ end
82
+
83
+ def event_name
84
+ @event['client']['name'] + '/' + @event['check']['name']
85
+ end
86
+
87
+ def handle
88
+ http = Net::HTTP.new(access_uri.host, access_uri.port)
89
+ http.use_ssl = true
90
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
91
+ body = 'body=' + URI.encode(sensu_message.to_s)
92
+ begin
93
+ timeout(10) do
94
+ res = http.post(access_uri, body, access_header)
95
+ puts JSON.parse(res.body)
96
+ end
97
+ rescue Timeout::Error
98
+ puts 'chatwork -- timed out while attempting to ' + @event['action'] + ' a incident -- ' + event_name
99
+ rescue Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
100
+ puts "chatwork -- HTTP Connection error #{e.message}"
101
+ end
102
+ end
103
+ end
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-chatwork/version'
@@ -0,0 +1,9 @@
1
+ module SensuPluginsChatwork
2
+ module Version
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ PATCH = 0
6
+
7
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,200 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-chatwork
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins and contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sensu-plugin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: codeclimate-test-reporter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: github-markup
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.5'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: redcarpet
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.2'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.2'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.4'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.4'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.40.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.40.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: yard
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.8'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.8'
153
+ description: |-
154
+ This plugin provides native Chatwork
155
+ instrumentation for monitoring and metrics
156
+ collection, including: handler for sending
157
+ notifications and more.
158
+ email: "<sensu-users@googlegroups.com>"
159
+ executables:
160
+ - handler-chatwork.rb
161
+ extensions: []
162
+ extra_rdoc_files: []
163
+ files:
164
+ - CHANGELOG.md
165
+ - LICENSE
166
+ - README.md
167
+ - bin/handler-chatwork.rb
168
+ - lib/sensu-plugins-chatwork.rb
169
+ - lib/sensu-plugins-chatwork/version.rb
170
+ homepage: https://github.com/sensu-plugins/sensu-plugins-chatwork
171
+ licenses:
172
+ - MIT
173
+ metadata:
174
+ maintainer: "@sensu-plugin"
175
+ development_status: active
176
+ production_status: unstable - testing recommended
177
+ release_draft: 'false'
178
+ release_prerelease: 'false'
179
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
180
+ in /etc/default/sensu
181
+ rdoc_options: []
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: 2.0.0
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ requirements: []
195
+ rubyforge_project:
196
+ rubygems_version: 2.4.5.1
197
+ signing_key:
198
+ specification_version: 4
199
+ summary: Sensu plugins for chatwork
200
+ test_files: []