ports/160222: Update net-mgmt/nagios-check_ports

Doug Barton dougb at FreeBSD.org
Fri Aug 26 20:20:08 UTC 2011


>Number:         160222
>Category:       ports
>Synopsis:       Update net-mgmt/nagios-check_ports
>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:   Fri Aug 26 20:20:07 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Doug Barton
>Release:        FreeBSD 8.2-STABLE i386
>Organization:
AAAG
>Environment:
	DNA
>Description:
	This patch adds the ability to specify the path to the INDEX
	file, as well as the path to portaudit. It also contains a few
	small shell cleanups. I've been running this in production for
	a while and it works great.
>How-To-Repeat:
	DNA
>Fix:
	Include the attached patch in the port, and bump PORTREVISION.


--- /usr/local/libexec/nagios/check_ports	2011-08-23 07:01:14.000000000 +0000
+++ check_ports	2011-08-24 02:32:14.000000000 +0000
@@ -30,20 +30,15 @@
 #
 
 # please change locations appropriate
-PORTAUDIT=/usr/local/sbin/portaudit
 PKG_VERSION=/usr/sbin/pkg_version
 JEXEC=/usr/sbin/jexec
 JLS=/usr/sbin/jls
-PORTDIR=/usr/ports
 # TMP_PATH will be created by check_ports, needs to be writable
 TMP_PATH=/tmp/jailaudit
 
 ###### global vars - don't touch ######
 
-RELEASE=$(uname -r | awk -F. '{ print $1 }')
-PORTINDEX=${PORTDIR}/INDEX-${RELEASE}
-
-PROGNAME=$(basename $0)
+PROGNAME="${0##*/}"
 VERSION=0.6.1
 DATE="10 Mar 2009"
 PROJECTURL=http://code.adminlife.net/check_ports
@@ -68,7 +63,7 @@
 
 # print help msg and exit
 print_help() {
-  printf "usage: ${PROGNAME} [options] [-j jailname ]\n\n"
+  printf "usage: ${PROGNAME} [options] [-j jailname] [-I <path>] [-P <path>]\n\n"
   printf "options:\n"
   printf "  -h\t\tshow this help message and exit.\n\n"
   printf "  -a\t\tshows if any updates are available.\n"
@@ -82,7 +77,9 @@
   printf "  \t\tHighly recommended before first run.\n\n"
   printf "  -u \t\trun check_ports in unprivileged mode.\n"
   printf "  \t\tMuch slower but more secure.\n\n"
-  printf "  -v\t\tshow version number.\n"
+  printf "  -v\t\tshow version number.\n\n"
+  printf "  -I <path>\tPath to INDEX file.\n\n"
+  printf "  -P <path>\tPath to portaudit.\n"
   exit 0
 }
 
@@ -254,13 +251,13 @@
   # count lines from portversion if asked
   if [ ${ANY_UPDATE} -eq 1 -o ${WARN_ON_ANY_UPDATE} -eq 1  ]
   then
-    UPDATES=$(${PKG_VERSION} ${PKGVERSION_OPTS} | grep -c "needs updating" -)
+    UPDATES=$(${PKG_VERSION} ${PKGVERSION_OPTS} ${PORTINDEX} | grep -c "needs updating")
   fi
   
   # count lines from find
   if [ ${CHECK_PORTS_AGE} -eq 1 ]
   then
-    PORTSAGE=$(find ${PORTINDEX} -name INDEX-${RELEASE} -mtime +1 | grep -c INDEX-${RELEASE} -)
+    PORTSAGE=$(find ${PORTINDEX} -name ${PORTINDEX##*/} -mtime +1 | grep -c ${PORTINDEX##*/})
   fi
 
   # count lines from portaudit
@@ -291,13 +288,13 @@
   # count lines from pkg_version if asked and set PKG_DBDIR
   if [ ${ANY_UPDATE} -eq 1 -o ${WARN_ON_ANY_UPDATE} -eq 1  ]
   then
-    UPDATES=$(PKG_DBDIR=${JAIL_PATH}/var/db/pkg ${PKG_VERSION} ${PKGVERSION_OPTS} | grep -c "needs updating" -)
+    UPDATES=$(PKG_DBDIR=${JAIL_PATH}/var/db/pkg ${PKG_VERSION} ${PKGVERSION_OPTS} ${JAIL_PATH}${PORTINDEX} | grep -c "needs updating")
   fi
 
   # count lines from find
   if [ ${CHECK_PORTS_AGE} -eq 1 ]
   then
-    PORTSAGE=$(find ${JAIL_PATH}${PORTINDEX} -name INDEX-${RELEASE} -mtime +1 | grep -c INDEX-${RELEASE} -)
+    PORTSAGE=$(find ${JAIL_PATH}${PORTINDEX} -name ${PORTINDEX##*/} -mtime +1 | grep -c ${PORTINDEX##*/})
   fi
 
   run_gen_state
@@ -305,12 +302,14 @@
 
 ###### main ######
 
-while getopts hvcrawpuj: opt 2>/dev/null
+while getopts I:P:hvcrawpuj: opt 2>/dev/null
 do
   case $opt in
+    I) PORTINDEX="$OPTARG" ;;
+    P) PORTAUDIT="$OPTARG" ;;
     h) print_help;;
     v) print_version;;
-    c) check_env;;
+    c) run_check_env=run_check_env;;
     r) ;; # parameter -r is now obsolete, we don't use portversion anymore
     a) ANY_UPDATE=1;;
     w) WARN_ON_ANY_UPDATE=1;;
@@ -321,6 +320,14 @@
   esac
 done
 
+PORTDIR=/usr/ports
+RELEASE=$(uname -r)
+RELEASE="${RELEASE%%.*}"
+: ${PORTINDEX:="${PORTDIR}/INDEX-${RELEASE}"}
+: ${PORTAUDIT:=/usr/local/sbin/portaudit}
+
+[ -n "$run_check_env" ] && check_env
+
 # check for improper usage
 if [ ${WARN_ON_ANY_UPDATE} -eq 1 -a ${ANY_UPDATE} -eq 1 ]
 then


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



More information about the freebsd-ports-bugs mailing list