Sha256: 25c183183a5d51313024477f011bd8775bffa29893e9f5ccd9125be5bcfbbf64

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 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 Host',
         short: '-s SERVER',
         long: '--server SERVER',
         default: 'localhost'

  option :mode,
         description: 'master or slave',
         short: '-m MODE',
         long: '--mode MODE',
         required: true

  option :timeout,
         description: 'timeout in seconds',
         short: '-t TIMEOUT',
         long: '--timeout TIMEOUT',
         proc: proc(&:to_i),
         default: 5

  def run
    case config[:mode]
    when 'master'
      port = '5050'
      uri = '/master/health'
    when 'slave'
      port = '5051'
      uri = '/slave(1)/health'
    end
    begin
      r = RestClient::Resource.new("http://#{config[:server]}:#{port}#{uri}", timeout: config[:timeout]).get
      if r.code == 200
        ok "Mesos #{config[:mode]} is up"
      else
        critical "Mesos #{config[:mode]} is not responding"
      end
    rescue Errno::ECONNREFUSED
      critical "Mesos #{config[:mode]} is not responding"
    rescue RestClient::RequestTimeout
      critical "Mesos #{config[:mode]} Connection timed out"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sensu-plugins-mesos-0.0.3 bin/check-mesos.rb