ports/184375: New port: net-mgmt/nagios-check_relayd_status Nagios plug-in to check on the status of relayd

Douglas K. Rand rand at meridian-enviro.com
Fri Nov 29 18:20:01 UTC 2013


>Number:         184375
>Category:       ports
>Synopsis:       New port: net-mgmt/nagios-check_relayd_status Nagios plug-in to check on the status of relayd
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 29 18:20:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Douglas K. Rand
>Release:        FreeBSD 9.2-RELEASE-p1 i386
>Organization:
Iteris, Inc
>Environment:
System: FreeBSD kuiper.meridian-enviro.com 9.2-RELEASE-p1 FreeBSD 9.2-RELEASE-p1 #3 r258721: Thu Nov 28 15:32:36 CST 2013 rand at kuiper.meridian-enviro.com:/usr/obj/usr/src/sys/FIREWALL i386


	
>Description:
	A new port based upon Daniel Werdermann's check_relayd_status
	Nagios plugin.
>How-To-Repeat:
	Deploy relayd and want to monitor it.
>Fix:


# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	nagios-check_relayd_status
#	nagios-check_relayd_status/Makefile
#	nagios-check_relayd_status/files
#	nagios-check_relayd_status/files/check_relayd_status
#	nagios-check_relayd_status/pkg-descr
#
echo c - nagios-check_relayd_status
mkdir -p nagios-check_relayd_status > /dev/null 2>&1
echo x - nagios-check_relayd_status/Makefile
sed 's/^X//' >nagios-check_relayd_status/Makefile << 'fb1fcceb555ae56b5de2f33a0bb94320'
X# Created by: Douglas K. Rand <rand at iteris.com>
X# $FreeBSD$
X
XPORTNAME=	check_relayd_status
XPORTVERSION=	1.1
XCATEGORIES=	net-mgmt
XMASTER_SITES=	# none
XPKGNAMEPREFIX=	nagios-
XDISTFILES=	# none
X
XMAINTAINER=	rand at iteris.com
XCOMMENT=	Nagios plug-in to check on the status of relayd
X
XLICENSE=	MPL
X
XRUN_DEPENDS=	${LOCALBASE}/sbin/relayctl:${PORTSDIR}/net/relayd
X
XUSES=		perl5
XUSE_PERL5=	run
XNO_BUILD=	yes
XPLIST_FILES=	libexec/nagios/check_relayd_status
X
Xdo-install:
X	@${MKDIR} ${STAGEDIR}${PREFIX}/libexec/nagios
X	${INSTALL_SCRIPT} ${FILESDIR}/check_relayd_status ${STAGEDIR}${PREFIX}/libexec/nagios/
X
X.include <bsd.port.mk>
fb1fcceb555ae56b5de2f33a0bb94320
echo c - nagios-check_relayd_status/files
mkdir -p nagios-check_relayd_status/files > /dev/null 2>&1
echo x - nagios-check_relayd_status/files/check_relayd_status
sed 's/^X//' >nagios-check_relayd_status/files/check_relayd_status << '2cdd921753fb36055323c9b9025d85d1'
X#!/usr/bin/perl
X
X# --------------------------------------------------------------------
X# **** BEGIN LICENSE BLOCK *****
X#
X# Version: MPL 1.1
X#
X# The contents of this file are subject to the Mozilla Public License Version
X# 1.1 (the "License"); you may not use this file except in compliance with
X# the License. You may obtain a copy of the License at
X# http://www.mozilla.org/MPL/
X#
X# Software distributed under the License is distributed on an "AS IS" basis,
X# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
X# for the specific language governing rights and limitations under the
X# License.
X#
X# The Original Code is echocat management.
X#
X# The Initial Developer of the Original Code is Daniel Werdermann.
X# Portions created by the Initial Developer are Copyright (C) 2011
X# the Initial Developer. All Rights Reserved.
X#
X# **** END LICENSE BLOCK *****
X# --------------------------------------------------------------------
X
X# --------------------------------------------------------------------
X# Check for specified pattern in commandoutput
X#
X# @author: Daniel Werdermann / dwerdermann at web.de
X# @version: 1.1
X# @date: Thu Oct 23 14:31:52 CEST 2008
X#
X# changes 1.1
X#  - add license information
X# --------------------------------------------------------------------
X
Xuse strict;
Xuse warnings;
Xuse Getopt::Long;
X
Xmy $help;
Xmy $redirect;
Xmy $table;
X
Xmy $command = "/usr/local/sbin/relayctl";
Xmy $parameter = "show summary";
X
XGetOptions (
X	"help"        => \$help,
X	"redirect=s"  => \$redirect,
X	"table=s"  => \$table,
X);
X
Xusage() if $help;
X
Xsub usage {
X	print << "EOF"
XUsage: $0 --help
X       $0 [--redirect STRING] [--table STRING]
X
XThis script checks the OpenBSD relayd. It returns a warning
Xif not all hosts in a table are up and a critical if a table
Xand/or redirect is totally down.
X
XOptions:
X --help 
X    Print detailed this screen
X --redirect STRING
X    String with name of redirect to check. Multiple redirects
X    can be seperated by comma
X --table STRING
X    String with name of table to check. Multiple tabless
X    can be seperated by comma
X
XExamples:
X $0 
X
X    Checks if all redirects, tables and hosts which are
X    defined at the relayd startup are active.
X
X $0 --redirect smtp --table pmtahost,pmtahostfallback
X    
X    Checks if the specified redirects and tables exists.
X    Besides there will be an alert if any other redirect
X    or table defined in the checked relayd is not active.
X    Or if any hosts are down.
X
X    This plugin is NOT developped by the Nagios Plugin group.
X    Please do not e-mail them for support on this plugin, since
X    they won't know what you're talking about.
X
X    For contact info, read the plugin itself...
X
XEOF
X;
X	exit(2);
X}
X
Xmy %cnt_redirects;
Xif (defined $redirect) {
X	foreach ( split(/,/, $redirect) ) {
X		$cnt_redirects{$_} = 0;
X	}
X}
X
Xmy %cnt_tables;
Xif (defined $table) {
X	foreach ( split(/,/, $table) ) {
X		$cnt_tables{$_} = 0;
X	}
X}
X
Xmy %cnt_hosts = (
X	'down'	=> 0,
X	'up'	=> 0
X);
X
X
Xif (! -x $command) {
X	print "CRITICAL: Cannot execute command: '$command'";
X	exit(2);
X}
X
Xmy @execute = ($command, $parameter);
X
X# make unbuffered output
X$|=1;
Xopen STDERR, ">&STDOUT" or die "Can’t dup STDOUT: $!";
X
Xeval {
X	my @return = split(/\n/, `@execute`) 
X		or die "command returns an errorcode $?: '@execute'";
X
X	foreach ( @return ) {
X		chomp;
X		if (/up$/) { $cnt_hosts{'up'}++ ; next; }
X		if (/down$/ or /disabled$/) { $cnt_hosts{'down'}++ ; next; }
X		if (/\d+\s+redirect\s+(.*?)\s+active$/) {
X			$cnt_redirects{$1}++;
X			next;
X		}
X		if (/\d+\s+table\s+(.*?)\s+(.*?)\s/) {
X			$cnt_tables{$1} = $2;
X			next;
X		}
X	}
X
X	if ( $cnt_hosts{'up'} == 0 ) {
X		print "CRITICAL: relayd does not find any hosts up\n";
X		exit(2);
X	} 
X
X	for my $red ( keys %cnt_redirects ) {
X		if ( $cnt_redirects{$red} == 0 ) {
X			print "CRITICAL: Redirect $red is not active\n";
X			exit(2);
X		}
X	}
X
X	for my $tab ( keys %cnt_tables ) {
X		if ( $cnt_tables{$tab} ne "active" ) {
X			print "CRITICAL: Table $tab is not active\n";
X			exit(2);
X		}
X	}
X
X	if ( $cnt_hosts{'down'} != 0 ) {
X		print "WARNING: relayd cannot reach all hosts. $cnt_hosts{'down'} hosts are down or disabled\n";
X		exit(1);
X	}
X
X	print "OK: nothing obvious in '@execute'";
X	exit(0);
X};
X
Xif ($@) {
X	print "CRITICAL: $@";
X	exit(2);
X}
X
Xprint "OK: no critical or warning patterns found";
Xexit(0);
X
2cdd921753fb36055323c9b9025d85d1
echo x - nagios-check_relayd_status/pkg-descr
sed 's/^X//' >nagios-check_relayd_status/pkg-descr << '1b714cd4e0b65c27835924e55d60488b'
XA plugin for Nagios to query relayd status. It returns a warning if not
Xall hosts in a table are up and a critical if a table and/or redirect
Xis totally down.
X
XAuthor: Daniel Werdermann <dwerdermann at web.de>
1b714cd4e0b65c27835924e55d60488b
exit


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-ports-bugs mailing list