portertech-sensu 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +961 -0
  3. data/MIT-LICENSE.txt +20 -0
  4. data/README.md +65 -0
  5. data/exe/sensu-api +10 -0
  6. data/exe/sensu-client +10 -0
  7. data/exe/sensu-install +195 -0
  8. data/exe/sensu-server +10 -0
  9. data/lib/sensu/api/http_handler.rb +434 -0
  10. data/lib/sensu/api/process.rb +79 -0
  11. data/lib/sensu/api/routes/aggregates.rb +196 -0
  12. data/lib/sensu/api/routes/checks.rb +44 -0
  13. data/lib/sensu/api/routes/clients.rb +171 -0
  14. data/lib/sensu/api/routes/events.rb +86 -0
  15. data/lib/sensu/api/routes/health.rb +45 -0
  16. data/lib/sensu/api/routes/info.rb +37 -0
  17. data/lib/sensu/api/routes/request.rb +44 -0
  18. data/lib/sensu/api/routes/resolve.rb +32 -0
  19. data/lib/sensu/api/routes/results.rb +153 -0
  20. data/lib/sensu/api/routes/settings.rb +23 -0
  21. data/lib/sensu/api/routes/silenced.rb +182 -0
  22. data/lib/sensu/api/routes/stashes.rb +107 -0
  23. data/lib/sensu/api/routes.rb +88 -0
  24. data/lib/sensu/api/utilities/filter_response_content.rb +44 -0
  25. data/lib/sensu/api/utilities/publish_check_request.rb +107 -0
  26. data/lib/sensu/api/utilities/publish_check_result.rb +39 -0
  27. data/lib/sensu/api/utilities/resolve_event.rb +29 -0
  28. data/lib/sensu/api/utilities/servers_info.rb +43 -0
  29. data/lib/sensu/api/utilities/transport_info.rb +43 -0
  30. data/lib/sensu/api/validators/check.rb +55 -0
  31. data/lib/sensu/api/validators/client.rb +35 -0
  32. data/lib/sensu/api/validators/invalid.rb +8 -0
  33. data/lib/sensu/cli.rb +69 -0
  34. data/lib/sensu/client/http_socket.rb +217 -0
  35. data/lib/sensu/client/process.rb +655 -0
  36. data/lib/sensu/client/socket.rb +207 -0
  37. data/lib/sensu/client/utils.rb +53 -0
  38. data/lib/sensu/client/validators/check.rb +53 -0
  39. data/lib/sensu/constants.rb +17 -0
  40. data/lib/sensu/daemon.rb +396 -0
  41. data/lib/sensu/sandbox.rb +19 -0
  42. data/lib/sensu/server/filter.rb +227 -0
  43. data/lib/sensu/server/handle.rb +201 -0
  44. data/lib/sensu/server/mutate.rb +92 -0
  45. data/lib/sensu/server/process.rb +1646 -0
  46. data/lib/sensu/server/socket.rb +54 -0
  47. data/lib/sensu/server/tessen.rb +170 -0
  48. data/lib/sensu/utilities.rb +398 -0
  49. data/lib/sensu.rb +3 -0
  50. data/sensu.gemspec +36 -0
  51. metadata +322 -0
data/MIT-LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2019 Sonian Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ ![sensu](https://raw.github.com/sensu/sensu/master/sensu-logo.png)
2
+
3
+ [![Build Status](https://img.shields.io/travis/sensu/sensu.svg)](https://travis-ci.org/sensu/sensu)
4
+ [![Gem Version](https://img.shields.io/gem/v/sensu.svg)](https://github.com/sensu/sensu/blob/master/CHANGELOG.md)
5
+ [![MIT Licensed](https://img.shields.io/github/license/sensu/sensu.svg)](https://raw.githubusercontent.com/sensu/sensu/master/MIT-LICENSE.txt)
6
+ [![Join the chat at https://slack.sensu.io/](https://slack.sensu.io/badge.svg)](https://slack.sensu.io/)
7
+
8
+ :warning: **ANNOUNCEMENT - Sensu 1.x has reached End-Of-Life (December 31st, 2019)**
9
+
10
+ The Sensu 1.x project reached end-of-life on December 31st, 2019. The
11
+ existing package repositories became unreachable on January 6th, 2020.
12
+ Please see our blog post for more details:
13
+ https://blog.sensu.io/announcing-the-sensu-archives
14
+
15
+ Sensu 1.x has been superseded by [Sensu Go](https://github.com/sensu/sensu-go).
16
+
17
+ As always, we want to hear from the Community and please reach out on
18
+ Slack or Discourse if you have any questions or concerns.
19
+
20
+ # Sensu
21
+
22
+ A simple, malleable, and scalable framework for composing
23
+ the monitoring system you need.
24
+
25
+ Sensu is offered in two flavors:
26
+
27
+ * Sensu Core - this open source project
28
+ * [Sensu Enterprise][1] - a full-featured commercial implementation, built on Sensu Core
29
+
30
+ ## Installation
31
+
32
+ Sensu supports a number of Unix-like platforms, as well as Windows.
33
+ Please see the [list of supported platforms][2] for installation instructions.
34
+
35
+ ## Documentation
36
+
37
+ Please refer to the [online documentation][3] for details
38
+ on configuring and operating Sensu.
39
+
40
+ ## Getting Help
41
+
42
+ If you have questions not covered by the documentation, the Sensu community
43
+ is here to help. Please check out our [chat][4] on Slack, or the
44
+ [sensu-users][5] discussion list.
45
+
46
+ Commercial support is also available. See the [support section of our website][6] for more detail.
47
+
48
+ ## Contributing
49
+
50
+ Please observe these [guidelines on contributing][7].
51
+
52
+
53
+ ## License
54
+
55
+ Sensu Core is released under the [MIT license][8].
56
+
57
+
58
+ [1]: https://sensu.io/solutions/enterprise
59
+ [2]: https://docs.sensu.io/sensu-core/latest/overview/platforms/
60
+ [3]: https://docs.sensu.io/sensu-core/latest/
61
+ [4]: https://slack.sensu.io/
62
+ [5]: http://groups.google.com/group/sensu-users
63
+ [6]: https://sensu.io/resources/support
64
+ [7]: https://github.com/sensu/sensu/blob/master/CONTRIBUTING.md
65
+ [8]: https://raw.github.com/sensu/sensu/master/MIT-LICENSE.txt
data/exe/sensu-api ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ unless $:.include?(File.dirname(__FILE__) + "/../lib/")
4
+ $: << File.dirname(__FILE__) + "/../lib"
5
+ end
6
+
7
+ require "sensu/api/process"
8
+
9
+ options = Sensu::CLI.read
10
+ Sensu::API::Process.run(options)
data/exe/sensu-client ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ unless $:.include?(File.dirname(__FILE__) + "/../lib/")
4
+ $: << File.dirname(__FILE__) + "/../lib"
5
+ end
6
+
7
+ require "sensu/client/process"
8
+
9
+ options = Sensu::CLI.read
10
+ Sensu::Client::Process.run(options)
data/exe/sensu-install ADDED
@@ -0,0 +1,195 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "optparse"
4
+
5
+ module Sensu
6
+ class Install
7
+ class << self
8
+ def cli_options(arguments=ARGV)
9
+ options = {
10
+ :verbose => false,
11
+ :plugins => [],
12
+ :extensions => [],
13
+ :clean => false,
14
+ :proxy => nil
15
+ }
16
+ optparse = OptionParser.new do |opts|
17
+ opts.on("-h", "--help", "Display this message") do
18
+ puts opts
19
+ exit
20
+ end
21
+ opts.on("-v", "--verbose", "Enable verbose logging") do
22
+ options[:verbose] = true
23
+ end
24
+ opts.on("-p", "--plugin PLUGIN", "Install a Sensu PLUGIN") do |plugin|
25
+ options[:plugins] << plugin
26
+ end
27
+ opts.on("-P", "--plugins PLUGIN[,PLUGIN]", "PLUGIN or comma-delimited list of Sensu plugins to install") do |plugins|
28
+ options[:plugins].concat(plugins.split(","))
29
+ end
30
+ opts.on("-e", "--extension EXTENSION", "Install a Sensu EXTENSION") do |extension|
31
+ options[:extensions] << extension
32
+ end
33
+ opts.on("-E", "--extensions EXTENSION[,EXT]", "EXTENSION or comma-delimited list of Sensu extensions to install") do |extensions|
34
+ options[:extensions].concat(extensions.split(","))
35
+ end
36
+ opts.on("-s", "--source SOURCE", "Install Sensu plugins and extensions from a custom SOURCE") do |source|
37
+ options[:source] = source
38
+ end
39
+ opts.on("-c", "--clean", "Clean up (remove) other installed versions of the plugin(s) and/or extension(s)") do
40
+ options[:clean] = true
41
+ end
42
+ opts.on("-x", "--proxy PROXY", "Install Sensu plugins and extensions via a PROXY URL") do |proxy|
43
+ options[:proxy] = proxy
44
+ end
45
+ end
46
+ optparse.parse!(arguments)
47
+ options
48
+ end
49
+
50
+ def log(message)
51
+ puts "[SENSU-INSTALL] #{message}"
52
+ end
53
+
54
+ def gem_installed?(raw_gem, options={})
55
+ log "determining if Sensu gem '#{raw_gem}' is already installed ..."
56
+ gem_name, gem_version = raw_gem.split(":")
57
+ gem_command = "gem list -i #{gem_name}"
58
+ gem_command << " --version '#{gem_version}'" if gem_version
59
+ log gem_command if options[:verbose]
60
+ if system(gem_command)
61
+ log "Sensu gem '#{gem_name}' has already been installed"
62
+ true
63
+ else
64
+ log "Sensu gem '#{gem_name}' has not been installed" if options[:verbose]
65
+ false
66
+ end
67
+ end
68
+
69
+ def install_gem(raw_gem, options={})
70
+ log "installing Sensu gem '#{raw_gem}'"
71
+ gem_name, gem_version = raw_gem.split(":")
72
+ gem_command = "gem install #{gem_name}"
73
+ gem_command << " --version '#{gem_version}'" if gem_version
74
+ gem_command << " --no-document"
75
+ gem_command << " --verbose" if options[:verbose]
76
+ gem_command << " --source #{options[:source]}" if options[:source]
77
+ gem_command << " --http-proxy #{options[:proxy]}" if options[:proxy]
78
+ log gem_command if options[:verbose]
79
+ unless system(gem_command)
80
+ log "failed to install Sensu gem '#{gem_name}'"
81
+ log "you can run the sensu-install command again with --verbose for more info" unless options[:verbose]
82
+ log "please take note of any failure messages above"
83
+ log "make sure you have build tools installed (e.g. gcc)"
84
+ log "trying to determine the Sensu plugin homepage for #{gem_name} ..."
85
+ system("gem specification #{gem_name} -r | grep homepage")
86
+ exit 2
87
+ end
88
+ end
89
+
90
+ def gem_installed_versions(raw_gem, options={})
91
+ gem_name, gem_version = raw_gem.split(":")
92
+ log "determining installed versions of Sensu gem '#{gem_name}' ..."
93
+ gem_command = "gem list #{gem_name}"
94
+ log gem_command if options[:verbose]
95
+ gem_command_output = `#{gem_command}`
96
+ last_line = gem_command_output.split("\n").last
97
+ if last_line == "false"
98
+ []
99
+ else
100
+ /\((.*)\)/.match(last_line)[1].split(", ")
101
+ end
102
+ end
103
+
104
+ def clean_gem(raw_gem, options={})
105
+ log "cleaning Sensu gem '#{raw_gem}'"
106
+ gem_name, gem_version = raw_gem.split(":")
107
+ gem_command = "gem clean #{gem_name}"
108
+ if gem_version
109
+ if gem_installed_versions(raw_gem, options) == [gem_version]
110
+ log "Sensu gem '#{gem_name}' version '#{gem_version}' is the only version installed"
111
+ else
112
+ gem_command = "gem uninstall #{gem_name} --version '!= #{gem_version}' -a"
113
+ end
114
+ end
115
+ log gem_command if options[:verbose]
116
+ if system(gem_command)
117
+ log "successfully cleaned Sensu gem '#{gem_name}'"
118
+ else
119
+ log "failed to clean Sensu gem '#{gem_name}'"
120
+ end
121
+ end
122
+
123
+ def install_plugins(plugins, options={})
124
+ log "installing Sensu plugins ..."
125
+ log "provided Sensu plugins: #{plugins}" if options[:verbose]
126
+ plugin_gems = plugins.map do |plugin|
127
+ if plugin.start_with?("sensu-plugins-")
128
+ plugin
129
+ else
130
+ "sensu-plugins-#{plugin}"
131
+ end
132
+ end
133
+ log "compiled Sensu plugin gems: #{plugin_gems}" if options[:verbose]
134
+ to_be_installed = plugin_gems.reject do |raw_gem|
135
+ gem_installed?(raw_gem, options)
136
+ end
137
+ log "Sensu plugin gems to be installed: #{to_be_installed}"
138
+ to_be_installed.each do |raw_gem|
139
+ install_gem(raw_gem, options)
140
+ end
141
+ log "successfully installed Sensu plugins: #{to_be_installed}"
142
+ if options[:clean]
143
+ log "cleaning Sensu plugin gems: #{plugin_gems}" if options[:verbose]
144
+ plugin_gems.each do |raw_gem|
145
+ clean_gem(raw_gem, options)
146
+ end
147
+ end
148
+ end
149
+
150
+ def install_extensions(extensions, options={})
151
+ if ENV["EMBEDDED_RUBY"] == "false"
152
+ log "EMBEDDED_RUBY must be set to true in order to install extensions"
153
+ log "failed to install extensions: #{extensions}"
154
+ exit 2
155
+ end
156
+ log "installing Sensu extensions ..."
157
+ log "provided Sensu extensions: #{extensions}" if options[:verbose]
158
+ extension_gems = extensions.map do |extension|
159
+ if extension.start_with?("sensu-extensions-")
160
+ extension
161
+ else
162
+ "sensu-extensions-#{extension}"
163
+ end
164
+ end
165
+ log "compiled Sensu extension gems: #{extension_gems}" if options[:verbose]
166
+ to_be_installed = extension_gems.reject do |raw_gem|
167
+ gem_installed?(raw_gem, options)
168
+ end
169
+ log "Sensu extension gems to be installed: #{to_be_installed}"
170
+ to_be_installed.each do |raw_gem|
171
+ install_gem(raw_gem, options)
172
+ end
173
+ log "successfully installed Sensu extensions: #{to_be_installed}"
174
+ if options[:clean]
175
+ log "cleaning Sensu extension gems: #{extension_gems}" if options[:verbose]
176
+ extension_gems.each do |raw_gem|
177
+ clean_gem(raw_gem, options)
178
+ end
179
+ end
180
+ end
181
+
182
+ def run
183
+ options = cli_options
184
+ unless options[:plugins].empty?
185
+ install_plugins(options[:plugins], options)
186
+ end
187
+ unless options[:extensions].empty?
188
+ install_extensions(options[:extensions], options)
189
+ end
190
+ end
191
+ end
192
+ end
193
+ end
194
+
195
+ Sensu::Install.run
data/exe/sensu-server ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ unless $:.include?(File.dirname(__FILE__) + "/../lib/")
4
+ $: << File.dirname(__FILE__) + "/../lib"
5
+ end
6
+
7
+ require "sensu/server/process"
8
+
9
+ options = Sensu::CLI.read
10
+ Sensu::Server::Process.run(options)