svn commit: r364391 - in head/net-mgmt: . nagios-check_relayd_status nagios-check_relayd_status/files
John Marino
marino at FreeBSD.org
Fri Aug 8 22:41:05 UTC 2014
Author: marino
Date: Fri Aug 8 22:41:03 2014
New Revision: 364391
URL: http://svnweb.freebsd.org/changeset/ports/364391
QAT: https://qat.redports.org/buildarchive/r364391/
Log:
Add new port net-mgmt/nagio-check_relayd_status
PR: 184375
Submitted by: rand (iteris.com)
================================================================
A plugin for Nagios to query relayd status. It returns a warning if not
all hosts in a table are up and a critical if a table and/or redirect
is totally down.
Added:
head/net-mgmt/nagios-check_relayd_status/
head/net-mgmt/nagios-check_relayd_status/Makefile (contents, props changed)
head/net-mgmt/nagios-check_relayd_status/files/
head/net-mgmt/nagios-check_relayd_status/files/check_relayd_status (contents, props changed)
head/net-mgmt/nagios-check_relayd_status/pkg-descr (contents, props changed)
head/net-mgmt/nagios-check_relayd_status/pkg-plist (contents, props changed)
Modified:
head/net-mgmt/Makefile
Modified: head/net-mgmt/Makefile
==============================================================================
--- head/net-mgmt/Makefile Fri Aug 8 21:36:33 2014 (r364390)
+++ head/net-mgmt/Makefile Fri Aug 8 22:41:03 2014 (r364391)
@@ -129,6 +129,7 @@
SUBDIR += nagios-check_netsnmp
SUBDIR += nagios-check_ports
SUBDIR += nagios-check_postgres
+ SUBDIR += nagios-check_relayd_status
SUBDIR += nagios-check_puppet
SUBDIR += nagios-check_smartmon
SUBDIR += nagios-check_tftp
Added: head/net-mgmt/nagios-check_relayd_status/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/net-mgmt/nagios-check_relayd_status/Makefile Fri Aug 8 22:41:03 2014 (r364391)
@@ -0,0 +1,31 @@
+# Created by: Douglas K. Rand <rand at iteris.com>
+# $FreeBSD$
+
+PORTNAME= check_relayd_status
+PORTVERSION= 1.1
+CATEGORIES= net-mgmt
+MASTER_SITES= # none
+PKGNAMEPREFIX= nagios-
+DISTFILES= # none
+
+MAINTAINER= rand at iteris.com
+COMMENT= Nagios plug-in to check on the status of relayd
+
+LICENSE= MPL
+
+RUN_DEPENDS= ${LOCALBASE}/sbin/relayctl:${PORTSDIR}/net/relayd
+
+USES= perl5 shebangfix
+USE_PERL5= run
+SHEBANG_FILES= check_relayd_status
+NO_BUILD= yes
+
+do-extract:
+ @${MKDIR} ${WRKSRC}
+ ${INSTALL_SCRIPT} ${FILESDIR}/check_relayd_status ${WRKSRC}
+
+do-install:
+ @${MKDIR} ${STAGEDIR}${PREFIX}/libexec/nagios
+ ${INSTALL_SCRIPT} ${WRKSRC}/check_relayd_status ${STAGEDIR}${PREFIX}/libexec/nagios/
+
+.include <bsd.port.mk>
Added: head/net-mgmt/nagios-check_relayd_status/files/check_relayd_status
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/net-mgmt/nagios-check_relayd_status/files/check_relayd_status Fri Aug 8 22:41:03 2014 (r364391)
@@ -0,0 +1,184 @@
+#!/usr/bin/perl
+
+# --------------------------------------------------------------------
+# **** BEGIN LICENSE BLOCK *****
+#
+# Version: MPL 1.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is echocat management.
+#
+# The Initial Developer of the Original Code is Daniel Werdermann.
+# Portions created by the Initial Developer are Copyright (C) 2011
+# the Initial Developer. All Rights Reserved.
+#
+# **** END LICENSE BLOCK *****
+# --------------------------------------------------------------------
+
+# --------------------------------------------------------------------
+# Check for specified pattern in commandoutput
+#
+# @author: Daniel Werdermann / dwerdermann at web.de
+# @version: 1.1
+# @date: Thu Oct 23 14:31:52 CEST 2008
+#
+# changes 1.1
+# - add license information
+# --------------------------------------------------------------------
+
+use strict;
+use warnings;
+use Getopt::Long;
+
+my $help;
+my $redirect;
+my $table;
+
+my $command = "/usr/local/sbin/relayctl";
+my $parameter = "show summary";
+
+GetOptions (
+ "help" => \$help,
+ "redirect=s" => \$redirect,
+ "table=s" => \$table,
+);
+
+usage() if $help;
+
+sub usage {
+ print << "EOF"
+Usage: $0 --help
+ $0 [--redirect STRING] [--table STRING]
+
+This script checks the OpenBSD relayd. It returns a warning
+if not all hosts in a table are up and a critical if a table
+and/or redirect is totally down.
+
+Options:
+ --help
+ Print detailed this screen
+ --redirect STRING
+ String with name of redirect to check. Multiple redirects
+ can be seperated by comma
+ --table STRING
+ String with name of table to check. Multiple tabless
+ can be seperated by comma
+
+Examples:
+ $0
+
+ Checks if all redirects, tables and hosts which are
+ defined at the relayd startup are active.
+
+ $0 --redirect smtp --table pmtahost,pmtahostfallback
+
+ Checks if the specified redirects and tables exists.
+ Besides there will be an alert if any other redirect
+ or table defined in the checked relayd is not active.
+ Or if any hosts are down.
+
+ This plugin is NOT developped by the Nagios Plugin group.
+ Please do not e-mail them for support on this plugin, since
+ they won't know what you're talking about.
+
+ For contact info, read the plugin itself...
+
+EOF
+;
+ exit(2);
+}
+
+my %cnt_redirects;
+if (defined $redirect) {
+ foreach ( split(/,/, $redirect) ) {
+ $cnt_redirects{$_} = 0;
+ }
+}
+
+my %cnt_tables;
+if (defined $table) {
+ foreach ( split(/,/, $table) ) {
+ $cnt_tables{$_} = 0;
+ }
+}
+
+my %cnt_hosts = (
+ 'down' => 0,
+ 'up' => 0
+);
+
+
+if (! -x $command) {
+ print "CRITICAL: Cannot execute command: '$command'";
+ exit(2);
+}
+
+my @execute = ($command, $parameter);
+
+# make unbuffered output
+$|=1;
+open STDERR, ">&STDOUT" or die "Can’t dup STDOUT: $!";
+
+eval {
+ my @return = split(/\n/, `@execute`)
+ or die "command returns an errorcode $?: '@execute'";
+
+ foreach ( @return ) {
+ chomp;
+ if (/up$/) { $cnt_hosts{'up'}++ ; next; }
+ if (/down$/ or /disabled$/) { $cnt_hosts{'down'}++ ; next; }
+ if (/\d+\s+redirect\s+(.*?)\s+active$/) {
+ $cnt_redirects{$1}++;
+ next;
+ }
+ if (/\d+\s+table\s+(.*?)\s+(.*?)\s/) {
+ $cnt_tables{$1} = $2;
+ next;
+ }
+ }
+
+ if ( $cnt_hosts{'up'} == 0 ) {
+ print "CRITICAL: relayd does not find any hosts up\n";
+ exit(2);
+ }
+
+ for my $red ( keys %cnt_redirects ) {
+ if ( $cnt_redirects{$red} == 0 ) {
+ print "CRITICAL: Redirect $red is not active\n";
+ exit(2);
+ }
+ }
+
+ for my $tab ( keys %cnt_tables ) {
+ if ( $cnt_tables{$tab} ne "active" ) {
+ print "CRITICAL: Table $tab is not active\n";
+ exit(2);
+ }
+ }
+
+ if ( $cnt_hosts{'down'} != 0 ) {
+ print "WARNING: relayd cannot reach all hosts. $cnt_hosts{'down'} hosts are down or disabled\n";
+ exit(1);
+ }
+
+ print "OK: nothing obvious in '@execute'";
+ exit(0);
+};
+
+if ($@) {
+ print "CRITICAL: $@";
+ exit(2);
+}
+
+print "OK: no critical or warning patterns found";
+exit(0);
+
Added: head/net-mgmt/nagios-check_relayd_status/pkg-descr
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/net-mgmt/nagios-check_relayd_status/pkg-descr Fri Aug 8 22:41:03 2014 (r364391)
@@ -0,0 +1,5 @@
+A plugin for Nagios to query relayd status. It returns a warning if not
+all hosts in a table are up and a critical if a table and/or redirect
+is totally down.
+
+Author: Daniel Werdermann <dwerdermann at web.de>
Added: head/net-mgmt/nagios-check_relayd_status/pkg-plist
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/net-mgmt/nagios-check_relayd_status/pkg-plist Fri Aug 8 22:41:03 2014 (r364391)
@@ -0,0 +1,2 @@
+libexec/nagios/check_relayd_status
+ at dirrmtry libexec/nagios
More information about the svn-ports-all
mailing list