Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Jul 2012 10:59:46 -0500
From:      "Bryan Drewery" <bryan@shatow.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/169977: [PATCH] net-mgmt/nagios-plugins: Update to 1.4.16
Message-ID:  <20120718155959.6D7AD106566B@hub.freebsd.org>
Resent-Message-ID: <201207181610.q6IGA4YI062488@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         169977
>Category:       ports
>Synopsis:       [PATCH] net-mgmt/nagios-plugins: Update to 1.4.16
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 18 16:10:03 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Bryan Drewery
>Release:        FreeBSD 8.3-RELEASE i386
>Organization:
>Environment:

	
>Description:
	Changelog: http://nagiosplugins.org/nagiosplugins-1.4.16
	check_users now uses utmpx. Extra patch provided (by me) to revert to previous non-utmpx version for 8.x.
>How-To-Repeat:
	
>Fix:

	

--- patch-nagios-plugins-1.4.16.txt begins here ---
diff -urN /usr/ports/net-mgmt/nagios-plugins.orig/Makefile ./Makefile
--- /usr/ports/net-mgmt/nagios-plugins.orig/Makefile	2012-06-30 07:42:49.000000000 -0500
+++ ./Makefile	2012-07-17 15:59:40.000000000 -0500
@@ -6,8 +6,7 @@
 #
 
 PORTNAME=	nagios-plugins
-PORTVERSION=	1.4.15
-PORTREVISION=	1
+PORTVERSION=	1.4.16
 PORTEPOCH=	1
 CATEGORIES=	net-mgmt
 MASTER_SITES=	SF/nagiosplug/nagiosplug/${PORTVERSION}
@@ -61,6 +60,11 @@
 LDFLAGS+=	-L${LOCALBASE}/lib
 CFLAGS+=	-I${LOCALBASE}/include
 
+# Restore 1.4.15 check_users without utmpx
+.if ${OSVERSION} < 900007
+EXTRA_PATCHES+=	${FILESDIR}/extra-patch-plugins-check_users
+.endif
+
 .if defined(WITH_QSTAT)
 BUILD_DEPENDS+=	qstat:${PORTSDIR}/games/qstat
 RUN_DEPENDS+=	qstat:${PORTSDIR}/games/qstat
diff -urN /usr/ports/net-mgmt/nagios-plugins.orig/distinfo ./distinfo
--- /usr/ports/net-mgmt/nagios-plugins.orig/distinfo	2011-03-20 07:53:56.000000000 -0500
+++ ./distinfo	2012-07-17 15:28:03.000000000 -0500
@@ -1,2 +1,2 @@
-SHA256 (nagios-plugins-1.4.15.tar.gz) = 51136e5210e3664e1351550de3aff4a766d9d9fea9a24d09e37b3428ef96fa5b
-SIZE (nagios-plugins-1.4.15.tar.gz) = 2095419
+SHA256 (nagios-plugins-1.4.16.tar.gz) = b0caf07e0084e9b7f10fdd71cbd3ebabcd85ad78df64da360b51233b0e73b2bd
+SIZE (nagios-plugins-1.4.16.tar.gz) = 2087089
diff -urN /usr/ports/net-mgmt/nagios-plugins.orig/files/extra-patch-plugins-check_users ./files/extra-patch-plugins-check_users
--- /usr/ports/net-mgmt/nagios-plugins.orig/files/extra-patch-plugins-check_users	1969-12-31 18:00:00.000000000 -0600
+++ ./files/extra-patch-plugins-check_users	2012-07-17 16:00:25.000000000 -0500
@@ -0,0 +1,82 @@
+Restore non-utmpx version from 1.4.15
+
+--- plugins/check_users.c.orig	2012-07-17 15:47:25.000000000 -0500
++++ plugins/check_users.c	2012-07-17 15:47:56.000000000 -0500
+@@ -35,8 +35,8 @@
+ const char *email = "nagiosplug-devel@lists.sourceforge.net";
+ 
+ #include "common.h"
++#include "popen.h"
+ #include "utils.h"
+-#include <utmpx.h>
+ 
+ #define possibly_set(a,b) ((a) == 0 ? (b) : 0)
+ 
+@@ -52,8 +52,8 @@
+ {
+ 	int users = -1;
+ 	int result = STATE_UNKNOWN;
++	char input_buffer[MAX_INPUT_BUFFER];
+ 	char *perf;
+-	struct utmpx *putmpx;
+ 
+ 	setlocale (LC_ALL, ""); setlocale(LC_NUMERIC, "C");
+ 	bindtextdomain (PACKAGE, LOCALEDIR);
+@@ -67,16 +67,40 @@
+ 	if (process_arguments (argc, argv) == ERROR)
+ 		usage4 (_("Could not parse arguments"));
+ 
+-	users = 0;
++	/* run the command */
++	child_process = spopen (WHO_COMMAND);
++	if (child_process == NULL) {
++		printf (_("Could not open pipe: %s\n"), WHO_COMMAND);
++		return STATE_UNKNOWN;
++	}
+ 
+-	/* get currently logged users from utmpx */
+-	setutxent ();
++	child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
++	if (child_stderr == NULL)
++		printf (_("Could not open stderr for %s\n"), WHO_COMMAND);
+ 
+-	while ((putmpx = getutxent ()) != NULL)
+-		if (putmpx->ut_type == USER_PROCESS)
++	users = 0;
++
++	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
++		/* increment 'users' on all lines except total user count */
++		if (input_buffer[0] != '#') {
+ 			users++;
++			continue;
++		}
++
++		/* get total logged in users */
++		if (sscanf (input_buffer, _("# users=%d"), &users) == 1)
++			break;
++
++	}
+ 
+-	endutxent ();
++	/* check STDERR */
++	if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
++		result = possibly_set (result, STATE_UNKNOWN);
++	(void) fclose (child_stderr);
++
++	/* close the pipe */
++	if (spclose (child_process))
++		result = possibly_set (result, STATE_UNKNOWN);
+ 
+ 	/* check the user count against warning and critical thresholds */
+ 	if (users > cusers)
+--- plugins/Makefile.am.orig	2012-07-17 15:59:53.000000000 -0500
++++ plugins/Makefile.am	2012-07-17 15:59:59.000000000 -0500
+@@ -101,7 +101,7 @@
+ check_time_LDADD = $(NETLIBS)
+ check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS)
+ check_ups_LDADD = $(NETLIBS)
+-check_users_LDADD = $(BASEOBJS)
++check_users_LDADD = $(BASEOBJS) popen.o
+ check_by_ssh_LDADD = $(NETLIBS)
+ check_ide_smart_LDADD = $(BASEOBJS)
+ negate_LDADD = $(BASEOBJS)
--- patch-nagios-plugins-1.4.16.txt ends here ---


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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120718155959.6D7AD106566B>