Sha256: 3bfd4b1f163a428cffac2a27ef8ebc8a41a0474bd735198ec7b296ceecf5ae10
Contents?: true
Size: 1.84 KB
Versions: 9
Compression:
Stored size: 1.84 KB
Contents
#! /usr/bin/env ruby # # check-metronome # # DESCRIPTION: # This plugin checks that Metronome can query the existing job graph. # # OUTPUT: # plain text # # PLATFORMS: # Linux # # DEPENDENCIES: # gem: sensu-plugin # gem: rest-client # # USAGE: # # # NOTES: # # LICENSE: # Copyright 2017, PTC (www.ptc.com) # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. # require 'sensu-plugin/check/cli' require 'rest-client' class MetronomeNodeStatus < Sensu::Plugin::Check::CLI option :server, description: 'Metronome hosts, comma separated', short: '-s SERVER', long: '--server SERVER', default: 'localhost' option :port, description: 'Metronome port', short: '-p PORT', long: '--port PORT', default: '9942' option :uri, description: 'Endpoint URI', short: '-u URI', long: '--uri URI', default: '/v1/jobs' option :timeout, description: 'timeout in seconds', short: '-t TIMEOUT', long: '--timeout TIMEOUT', proc: proc(&:to_i), default: 5 def run servers = config[:server] uri = config[:uri] failures = [] servers.split(',').each do |server| begin r = RestClient::Resource.new("http://#{server}:#{config[:port]}#{uri}", timeout: config[:timeout]).get if r.code != 200 failures << "Metronome on #{server} is not responding" end rescue Errno::ECONNREFUSED, RestClient::ResourceNotFound, SocketError failures << "Metronome on #{server} is not responding" rescue RestClient::RequestTimeout failures << "Metronome on #{server} connection timed out" end end if failures.empty? ok "Metronome is running on #{servers}" else critical failures.join("\n") end end end
Version data entries
9 entries across 9 versions & 1 rubygems