diff options
author | demon <demon@FreeBSD.org> | 2014-02-03 19:27:39 +0800 |
---|---|---|
committer | demon <demon@FreeBSD.org> | 2014-02-03 19:27:39 +0800 |
commit | 726ca90ada5ad903205bffc3d9c41a649099990b (patch) | |
tree | 141733f62cc52f5eaaf2d29153d32ed7284d0aa4 /databases | |
parent | b1c046de1f0e61ec202989a62d7fe7db94096a7a (diff) | |
download | freebsd-ports-gnome-726ca90ada5ad903205bffc3d9c41a649099990b.tar.gz freebsd-ports-gnome-726ca90ada5ad903205bffc3d9c41a649099990b.tar.zst freebsd-ports-gnome-726ca90ada5ad903205bffc3d9c41a649099990b.zip |
New port: nagios-check_redis.
Nagios plugin to check redis status.
Diffstat (limited to 'databases')
-rw-r--r-- | databases/Makefile | 1 | ||||
-rw-r--r-- | databases/nagios-check_redis/Makefile | 27 | ||||
-rw-r--r-- | databases/nagios-check_redis/files/check_redis | 83 | ||||
-rw-r--r-- | databases/nagios-check_redis/pkg-descr | 4 |
4 files changed, 115 insertions, 0 deletions
diff --git a/databases/Makefile b/databases/Makefile index 8b80875f8f86..1b35f89d6dd6 100644 --- a/databases/Makefile +++ b/databases/Makefile @@ -246,6 +246,7 @@ SUBDIR += mytop SUBDIR += mywwwatcher SUBDIR += nagios-check_postgres_replication + SUBDIR += nagios-check_redis SUBDIR += namazu2 SUBDIR += ocaml-mysql SUBDIR += ocaml-pgocaml diff --git a/databases/nagios-check_redis/Makefile b/databases/nagios-check_redis/Makefile new file mode 100644 index 000000000000..11b8e03b7f99 --- /dev/null +++ b/databases/nagios-check_redis/Makefile @@ -0,0 +1,27 @@ +# Created by: Dmitry Sivachenko <demon@FreeBSD.org> +# $FreeBSD$ + +PORTNAME= check_netsnmp +PORTVERSION= 0.1 +CATEGORIES= databases perl5 +MASTER_SITES= # +PKGNAMEPREFIX= nagios- +DISTFILES= # none + +MAINTAINER= demon@FreeBSD.org +COMMENT= Nagios plugin to check redis server + +RUN_DEPENDS= ${LOCALBASE}/libexec/nagios/utils.pm:${PORTSDIR}/net-mgmt/nagios-plugins \ + p5-Redis>=0:${PORTSDIR}/databases/p5-Redis \ + p5-Net-SNMP>=0:${PORTSDIR}/net-mgmt/p5-Net-SNMP + +USES= perl5 +USE_PERL5= run +NO_BUILD= yes +PLIST_FILES= libexec/nagios/check_redis + +do-install: + ${MKDIR} ${STAGEDIR}${PREFIX}/libexec/nagios + ${INSTALL_SCRIPT} ${FILESDIR}/check_redis ${STAGEDIR}${PREFIX}/libexec/nagios/ + +.include <bsd.port.mk> diff --git a/databases/nagios-check_redis/files/check_redis b/databases/nagios-check_redis/files/check_redis new file mode 100644 index 000000000000..812c50adabd4 --- /dev/null +++ b/databases/nagios-check_redis/files/check_redis @@ -0,0 +1,83 @@ +#!/usr/bin/env perl + +use warnings; +use strict; +use Getopt::Long qw(:config gnu_getopt); +use Redis; +use Nagios::Plugin; + +my $VERSION="0.1"; +my $np; + +$np = Nagios::Plugin->new(usage => "Usage: %s [--host|-H <host>] [--port|-p <port>] [ -c|--critical=<threshold> ] [ -w|--warning=<threshold>] [-?|--usage] [-V|--version] [-h|--help] [-v|--verbose] [-t|--timeout=<timeout>]", + version => $VERSION, + blurb => 'This plugin checks the availability of a redis server, expecting that a slave server is sync with master, and the replication delay is not too high.', + license => "Brought to you AS IS, WITHOUT WARRANTY, under GPL. (C) Remi Paulmier <remi.paulmier\@gmail.com>", + shortname => "CHECK_REDIS", + ); + +$np->add_arg(spec => 'host|H=s', + help => q(Check the host indicated in STRING), + required => 0, + default => 'localhost', + ); + +$np->add_arg(spec => 'port|p=i', + help => q(Use the TCP port indicated in INTEGER), + required => 0, + default => 4730, + ); + +$np->add_arg(spec => 'critical|c=s', + help => q(Exit with CRITICAL status if replication delay is greater than INTEGER), + required => 0, + default => 10, + ); + +$np->add_arg(spec => 'warning|w=s', + help => q(Exit with WARNING status if replication delay is greater than INTEGER), + required => 0, + default => 1, + ); + +$np->getopts; +my $ng = $np->opts; + +# manage timeout +alarm $ng->timeout; + +# host & port +my $host = $ng->get('host'); +my $port = $ng->get('port'); + +# verbosity +my $verbose = $ng->get('verbose'); + +my $redis; +eval { + $redis = Redis->new( server => "$host:$port", debug => 0); +}; +if ($@) { + $np->nagios_exit( CRITICAL, "Can't connect to $host:$port" ); +} + +my $info = $redis->info(); +my $code = OK; +my $msg = "Everything is OK"; + +$redis->ping || $np->nagios_exit( CRITICAL, "Can't ping server $host:$port" ); + +if ($info->{'role'} eq "slave") { + $code = $np->check_threshold(check => $info->{'master_last_io_seconds_ago'}); + $msg = ("redis replication is late (" . + $info->{'master_last_io_seconds_ago'} . + "s)" + ) if $code != OK; + + if ($info->{'master_sync_in_progress'} != 0) { + $msg = "redis replication sync is in progress"; + $code = CRITICAL; + } +} + +$np->nagios_exit( $code, $msg ); diff --git a/databases/nagios-check_redis/pkg-descr b/databases/nagios-check_redis/pkg-descr new file mode 100644 index 000000000000..62897ef5bf2b --- /dev/null +++ b/databases/nagios-check_redis/pkg-descr @@ -0,0 +1,4 @@ +This plugin checks a redis server, expecting that a slave server is in sync +with master, and the replication delay is not too high. + +WWW: http://exchange.nagios.org/directory/Plugins/Others/check_redis/details |