Sha256: 55962e7937eca2454a359917999918d89ddc5059de0a1e53b6786d25937a9b7b

Contents?: true

Size: 1.92 KB

Versions: 9

Compression:

Stored size: 1.92 KB

Contents

#! /usr/bin/env ruby
#
#   check-mesos
#
# DESCRIPTION:
#   This plugin checks that the health url returns 200 OK
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Linux
#
# DEPENDENCIES:
#   gem: sensu-plugin
#   gem: rest-client
#
# USAGE:
#   #YELLOW
#
# NOTES:
#
# LICENSE:
#   Copyright 2015, Tom Stockton (tom@stocktons.org.uk)
#   Released under the same terms as Sensu (the MIT license); see LICENSE
#   for details.
#

require 'sensu-plugin/check/cli'
require 'rest-client'

class MesosNodeStatus < Sensu::Plugin::Check::CLI
  option :server,
         description: 'Mesos servers, comma separated',
         short: '-s SERVER1,SERVER2,...',
         long: '--server SERVER1,SERVER2,...',
         default: 'localhost'

  option :port,
         description: 'port (default 5050, use 5051 for slaves)',
         short: '-p PORT',
         long: '--port PORT',
         default: 5050,
         required: false

  option :uri,
         description: 'Endpoint URI',
         short: '-u URI',
         long: '--uri URI',
         default: '/health'

  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]
    port = config[:port]
    failures = []
    servers.split(',').each do |server|
      begin
        r = RestClient::Resource.new("http://#{server}:#{port}#{uri}", timeout: config[:timeout]).get
        if r.code != 200
          failures << "Mesos on #{server} is not responding"
        end
      rescue Errno::ECONNREFUSED, RestClient::ResourceNotFound, SocketError
        failures << "Mesos on #{server} is not responding"
      rescue RestClient::RequestTimeout
        failures << "Mesos on #{server} connection timed out"
      end
    end
    if failures.empty?
      ok "Mesos is running on #{servers}"
    else
      critical failures.join("\n")
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sensu-plugins-mesos-2.5.0 bin/check-mesos.rb
sensu-plugins-mesos-2.4.0 bin/check-mesos.rb
sensu-plugins-mesos-2.3.0 bin/check-mesos.rb
sensu-plugins-mesos-2.1.2 bin/check-mesos.rb
sensu-plugins-mesos-2.1.1 bin/check-mesos.rb
sensu-plugins-mesos-2.1.0 bin/check-mesos.rb
sensu-plugins-mesos-2.0.0 bin/check-mesos.rb
sensu-plugins-mesos-1.1.0 bin/check-mesos.rb
sensu-plugins-mesos-1.0.0 bin/check-mesos.rb