ports/188325: Resurrecting the nagios-pf-plugin port

Douglas K. Rand rand at iteris.com
Sun Apr 6 20:00:00 UTC 2014


>Number:         188325
>Category:       ports
>Synopsis:       Resurrecting the nagios-pf-plugin port
>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:   Sun Apr 06 20:00:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     Douglas K. Rand
>Release:        FreeBSD 9.2-RELEASE-p3 i386
>Organization:
Iteris Inc.
>Environment:
System: FreeBSD venus.meridian-enviro.com 9.2-RELEASE-p3 FreeBSD 9.2-RELEASE-p3 #2 r264082: Thu Apr 3 17:51:22 CDT 2014 rand at venus.meridian-enviro.com:/usr/obj/usr/src/sys/FIREWALL i386

>Description:
	The nagios-pf-plugin port was expired as the website was no
	longer operating. But the project on GitHub is up. I re did
	the port to use GitHub.
>How-To-Repeat:
	Wish to monitor how many pf state table entries are in use
	with Nagios.
>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-pf-plugin
#	nagios-pf-plugin/files
#	nagios-pf-plugin/files/pkg-message.in
#	nagios-pf-plugin/files/patch-check_pf.c
#	nagios-pf-plugin/files/patch-Makefile
#	nagios-pf-plugin/Makefile
#	nagios-pf-plugin/distinfo
#	nagios-pf-plugin/pkg-descr
#
echo c - nagios-pf-plugin
mkdir -p nagios-pf-plugin > /dev/null 2>&1
echo c - nagios-pf-plugin/files
mkdir -p nagios-pf-plugin/files > /dev/null 2>&1
echo x - nagios-pf-plugin/files/pkg-message.in
sed 's/^X//' >nagios-pf-plugin/files/pkg-message.in << '00e02b91c310aa8d0ebfb5ba10abd493'
X
Xcheck_pf has been installed to %%PREFIX%%/libexec/nagios.
X
Xcheck_pf needs read permission to the pf(4) pseudo-device, i.e. /dev/pf.
X
XAssuming check_pf will be run by user `nagios', the following will work:
X
X	# chmod 640 /dev/pf
X	# chgrp nagios /dev/pf
X
XTo make sure the change persists across reboots, add the following
Xto /etc/devfs.conf:
X
X	# nrpe2/nagios needs to be able to read statistics
X	own     pf    root:nagios
X	perm    pf    0640
X	
XPlease refer to the online documentation for additional information.
X
Xhttps://github.com/kian/nagios-pf-plugin/
X
00e02b91c310aa8d0ebfb5ba10abd493
echo x - nagios-pf-plugin/files/patch-check_pf.c
sed 's/^X//' >nagios-pf-plugin/files/patch-check_pf.c << 'b3749c04de0483a38b1a2c661f907a7c'
X--- check_pf.c.orig	2014-04-05 18:32:50.000000000 -0500
X+++ check_pf.c	2014-04-05 18:44:27.000000000 -0500
X@@ -65,10 +65,13 @@
X 	const char          *errstr;
X 	const char          *pf_device;
X 	const char          *msg;
X+	char                *pctindex;
X 	float               percent;
X 	int                 ch, wflag, cflag, dev;
X 	int                 states_warning; 
X 	int                 states_critical;
X+	int                 default_warn_percent=DEFAULT_WARN_PERCENT;
X+	int                 default_crit_percent=DEFAULT_CRIT_PERCENT;
X 	int                 ret;
X 
X 	pf_device = "/dev/pf"; 
X@@ -85,16 +88,30 @@
X 			help();
X 			break;
X 		case 'w':
X-			wflag = 1;
X-			states_warning = strtonum(optarg, 0, UINT_MAX, &errstr);
X+			pctindex = strchr(optarg, '%');
X+			if(pctindex) {
X+				/* Ends in a %, treat as a percentage */
X+				*pctindex = '\0';
X+				default_warn_percent = strtonum(optarg, 0, 100, &errstr);
X+			} else {
X+				wflag = 1;
X+				states_warning = strtonum(optarg, 0, UINT_MAX, &errstr);
X+			}
X 			if (errstr) {
X 				printf("PF UNKNOWN - -w is %s: %s\n", errstr, optarg);
X 				return (STATE_UNKNOWN);
X 			}
X 			break;
X 		case 'c':
X-			cflag = 1;
X-			states_critical = strtonum(optarg, 0, UINT_MAX, &errstr);
X+			pctindex = strchr(optarg, '%');
X+			if(pctindex) {
X+				/* Ends in a %, treat as a percentage */
X+				*pctindex = '\0';
X+				default_crit_percent = strtonum(optarg, 0, 100, &errstr);
X+			} else {
X+				cflag = 1;
X+				states_critical = strtonum(optarg, 0, UINT_MAX, &errstr);
X+			}
X 			if (errstr) {
X 				printf("PF UNKNOWN - -c is %s: %s\n", errstr, optarg);
X 				return (STATE_UNKNOWN);
X@@ -128,10 +145,10 @@
X 
X 	/* default thresholds will be based on the current state limit */
X 	if (!wflag)
X-		states_warning = pl.limit * DEFAULT_WARN_PERCENT / 100;
X+		states_warning = pl.limit * default_warn_percent / 100;
X 
X 	if (!cflag)
X-		states_critical = pl.limit * DEFAULT_CRIT_PERCENT / 100;
X+		states_critical = pl.limit * default_crit_percent / 100;
X 
X 	if (states_warning >= states_critical) {
X 		printf("PF UNKNOWN - <warning> must be less than <critical>\n");
b3749c04de0483a38b1a2c661f907a7c
echo x - nagios-pf-plugin/files/patch-Makefile
sed 's/^X//' >nagios-pf-plugin/files/patch-Makefile << 'd0e023e144601fedea445dcb2ede9134'
X--- Makefile.old	2014-04-06 14:08:46.000000000 -0500
X+++ Makefile	2014-04-06 14:08:47.000000000 -0500
X@@ -14,7 +14,7 @@
X 	$(CC) $(CFLAGS) -o $(PROGRAM) $(PROGRAM).c
X 
X install:
X-	install -m 755 -o root -g wheel $(PROGRAM) $(DESTDIR)/$(PROGRAM)
X+	install -m 755 -o root -g wheel $(PROGRAM) $(DESTDIR)/$(PREFIX)/libexec/nagios
X 
X uninstall:
X 	rm -f $(DESTDIR)/$(PROGRAM)
d0e023e144601fedea445dcb2ede9134
echo x - nagios-pf-plugin/Makefile
sed 's/^X//' >nagios-pf-plugin/Makefile << '04f81788f4ca263c1d4077a3715c22b0'
X# Created by: Kian Mohageri <kian.mohageri at gmail.com>
X# $FreeBSD: net-mgmt/nagios-pf-plugin/Makefile 327757 2013-09-20 22:24:43Z bapt $
X
XPORTNAME=	nagios-pf-plugin
XPORTVERSION=	0.1
XPORTREVISION=	1
XCATEGORIES=	net-mgmt
XDISTNAME=	check_pf-${PORTVERSION}
X
XMAINTAINER=	rand at iteris.com
XCOMMENT=	Nagios plugin for checking PF
X
XMASTER_SITES=	https://github.com/kian/nagios-pf-plugin/tarball/${GH_COMMIT}/check_pf-0.1.tar.gz?dummy=/
XUSE_GITHUB=	YES
XGH_ACCOUNT=	kian
XGH_PROJECT=	nagios-pf-plugin
XGH_COMMIT=	2aba423
X
XPLIST_FILES=	libexec/nagios/check_pf
XPLIST_DIRS=	libexec/nagios/
XSUB_FILES=	pkg-message
X
Xpre-su-install:
X	@${MKDIR} ${STAGEDIR}${PREFIX}/libexec/nagios
X
X.include <bsd.port.mk>
04f81788f4ca263c1d4077a3715c22b0
echo x - nagios-pf-plugin/distinfo
sed 's/^X//' >nagios-pf-plugin/distinfo << '9ef3fe2f65e1746cd7ecf981864146a9'
XSHA256 (check_pf-0.1.tar.gz) = 5a6a5a2cdfed35bf1f07a8a49b139a7e423fb6cc06403aabc1fc1609c5d8782d
XSIZE (check_pf-0.1.tar.gz) = 3145
9ef3fe2f65e1746cd7ecf981864146a9
echo x - nagios-pf-plugin/pkg-descr
sed 's/^X//' >nagios-pf-plugin/pkg-descr << 'e5f5d0000e588529cb73e899b9e45a89'
Xcheck_pf is a plugin intended for use with the Nagios network
Xmonitoring system.  This plugin checks the status of PF, the OpenBSD
Xpacket filter, and compares the current state count to given or default
Xthresholds, returning the result.  It is written in C.
X
XWWW: https://github.com/kian/nagios-pf-plugin/
e5f5d0000e588529cb73e899b9e45a89
exit

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


More information about the freebsd-ports-bugs mailing list