Adding check_sentinel

This commit is contained in:
Jan Wagner 2014-10-06 13:50:32 +02:00
parent 43be123a11
commit 9c91dfd76e
8 changed files with 156 additions and 1 deletions

4
check_sentinel/Makefile Normal file
View file

@ -0,0 +1,4 @@
#/usr/bin/make -f
include ../common.mk

View 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

View 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
View 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
View 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.

View file

@ -34,6 +34,9 @@ check_phpfpm_status:
check_redis:
Required Packages: libredis-perl
check_sentinel:
Required Packages: ruby-redis
check_tftp:
Required Packages: libnet-tftp-perl

3
debian/control vendored
View file

@ -11,7 +11,7 @@ Vcs-Browser: http://github.com/waja/monitoring-plugins-cyconet
Package: monitoring-plugins-cyconet
Architecture: any
Depends: ${misc:Depends}
Recommends: ${shlibs:Depends}, ${python:Depends}, libnet-snmp-perl, nagios-plugins-common, libtime-modules-perl, libwww-perl, python-argparse, libredis-perl, libnet-tftp-perl, libxml-xpath-perl, ${perl:Depends}
Recommends: ${shlibs:Depends}, ${python:Depends}, libnet-snmp-perl, nagios-plugins-common, libtime-modules-perl, libwww-perl, python-argparse, libredis-perl, ruby-redis, libnet-tftp-perl, libxml-xpath-perl, ${perl:Depends}
Suggests:
Enhances: nagios-plugins, nagios-plugins-basic, nagios-plugins-standard
Description: Plugins for nagios compatible monitoring systems
@ -29,6 +29,7 @@ Description: Plugins for nagios compatible monitoring systems
* check_openvpn (20130904): plugin to check if an OpenVPN server runs on a given port
* check_phpfpm_status (0.9): plugin to check the fpm-status page report from php-fpm
* check_redis (0.72): plugin that verifies redis server is working.
* check_sentinel (0b8e0e388a): plugin to monitor Redis sentinel
* check_tftp (0.11): plugin that verifies TFTP server is working.
* check_tomcat (1.4): plugin to check the tomcat status page.
.

30
debian/copyright vendored
View file

@ -169,6 +169,36 @@ http://william.leibzon.org/nagios/
------------------------------------------------------------------------------
check_sentinel:
The plugin was downloaded from:
https://raw.github.com/reedox/check_sentinel/master/check_sentinel
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.
------------------------------------------------------------------------------
check_tftp: