sensu-plugins-kubernetes 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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzEzYTU0MzBhOWY3ZDRkZTNlYTIyMmEyOTIwYmQwYjA1Y2QxMzVjZQ==
5
+ data.tar.gz: !binary |-
6
+ NGY2YTVmMWE5MGI3YTExZjIwZmE1ZTA2NWIzMmZiYmI1MWM1ZmYwYg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ M2VkZTE3OThlNTUzNTM2NmI1ZWYxYWY1ODFkMDUzYTc3OWY3M2RhMzgzMzQz
10
+ ZWRhZDcyYTYyNzYxMzFmNWFkOWQ1MzY4OTRlOWIzNDZhNDdhMWJhNGU1ZDA4
11
+ ZTI5ZTU5MDg5MzBhODljZmQwMDk3ZTRmYjFlNDY3OTI1Y2YwNjY=
12
+ data.tar.gz: !binary |-
13
+ ZjI0Y2U2NjU1ZWNlMDVlZDE3MTQ1YmY5YWVlNjFlNzdkMmUxNWJlNDIxMWZh
14
+ YWY3MmNmOGQ5NmEwMTJlYzdmMWY5NmE1NzU1NTY0YzNjOTJjOTRiYmU5N2M0
15
+ MDlhMTFhNTY1NmNhYzE1ZjExZmFiYmJlMzZlOTlmODBhMTA1MTI=
@@ -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 at [Keep A Changelog](http://keepachangelog.com/)
5
+
6
+ ## [Unreleased]
7
+
8
+ ## 0.0.1 - 2016-03-03
9
+ ### Added
10
+ - initial release
11
+
12
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/0.0.1...HEAD
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Sensu Community Plugins
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.
22
+
@@ -0,0 +1,31 @@
1
+ ## Sensu-Plugins-kubernetes
2
+
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-kubernetes.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-kubernetes)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-kubernetes.svg)](http://badge.fury.io/rb/sensu-plugins-kubernetes)
5
+ [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-kubernetes/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-kubernetes)
6
+ [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-kubernetes/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-kubernetes)
7
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-kubernetes.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-kubernetes)
8
+
9
+ ## Functionality
10
+ This provides functionality to check node and pod status as well as api and service availability.
11
+
12
+ ## Files
13
+ - bin/check-kube-nodes-ready.rb
14
+ - bin/check-kube-apiserver-available.rb
15
+ - bin/check-kube-pods-pending.rb
16
+ - bin/check-kube-service-available.rb
17
+ - bin check/kube-pods-runtime.rb
18
+ - bin/handler-kube-pod.rb
19
+
20
+ ## Usage
21
+ ```
22
+ check-kube-nodes-ready.rb -s SERVER -v API_VERSION
23
+ check-kube-apiserver-available.rb -s SERVER
24
+ check-kube-pods-pending.rb -s SERVER
25
+ check-kube-service-available.rb -s SERVER -l SERVICE1,SERVICE2
26
+ ```
27
+ ## Installation
28
+
29
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
30
+
31
+ ## Notes
@@ -0,0 +1,55 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-kube-apiserver-available.rb
4
+ #
5
+ # DESCRIPTION:
6
+ # => Check if the Kubernetes API server is up
7
+ #
8
+ # OUTPUT:
9
+ # plain text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ # gem: kube-client
17
+ #
18
+ # USAGE:
19
+ # -s SERVER - The kubernates SERVER
20
+ # -v VERSION - The kubernates api VERSION. Defaults to v1
21
+ #
22
+ # LICENSE:
23
+ # Kel Cecil <kelcecil@praisechaos.com>
24
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
25
+ # for details.
26
+ #
27
+
28
+ require 'sensu-plugin/check/cli'
29
+ require 'net/http'
30
+ require 'uri'
31
+
32
+ class ApiServerIsAvailable < Sensu::Plugin::Check::CLI
33
+ option :api_server,
34
+ description: 'URL to API server',
35
+ short: '-s URL',
36
+ long: '--api-server',
37
+ default: ENV['KUBERNETES_MASTER']
38
+
39
+ def run
40
+ cli = ApiServerIsAvailable.new
41
+ api_server = cli.config[:api_server]
42
+ uri = URI.parse "#{api_server}/healthz"
43
+
44
+ begin
45
+ response = Net::HTTP.get_response(uri)
46
+ rescue
47
+ warning 'Host is unavailable'
48
+ end
49
+
50
+ if response.code.include? '200'
51
+ ok 'Kubernetes API server is available'
52
+ end
53
+ critical 'Kubernetes API server is unavailable'
54
+ end
55
+ end
@@ -0,0 +1,71 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-kube-nodes-ready.rb
4
+ #
5
+ # DESCRIPTION:
6
+ # => Check if the Kubernetes nodes are in a ready to use state
7
+ #
8
+ # OUTPUT:
9
+ # plain text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ # gem: kube-client
17
+ #
18
+ # USAGE:
19
+ # -s SERVER - The kubernates SERVER
20
+ # -v VERSION - The kubernates api VERSION. Defaults to v1
21
+ #
22
+ # LICENSE:
23
+ # Kel Cecil <kelcecil@praisechaos.com>
24
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
25
+ # for details.
26
+ #
27
+
28
+ require 'sensu-plugin/check/cli'
29
+ require 'json'
30
+ require 'kubeclient'
31
+
32
+ class AllNodesAreReady < Sensu::Plugin::Check::CLI
33
+ option :api_server,
34
+ description: 'URL to API server',
35
+ short: '-s URL',
36
+ long: '--api-server',
37
+ default: ENV['KUBERNETES_MASTER']
38
+
39
+ option :api_version,
40
+ description: 'API version',
41
+ short: '-v VERSION',
42
+ long: '--api-version',
43
+ default: 'v1'
44
+
45
+ def run
46
+ cli = AllNodesAreReady.new
47
+ api_server = cli.config[:api_server]
48
+ api_version = cli.config[:api_version]
49
+
50
+ begin
51
+ client = Kubeclient::Client.new(api_server, api_version)
52
+ rescue
53
+ warning 'Unable to connect to Kubernetes API server'
54
+ end
55
+
56
+ failed_nodes = []
57
+ client.get_nodes.each do |node|
58
+ item = node.status.conditions.detect { |condition| condition.type == 'Ready' }
59
+ if item.nil?
60
+ warning "#{node.name} does not have a status"
61
+ elsif item.status != 'True'
62
+ failed_nodes << node.metadata.name
63
+ end
64
+ end
65
+
66
+ if failed_nodes.empty?
67
+ ok 'All nodes are reporting as ready'
68
+ end
69
+ critical "Nodes are not ready: #{failed_nodes.join(' ')}"
70
+ end
71
+ end
@@ -0,0 +1,137 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-kube-pods-pending
4
+ #
5
+ # DESCRIPTION:
6
+ # => Check if pods are stuck in a pending state or constantly restarting
7
+ #
8
+ # OUTPUT:
9
+ # plain text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ # gem: kube-client
17
+ #
18
+ # USAGE:
19
+ # -s SERVER - The kubernates SERVER
20
+ # -p PODS - Optional, list of specific pods to check. Defaults to all
21
+ # -t TIMEOUT - The timeout in seconds to warn on
22
+ # -r COUNT - The number of restarts to warn on
23
+ # -f FILTER - The selector filter to use to determine the pods to check
24
+ #
25
+ # NOTES:
26
+ # => The filter used for the -f flag is in the form key=value. If multiple
27
+ # filters need to be specfied, use a comma. ex. foo=bar,red=color
28
+ #
29
+ # LICENSE:
30
+ # Barry Martin <nyxcharon@gmail.com>
31
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
32
+ # for details.
33
+ #
34
+
35
+ require 'sensu-plugin/check/cli'
36
+ require 'json'
37
+ require 'kubeclient'
38
+
39
+ class AllPodsAreReady < Sensu::Plugin::Check::CLI
40
+ option :api_server,
41
+ description: 'URL to API server',
42
+ short: '-s URL',
43
+ long: '--api-server',
44
+ default: ENV['KUBERNETES_MASTER']
45
+
46
+ option :api_version,
47
+ description: 'API version',
48
+ short: '-v VERSION',
49
+ long: '--api-version',
50
+ default: 'v1'
51
+
52
+ option :pod_list,
53
+ description: 'List of pods to check',
54
+ short: '-p PODS',
55
+ long: '--pods',
56
+ default: 'all'
57
+
58
+ option :pending_timeout,
59
+ description: 'Threshold for pods to be in the pending state',
60
+ short: '-t TIMEOUT',
61
+ long: '--timeout',
62
+ proc: proc(&:to_i),
63
+ default: 300
64
+
65
+ option :restart_count,
66
+ description: 'Threshold for number of restarts allowed',
67
+ short: '-r COUNT',
68
+ long: '--restart',
69
+ proc: proc(&:to_i),
70
+ default: 10
71
+
72
+ option :pod_filter,
73
+ description: 'Selector filter for pods to be checked',
74
+ short: '-f FILTER',
75
+ long: '--filter'
76
+
77
+ def run
78
+ cli = AllPodsAreReady.new
79
+ api_server = cli.config[:api_server]
80
+ api_version = cli.config[:api_version]
81
+
82
+ begin
83
+ client = Kubeclient::Client.new(api_server, api_version)
84
+ rescue
85
+ warning 'Unable to connect to Kubernetes API server'
86
+ end
87
+
88
+ pods_list = []
89
+ failed_pods = []
90
+ restarted_pods = []
91
+ pods = []
92
+ if cli.config[:pod_filter].nil?
93
+ pods_list = parse_list(cli.config[:pod_list])
94
+ pods = client.get_pods
95
+ else
96
+ pods = client.get_pods(label_selector: cli.config[:pod_filter].to_s)
97
+ if pods.empty?
98
+ unknown 'The filter specified resulted in 0 pods'
99
+ end
100
+ pods_list = ['all']
101
+ end
102
+ pods.each do |pod|
103
+ next if pod.nil?
104
+ next unless pods_list.include?(pod.metadata.name) || pods_list.include?('all')
105
+ # Check for pending state
106
+ if pod.status.phase == 'Pending'
107
+ pod_stamp = Time.parse(pod.metadata.creationTimestamp)
108
+ if (Time.now.utc - pod_stamp.utc).to_i > cli.config[:pending_timeout]
109
+ failed_pods << pod.metadata.name
110
+ end
111
+ end
112
+ # Check restarts
113
+ next if pod.status.containerStatuses.nil?
114
+ pod.status.containerStatuses.each do |container|
115
+ if container.restartCount.to_i > cli.config[:restart_count]
116
+ restarted_pods << container.name
117
+ end
118
+ end
119
+ end
120
+
121
+ if failed_pods.empty? && restarted_pods.empty?
122
+ ok 'All pods are reporting as ready'
123
+ elsif failed_pods.empty?
124
+ critical "Pods exceeded restart threshold: #{restarted_pods.join(' ')}"
125
+ elsif restarted_pods.empty?
126
+ critical "Pods exceeded pending threshold: #{failed_pods.join(' ')}"
127
+ else
128
+ critical "Pod restart and pending thresholds exceeded, pending: #{failed_pods.join(' ')} restarting: #{restarted_pods.join(' ')}"
129
+ end
130
+ end
131
+
132
+ def parse_list(list)
133
+ return list.split(',') if list && list.include?(',')
134
+ return [list] if list
135
+ ['']
136
+ end
137
+ end
@@ -0,0 +1,126 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-kube-pods-runtime
4
+ #
5
+ # DESCRIPTION:
6
+ # => Check if pods are running longer than expected
7
+ #
8
+ # OUTPUT:
9
+ # plain text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ # gem: kube-client
17
+ #
18
+ # USAGE:
19
+ # -s SERVER - The kubernates SERVER
20
+ # -p PODS - REQUIRED, list of specific pods to check. Defaults to all
21
+ # -w WARN - The time in seconds to warn on
22
+ # -c CRIT - The time in seconds to flag as critical
23
+ #
24
+ # LICENSE:
25
+ # Barry Martin <nyxcharon@gmail.com>
26
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
27
+ # for details.
28
+ #
29
+
30
+ require 'sensu-plugin/check/cli'
31
+ require 'json'
32
+ require 'kubeclient'
33
+
34
+ class PodRuntime < Sensu::Plugin::Check::CLI
35
+ option :api_server,
36
+ description: 'URL to API server',
37
+ short: '-s URL',
38
+ long: '--api-server',
39
+ default: ENV['KUBERNETES_MASTER']
40
+
41
+ option :api_version,
42
+ description: 'API version',
43
+ short: '-v VERSION',
44
+ long: '--api-version',
45
+ default: 'v1'
46
+
47
+ option :pod_list,
48
+ description: 'List of pods to check',
49
+ short: '-p PODS',
50
+ long: '--pods',
51
+ default: 'all'
52
+
53
+ option :pod_filter,
54
+ description: 'Selector filter for pods to be checked',
55
+ short: '-f FILTER',
56
+ long: '--filter'
57
+
58
+ option :warn_timeout,
59
+ description: 'Threshold for pods to be in the pending state',
60
+ short: '-w TIMEOUT',
61
+ long: '--warn',
62
+ proc: proc(&:to_i)
63
+
64
+ option :critical_timeout,
65
+ description: 'Threshold for Pods to be critical',
66
+ short: '-c COUNT',
67
+ long: '--critical',
68
+ proc: proc(&:to_i)
69
+
70
+ def run
71
+ cli = PodRuntime.new
72
+ api_server = cli.config[:api_server]
73
+ api_version = cli.config[:api_version]
74
+
75
+ begin
76
+ client = Kubeclient::Client.new(api_server, api_version)
77
+ rescue
78
+ warning 'Unable to connect to Kubernetes API server'
79
+ end
80
+
81
+ pods_list = []
82
+ pods = []
83
+ warn = false
84
+ crit = false
85
+ message = ''
86
+
87
+ if cli.config[:pod_filter].nil?
88
+ pods_list = parse_list(cli.config[:pod_list])
89
+ pods = client.get_pods
90
+ else
91
+ pods = client.get_pods(label_selector: cli.config[:pod_filter].to_s)
92
+ pods_list = ['all']
93
+ end
94
+
95
+ pods.each do |pod|
96
+ next if pod.nil?
97
+ next unless pods_list.include?(pod.metadata.name) || pods_list.include?('all')
98
+ # Check for Running state
99
+ next unless pod.status.phase == 'Running'
100
+ pod_stamp = Time.parse(pod.status.startTime)
101
+ runtime = (Time.now.utc - pod_stamp.utc).to_i
102
+
103
+ if !cli.config[:critical_timeout].nil? && runtime > cli.config[:critical_timeout]
104
+ message << "#{pod.metadata.name} exceeds threshold #{cli.config[:critical_timeout]} "
105
+ crit = true
106
+ elsif !cli.config[:warn_timeout].nil? && runtime > cli.config[:warn_timeout]
107
+ message << "#{pod.metadata.name} exceeds threshold #{cli.config[:warn_timeout]} "
108
+ warn = true
109
+ end
110
+ end
111
+
112
+ if crit
113
+ critical message
114
+ elsif warn
115
+ warning message
116
+ else
117
+ ok 'All pods within threshold'
118
+ end
119
+ end
120
+
121
+ def parse_list(list)
122
+ return list.split(',') if list && list.include?(',')
123
+ return [list] if list
124
+ ['']
125
+ end
126
+ end
@@ -0,0 +1,107 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-kube-pods-service-available
4
+ #
5
+ # DESCRIPTION:
6
+ # => Check if your kube services are up and ready
7
+ #
8
+ # OUTPUT:
9
+ # plain text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ # gem: kube-client
17
+ #
18
+ # USAGE:
19
+ # -s SERVER - The kube server to use
20
+ # -l SERVICES - The comma delimited list of services to check
21
+ #
22
+ # NOTES:
23
+ #
24
+ # LICENSE:
25
+ # Barry Martin <nyxcharon@gmail.com>
26
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
27
+ # for details.
28
+ #
29
+
30
+ require 'sensu-plugin/check/cli'
31
+ require 'json'
32
+ require 'kubeclient'
33
+
34
+ class AllServicesUp < Sensu::Plugin::Check::CLI
35
+ option :api_server,
36
+ description: 'URL to API server',
37
+ short: '-s URL',
38
+ long: '--api-server',
39
+ default: ENV['KUBERNETES_MASTER']
40
+
41
+ option :api_version,
42
+ description: 'API version',
43
+ short: '-v VERSION',
44
+ long: '--api-version',
45
+ default: 'v1'
46
+
47
+ option :service_list,
48
+ description: 'List of services to check',
49
+ short: '-l SERVICES',
50
+ long: '--list',
51
+ required: true
52
+
53
+ def run
54
+ cli = AllServicesUp.new
55
+ api_server = cli.config[:api_server]
56
+ api_version = cli.config[:api_version]
57
+
58
+ begin
59
+ client = Kubeclient::Client.new(api_server, api_version)
60
+ rescue
61
+ warning 'Unable to connect to Kubernetes API server'
62
+ end
63
+
64
+ services = parse_list(cli.config[:service_list])
65
+ failed_services = []
66
+ s = client.get_services
67
+ s.each do |a|
68
+ next unless services.include?(a.metadata.name)
69
+ # Build the selector key so we can fetch the corresponding pod
70
+ selector_key = []
71
+ services.delete(a.metadata.name)
72
+ a.spec.selector.to_h.each do |k, v|
73
+ selector_key << "#{k}=#{v}"
74
+ end
75
+ # Get the pod
76
+ pod = nil
77
+ begin
78
+ pod = client.get_pods(label_selector: selector_key.join(',').to_s)
79
+ rescue
80
+ failed_services << a.metadata.name.to_s
81
+ end
82
+ # Make sure our pod is running
83
+ next if pod.nil?
84
+ pod.each do |p|
85
+ unless p.status.phase.include?('Running')
86
+ failed_services << p.metadata.name
87
+ end
88
+ end
89
+ end
90
+
91
+ if failed_services.empty? && services.empty?
92
+ ok 'All services are reporting as up'
93
+ end
94
+
95
+ if !failed_services.empty?
96
+ critical "All services are not ready: #{failed_services.join(' ')}"
97
+ else
98
+ critical "Some services could not be checked: #{services.join(' ')}"
99
+ end
100
+ end
101
+
102
+ def parse_list(list)
103
+ return list.split(',') if list && list.include?(',')
104
+ return [list] if list
105
+ ['']
106
+ end
107
+ end
@@ -0,0 +1,79 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # handler-kube-pod
4
+ #
5
+ # DESCRIPTION:
6
+ # => Deletes pods from the k8s cluster and sensu, intended to be used as a
7
+ # keepalive handler.
8
+ #
9
+ # OUTPUT:
10
+ # plain text
11
+ #
12
+ # PLATFORMS:
13
+ # Linux
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ # gem: kube-client
18
+ #
19
+ # USAGE:
20
+ # -j JSONCONFIG - The config file to us
21
+ #
22
+ # NOTES:
23
+ #
24
+ # LICENSE:
25
+ # Justin McCarty <jmccarty3@gmail.com>
26
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
27
+ # for details.
28
+ #
29
+
30
+ require 'sensu-handler'
31
+ require 'kubeclient'
32
+ require 'json'
33
+
34
+ class KubePod < Sensu::Handler
35
+ option :json_config,
36
+ description: 'Configuration name',
37
+ short: '-j JSONCONFIG',
38
+ long: '--json JSONCONFIG',
39
+ default: 'k8s'
40
+
41
+ def api_server
42
+ get_setting('api_server') || ENV['KUBERNETES_MASTER']
43
+ end
44
+
45
+ def api_version
46
+ get_setting('api_version') || 'v1'
47
+ end
48
+
49
+ def get_setting(name)
50
+ settings[config[:json_config]][name]
51
+ end
52
+
53
+ def handle
54
+ puts 'K8 handler'
55
+ response = api_request(:DELETE, '/clients/' + @event['client']['name']).code
56
+ deletion_status(response)
57
+ begin
58
+ client = Kubeclient::Client.new(api_server, api_version)
59
+ client.delete_pod @event['client']['name']
60
+ rescue KubeException => e
61
+ puts "[Kube Pod] KubeException: #{e.message}"
62
+ rescue Exception => e # rubocop:disable Lint/RescueException
63
+ puts "[Kube Pod] Unknown error #{e}"
64
+ end
65
+ end
66
+
67
+ def deletion_status(code)
68
+ case code
69
+ when '202'
70
+ puts "[Kube Pod] 202: Successfully deleted Sensu client: #{@event['client']['name']}"
71
+ when '404'
72
+ puts "[Kube Pod] 404: Unable to delete #{@event['client']['name']}, doesn't exist!"
73
+ when '500'
74
+ puts "[Kube Pod] 500: Miscellaneous error when deleting #{@event['client']['name']}"
75
+ else
76
+ puts "[Kube Pod] #{code}: Completely unsure of what happened!"
77
+ end
78
+ end
79
+ end
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-kubernetes/version'
@@ -0,0 +1,9 @@
1
+ module SensuPluginsKubernetes
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 1
6
+
7
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-kubernetes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins and contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-04 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: kubeclient
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.1
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.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '10.5'
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.37'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: '0.37'
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.4'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: '3.4'
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 kubernetes plugins
168
+ email: <sensu-users@googlegroups.com>
169
+ executables:
170
+ - check-kube-apiserver-available.rb
171
+ - check-kube-nodes-ready.rb
172
+ - check-kube-pods-pending.rb
173
+ - check-kube-pods-runtime.rb
174
+ - check-kube-service-available.rb
175
+ - handler-kube-pod.rb
176
+ extensions: []
177
+ extra_rdoc_files: []
178
+ files:
179
+ - CHANGELOG.md
180
+ - LICENSE
181
+ - README.md
182
+ - bin/check-kube-apiserver-available.rb
183
+ - bin/check-kube-nodes-ready.rb
184
+ - bin/check-kube-pods-pending.rb
185
+ - bin/check-kube-pods-runtime.rb
186
+ - bin/check-kube-service-available.rb
187
+ - bin/handler-kube-pod.rb
188
+ - lib/sensu-plugins-kubernetes.rb
189
+ - lib/sensu-plugins-kubernetes/version.rb
190
+ homepage: https://github.com/sensu-plugins/sensu-plugins-kubernetes
191
+ licenses:
192
+ - MIT
193
+ metadata:
194
+ maintainer: sensu-plugin
195
+ development_status: active
196
+ production_status: unstable - testing recommended
197
+ release_draft: 'false'
198
+ release_prerelease: 'false'
199
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
200
+ in /etc/default/sensu
201
+ rdoc_options: []
202
+ require_paths:
203
+ - lib
204
+ required_ruby_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ! '>='
207
+ - !ruby/object:Gem::Version
208
+ version: 2.0.0
209
+ required_rubygems_version: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ requirements: []
215
+ rubyforge_project:
216
+ rubygems_version: 2.4.5
217
+ signing_key:
218
+ specification_version: 4
219
+ summary: Sensu plugins for kubernetes
220
+ test_files: []