[collectd] Variables in collectd.conf

Dan Fandrich dan at coneharvesters.com
Sat Mar 2 15:21:31 CET 2013


The default collectd.conf file created for me by autoconf from the
collectd.conf.in file contains this for the first four entries with variable
substitutions:

#BaseDir     "${prefix}/var/lib/collectd"
#PIDFile     "${prefix}/var/run/collectd.pid"
#PluginDir   "${exec_prefix}/lib/collectd"
#TypesDB     "/usr/local/share/collectd/types.db"

That is, all but the last contains variable references like
${prefix}. Needless to say, collectd doesn't expand these references
and it ends up creating files in directories named literally
"${prefix}". Looking at the autoconf output, it appears that all autoconf
substitution variables except for @prefix@ do this, and some (like
@execdir@) go through two levels of variable indirection.

It looks like this is by design, as the autoconf documentation says
"...you should not use these variables except in makefiles". The workaround
they suggest is to use sed to do the variable substitution manually for each
desired variable, instead of using AC_CONFIG_FILES.

The attached patch changes collectd to use the specified method of replacing
the directory variables.

>>> Dan
-------------- next part --------------
From cb6f9bd1dfd50cfcc1a2759fdcedf3aee30ad4f8 Mon Sep 17 00:00:00 2001
From: Dan Fandrich <dan at coneharvesters.com>
Date: Sat, 2 Mar 2013 13:08:01 +0100
Subject: [PATCH 1/2] collectd.conf: Fixed the installation directory paths

These variables are designed to be used from within a makefile,
so they must be substituted from a script called from there.
Also, removed the use of obsolete AC_OUTPUT parameters.
---
 configure.in                                  |   14 +++++++++++---
 src/Makefile.am                               |   12 ++++++++++++
 src/{collectd.conf.in => collectd.conf.in.in} |   20 ++++++++++----------
 3 files changed, 33 insertions(+), 13 deletions(-)
 rename src/{collectd.conf.in => collectd.conf.in.in} (97%)

diff --git a/configure.in b/configure.in
index 1492ba2..6572a19 100644
--- a/configure.in
+++ b/configure.in
@@ -5121,9 +5121,17 @@ AC_SUBST(LCC_VERSION_PATCH)
 AC_SUBST(LCC_VERSION_EXTRA)
 AC_SUBST(LCC_VERSION_STRING)
 
-AC_CONFIG_FILES(src/libcollectdclient/collectd/lcc_features.h)
-
-AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile)
+AC_CONFIG_FILES(
+	src/libcollectdclient/collectd/lcc_features.h
+	Makefile
+	src/Makefile
+	src/collectd.conf.in
+	src/libcollectdclient/Makefile
+	src/libcollectdclient/libcollectdclient.pc
+	src/liboconfig/Makefile
+	bindings/Makefile
+	bindings/java/Makefile)
+AC_OUTPUT
 
 if test "x$with_librrd" = "xyes" \
 	&& test "x$librrd_threadsafe" != "xyes"
diff --git a/src/Makefile.am b/src/Makefile.am
index 8f8fafe..c41afb3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1371,6 +1371,10 @@ collectd_LDADD += "-dlopen" zfs_arc.la
 collectd_DEPENDENCIES += zfs_arc.la
 endif
 
+collectd_conf_DATA = collectd.conf
+collectd_confdir =
+CLEANFILES += collectd.conf
+
 BUILT_SOURCES += $(dist_man_MANS)
 
 dist_man_MANS = collectd.1 \
@@ -1432,6 +1436,14 @@ pinba.pb-c.c pinba.pb-c.h: pinba.proto
 riemann.pb-c.c riemann.pb-c.h: riemann.proto
 	protoc-c -I$(srcdir) --c_out . $(srcdir)/riemann.proto
 
+# This is the autoconf-recommended way to substitute build path variables
+# instead of AC_CONFIG_FILES
+collectd.conf: collectd.conf.in
+	$(SED) -e 's|@localstatedir_canon[@]|$(localstatedir)|' \
+	       -e 's|@libdir_canon[@]|$(libdir)|' \
+	       -e 's|@prefix_canon[@]|$(prefix)|' \
+	       $< >collectd.conf.tmp.$$$$ && mv -f collectd.conf.tmp.$$$$ $@
+
 install-exec-hook:
 	$(mkinstalldirs) $(DESTDIR)$(sysconfdir)
 	if test -e $(DESTDIR)$(sysconfdir)/collectd.conf; \
diff --git a/src/collectd.conf.in b/src/collectd.conf.in.in
similarity index 97%
rename from src/collectd.conf.in
rename to src/collectd.conf.in.in
index 9d8e688..c64bdc5 100644
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in.in
@@ -12,10 +12,10 @@
 
 #Hostname    "localhost"
 #FQDNLookup   true
-#BaseDir     "@localstatedir@/lib/@PACKAGE_NAME@"
-#PIDFile     "@localstatedir@/run/@PACKAGE_NAME at .pid"
-#PluginDir   "@libdir@/@PACKAGE_NAME@"
-#TypesDB     "@prefix@/share/@PACKAGE_NAME@/types.db"
+#BaseDir     "@localstatedir_canon@/lib/@PACKAGE_NAME@"
+#PIDFile     "@localstatedir_canon@/run/@PACKAGE_NAME at .pid"
+#PluginDir   "@libdir_canon@/@PACKAGE_NAME@"
+#TypesDB     "@prefix_canon@/share/@PACKAGE_NAME@/types.db"
 
 #----------------------------------------------------------------------------#
 # Interval at which to query values. This may be overwritten on a per-plugin #
@@ -250,7 +250,7 @@
 #</Plugin>
 
 #<Plugin csv>
-#	DataDir "@localstatedir@/lib/@PACKAGE_NAME@/csv"
+#	DataDir "@localstatedir_canon@/lib/@PACKAGE_NAME@/csv"
 #	StoreRates false
 #</Plugin>
 
@@ -364,7 +364,7 @@
 #</Plugin>
 
 #<Plugin email>
-#	SocketFile "@localstatedir@/run/@PACKAGE_NAME at -email"
+#	SocketFile "@localstatedir_canon@/run/@PACKAGE_NAME at -email"
 #	SocketGroup "collectd"
 #	SocketPerms "0770"
 #	MaxConns 5
@@ -439,7 +439,7 @@
 
 #<Plugin "java">
 #	JVMArg "-verbose:jni"
-#	JVMArg "-Djava.class.path=@prefix@/share/collectd/java/collectd-api.jar"
+#	JVMArg "-Djava.class.path=@prefix_canon@/share/collectd/java/collectd-api.jar"
 #
 #	LoadPlugin "org.collectd.java.Foobar"
 #	<Plugin "org.collectd.java.Foobar">
@@ -852,14 +852,14 @@
 
 #<Plugin rrdcached>
 #	DaemonAddress "unix:/tmp/rrdcached.sock"
-#	DataDir "@localstatedir@/lib/@PACKAGE_NAME@/rrd"
+#	DataDir "@localstatedir_canon@/lib/@PACKAGE_NAME@/rrd"
 #	CreateFiles true
 #	CreateFilesAsync false
 #	CollectStatistics true
 #</Plugin>
 
 #<Plugin rrdtool>
-#	DataDir "@localstatedir@/lib/@PACKAGE_NAME@/rrd"
+#	DataDir "@localstatedir_canon@/lib/@PACKAGE_NAME@/rrd"
 #	CreateFilesAsync false
 #	CacheTimeout 120
 #	CacheFlush   900
@@ -988,7 +988,7 @@
 #</Plugin>
 
 #<Plugin unixsock>
-#	SocketFile "@prefix@/var/run/@PACKAGE_NAME at -unixsock"
+#	SocketFile "@prefix_canon@/var/run/@PACKAGE_NAME at -unixsock"
 #	SocketGroup "collectd"
 #	SocketPerms "0660"
 #	DeleteSocket false
-- 
1.7.10



More information about the collectd mailing list