ports/81139: UPDATE port: net-mgmt/nrpe2

Meno Abels meno.abels at adviser.com
Mon May 16 22:50:07 UTC 2005


>Number:         81139
>Category:       ports
>Synopsis:       UPDATE port: net-mgmt/nrpe2
>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:   Mon May 16 22:50:01 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Meno Abels <meno.abels at adviser.com>
>Release:        FreeBSD 5.3 i386
>Organization:
Adviser COM
>Environment:
System: FreeBSD race 5.3 FreeBSD 5.3 #4: Tue Apr 19 14:18:44 CEST 2005 root at jamal.abels.adviser.com:/usr/obj/usr/src/sys/GENERIC i386


>Description:
	The nrpe2 does not write a pid file to /var/run. This does 
	not allow to run the standard rc.subr start/stop script.
	The current start/stop script has also some faults in the paths.
	So I added the writing of the pid to the source and changed
	the start/stop script to standard freebsd.
	I also deleted the following file:
		net-mgmt/nrpe2/pkg-plis
	And I added:
		net-mgmt/nrpe2/files/patch-pid-file
		net-mgmt/nrpe2/files/nrpe2.sh.in
	And I increased the PORTREVISION by one.
	So I think that a patch is more complex than a new shar. If you
	want to get a patch feel free to contact me. I also send the
	this change to Ethan Galstad (nagios at nagios.org) in the hope
	that i will accept this harmless extention.
>How-To-Repeat:
	not applied change request
>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:
#
#	net-mgmt/nrpe2
#	net-mgmt/nrpe2/Makefile
#	net-mgmt/nrpe2/files
#	net-mgmt/nrpe2/files/patch-pid-file
#	net-mgmt/nrpe2/files/nrpe2.sh.in
#	net-mgmt/nrpe2/distinfo
#	net-mgmt/nrpe2/pkg-descr
#	net-mgmt/nrpe2/pkg-install
#
echo c - net-mgmt/nrpe2
mkdir -p net-mgmt/nrpe2 > /dev/null 2>&1
echo x - net-mgmt/nrpe2/Makefile
sed 's/^X//' >net-mgmt/nrpe2/Makefile << 'END-of-net-mgmt/nrpe2/Makefile'
X# New ports collection makefile for:	nrpe
X# Date created:				1 Aug 2002
X# Whom:					Paul Dlug<paul at nerdlabs.com>
X#
X# $FreeBSD$
X#
X
XPORTNAME=		nrpe2
XPORTVERSION=		2.0
XPORTREVISION=		1
XCATEGORIES=		net-mgmt
XMASTER_SITES=		${MASTER_SITE_SOURCEFORGE}
XMASTER_SITE_SUBDIR=	nagios
XDISTNAME=		nrpe-${PORTVERSION}
X
XMAINTAINER=		paul at nerdlabs.com
XCOMMENT=		Nagios Remote Plugin Executor
X
XRUN_DEPENDS=		${LOCALBASE}/libexec/nagios/check_nagios:${PORTSDIR}/net-mgmt/nagios-plugins
X
XGNU_CONFIGURE=		yes
XUSE_PERL5_BUILD=	yes
XUSE_REINPLACE=		yes
X
XUSE_RC_SUBR=    	nrpe2.sh
XSUB_FILES=      	nrpe2.sh
X
XPLIST_FILES=   		sbin/nrpe2 etc/nrpe.cfg-sample libexec/nagios/check_nrpe2
X
XCONFIGURE_ARGS+=	--libexecdir=${PREFIX}/libexec/nagios --bindir=${PREFIX}/sbin --sysconfdir=${PREFIX}/etc
X
XOPTIONS=		SSL "SSL support" off \
X			ARGS "Enable command arguments *POTENTIAL SECURITY RISK*" off
X.if defined(WITH_SSL)
XUSE_OPENSSL=	yes
XCONFIGURE_ARGS+=	--enable-ssl
X.else
XCONFIGURE_ARGS+=	--disable-ssl
X.endif
X
X.if defined(WITH_ARGS)
XCONFIGURE_ARGS+=	--enable-command-args
X.endif
X
Xdo-install:
X	${INSTALL_PROGRAM} ${WRKSRC}/src/nrpe ${PREFIX}/sbin/nrpe2
X	${INSTALL_PROGRAM} ${WRKSRC}/src/check_nrpe ${PREFIX}/libexec/nagios/check_nrpe2
X	${INSTALL_DATA} ${WRKSRC}/nrpe.cfg ${PREFIX}/etc/nrpe.cfg-sample
X
X.include <bsd.port.mk>
END-of-net-mgmt/nrpe2/Makefile
echo c - net-mgmt/nrpe2/files
mkdir -p net-mgmt/nrpe2/files > /dev/null 2>&1
echo x - net-mgmt/nrpe2/files/patch-pid-file
sed 's/^X//' >net-mgmt/nrpe2/files/patch-pid-file << 'END-of-net-mgmt/nrpe2/files/patch-pid-file'
X--- orig/nrpe-2.0/src/Makefile.in	Tue Aug  5 07:01:53 2003
X+++ src/Makefile.in	Tue May 17 00:25:33 2005
X@@ -9,7 +9,7 @@
X SRC_COMMON=../common
X 
X CC=@CC@
X-CFLAGS=@CFLAGS@ @DEFS@
X+CFLAGS=@CFLAGS@ @DEFS@ -DPID_DIR=\"/var/run/\" 
X LDFLAGS=@LDFLAGS@ @LIBS@
X SOCKETLIBS=@SOCKETLIBS@
X 
X--- orig/nrpe-2.0/src/nrpe.c	Tue Sep  9 04:52:37 2003
X+++ src/nrpe.c	Tue May 17 00:24:29 2005
X@@ -23,6 +23,7 @@
X #include "nrpe.h"
X #include "utils.h"
X 
X+
X #ifdef HAVE_SSL
X #include "dh.h"
X #endif
X@@ -83,7 +84,6 @@
X #endif
X 
X 
X-
X int main(int argc, char **argv){
X 	int result=OK;
X 	int x;
X@@ -219,7 +219,45 @@
X 
X 	/* else daemonize and start listening for requests... */
X 	else if(fork()==0){
X-
X+#ifdef PID_DIR
X+		int fd;
X+		int pid_written = 0;
X+		char *pid_fname;
X+		char pbuf[16];
X+		char *bname = strrchr(argv[0], '/'); /* basename from XPG4.2 would be nice */
X+
X+		bname = !bname ? argv[0] : ++bname;
X+		pid_fname = malloc(strlen(PID_DIR) + strlen(bname) + sizeof(".pid"));
X+		strcpy(pid_fname, PID_DIR);
X+		strcat(pid_fname, bname); strcat(pid_fname, ".pid");
X+		if ((fd = open (pid_fname, O_RDONLY)) >= 0) {
X+			int status = read (fd, pbuf, (sizeof pbuf) - 1);
X+			close (fd);
X+			if (status > 0) {
X+				int pid;
X+				pbuf [status] = 0;
X+				pid = atoi (pbuf);
X+				/* If the previous server process is not still running,
X+				   write a new pid file immediately. */
X+				if (pid && (pid == getpid() || kill (pid, 0) < 0)) {
X+					unlink (pid_fname);
X+				} else {
X+					syslog(LOG_ERR,"There's already a nrpe server running.");
X+					free(pid_fname);
X+					return STATE_CRITICAL;
X+				}
X+			}
X+		} 
X+		if ((fd = open (pid_fname, O_WRONLY | O_CREAT, 0644)) >= 0) {
X+			sprintf (pbuf, "%d\n", (int)getpid ());
X+			write (fd, pbuf, strlen (pbuf));
X+			close (fd);
X+		} else {
X+			syslog(LOG_ERR,"Can not write the pidfile(%s).", pid_fname);
X+		}
X+		free(pid_fname);
X+#endif
X+		
X 		/* we're a daemon - set up a new process group */
X 		setsid();
X 
END-of-net-mgmt/nrpe2/files/patch-pid-file
echo x - net-mgmt/nrpe2/files/nrpe2.sh.in
sed 's/^X//' >net-mgmt/nrpe2/files/nrpe2.sh.in << 'END-of-net-mgmt/nrpe2/files/nrpe2.sh.in'
X#!/bin/sh
X#
X# $FreeBSD$
X#
X
X# PROVIDE: nrpe2
X# REQUIRE: NETWORKING
X# KEYWORD: FreeBSD shutdown
X
X#
X# Add the following lines to /etc/rc.conf to enable nrpe2:
X#
X#nrpe2_enable="YES"
X#
X#
X
X. %%RC_SUBR%%
X
Xname=nrpe2
Xrcvar=`set_rcvar`
X
Xcommand="%%PREFIX%%/sbin/nrpe2"
Xrequired_files=%%PREFIX%%/etc/nrpe.cfg
Xcommand_args="-c ${required_files} -d"
Xpidfile=/var/run/${name}.pid
X
X# set defaults
X
Xnrpe2_enable=${nrpe2_enable:-"NO"}
Xnrpe2_flags=${nrpe2_flags:-""}
X
Xload_rc_config ${name}
Xrun_rc_command "$1"
END-of-net-mgmt/nrpe2/files/nrpe2.sh.in
echo x - net-mgmt/nrpe2/distinfo
sed 's/^X//' >net-mgmt/nrpe2/distinfo << 'END-of-net-mgmt/nrpe2/distinfo'
XMD5 (nrpe-2.0.tar.gz) = 70ef9502a3b7e49fa520dbceabfa04d0
XSIZE (nrpe-2.0.tar.gz) = 52157
END-of-net-mgmt/nrpe2/distinfo
echo x - net-mgmt/nrpe2/pkg-descr
sed 's/^X//' >net-mgmt/nrpe2/pkg-descr << 'END-of-net-mgmt/nrpe2/pkg-descr'
Xnrpe is used to execute Nagios plugins on remote hosts and report the results
Xto the main Nagios server. From the Nagios homepage:
X
XAllows you to execute "local" plugins (like check_disk, check_procs, etc.) on 
Xremote hosts. The check_nrpe plugin is called from Nagios and actually makes 
Xthe plugin requests to the remote host. Requires that nrpe be running on the 
Xremote host (either as a standalone daemon or as a service under inetd). 
X
Xnrpe2 is incompatible with nrpe version 1, if you are running this version
Xsee net-mgmt/nrpe. Both ports can be installed in parallel but share the same
Xconfiguration file by default. This is easily changed in the nrpe startup
Xfile.
X
XWWW: http://www.nagios.org/
END-of-net-mgmt/nrpe2/pkg-descr
echo x - net-mgmt/nrpe2/pkg-install
sed 's/^X//' >net-mgmt/nrpe2/pkg-install << 'END-of-net-mgmt/nrpe2/pkg-install'
X#!/bin/sh
X#
X#	$FreeBSD: ports/net/nagios/pkg-install,v 1.2 2002/05/29 06:35:16 kuriyama Exp $
X#
X
XPKG_PREFIX=${PKG_PREFIX:=/usr/local}
X
Xuser=nagios
Xgroup=nagios
X
Xask() {
X    local question default answer
X
X    question=$1
X    default=$2
X    if [ -z "${PACKAGE_BUILDING}" ]; then
X        read -p "${question} [${default}]? " answer
X    fi
X    if [ x${answer} = x ]; then
X        answer=${default}
X    fi
X    echo ${answer}
X}
X
Xyesno() {
X    local dflt question answer
X
X    question=$1
X    dflt=$2
X    while :; do
X        answer=$(ask "${question}" "${dflt}")
X        case "${answer}" in
X        [Yy]*)          return 0;;
X        [Nn]*)          return 1;;
X        esac
X        echo "Please answer yes or no."
X    done
X}
X
Xif [ x"$2" = xPRE-INSTALL ]; then
X    if /usr/sbin/pw groupshow "${group}" 2>/dev/null; then
X        echo "You already have a group \"${group}\", so I will use it."
X    else
X        echo "You need a group \"${group}\"."
X        if yesno "Would you like me to create it" y; then
X            /usr/sbin/pw groupadd ${group} -h - || exit
X            echo "Done."
X        else
X            echo "Please create it, and try again."
X            exit 1
X        fi
X    fi
X
X    if /usr/sbin/pw user show "${user}" 2>/dev/null; then
X        echo "You already have a user \"${user}\", so I will use it."
X    else
X        echo "You need a user \"${user}\"."
X        if yesno "Would you like me to create it" y; then
X            /usr/sbin/pw useradd ${user} -g ${group} -h - -d ${PKG_PREFIX}/var/nagios \
X                -s /nonexistent -c "Nagios pseudo-user" || exit
X            echo "Done."
X        else
X            echo "Please create it, and try again."
X            exit 1
X        fi
X    fi
X
Xfi
END-of-net-mgmt/nrpe2/pkg-install
exit

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



More information about the freebsd-ports-bugs mailing list