Date: Sat, 03 May 2008 16:28:42 +0200 From: Daniel Roethlisberger <daniel@roe.ch> To: FreeBSD-gnats-submit@FreeBSD.org Cc: daniel@roe.ch Subject: ports/123367: [maintainer] net-mgmt/collectd various fixes and improvements Message-ID: <E1JsIjC-000GLM-9Q@calvin.ustdmz.roe.ch> Resent-Message-ID: <200805031430.m43EU1ou001708@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 123367 >Category: ports >Synopsis: [maintainer] net-mgmt/collectd various fixes and improvements >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: maintainer-update >Submitter-Id: current-users >Arrival-Date: Sat May 03 14:30:01 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Daniel Roethlisberger >Release: FreeBSD 6.3-RELEASE-p1 i386 >Organization: >Environment: System: FreeBSD calvin.ustdmz.roe.ch 6.3-RELEASE-p1 FreeBSD 6.3-RELEASE-p1 #0: Wed Feb 13 02:56:56 UTC 2008 root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/SMP i386 >Description: Note that I am not maintainer according to CVS yet, but the former maintainer Matt Peterson has already agreed to hand over maintainership in PR ports/122791, which has not been committed yet. Therefore, this PR depends on PR 122791: http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/122791 This patch improves some rough edges about the collectd port: . Do not delete modified config files on uninstall . Reduce filesystem hierarchy pollution by moving $PREFIX/var/{run,lib}/* to /var/run (PID file) and /var/db/collectd (default location of databases) . Add an rc script for collectd . Optionally install collection.cgi from contrib/ . Fix dependencies, general cleanup New files: files/* Please also add a note to UPDATING: AFFECTS: users of net-mgmt/collectd AUTHOR: daniel@roe.ch Previously, net-mgmt/collectd used to remove the config file even if it was changed by the user. This has now been fixed. To upgrade without losing your configuration, copy the file ${PREFIX}/etc/collectd.conf away to a safe place before upgrading net-mgmt/collectd. >How-To-Repeat: >Fix: --- collectd-improve.diff begins here --- diff -ruN collectd.owned/Makefile collectd/Makefile --- collectd.owned/Makefile 2008-05-03 11:27:05.000000000 +0200 +++ collectd/Makefile 2008-05-03 13:26:08.000000000 +0200 @@ -7,49 +7,46 @@ PORTNAME= collectd PORTVERSION= 4.1.2 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= net-mgmt MASTER_SITES= http://collectd.org/files/ \ - http://matt.peterson.org/FreeBSD/ports/ + http://mirror.roe.ch/dist/${PORTNAME}/ MAINTAINER= daniel@roe.ch COMMENT= Systems & network statistics collection daemon USE_GMAKE= yes GNU_CONFIGURE= yes +WANT_GNOME= yes -OPTIONS= APACHE "Apache mod_status statistics (libcurl)" Off \ - APCUPS "APC UPS support" Off \ - DEBUG "enable debugging" Off \ - INTERFACE "Network interface statistics (libstatgrab)" On \ - MBMON "Query mbmond" Off \ - MYSQL "MySQL statistics" Off \ - PING "Network latency statistics (liboping)" On \ - RRDTOOL "RRDTool output plugin" On \ - SNMP "SNMP support" On \ - XMMS "XMMS statistics" Off +OPTIONS= CGI "Install collection.cgi (requires RRDTOOL)" Off \ + DEBUG "Enable debugging" Off \ + APACHE "Input: Apache mod_status (libcurl)" Off \ + APCUPS "Input: APC UPS (apcupsd)" Off \ + INTERFACE "Input: Network interfaces (libstatgrab)" On \ + MBMON "Input: MBMon" Off \ + MYSQL "Input: MySQL" Off \ + PING "Input: Network latency (liboping)" On \ + SNMP "Input: SNMP" On \ + XMMS "Input: XMMS" Off \ + RRDTOOL "Output: RRDTool" On MAN1= collectd.1 collectd-nagios.1 MAN5= collectd.conf.5 collectd-email.5 collectd-exec.5 \ collectd-snmp.5 collectd-unixsock.5 collectd-perl.5 +USE_RC_SUBR= collectd CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \ LDFLAGS="-L${LOCALBASE}/lib" -.if defined(WITH_XMMS) || defined(WITH_INTERFACE) -USE_GNOME= pkgconfig -. if defined(WITH_XMMS) -USE_GNOME+= glib -. endif -.endif - .include <bsd.port.pre.mk> .if ( ${OSVERSION} < 601103 ) -BROKEN= Need bind9 import post 6.1 +BROKEN= Need bind9 import post 6.1 .endif -CONFIGURE_ARGS= --disable-apple_sensors \ +CONFIGURE_ARGS= --localstatedir=/var \ + --disable-apple_sensors \ --disable-battery \ --disable-hddtemp \ --disable-multimeter \ @@ -61,90 +58,134 @@ --disable-wireless .if defined(WITH_DEBUG) -CONFIGURE_ARGS+= --enable-debug +CONFIGURE_ARGS+=--enable-debug +.endif + +.if defined(WITH_CGI) +RUN_DEPENDS+= ${SITE_PERL}/URI/Escape.pm:${PORTSDIR}/net/p5-URI \ + ${SITE_PERL}/CGI.pm:${PORTSDIR}/www/p5-CGI.pm \ + ${SITE_PERL}/Data/Dumper.pm:${PORTSDIR}/devel/p5-Data-Dumper +PLIST_SUB+= CGI="" +.else +PLIST_SUB+= CGI="@comment " .endif .if defined(WITH_APACHE) -CONFIGURE_ARGS+= --enable-apache -LIB_DEPENDS+= curl.4:${PORTSDIR}/ftp/curl -PLIST_SUB+= APACHE="" +CONFIGURE_ARGS+=--enable-apache +LIB_DEPENDS+= curl.4:${PORTSDIR}/ftp/curl +PLIST_SUB+= APACHE="" .else -CONFIGURE_ARGS+= --disable-apache -PLIST_SUB+= APACHE="@comment " +CONFIGURE_ARGS+=--disable-apache +PLIST_SUB+= APACHE="@comment " .endif .if defined(WITH_APCUPS) -CONFIGURE_ARGS+= --enable-apcups -BUILD_DEPENDS+= ${LOCALBASE}/sbin/apcupsd:${PORTSDIR}/sysutils/apcupsd -PLIST_SUB+= APCUPS="" +CONFIGURE_ARGS+=--enable-apcups +BUILD_DEPENDS+= ${LOCALBASE}/sbin/apcupsd:${PORTSDIR}/sysutils/apcupsd +PLIST_SUB+= APCUPS="" .else -CONFIGURE_ARGS+= --disable-apcups -PLIST_SUB+= APCUPS="@comment " +CONFIGURE_ARGS+=--disable-apcups +PLIST_SUB+= APCUPS="@comment " .endif .if defined(WITH_INTERFACE) -CONFIGURE_ARGS+= --enable-interface -LIB_DEPENDS+= statgrab.8:${PORTSDIR}/devel/libstatgrab -PLIST_SUB+= INTERFACE="" +CONFIGURE_ARGS+=--enable-interface +LIB_DEPENDS+= statgrab.8:${PORTSDIR}/devel/libstatgrab +PLIST_SUB+= INTERFACE="" CONFIGURE_ENV+= LIBS="`pkg-config --libs libstatgrab`" .else -CONFIGURE_ARGS+= --disable-interface -PLIST_SUB+= INTERFACE="@comment " +CONFIGURE_ARGS+=--disable-interface +PLIST_SUB+= INTERFACE="@comment " .endif .if defined(WITH_MBMON) -CONFIGURE_ARGS+= --enable-mbmon -RUN_DEPENDS+= ${LOCALBASE}/sbin/mbmond:${PORTSDIR}/sysutils/mbmon -PLIST_SUB+= MBMON="" +CONFIGURE_ARGS+=--enable-mbmon +RUN_DEPENDS+= ${LOCALBASE}/sbin/mbmond:${PORTSDIR}/sysutils/mbmon +PLIST_SUB+= MBMON="" .else -CONFIGURE_ARGS+= --disable-mbmon -PLIST_SUB+= MBMON="@comment " +CONFIGURE_ARGS+=--disable-mbmon +PLIST_SUB+= MBMON="@comment " .endif .if defined(WITH_MYSQL) -USE_MYSQL= yes -CONFIGURE_ARGS+= --enable-mysql -PLIST_SUB+= MYSQL="" +USE_MYSQL= yes +CONFIGURE_ARGS+=--enable-mysql +PLIST_SUB+= MYSQL="" .else -CONFIGURE_ARGS+= --disable-mysql -PLIST_SUB+= MYSQL="@comment " +CONFIGURE_ARGS+=--disable-mysql +PLIST_SUB+= MYSQL="@comment " .endif .if defined(WITH_PING) -LIB_DEPENDS+= oping:${PORTSDIR}/net/liboping -CONFIGURE_ARGS+= --enable-ping -PLIST_SUB+= PING="" +LIB_DEPENDS+= oping:${PORTSDIR}/net/liboping +CONFIGURE_ARGS+=--enable-ping +PLIST_SUB+= PING="" .else -CONFIGURE_ARGS+= --disable-ping -PLIST_SUB+= PING="@comment " +CONFIGURE_ARGS+=--disable-ping +PLIST_SUB+= PING="@comment " .endif .if defined(WITH_RRDTOOL) -LIB_DEPENDS+= rrd:${PORTSDIR}/databases/rrdtool -CONFIGURE_ARGS+= --enable-rrdtool -PLIST_SUB+= RRD="" +LIB_DEPENDS+= rrd:${PORTSDIR}/databases/rrdtool +CONFIGURE_ARGS+=--enable-rrdtool +PLIST_SUB+= RRD="" .else -CONFIGURE_ARGS+= --disable-rrdtool -PLIST_SUB+= RRD="@comment " +CONFIGURE_ARGS+=--disable-rrdtool +PLIST_SUB+= RRD="@comment " .endif .if defined(WITH_SNMP) -LIB_DEPENDS+= netsnmp.16:${PORTSDIR}/net-mgmt/net-snmp -CONFIGURE_ARGS+= --enable-snmp -PLIST_SUB+= SNMP="" +LIB_DEPENDS+= netsnmp.16:${PORTSDIR}/net-mgmt/net-snmp +CONFIGURE_ARGS+=--enable-snmp +PLIST_SUB+= SNMP="" .else -CONFIGURE_ARGS+= --disable-snmp -PLIST_SUB+= SNMP="@comment " +CONFIGURE_ARGS+=--disable-snmp +PLIST_SUB+= SNMP="@comment " .endif .if defined(WITH_XMMS) -LIB_DEPENDS+= xmms.4:${PORTSDIR}/multimedia/xmms -CONFIGURE_ARGS+= --enable-xmms -CFLAGS= `pkg-config glib --cflags` -PLIST_SUB+= XMMS="" -.else -CONFIGURE_ARGS+= --disable-xmms -PLIST_SUB+= XMMS="@comment " +USE_GNOME+= glib +LIB_DEPENDS+= xmms.4:${PORTSDIR}/multimedia/xmms +CONFIGURE_ARGS+=--enable-xmms +CFLAGS+= `pkg-config glib --cflags` +PLIST_SUB+= XMMS="" +.else +CONFIGURE_ARGS+=--disable-xmms +PLIST_SUB+= XMMS="@comment " +.endif + +post-patch: + @${REINPLACE_CMD} \ + -e 's;@prefix@/var/;/var/;' \ + -e 's;/var/lib/;/var/db/;' \ + ${WRKSRC}/src/collectd.conf.in + @${REINPLACE_CMD} \ + -e 's;$$[(]DESTDIR)$$[(]sysconfdir)/collectd\.conf;&.sample;' \ + ${WRKSRC}/src/Makefile.in + @${REINPLACE_CMD} -e '/$$[(]mkinstalldirs)/d' ${WRKSRC}/Makefile.in + @${REINPLACE_CMD} \ + -e 's;/etc/collection\.conf;${WWWDIR}/collection.conf;' \ + ${WRKSRC}/contrib/collection.cgi + @${REINPLACE_CMD} \ + -e 's;/opt/collectd/var/lib;/var/db;' \ + -e 's;/opt/collectd/lib;${PREFIX}/lib;' \ + ${WRKSRC}/contrib/collection.conf + +post-install: + ${MKDIR} /var/db/collectd + if [ ! -f ${PREFIX}/etc/collectd.conf ]; then \ + ${CP} -p ${PREFIX}/etc/collectd.conf.sample \ + ${PREFIX}/etc/collectd.conf ; \ + fi +.if defined(WITH_CGI) + ${MKDIR} ${WWWDIR} + ${INSTALL_SCRIPT} ${WRKSRC}/contrib/collection.cgi ${WWWDIR}/ + ${INSTALL_DATA} ${WRKSRC}/contrib/collection.conf \ + ${WWWDIR}/collection.conf.sample + if [ ! -f ${WWWDIR}/collection.conf ]; then \ + ${CP} -p ${WWWDIR}/collection.conf.sample \ + ${WWWDIR}/collection.conf ; \ + fi .endif .include <bsd.port.post.mk> diff -ruN collectd.owned/files/collectd.in collectd/files/collectd.in --- collectd.owned/files/collectd.in 1970-01-01 01:00:00.000000000 +0100 +++ collectd/files/collectd.in 2008-05-02 22:33:24.000000000 +0200 @@ -0,0 +1,27 @@ +#!/bin/sh + +# PROVIDE: collectd +# REQUIRE: LOGIN +# +# Add the following lines to /etc/rc.conf.local or /etc/rc.conf +# to enable this service: +# +# collectd_enable (bool): Set to NO by default. +# Set it to YES to enable collectd. +# collectd_flags (string): Set to "" by default. +# Additional flags to collecd, see manual page. +# + +. %%RC_SUBR%% + +name="collectd" +rcvar=${name}_enable + +command=%%PREFIX%%/sbin/${name} + +load_rc_config $name + +: ${collectd_enable="NO"} +: ${collectd_flags=""} + +run_rc_command "$1" diff -ruN collectd.owned/files/patch-src_collectd.h collectd/files/patch-src_collectd.h --- collectd.owned/files/patch-src_collectd.h 1970-01-01 01:00:00.000000000 +0100 +++ collectd/files/patch-src_collectd.h 2008-05-02 17:38:06.000000000 +0200 @@ -0,0 +1,20 @@ +--- src/collectd.h.orig 2008-05-02 17:36:28.000000000 +0200 ++++ src/collectd.h 2008-05-02 17:37:36.000000000 +0200 +@@ -183,7 +183,7 @@ + #endif + + #ifndef LOCALSTATEDIR +-#define LOCALSTATEDIR PREFIX "/var" ++#define LOCALSTATEDIR "/var" + #endif + + #ifndef PKGLOCALSTATEDIR +@@ -191,7 +191,7 @@ + #endif + + #ifndef PIDFILE +-#define PIDFILE PREFIX "/var/run/" PACKAGE_NAME ".pid" ++#define PIDFILE "/var/run/" PACKAGE_NAME ".pid" + #endif + + #ifndef PLUGINDIR diff -ruN collectd.owned/pkg-descr collectd/pkg-descr --- collectd.owned/pkg-descr 2007-10-08 20:28:19.000000000 +0200 +++ collectd/pkg-descr 2008-05-02 22:16:36.000000000 +0200 @@ -1,6 +1,6 @@ collectd is a small daemon written in C for performance. It reads various system & network statistics along with updating output RRD or CSV files. The daemon is very fast and allows for frequent polling of values, with -support for polling as frequent as every 10 seconds. +support for polling as frequent as every 10 seconds. WWW: http://www.collectd.org/ diff -ruN collectd.owned/pkg-plist collectd/pkg-plist --- collectd.owned/pkg-plist 2007-10-08 20:28:19.000000000 +0200 +++ collectd/pkg-plist 2008-05-03 14:02:11.000000000 +0200 @@ -1,5 +1,14 @@ +@stopdaemon collectd +sbin/collectd +@unexec if cmp -s %D/etc/collectd.conf.sample %D/etc/collectd.conf; then rm -f %D/etc/collectd.conf; fi +etc/collectd.conf.sample +@exec if [ ! -f %B/collectd.conf ] ; then cp -p %B/%f %B/collectd.conf; fi +%%CGI%%%%WWWDIR%%/collection.cgi +%%CGI%%@unexec if cmp -s %%WWWDIR%%/collection.conf.sample %%WWWDIR%%/collection.conf; then rm -f %%WWWDIR%%/collection.conf; fi +%%CGI%%%%WWWDIR%%/collection.conf.sample +%%CGI%%@exec if [ ! -f %B/collection.conf ] ; then cp -p %B/%f %B/collection.conf; fi bin/collectd-nagios -etc/collectd.conf +lib/collectd/types.db %%APACHE%%lib/collectd/apache.la %%APACHE%%lib/collectd/apache.so %%APCUPS%%lib/collectd/apcups.la @@ -42,11 +51,10 @@ lib/collectd/swap.so lib/collectd/syslog.la lib/collectd/syslog.so -lib/collectd/types.db lib/collectd/unixsock.la lib/collectd/unixsock.so %%XMMS%%lib/collectd/xmms.la %%XMMS%%lib/collectd/xmms.so @dirrm lib/collectd -sbin/collectd -@dirrmtry var/lib/collectd +@exec mkdir -p /var/db/collectd +@unexec rmdir /var/db/collectd 2>/dev/null || true --- collectd-improve.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1JsIjC-000GLM-9Q>