summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorrodent <rodent>2015-04-03 18:59:52 +0000
committerrodent <rodent>2015-04-03 18:59:52 +0000
commit70e941f93e6ccd50b276db88c1f8e48e7efad4a9 (patch)
tree0e6cc5af95bfcc0ba98b81767f1af608f9cc97f0 /net
parent8924d0553cc89dcf9fb2377bba06769c98677eb7 (diff)
downloadpkgsrc-70e941f93e6ccd50b276db88c1f8e48e7efad4a9.tar.gz
Update to 1.6.0. This is a different script than what was fetched
previously. That script was something from 10 years ago maintained on one of our FTP servers. This one is the "official" one listed on the Nagios plugin exchange. Their plugin links aren't DDLs and the upstream author doesn't have the latest version in their repository. Therefore, it's included here. This package doesn't change often (last change being 6 years ago) so it doesn't seem to be an issue. If upstream updates their repo, we'll stop maintaining the file in our repo. While the flags from the old version and new version are similar, the newer version lacks some knobs though it seems the overall functionality is retained.
Diffstat (limited to 'net')
-rw-r--r--net/nagios-plugin-spamd/Makefile30
-rw-r--r--net/nagios-plugin-spamd/distinfo8
-rw-r--r--net/nagios-plugin-spamd/files/check_spamd-1.6.0.pl208
3 files changed, 228 insertions, 18 deletions
diff --git a/net/nagios-plugin-spamd/Makefile b/net/nagios-plugin-spamd/Makefile
index 6aedd3f7096..adb28a0378f 100644
--- a/net/nagios-plugin-spamd/Makefile
+++ b/net/nagios-plugin-spamd/Makefile
@@ -1,40 +1,42 @@
-# $NetBSD: Makefile,v 1.7 2014/05/29 23:37:05 wiz Exp $
+# $NetBSD: Makefile,v 1.8 2015/04/03 18:59:52 rodent Exp $
#
-DISTNAME= check_spamd-1.4.pl
-PKGNAME= nagios-plugin-spamd-${DISTNAME:S/check_spamd-//:S/.pl//}
-PKGREVISION= 3
+DISTNAME= check_spamd-1.6.0
+DISTDIR= ${.CURDIR}/files
+PKGNAME= nagios-plugin-${DISTNAME:S/check_//1}
CATEGORIES= net mail
-MASTER_SITES= # ftp://jhweiss.de/pub/users/weiss/nagios/plugins/
-EXTRACT_SUFX= # empty
+MASTER_SITES= # http://exchange.nagios.org/components/com_mtree/
+EXTRACT_SUFX= .pl
MAINTAINER= pkgsrc-users@NetBSD.org
-HOMEPAGE= http://www.jhweiss.de/software/nagios.html
+HOMEPAGE= http://exchange.nagios.org/directory/Plugins/Email-and-Groupware/SpamAssasin/check_spamd
COMMENT= Nagios plugin for monitoring the SpamAssassin daemon
+LICENSE= gnu-gpl-v3
DEPENDS+= nagios-plugins-[0-9]*:../../net/nagios-plugins
+DEPENDS+= p5-Time-HiRes-[0-9]*:../../time/p5-Time-HiRes
+DEPENDS+= p5-Switch-[0-9]*:../../lang/p5-Switch
+DEPENDS+= spamassassin-[0-9]*:../../mail/spamassassin
WRKSRC= ${WRKDIR}
NO_BUILD= yes
USE_TOOLS+= perl:run
-REPLACE_PERL+= ${DISTNAME}
+REPLACE_PERL+= ${DISTFILES}
PLUGIN_DIR= ${PREFIX}/libexec/nagios
SUBST_CLASSES+= check_spamd
SUBST_STAGE.check_spamd=post-configure
-SUBST_FILES.check_spamd=${DISTNAME}
-SUBST_SED.check_spamd= -e 's,/usr/local/nagios/libexec,${PLUGIN_DIR},'
+SUBST_FILES.check_spamd=${DISTFILES}
+SUBST_MESSAGE.check_spamd=Fixing path to spamc.
+SUBST_SED.check_spamd= -e 's|/usr/local/perl/bin/|${PREFIX}/${PERL5_SUB_INSTALLVENDORBIN}|1'
INSTALLATION_DIRS+= ${PLUGIN_DIR}
-do-extract:
- cp "${DISTDIR}/${DISTNAME}" "${WRKDIR}"
-
do-install:
- ${INSTALL_SCRIPT} "${WRKDIR}/${DISTNAME}" \
+ ${INSTALL_SCRIPT} "${WRKDIR}/${DISTFILES}" \
"${DESTDIR}${PLUGIN_DIR}/check_spamd"
.include "../../mk/bsd.pkg.mk"
diff --git a/net/nagios-plugin-spamd/distinfo b/net/nagios-plugin-spamd/distinfo
index f73357e18a2..4fe0742801a 100644
--- a/net/nagios-plugin-spamd/distinfo
+++ b/net/nagios-plugin-spamd/distinfo
@@ -1,5 +1,5 @@
-$NetBSD: distinfo,v 1.1.1.1 2007/10/14 17:37:49 heinz Exp $
+$NetBSD: distinfo,v 1.2 2015/04/03 18:59:52 rodent Exp $
-SHA1 (check_spamd-1.4.pl) = 6cb0a7e3adb6230c404dbe6179c2c9233b126b93
-RMD160 (check_spamd-1.4.pl) = ebf415a25ccc6154a17bd146c56775bea37e9d09
-Size (check_spamd-1.4.pl) = 6215 bytes
+SHA1 (check_spamd-1.6.0.pl) = 35e5a9c1694ad49fa722dab24dd44ba906d0dc30
+RMD160 (check_spamd-1.6.0.pl) = 98cc8e8c61decd0e230818eebd777c19005b74c9
+Size (check_spamd-1.6.0.pl) = 6850 bytes
diff --git a/net/nagios-plugin-spamd/files/check_spamd-1.6.0.pl b/net/nagios-plugin-spamd/files/check_spamd-1.6.0.pl
new file mode 100644
index 00000000000..a5725285351
--- /dev/null
+++ b/net/nagios-plugin-spamd/files/check_spamd-1.6.0.pl
@@ -0,0 +1,208 @@
+#!/usr/bin/env perl
+
+#####################################################
+# Program to check to make sure spamd is running and report back to nrpe for
+# nagios. The variable that most folks will want to change is "$spamc" which
+# is the location of the spamc program.
+# Created: 2006-11-29
+# Version: 1.6.0
+# Author: Erinn Looney-Triggs
+# Revised: 2009-02-18
+# Revised by: Martin Mares
+# Revision history:
+# 1.6.0: Added remote host checks and Time::HiRes thanks to Martin Mares. Also
+# added a revision history, you have to start somewhere.
+#####################################################
+
+use English qw( -no_match_vars );
+use Getopt::Long; #Grab command line switches
+use Pod::Usage;
+use POSIX qw( WIFEXITED ); #Fix system call's strange return values
+use strict; #Do it right
+use Switch; #Standard perl 5.8 module to use switch statement
+use Time::HiRes; #High-precision timers
+use warnings;
+
+my $timeout = 10; #Default timeout of 10 seconds
+my $return_code; #Return code holder
+my $spamc = '/usr/local/perl/bin/spamc'; #Location of spamc
+my $host;
+my $port;
+my $VERSION = '1.6.0'; #Version number
+
+Getopt::Long::Configure( 'bundling', 'gnu_compat', );
+
+GetOptions( 'man' => sub { pod2usage(-verbose => 2) },
+ 'spamc|s=s' => \$spamc,
+ 'timeout|t=i' => \$timeout,
+ 'host|H=s' => \$host,
+ 'port|p=i' => \$port,
+ 'version|V' => sub { VersionMessage() },
+ 'help|h' => sub { pod2usage(1) },
+);
+
+#Make sure spamc exists and if not give back a nagios warning
+if ( !-e $spamc ) {
+ print "$spamc does not exist.\n";
+ exit 2;
+}
+
+#Which command we should run
+my $opts = "-x";
+$opts .= " -d $host" if defined $host;
+$opts .= " -p $port" if defined $port;
+my $spamc_command = "echo foo | $spamc $opts > /dev/null 2>&1";
+
+#Timer operation. Times out after $timeout seconds.
+my $start_time = Time::HiRes::time;
+eval {
+
+ #Set the alarm and set the timeout
+ local $SIG{ALRM} = sub { die "alarm\n" };
+ alarm $timeout;
+
+ #Run the command
+ WIFEXITED( system $spamc_command)
+ or die "Could not run $spamc_command\n";
+ $return_code = $CHILD_ERROR;
+
+ alarm 0;
+};
+
+my $elapsed_time = Time::HiRes::time - $start_time;
+
+#Test return value and exit if eval caught the alarm
+if ($EVAL_ERROR) {
+ if ( $EVAL_ERROR eq "alarm\n" ) {
+ print "Operation timed out after $timeout seconds.\n";
+ exit 2;
+ }
+ else {
+ print "An unknown error has occured: $EVAL_ERROR \n";
+ exit 3;
+ }
+}
+
+#Divide by 256 or bitshift right by 8 to get the original error code
+$return_code >>= 8;
+
+#Parse the errors and give Nagios parsible error codes and messages
+switch ($return_code) {
+ case 0 { printf "OK - %.3fs response time\n", $elapsed_time; exit 0; }
+ case 64 { print "Command line usage error\n"; exit 1; }
+ case 65 { print "Data format error\n"; exit 1; }
+ case 66 { print "Cannot open input\n"; exit 1; }
+ case 67 { print "Addressee unknown\n"; exit 1; }
+ case 68 { print "Host name unknown\n"; exit 1; }
+ case 69 { print "Spamd service unavailable\n"; exit 2; }
+ case 70 { print "Internal software error\n"; exit 2; }
+ case 71 { print "System error (e.g., can't fork)\n"; exit 2; }
+ case 72 { print "Critical OS file missing\n"; exit 2; }
+ case 73 { print "Can't create (user) output file\n"; exit 1; }
+ case 74 { print "Input/output error\n"; exit 1; }
+ case 75 { print "Temp failure; user is invited to retry\n"; exit 1; }
+ case 76 { print "Remote error in protocol\n"; exit 2; }
+ case 77 { print "Permission denied\n"; exit 1; }
+ case 78 { print "Configuration error\n"; exit 1; }
+ else { print "An unknown error has occured in $spamc\n"; exit 3; }
+}
+
+#Version message information displayed in both --version and --help
+sub main::VersionMessage {
+ print <<"EOF";
+This is version $VERSION of check_spamd.
+
+Copyright (c) 2009 Erinn Looney-Triggs (erinn.looneytriggs\@gmail.com).
+All rights reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License.
+See http://www.fsf.org/licensing/licenses/gpl.html
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+EOF
+
+ exit 1;
+}
+__END__
+
+=head1 NAME
+
+check_spamd - Checks the status of SpamAssassin's spamd daemon via spamc.
+
+=head1 VERSION
+
+This documentation refers to check_spamd version 1.6.0
+
+=head1 USAGE
+
+check_spamd.pl
+
+=head1 REQUIRED ARGUMENTS
+
+None
+
+=head1 OPTIONS
+
+--host (-H) Set the host on which spamd runs (default: localhost).
+--port (-p) Set TCP port number of spamd.
+--spamc (-s) Set the location of the spamc executable.
+--timeout (-t) Sets the timeout, defaults to 10 seconds.
+
+
+=head1 DESCRIPTION
+
+This is a Nagios plugin that runs spamc to check the status of the spamd
+daemon. It then parses the resultant exit codes and NRPE grabs them.
+
+The plugin is able to check spamd either at the local host or over the network.
+
+=head1 DIAGNOSTICS
+
+=head2 spamc does not exist:
+
+The spamc program does not exist where the plugin is looking for it. By
+default check_spamd looks for spamc in /usr/local/perl/bin/spamc. This may
+not be the location of spamc on your system. Change the variable $spamc to
+fix this issue.
+
+=head1 CONFIGURATION AND ENVIRONMENT
+
+spamc should be available on the checking system.
+
+=head1 DEPENDENCIES
+
+ check_spamd depends on the following modules:
+ Switch Standard Perl 5.8 module
+ POSIX Standard Perl 5.8 module
+ Getopt::Std Standard Perl 5.8 module
+ Time::HiRes Standard Perl 5.8 module
+
+=head1 INCOMPATIBILITIES
+
+None known yet.
+
+=head1 BUGS AND LIMITATIONS
+
+Bugs, never heard of 'em ;).
+If you encounter any bugs let me know. (erinn.looneytriggs@gmail.com)
+
+=head1 AUTHOR
+
+Erinn Looney-Triggs (erinn.looneytriggs@gmail.com)
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) 2009 Erinn Looney-Triggs (erinn.looneytriggs@gmail.com).
+All rights reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License.
+See L<http://www.fsf.org/licensing/licenses/gpl.html>.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.