sensu-plugins-particle 0.0.1
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 +7 -0
- data/CHANGELOG.md +12 -0
- data/LICENSE +21 -0
- data/README.md +3 -0
- data/bin/handler-particle-publish-event.rb +97 -0
- data/lib/sensu-plugins-particle.rb +1 -0
- data/lib/sensu-plugins-particle/version.rb +9 -0
- metadata +210 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 81947e22dea5205e12d1eeea324e336ef64cd025
|
4
|
+
data.tar.gz: 74dcc2435a3b9a94ea5f3bdc6ae23ce28dc85001
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6fe3f8de243a2e838bf6664bfa74fda75bc33a55010711161954aa05ef636ad04eee04b185ee0a89d7566c573be69577a5487b9b943d7780f661203a017cb1e2
|
7
|
+
data.tar.gz: 17de9ff9425afff52ef4ae3664c5c48509ef1b0f6c7e7d610404c15926515966339cc976e3b606797879f7e83a6ead6160c4490dd9a45b32dec8c95661f84b12
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Change Log
|
2
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
|
+
|
4
|
+
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)
|
5
|
+
|
6
|
+
## [Unreleased]
|
7
|
+
|
8
|
+
## 0.0.1 - 2018-07-15
|
9
|
+
### Added
|
10
|
+
- initial release: includes handler-particle-publish-event.rb
|
11
|
+
|
12
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Jef Spaleta
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright 2018 Jef Spaleta and contributors.
|
4
|
+
#
|
5
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
6
|
+
# for details.
|
7
|
+
#
|
8
|
+
# In order to use this plugin, you must first configure a
|
9
|
+
# particle.io cloud api account
|
10
|
+
# You'll make use of the particle.io login information
|
11
|
+
#
|
12
|
+
|
13
|
+
require 'sensu-handler'
|
14
|
+
require 'particle'
|
15
|
+
require 'json'
|
16
|
+
|
17
|
+
class ParticleHandler < Sensu::Handler
|
18
|
+
option :particle_config_file,
|
19
|
+
description: 'Particle config JSON file location',
|
20
|
+
short: '-c CONFIG_FILE',
|
21
|
+
long: '--config_file CONFIG_FILE'
|
22
|
+
option :particle_user,
|
23
|
+
description: 'Particle user',
|
24
|
+
short: '-u USER',
|
25
|
+
long: '--user USER'
|
26
|
+
option :particle_password,
|
27
|
+
description: 'Particle password',
|
28
|
+
short: '-p PASSWORD',
|
29
|
+
long: '--password PASSWORD'
|
30
|
+
option :particle_token,
|
31
|
+
description: 'Particle access token',
|
32
|
+
short: '-t TOKEN',
|
33
|
+
long: '--token TOKEN',
|
34
|
+
default: ENV['PARTICLE_ACCESS_TOKEN']
|
35
|
+
option :particle_event,
|
36
|
+
description: 'Particle event name',
|
37
|
+
short: '-e EVENT',
|
38
|
+
long: '--event EVENT',
|
39
|
+
default: 'sensu_particle_handler'
|
40
|
+
option :particle_data,
|
41
|
+
description: 'Particle event data',
|
42
|
+
short: '-d DATA',
|
43
|
+
long: '--data DATA'
|
44
|
+
option :particle_private,
|
45
|
+
description: 'Particle event data',
|
46
|
+
boolean: true,
|
47
|
+
short: '-p',
|
48
|
+
long: '--private'
|
49
|
+
option :verbose,
|
50
|
+
description: 'Verbose output',
|
51
|
+
short: '-v',
|
52
|
+
long: '--verbose'
|
53
|
+
|
54
|
+
##
|
55
|
+
# Setup helper function to deal with configuration processing
|
56
|
+
##
|
57
|
+
def setup
|
58
|
+
if config.key?(:particle_config_file)
|
59
|
+
if File.readable?(config[:particle_config_file])
|
60
|
+
file = File.read(config[:particle_config_file])
|
61
|
+
config_hash = JSON.parse(file)
|
62
|
+
keys = %w[particle_user particle_password particle_token particle_event particle_data particle_private]
|
63
|
+
keys.each do |key|
|
64
|
+
config[key.to_sym] = config_hash[key] if config_hash.key?(key)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
unless (config[:particle_user] && config[:particle_password]) || config[:particle_token]
|
70
|
+
puts 'Must supply user and password or token, check --help message for more information'
|
71
|
+
exit 2
|
72
|
+
end
|
73
|
+
|
74
|
+
config[:particle_data] = "#{@event['check']['name']}::#{@event['occurrences']}" unless config.key?(:particle_data)
|
75
|
+
config[:particle_private] = false unless config.key?(:particle_private)
|
76
|
+
|
77
|
+
return unless config[:verbose]
|
78
|
+
|
79
|
+
puts "Post Setup:: Private: #{config[:particle_private]}"
|
80
|
+
if config[:particle_token]
|
81
|
+
puts "Post Setup:: Token: #{config[:particle_token]}"
|
82
|
+
else
|
83
|
+
puts 'Post Setup:: Using Login'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def handle
|
88
|
+
setup
|
89
|
+
client = Particle::Client.new
|
90
|
+
client.access_token = config[:particle_token] if config[:particle_token]
|
91
|
+
client.login(config[:particle_user], config[:particle_password]) if config[:particle_user] && config[:particle_password]
|
92
|
+
client.publish(name: config[:particle_event], data: config[:particle_data], private: config[:particle_private])
|
93
|
+
rescue Particle::BadRequest, Particle::MissingTokenError => e
|
94
|
+
puts "error: #{e.message}"
|
95
|
+
exit 3 # unknown
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'sensu-plugins-particle/version'
|
metadata
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-particle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jef Spaleta and contributors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: particlerb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sensu-plugin
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: codeclimate-test-reporter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: github-markup
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.10'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.10'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: redcarpet
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.2'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.2'
|
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.49.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.49.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '3.1'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '3.1'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: yard
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.8'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.8'
|
167
|
+
description: Sensu plugins for interfacing with Particle.io Cloud API
|
168
|
+
email: "<jspaleta@gmail.com>"
|
169
|
+
executables:
|
170
|
+
- handler-particle-publish-event.rb
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- CHANGELOG.md
|
175
|
+
- LICENSE
|
176
|
+
- README.md
|
177
|
+
- bin/handler-particle-publish-event.rb
|
178
|
+
- lib/sensu-plugins-particle.rb
|
179
|
+
- lib/sensu-plugins-particle/version.rb
|
180
|
+
homepage: https://github.com/jspaleta/sensu-plugins-slack
|
181
|
+
licenses:
|
182
|
+
- MIT
|
183
|
+
metadata:
|
184
|
+
maintainer: jspaleta
|
185
|
+
development_status: active
|
186
|
+
production_status: unstable - testing recommended
|
187
|
+
release_draft: 'false'
|
188
|
+
release_prerelease: 'false'
|
189
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
190
|
+
in /etc/default/sensu
|
191
|
+
rdoc_options: []
|
192
|
+
require_paths:
|
193
|
+
- lib
|
194
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
195
|
+
requirements:
|
196
|
+
- - ">="
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: 2.0.0
|
199
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
|
+
requirements:
|
201
|
+
- - ">="
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '0'
|
204
|
+
requirements: []
|
205
|
+
rubyforge_project:
|
206
|
+
rubygems_version: 2.6.14
|
207
|
+
signing_key:
|
208
|
+
specification_version: 4
|
209
|
+
summary: Sensu plugins for interfacing with Particle.io Cloud API
|
210
|
+
test_files: []
|