svn commit: r533804 - in head: . net-mgmt/librenms net-mgmt/librenms/files

Dan Langille dvl at FreeBSD.org
Sun May 3 19:31:29 UTC 2020


Author: dvl
Date: Sun May  3 19:31:28 2020
New Revision: 533804
URL: https://svnweb.freebsd.org/changeset/ports/533804

Log:
  Add support for polling as a service
  
  Two new options
  
  * PYPOLLER  - default, deprecated, needs Python 2.7
  * PYSERVICE - Dispatcher service, recompile required
  
  HEADS UP HEADS UP
  
  Polling via cron job is now deprecated. Please use the Dispatcher.
  
  LibreNMS will be dropping support for PHP 7.1 and Python 2 in the next release
  expected May 31 2020.  see https://community.librenms.org/t/dropping-support-for-php-7-1-and-python-2/11851
  
  Your existing crontab entries for the PYPOLLER option will be going away.
  
  You can migrate to the PYSERVICE option of LibreNMS now.
  
  PR:		246105
  Submitted by:	Dries Michiels <driesm.michiels at gmail.com>

Added:
  head/net-mgmt/librenms/files/librenms.in   (contents, props changed)
Modified:
  head/UPDATING
  head/net-mgmt/librenms/Makefile
  head/net-mgmt/librenms/files/pkg-message.in

Modified: head/UPDATING
==============================================================================
--- head/UPDATING	Sun May  3 19:10:20 2020	(r533803)
+++ head/UPDATING	Sun May  3 19:31:28 2020	(r533804)
@@ -5,6 +5,29 @@ they are unavoidable.
 You should get into the habit of checking this file for changes each time
 you update your ports collection, before attempting any port upgrades.
 
+20200503:
+  AFFECTS: users of net-mgmt/librenms
+  AUTHOR:  dvl at FreeBSD.org
+
+  Polling via cronjob is deprecated as of release 1.63
+  see see https://community.librenms.org/t/dropping-support-for-php-7-1-and-python-2/11851
+
+  Please migrate to the Dispatch Service:
+  https://docs.librenms.org/Extensions/Dispatcher-Service/
+
+  These steps should get you running:
+  * comment out the crontab entries listed above under PYPOLLER
+  * populate %%WWWDIR%%/.env with:
+    * APP_KEY - see farther below for how to create
+    * NODE_ID - see just below for how to create
+    * DB_HOST
+    * DB_DATABASE
+    * DB_USERNAME
+    * DB_PASSWORD
+  * you can create a NODE_ID with: php -r 'echo uniqid() . "\n";'
+  * sysrc librenms_enable="YES"
+  * service librenms start
+
 20200501:
   AFFECTS: users of www/phpmyfaq
   AUTHOR: flo at FreeBSD.org

Modified: head/net-mgmt/librenms/Makefile
==============================================================================
--- head/net-mgmt/librenms/Makefile	Sun May  3 19:10:20 2020	(r533803)
+++ head/net-mgmt/librenms/Makefile	Sun May  3 19:31:28 2020	(r533804)
@@ -3,8 +3,8 @@
 
 PORTNAME=	librenms
 PORTVERSION=	1.63
+PORTREVISION=	1
 PORTEPOCH=	1
-PORTREVISION=	0
 CATEGORIES=	net-mgmt
 MASTER_SITES=	LOCAL/dvl:vendor
 DISTFILES=	${PORTNAME}-vendor-${DISTVERSIONPREFIX}${DISTVERSION}${DISTVERSIONSUFFIX}${EXTRACT_SUFX}:vendor
@@ -14,7 +14,7 @@ COMMENT=	Autodiscovering PHP/MySQL/SNMP based network 
 
 LICENSE=	GPLv3
 
-USES=		python${PY_MYSQL} shebangfix
+USES=		shebangfix
 
 # RELEASE_TIMESTAMP is used for a patch inside the vendor code
 # it represents the release date via: git show --pretty='%H|%ct' -s 1.42.01
@@ -37,18 +37,24 @@ USE_PHP=	ctype curl dom fileinfo filter gd hash json l
 USE_GITHUB=	yes
 GH_ACCOUNT=	librenms
 
+USE_RC_SUBR=	librenms
+
 USERS=		www
-WWW_USER=	www
 
 NO_BUILD=	yes
 
-OPTIONS_DEFINE=	FPING IPMITOOL LIBVIRT MYSQLD NAGPLUGINS NMAP PYPOLLER WMIC DOCS EXAMPLES X11
+OPTIONS_DEFINE=	FPING IPMITOOL LIBVIRT MYSQLD NAGPLUGINS NMAP WMIC DOCS EXAMPLES X11
 OPTIONS_DEFAULT=	 FPING IPMITOOL LIBVIRT NAGPLUGINS NMAP PYPOLLER WMIC
+
+OPTIONS_SINGLE=	POLLERSYSTEM
+OPTIONS_SINGLE_POLLERSYSTEM=	PYPOLLER PYSERVICE #conflicting python versions
+
 FPING_DESC=	Enable fping support ping monitoring
 IPMITOOL_DESC=	Enable support for monitoring hardware IPMI
 MYSQLD_DESC=	Use local MySQL server
 WMIC_DESC=	Enable support for WMI polling
-PYPOLLER_DESC=	Enable Python Poller Wrapper
+PYPOLLER_DESC=	Support for polling using cron entries
+PYSERVICE_DESC=	Support for polling using a daemon
 
 FPING_RUN_DEPENDS=	fping:net/fping
 IPMITOOL_RUN_DEPENDS=	ipmitool:sysutils/ipmitool
@@ -56,7 +62,10 @@ LIBVIRT_RUN_DEPENDS=	virsh:devel/libvirt
 NAGPLUGINS_RUN_DEPENDS=	${LOCALBASE}/libexec/nagios/check_nagios:net-mgmt/nagios-plugins
 NMAP_RUN_DEPENDS=	nmap:security/nmap
 PYPOLLER_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}MySQLdb>=1.2.3:databases/py-MySQLdb@${PY_FLAVOR}
-PYPOLLER_VARS=	PY_MYSQL=:2.7
+PYPOLLER_USES=		python:2.7
+PYSERVICE_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}python-dotenv>0:www/py-python-dotenv@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}pymysql>0:databases/py-pymysql@${PY_FLAVOR}
+PYSERVICE_USES=		python:3.6+
 X11_RUN_DEPENDS=	Magick-config:graphics/ImageMagick6 \
 			mtr:net/mtr
 X11_RUN_DEPENDS_OFF=	Magick-config:graphics/ImageMagick6-nox11 \
@@ -92,7 +101,8 @@ SHEBANG_FILES=	scripts/auth_test.php scripts/deploy-do
 		../${PORTNAME}-vendor-${PORTVERSION}/tecnickcom/tcpdf/tools/tcpdf_addfont.php
 
 SUB_FILES+=	pkg-message
-SUB_LIST+=	PHP="${PHPBASE}/bin/php" PYTHON=${PYTHON_CMD}
+SUB_LIST+=	PHP="${PHPBASE}/bin/php" PYTHON=${PYTHON_CMD} \
+		USER="${WWWOWN}" GROUP="${WWWGRP}" WWWDIR="${WWWDIR}"
 
 ROOT_FILES=	addhost.php adduser.php alerts.php artisan billing-calculate.php \
 		build-base.php build.sql check-services.php composer.json \
@@ -135,7 +145,7 @@ NO_ARCH=	yes
 
 post-patch:
 	@${REINPLACE_CMD}    's|%%PORTNAME%%|${PORTNAME}|g'                   ${WRKSRC}/config.php.default
-	@${REINPLACE_CMD}    's|%%WWW_USER%%|${WWW_USER}|g'                   ${WRKSRC}/config.php.default
+	@${REINPLACE_CMD}    's|%%WWW_USER%%|${WWWOWN}|g'                     ${WRKSRC}/config.php.default
 	@${REINPLACE_CMD}    's|%%LOCALBASE%%|${LOCALBASE}|g'                 ${WRKSRC}/poller-wrapper.py ${WRKSRC}/poller.php
 	@${REINPLACE_CMD}    's|%%PORTVERSION%%|${PORTVERSION}|g'             ${WRKSRC}/includes/common.php
 	@${REINPLACE_CMD}    's|%%RELEASE_TIMESTAMP%%|${RELEASE_TIMESTAMP}|g' ${WRKSRC}/includes/common.php
@@ -168,6 +178,7 @@ do-install:
 # these values should be outside the www tree now
 	${MKDIR} ${STAGEDIR}/var/log/${PORTNAME}
 	${MKDIR} ${STAGEDIR}/var/db/${PORTNAME}
+	${MKDIR} ${STAGEDIR}/var/run/${PORTNAME}
 
 do-install-DOCS-on:
 	${MKDIR} ${STAGEDIR}/${DOCSDIR}
@@ -200,6 +211,7 @@ post-install:
 	@${ECHO_CMD} "@dir(www,www,0775) ${WWWDIR}/storage/framework/views" >> ${TMPPLIST}
 	@${ECHO_CMD} "@dir(www,www,0775) /var/log/${PORTNAME}" >> ${TMPPLIST}
 	@${ECHO_CMD} "@dir(www,www,0775) /var/db/${PORTNAME}" >> ${TMPPLIST}
+	@${ECHO_CMD} "@dir(www,www,0775) /var/run/${PORTNAME}" >> ${TMPPLIST}
 .for f in ${OTHER_DIRS}
 	@${ECHO_CMD} "@dir(root,www,0775) ${WWWDIR}/${f}" >> ${TMPPLIST}
 .endfor

Added: head/net-mgmt/librenms/files/librenms.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net-mgmt/librenms/files/librenms.in	Sun May  3 19:31:28 2020	(r533804)
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: librenms
+# REQUIRE: SERVERS
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# librenms_enable:	Set to NO by default.
+#			Set it to YES to enable librenms
+# librenms_user:	The user account used to run the daemon.
+#			Default: %%USER%%
+# librenms_group:	The group account used to run the daemon.
+#			Default: %%GROUP%%
+# librenms_pid:		Path of the pid file.
+#			Default /var/run/librenms/librenms.pid
+#
+# Contributed by: Dries Michiels (driesm.michiels at gmail.com)
+
+. /etc/rc.subr
+
+name=librenms
+rcvar="${name}_enable"
+
+load_rc_config $name
+
+: ${librenms_enable:="NO"}
+: ${librenms_user:="%%USER%%"}
+: ${librenms_group:="%%GROUP%%"}
+: ${librenms_pid:="/var/run/librenms/librenms.pid"}
+
+pidfile="$librenms_pid"
+procname="%%PYTHON%%"
+command="/usr/sbin/daemon"
+
+start_precmd=librenms_precmd
+
+librenms_precmd()
+{
+     [ -f /var/log/$name/$name-service.log ] || install -g $librenms_user -o $librenms_user -m 644 /var/log/$name/$name-service.log
+     [ -f /var/log/$name/$name.log ] || install -g $librenms_user -o $librenms_user -m 644 /var/log/$name/$name.log
+}
+
+command_args="-T $name -o /var/log/$name/$name-service.log -p $pidfile $procname %%WWWDIR%%/librenms-service.py -m"
+
+run_rc_command "$1"

Modified: head/net-mgmt/librenms/files/pkg-message.in
==============================================================================
--- head/net-mgmt/librenms/files/pkg-message.in	Sun May  3 19:10:20 2020	(r533803)
+++ head/net-mgmt/librenms/files/pkg-message.in	Sun May  3 19:31:28 2020	(r533804)
@@ -1,16 +1,34 @@
 [
 { type: install
   message: <<EOM
-NOTE: setting sql-mode="" is no longer required. You can remove
-it from /usr/local/etc/mysql/my.cnf
 
 You can mostly follow the guide at:
 http://docs.librenms.org/
 
 with the following notes:
 - Installation directory is %%WWWDIR%%
-- The following lines should be added to /etc/crontab:
 
+NOTE: setting sql-mode="" is no longer required. You can remove
+it from /usr/local/etc/mysql/my.cnf
+
+HEADS UP
+
+Polling via cron job is now deprecated. Please use the Dispatcher.
+
+LibreNMS will be dropping support for PHP 7.1 and Python 2 in the next release
+expected May 31 2020.  see https://community.librenms.org/t/dropping-support-for-php-7-1-and-python-2/11851
+
+Your existing crontab entries for the PYPOLLER option will be going away.
+
+You can migrate to the PYSERVICE option of LibreNMS now
+(also known as the Dispatcher Service).
+
+The next release will not include the the PYPOLLER option.
+
+PYROLLER (deprecated) configuration (default):
+
+The following lines should be added to /etc/crontab:
+
 PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
 33	*/6	*	*	*	www	cd %%WWWDIR%% && %%PHP%% discovery.php -h all >> /dev/null 2>&1
 */5	*	*	*	*	www	cd %%WWWDIR%% && %%PHP%% discovery.php -h new >> /dev/null 2>&1
@@ -21,18 +39,49 @@ PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
 01	*	*	*	*	www	%%PHP%% %%WWWDIR%%/billing-calculate.php >> /dev/null 2>&1
 */5	*	*	*	*	www	%%PHP%% %%WWWDIR%%/check-services.php >> /dev/null 2>&1
 
-For a fresh install, you need to create an APP_KEY:
+PYSERVICE configuration (non-default):
 
+Enable the poller service with this command:
+
+sysrc librenms_enable="YES"
+
+The service will log to /var/log/librems/librenms-service.log
+
+see also https://docs.librenms.org/Extensions/Dispatcher-Service/
+
+When converting from PYPOLLER to the Dispatcher Service (PYSERVICE),
+these steps will help you get started:
+
+* compile with PYSERVICE enabled and PYPOLLER disabled
+* comment out the crontab entries listed above under PYPOLLER
+* populate %%WWWDIR%%/.env with:
+  * APP_KEY - see farther below for how to create
+  * NODE_ID - see just below for how to create
+  * DB_HOST
+  * DB_DATABASE
+  * DB_USERNAME
+  * DB_PASSWORD
+* you can create a NODE_ID with: php -r 'echo uniqid() . "\n";'
+
+When setting up a new install, you need a %%WWWDIR%%/.env file.
+
+You need an APP_KEY.
+
+To create:
+
 cd %%WWWDIR%%
 cp -i .env.example .env
 
 That file will eventually contain secrets.  Make sure it is not world-readable.
 
+When migrating to PYSERVICE (also known as the Dispatcher Service):
+
 It is also a good idea to:
 cd %%WWWDIR%%
 ./validate
 
-You might need to set your database details in that file
+Database connection details are required in that file.
+
 Then run:
 
 php artisan key:generate
@@ -61,7 +110,21 @@ cd %%WWWDIR%%
 
 re: https://docs.librenms.org/#General/Updating/
 
-Make sure your %%WWWDIR%%/.env file is not world-readable.
+HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP 
+
+Polling via cron job is now deprecated. Please use the Dispatcher.
+
+LibreNMS will be dropping support for PHP 7.1 and Python 2 in the next release
+expected May 31 2020.  see https://community.librenms.org/t/dropping-support-for-php-7-1-and-python-2/11851
+
+Your existing crontab entries for the PYPOLLER option will be going away.
+
+You can migrate to the PYSERVICE option of LibreNMS now
+(also known as the Dispatcher Service).
+
+The next release will not include the PYPOLLER option.
+
+For more information, see pkg info --pkg-message librenms
 
 EOM
 }


More information about the svn-ports-head mailing list