Adding check_sentinel
This commit is contained in:
parent
43be123a11
commit
9c91dfd76e
8 changed files with 156 additions and 1 deletions
4
check_sentinel/Makefile
Normal file
4
check_sentinel/Makefile
Normal file
|
@ -0,0 +1,4 @@
|
|||
#/usr/bin/make -f
|
||||
|
||||
include ../common.mk
|
||||
|
84
check_sentinel/check_sentinel
Normal file
84
check_sentinel/check_sentinel
Normal file
|
@ -0,0 +1,84 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Nagios plugin to monitor Redis sentinel
|
||||
#
|
||||
# Checks general connectivity to a Redis sentinel server and will go critical
|
||||
# for any of the following conditions:
|
||||
# * Inability to connect to the sentinel server
|
||||
# * Sentinel reports it isn't monitoring any masters
|
||||
# * Sentinel has entered TILT mode
|
||||
#
|
||||
# Arguments:
|
||||
# -H --host HOSTNAME to connect to (defaults to 127.0.0.1)
|
||||
# -p --port PORT to connect to (defaults to 26379)
|
||||
#
|
||||
# Requires the "redis" Rubygem
|
||||
#
|
||||
# Author: Chris Boulton <chris@chrisboulton.com>
|
||||
# License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
#
|
||||
|
||||
require 'redis'
|
||||
require 'optparse'
|
||||
|
||||
STATES = {
|
||||
:ok => 0,
|
||||
:warning => 1,
|
||||
:critical => 2,
|
||||
:unknown => 3,
|
||||
}
|
||||
|
||||
options = {
|
||||
:host => '127.0.0.1',
|
||||
:port => 26379,
|
||||
:timeout => 2,
|
||||
}
|
||||
|
||||
$results = []
|
||||
$exit_status = :ok
|
||||
|
||||
def add_state(status, msg, should_exit = false)
|
||||
$results.push(msg)
|
||||
$exit_status = status if STATES[status] > STATES[$exit_status]
|
||||
if should_exit
|
||||
do_exit
|
||||
end
|
||||
end
|
||||
|
||||
def add_info(msg)
|
||||
$results.push(msg)
|
||||
end
|
||||
|
||||
def do_exit
|
||||
puts "#{$exit_status.upcase} - #{$results.join('. ')}"
|
||||
exit STATES[$exit_status]
|
||||
end
|
||||
|
||||
optparse = OptionParser.new do |opts|
|
||||
opts.on('-H', '--host HOST', 'Hostname') do |h|
|
||||
options[:host] = h
|
||||
end
|
||||
|
||||
opts.on('-p', '--port PORT', 'Port') do |p|
|
||||
options[:port] = p.to_i
|
||||
end
|
||||
end
|
||||
optparse.parse!
|
||||
|
||||
begin
|
||||
redis = Redis.new(:host => options[:host], :port => options[:port], :timeout => options[:timeout])
|
||||
|
||||
info = redis.info
|
||||
add_state(:critical, "Redis instance is not configured as a sentinel", true) unless info['sentinel_masters']
|
||||
add_state(:critical, "Sentinel has entered TILT mode", true) if info['sentinel_tilt'] != '0'
|
||||
|
||||
if info['sentinel_masters'] == '0'
|
||||
add_state(:critical, "Sentinel is not monitoring any masters", true)
|
||||
else
|
||||
add_info("Monitoring #{info['sentinel_masters']} masters")
|
||||
end
|
||||
rescue Redis::CannotConnectError => e
|
||||
add_state(:critical, e, true)
|
||||
end
|
||||
|
||||
do_exit
|
6
check_sentinel/check_sentinel.cfg
Normal file
6
check_sentinel/check_sentinel.cfg
Normal file
|
@ -0,0 +1,6 @@
|
|||
# 'check_sentinel' command definition
|
||||
define command {
|
||||
command_name check_sentinel
|
||||
command_line /usr/lib/monitoring-plugins/check_sentinel -H '$HOSTADDRESS$' -p '$ARG1$'
|
||||
}
|
||||
|
6
check_sentinel/control
Normal file
6
check_sentinel/control
Normal file
|
@ -0,0 +1,6 @@
|
|||
Homepage: https://raw.github.com/reedox/check_sentinel/master/check_sentinel
|
||||
Watch: https://github.com/reedox/check_sentinel <span class="sha">([0-9a-f]+)</span>
|
||||
Recommends: ruby-redis
|
||||
Version: 0b8e0e388a
|
||||
Uploaders: Jan Wagner <waja@cyconet.org>
|
||||
Description: plugin to monitor Redis sentinel
|
21
check_sentinel/copyright
Normal file
21
check_sentinel/copyright
Normal file
|
@ -0,0 +1,21 @@
|
|||
Copyright Chris Boulton <chris@chrisboulton.com>
|
||||
|
||||
License: MIT
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
Loading…
Add table
Add a link
Reference in a new issue