sensu-plugins-foreman 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bd5b7dac8c5758b96aa6e960ebb54421789e6ae23f0b6fee6a2eb696bd338634
4
+ data.tar.gz: 1358f88d1859c86092fb7e99d7c5f0ebfa5c323ee268acff97f4605fe09caeb9
5
+ SHA512:
6
+ metadata.gz: 4c4e5e194f4f4c4a17186c3b9324f97b52b2dce719624e6c1fc9754e6b1d2f167ec23b16eeef40ed48bf4c04eab334e25ad540f68f67fd4f3d5ec833c0b53899
7
+ data.tar.gz: 1c5370a186a624bc8688d7c71ebfd2b7ef571db1cf092a2055a3d8e2e0dd2f5b544916d892fc3ad88f3165235a8f8d574cc8c1b9ec368556c540c7e508bc0b95
@@ -0,0 +1,26 @@
1
+ description: "#{repo}"
2
+ builds:
3
+ - platform: "debian"
4
+ arch: "amd64"
5
+ asset_filename: "#{repo}_#{version}_debian_linux_amd64.tar.gz"
6
+ sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
7
+ filter:
8
+ - "entity.system.os == 'linux'"
9
+ - "entity.system.arch == 'amd64'"
10
+ - "entity.system.platform == 'debian'"
11
+ - platform: "centos"
12
+ arch: "amd64"
13
+ asset_filename: "#{repo}_#{version}_centos_linux_amd64.tar.gz"
14
+ sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
15
+ filter:
16
+ - "entity.system.os == 'linux'"
17
+ - "entity.system.arch == 'amd64'"
18
+ - "entity.system.platform == 'rhel'"
19
+ - platform: "alpine"
20
+ arch: "amd64"
21
+ asset_filename: "#{repo}_#{version}_alpine_linux_amd64.tar.gz"
22
+ sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
23
+ filter:
24
+ - "entity.system.os == 'linux'"
25
+ - "entity.system.arch == 'amd64'"
26
+ - "entity.system.platform == 'alpine'"
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,18 @@
1
+ require:
2
+ - rubocop-performance
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.4
6
+
7
+ Naming/FileName:
8
+ Exclude:
9
+ - 'lib/sensu-plugins-foreman.rb'
10
+
11
+ Metrics/LineLength:
12
+ Max: 120
13
+
14
+ Metrics/MethodLength:
15
+ Max: 20
16
+
17
+ Metrics/AbcSize:
18
+ Max: 20
@@ -0,0 +1,48 @@
1
+ sudo: required
2
+ language: ruby
3
+
4
+ rvm:
5
+ - 2.5.5
6
+
7
+ services:
8
+ - docker
9
+
10
+ cache:
11
+ - bundler
12
+
13
+ before_install:
14
+ - gem install bundler
15
+
16
+ install:
17
+ - bundle install
18
+
19
+ script:
20
+ - gem build sensu-plugins-foreman.gemspec
21
+ - gem install sensu-plugins-foreman-*.gem
22
+
23
+ before_deploy:
24
+ - bash -c "[ ! -d bonsai/ ] && git clone https://github.com/sensu/sensu-go-bonsai-asset.git bonsai || echo 'bonsai/ exists, skipping git clone'"
25
+
26
+ deploy:
27
+ - provider: rubygems
28
+ api_key:
29
+ secure: acgMaDcv3myahq4wzN4i7b4g22vrd2EOAutZEyYcmczQTEXM8PGRo08n0F6HkJs1Mgo73jn+u8nrlTItTserEsaiRFyGcyFgi8EQt8DvqPzbDPyq/yPse0/r7uxPVTHAUREVuQRoZreEi+V+aSkNn9R3GRbXFjiVorYnM2rZvGhDiw9i+S3gq0j0jo2H2AE3JKHtatdrI3MTAha3LCgkfhwmJURr/4r0Dp/0wfuRpLhrO+tLTVDfIffxAQ/oRDLXnu4VJ21cM2ejyx4lGHxPPmGoOvc3rZFLFd8MQN/CtsuBqIbBIjLe5gkqD4HxfM3DM1HFxE7GGquk7V1RpW2rjcTF+kO6zYh7hS9fz4ccRL3prWFXg9qwQ24D54XVqDhXm3R2e5IRRoq4vOYq7LMv4ejdBZGNzEnGYzZSy/up9W9wydtySP7mFZsxu0qlJLgSXCgM5dz6KHth9U6HJgp46LwkQVrF6czWH1lGyPv9HqgASjrTUaNdFjoaseZEVB6CXiiCbhj2iT7EHk7/AGNW3hmp3YODgdFm3Ehd+gwK6KhTS4btfRsQwGA6qBhrwOTpmedx+B53Y5clcpkxZRYQfsz3pN9KU2lVSsWj70mOofwdl6VwFJoX/Q0jd9fDncGyH9+KrwfyGSQb5yKMn8OQcVIg5w+HKlya2XroH0faPTI=
30
+ gem: sensu-plugins-foreman
31
+ on:
32
+ tags: true
33
+ all_branches: true
34
+ rvm: 2.5.5
35
+ repo: SICSoftwareGmbH/sensu-plugins-foreman
36
+
37
+ - provider: script
38
+ script:
39
+ - ./deploy.sh
40
+ skip_cleanup: true
41
+ on:
42
+ tags: true
43
+ all_branches: true
44
+ rvm: 2.5.5
45
+
46
+ env:
47
+ global:
48
+ secure: "FLaeOypv/KK9RPGjshGWB5Vbh3JigzxeKD0XGhur/flxxCu8LhbUuNRd2maxU77cZoYEk+wU/YiHSJbWyjmA2JTPvmgrKGz4O5AjPG6+F52D8VhkX8dzYwi/7S4XlfMl9i33tog3ifpwi2lVYoImIr1SDzJKZBg7NyEqAkvAUGGLIaUZILc0EtIROgL72wsUk+Xcr2Y+9HXgk+LCNSuoFEPsKrOV5NAWvLfAdhStmkF7s40SdigEtmqovy7tbhn+EA84QoU4VuzhR8d1+IlovmvuTODUg00br5kPMLXwwVjMvZlcDSm1G02GaUiADccRwjuYdOrApWRJSECUYHDVkDLMcitCvuAlmm0+dCAQ+kzH41BV0+FnAKUl3m0wsp+PgfULG6c6/B+dxwg3xrcq04eINJpa8jchJ623Tt11LmkTxQ4N6fcpGYeFLiP6onwrjUCr0eK0v8cdrIg8gb/kw55MnpNKSkjt2RseJRK8yy5yIFA6Jzkja/rlMhVgvxKNcjdHcfaZnyA1tbvM301vfwP7DFCwZSpJfIcsCeMNkMcM7aKabXx3Mx9/TVWm2fehkjfvyRT8FKk9b8Qzlc4u5TYdOTg9RA+B/eF3cqef0S+QMSfVmijBjSqwMHXJCkUqe4GLIHueTu9agXTaMoFU0tZsnlFOxgrBRxSlVLcs8qA="
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2019-08-12
10
+ ### Added
11
+ - check if foreman-proxy is alive
12
+ - check if foreman-proxy provides required features
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in foo.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 SIC! Software GmbH
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ ## sensu-plugins-foreman
2
+
3
+ [![Build Status](https://travis-ci.org/SICSoftwareGmbH/sensu-plugins-foreman.svg?branch=master)](https://travis-ci.org/SICSoftwareGmbH/sensu-plugins-foreman)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-foreman.svg)](http://badge.fury.io/rb/sensu-plugins-foreman)
5
+ [![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/SICSoftwareGmbH/sensu-plugins-foreman)
6
+
7
+ This plugin provides checks for [foreman](https://theforeman.org).
8
+
9
+ ## Sensu Asset
10
+ The Sensu assets packaged from this repository are built against the Sensu ruby runtime environment. When using these assets as part of a Sensu Go resource (check, mutator or handler), make sure you include the corresponding Sensu ruby runtime asset in the list of assets needed by the resource. The current ruby-runtime assets can be found [here](https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime) in the [Bonsai Asset Index](https://bonsai.sensu.io).
11
+
12
+ ## Functionality
13
+
14
+ ## Files
15
+ * bin/check-foreman-proxy-alive
16
+ * bin/check-foreman-proxy-features
17
+
18
+ ## Installation
19
+
20
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ task default: :spec
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # check-foreman-proxy-alive
6
+ #
7
+ # DESCRIPTION:
8
+ # Checks if foreman-proxy is alive
9
+ #
10
+ # OUTPUT:
11
+ # Plain text
12
+ #
13
+ # PLATFORMS:
14
+ # Linux
15
+ #
16
+ # DEPENDENCIES:
17
+ # gem: sensu-plugin
18
+ #
19
+ # LICENSE:
20
+ # SIC! Software GmbH <info@sic.software>
21
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
22
+ # for details.
23
+ #
24
+
25
+ require 'sensu-plugin/check/cli'
26
+ require 'net/https'
27
+ require 'json'
28
+
29
+ # Checks if foreman-proxy daemon is working
30
+ class CheckForemanProxy < Sensu::Plugin::Check::CLI
31
+ DEFAULT_URL = 'https://localhost:8443/'
32
+
33
+ option :url,
34
+ short: '-u URL',
35
+ long: '--url URL',
36
+ description: 'URL of foreman-proxy',
37
+ default: nil
38
+
39
+ def run
40
+ check
41
+ rescue StandardError => e
42
+ critical("Request error: #{e.message}")
43
+ end
44
+
45
+ private
46
+
47
+ def url
48
+ return config[:url] if config[:url]&.positive?
49
+
50
+ DEFAULT_URL
51
+ end
52
+
53
+ def version_response
54
+ uri = URI.parse(File.join(url, 'version'))
55
+
56
+ http = Net::HTTP.new(uri.host, uri.port, nil, nil)
57
+ http.use_ssl = true
58
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
59
+
60
+ req = Net::HTTP::Get.new(uri.request_uri)
61
+
62
+ http.request(req)
63
+ end
64
+
65
+ def parse_version_response(res)
66
+ data = JSON.parse(res.body)
67
+
68
+ [data['version'], data['modules']]
69
+ end
70
+
71
+ def check
72
+ res = version_response
73
+
74
+ if res.code.to_i == 200
75
+ version, modules = parse_version_response(res)
76
+
77
+ modules = modules.keys.map { |k| "#{k} (#{modules[k]})" }.join(', ')
78
+
79
+ ok("version: #{version}, modules: #{modules}")
80
+ else
81
+ critical(res.body)
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # check-foreman-proxy-features
6
+ #
7
+ # DESCRIPTION:
8
+ # Checks for required foreman-proxy features
9
+ #
10
+ # OUTPUT:
11
+ # Plain text
12
+ #
13
+ # PLATFORMS:
14
+ # Linux
15
+ #
16
+ # DEPENDENCIES:
17
+ # gem: sensu-plugin
18
+ #
19
+ # LICENSE:
20
+ # SIC! Software GmbH <info@sic.software>
21
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
22
+ # for details.
23
+ #
24
+
25
+ require 'sensu-plugin/check/cli'
26
+ require 'net/https'
27
+ require 'json'
28
+
29
+ # Checks if foreman-proxy daemon is working
30
+ class CheckForemanProxy < Sensu::Plugin::Check::CLI
31
+ DEFAULT_URL = 'https://localhost:8443/'
32
+
33
+ option :url,
34
+ short: '-u URL',
35
+ long: '--url URL',
36
+ description: 'URL of foreman-proxy',
37
+ default: nil
38
+
39
+ option :features,
40
+ short: '-f FEATURES',
41
+ long: '--features FEATURES',
42
+ description: 'Comma separated list of required features',
43
+ default: ''
44
+
45
+ def run
46
+ check
47
+ rescue StandardError => e
48
+ critical("Request error: #{e.message}")
49
+ end
50
+
51
+ private
52
+
53
+ def url
54
+ return config[:url] if config[:url]&.positive?
55
+
56
+ DEFAULT_URL
57
+ end
58
+
59
+ def features
60
+ config[:features].split(',').map(&:strip)
61
+ end
62
+
63
+ def features_response
64
+ uri = URI.parse(File.join(url, 'features'))
65
+
66
+ http = Net::HTTP.new(uri.host, uri.port, nil, nil)
67
+ http.use_ssl = true
68
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
69
+
70
+ req = Net::HTTP::Get.new(uri.request_uri)
71
+
72
+ http.request(req)
73
+ end
74
+
75
+ def parse_features_response(res)
76
+ JSON.parse(res.body)
77
+ end
78
+
79
+ def process_available_features(available_features)
80
+ missing = features - available_features
81
+ unwanted = available_features - features
82
+
83
+ if missing.any? || unwanted.any?
84
+ messages = []
85
+ messages << "missing: #{missing.join(', ')}" if missing.any?
86
+ messages << "unwanted: #{unwanted.join(', ')}" if unwanted.any?
87
+
88
+ warning(messages.join(', '))
89
+ else
90
+ ok("available: #{available_features.join(', ')}")
91
+ end
92
+ end
93
+
94
+ def check
95
+ res = features_response
96
+
97
+ if res.code.to_i == 200
98
+ available_features = parse_features_response(res)
99
+
100
+ process_available_features(available_features)
101
+ else
102
+ critical(res.body)
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,5 @@
1
+ #!/bin/bash -e
2
+
3
+ curl -s -H "Authorization: token ${GITHUB_TOKEN}" --data "{\"tag_name\": \"${TRAVIS_TAG}\"}" -X POST "https://api.github.com/repos/${TRAVIS_REPO_SLUG}/releases"
4
+
5
+ ./bonsai/ruby-runtime/travis-build-ruby-plugin-assets.sh sensu-plugins-foreman
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'sensu-plugins-foreman/version'
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SensuPluginsForeman
4
+ module Version
5
+ MAJOR = 0
6
+ MINOR = 1
7
+ PATCH = 0
8
+
9
+ STRING = [MAJOR, MINOR, PATCH].compact.join('.')
10
+ end
11
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'sensu-plugins-foreman/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'sensu-plugins-foreman'
9
+ spec.version = SensuPluginsForeman::Version::STRING
10
+ spec.authors = ['SIC! Software GmbH', 'Florian Schwab']
11
+ spec.email = ['info@sic.software', 'me@ydkn.io']
12
+ spec.summary = 'This plugin provides checks for foreman'
13
+ spec.description = 'Sensu plugins for foreman'
14
+ spec.homepage = 'https://github.com/SICSoftwareGmbH/sensu-plugins-foreman'
15
+ spec.license = 'MIT'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = spec.homepage
19
+ spec.metadata['changelog_uri'] = 'https://github.com/SICSoftwareGmbH/sensu-plugins-foreman/blob/master/CHANGELOG.md'
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = 'bin'
27
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_development_dependency 'bundler', '~> 2.0'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-foreman
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - SIC! Software GmbH
8
+ - Florian Schwab
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2019-08-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ description: Sensu plugins for foreman
43
+ email:
44
+ - info@sic.software
45
+ - me@ydkn.io
46
+ executables:
47
+ - check-foreman-proxy-alive
48
+ - check-foreman-proxy-features
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - ".bonsai.yml"
53
+ - ".gitignore"
54
+ - ".rubocop.yml"
55
+ - ".travis.yml"
56
+ - CHANGELOG.md
57
+ - Gemfile
58
+ - LICENSE
59
+ - README.md
60
+ - Rakefile
61
+ - bin/check-foreman-proxy-alive
62
+ - bin/check-foreman-proxy-features
63
+ - deploy.sh
64
+ - lib/sensu-plugins-foreman.rb
65
+ - lib/sensu-plugins-foreman/version.rb
66
+ - sensu-plugins-foreman.gemspec
67
+ homepage: https://github.com/SICSoftwareGmbH/sensu-plugins-foreman
68
+ licenses:
69
+ - MIT
70
+ metadata:
71
+ homepage_uri: https://github.com/SICSoftwareGmbH/sensu-plugins-foreman
72
+ source_code_uri: https://github.com/SICSoftwareGmbH/sensu-plugins-foreman
73
+ changelog_uri: https://github.com/SICSoftwareGmbH/sensu-plugins-foreman/blob/master/CHANGELOG.md
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubygems_version: 3.0.4
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: This plugin provides checks for foreman
93
+ test_files: []