Sha256: f0cd332108c0232b7cef809f73eab7883d342b311b676e9ae1c257086e1b6111
Contents?: true
Size: 1.95 KB
Versions: 2
Compression:
Stored size: 1.95 KB
Contents
#! /usr/bin/env ruby # # check-boundary-meters # # DESCRIPTION: # This plugin interrogates a boundary api endpoint for the connection health of meters. # It reports a list of meters that are currently disconnected. # # OUTPUT: # metric-data # # PLATFORMS: # Linux # # DEPENDENCIES: # gem: beaneater # gem: json # gem: sensu-plugin # # USAGE: # #YELLOW # # NOTES: # Based on code from check-chef-nodes.rb # # LICENSE: # Copyright 2014 Sonian, Inc. and contributors. <support@sensuapp.org> # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. # require 'sensu-plugin/check/cli' require 'rest-client' require 'json' # # Boundary Meters Checker # class BoundaryMetersChecker < Sensu::Plugin::Check::CLI option :endpoint, description: 'Boundary API endpoint', short: '-e API-ENDPOINT', long: '--endpoint API-ENDPOINT', default: 'api.boundary.com' option :org, description: 'Organisation ID', short: '-o ORG-ID', long: '--org-id ORG-ID', required: true option :key, description: 'API key', short: '-k API-KEY', long: '--key API-KEY', required: true def meter_connected_status meters.map do |meter| { meter['name'] => meter['connected'] } end end def run if all_meters_connected? ok 'Boundary connectivity is ok, all meters reporting' else critical "The following meters are not reporting: #{disconnected_names}" end end private def meters response = RestClient.get("https://#{config[:key]}:@#{config[:endpoint]}/#{config[:org]}/meters") JSON.parse response.body end def all_meters_connected? meter_connected_status.map(&:values).flatten.all? { |x| x == 'true' } end def disconnected_names disconnected = meter_connected_status.select { |meter| meter.values.first == 'false' } disconnected.map(&:keys).flatten.sort.join(', ').downcase end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sensu-plugins-boundary-0.0.1 | bin/check-boundary-meters.rb |
sensu-plugins-boundary-0.0.1.alpha.1 | bin/check-boundary-meters.rb |