mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-21 00:25:50 +00:00
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.
This commit is contained in:
parent
c0b12d6081
commit
07986829fb
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=364391
@ -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
|
||||
|
31
net-mgmt/nagios-check_relayd_status/Makefile
Normal file
31
net-mgmt/nagios-check_relayd_status/Makefile
Normal file
@ -0,0 +1,31 @@
|
||||
# Created by: Douglas K. Rand <rand@iteris.com>
|
||||
# $FreeBSD$
|
||||
|
||||
PORTNAME= check_relayd_status
|
||||
PORTVERSION= 1.1
|
||||
CATEGORIES= net-mgmt
|
||||
MASTER_SITES= # none
|
||||
PKGNAMEPREFIX= nagios-
|
||||
DISTFILES= # none
|
||||
|
||||
MAINTAINER= rand@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>
|
184
net-mgmt/nagios-check_relayd_status/files/check_relayd_status
Normal file
184
net-mgmt/nagios-check_relayd_status/files/check_relayd_status
Normal file
@ -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@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);
|
||||
|
5
net-mgmt/nagios-check_relayd_status/pkg-descr
Normal file
5
net-mgmt/nagios-check_relayd_status/pkg-descr
Normal file
@ -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@web.de>
|
2
net-mgmt/nagios-check_relayd_status/pkg-plist
Normal file
2
net-mgmt/nagios-check_relayd_status/pkg-plist
Normal file
@ -0,0 +1,2 @@
|
||||
libexec/nagios/check_relayd_status
|
||||
@dirrmtry libexec/nagios
|
Loading…
Reference in New Issue
Block a user