From owner-svn-ports-all@FreeBSD.ORG Mon Feb 3 11:27:40 2014 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8794C29B; Mon, 3 Feb 2014 11:27:40 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 66E261D79; Mon, 3 Feb 2014 11:27:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s13BRe6G047740; Mon, 3 Feb 2014 11:27:40 GMT (envelope-from demon@svn.freebsd.org) Received: (from demon@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s13BRdae047736; Mon, 3 Feb 2014 11:27:39 GMT (envelope-from demon@svn.freebsd.org) Message-Id: <201402031127.s13BRdae047736@svn.freebsd.org> From: Dmitry Sivachenko Date: Mon, 3 Feb 2014 11:27:39 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r342424 - in head/databases: . nagios-check_redis nagios-check_redis/files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Feb 2014 11:27:40 -0000 Author: demon Date: Mon Feb 3 11:27:39 2014 New Revision: 342424 URL: http://svnweb.freebsd.org/changeset/ports/342424 QAT: https://qat.redports.org/buildarchive/r342424/ Log: New port: nagios-check_redis. Nagios plugin to check redis status. Added: head/databases/nagios-check_redis/ head/databases/nagios-check_redis/Makefile (contents, props changed) head/databases/nagios-check_redis/files/ head/databases/nagios-check_redis/files/check_redis (contents, props changed) head/databases/nagios-check_redis/pkg-descr (contents, props changed) Modified: head/databases/Makefile Modified: head/databases/Makefile ============================================================================== --- head/databases/Makefile Mon Feb 3 11:12:04 2014 (r342423) +++ head/databases/Makefile Mon Feb 3 11:27:39 2014 (r342424) @@ -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 Added: head/databases/nagios-check_redis/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/databases/nagios-check_redis/Makefile Mon Feb 3 11:27:39 2014 (r342424) @@ -0,0 +1,27 @@ +# Created by: Dmitry Sivachenko +# $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 Added: head/databases/nagios-check_redis/files/check_redis ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/databases/nagios-check_redis/files/check_redis Mon Feb 3 11:27:39 2014 (r342424) @@ -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 ] [--port|-p ] [ -c|--critical= ] [ -w|--warning=] [-?|--usage] [-V|--version] [-h|--help] [-v|--verbose] [-t|--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 ", + 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 ); Added: head/databases/nagios-check_redis/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/databases/nagios-check_redis/pkg-descr Mon Feb 3 11:27:39 2014 (r342424) @@ -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