[collectd] [PATCH 2/2] Add config file for init script Separate mackages for rrdtool/rrdcached Run as non-privileged user

Fabien Wernli cpan at faxm0dem.org
Tue Sep 6 12:21:47 CEST 2011


Signed-off-by: Fabien Wernli <cpan at faxm0dem.org>
---
 contrib/redhat/collectd.conf      |    6 -----
 contrib/redhat/collectd.spec      |   41 ++++++++++++++++++++++++++++++++++--
 contrib/redhat/init.d-collectd    |   15 ++++++++++---
 contrib/redhat/rrdcached.conf     |    9 ++++++++
 contrib/redhat/rrdtool.conf       |    8 +++++++
 contrib/redhat/sysconfig-collectd |    6 +++++
 6 files changed, 72 insertions(+), 13 deletions(-)
 create mode 100644 contrib/redhat/rrdcached.conf
 create mode 100644 contrib/redhat/rrdtool.conf
 create mode 100644 contrib/redhat/sysconfig-collectd

diff --git a/contrib/redhat/collectd.conf b/contrib/redhat/collectd.conf
index f8352ff..458fa4c 100644
--- a/contrib/redhat/collectd.conf
+++ b/contrib/redhat/collectd.conf
@@ -180,12 +180,6 @@ LoadPlugin wireless
 #	Process "name"
 #</Plugin>
 
-#<Plugin rrdtool>
-#	DataDir "/usr/var/lib/collectd/rrd"
-#	CacheTimeout 120
-#	CacheFlush   900
-#</Plugin>
-
 #<Plugin syslog>
 #	LogLevel info
 #</Plugin>
diff --git a/contrib/redhat/collectd.spec b/contrib/redhat/collectd.spec
index 5f31655..e928e0c 100644
--- a/contrib/redhat/collectd.spec
+++ b/contrib/redhat/collectd.spec
@@ -12,7 +12,7 @@ BuildRoot:	%{_tmppath}/%{name}-%{version}-root
 BuildPrereq:	lm_sensors-devel, rrdtool-devel, libpcap-devel, net-snmp-devel, libstatgrab-devel, libxml2-devel, libiptcdata-devel
 # libcurl deps
 BuildPrereq:	curl-devel,libidn-devel,openssl-devel
-Requires:	rrdtool, perl-Regexp-Common, libstatgrab
+Requires:	perl-Regexp-Common, libstatgrab
 Packager:	RightScale <support at rightscale.com>
 Vendor:		collectd development team <collectd at verplant.org>
 
@@ -54,6 +54,20 @@ Requires:	collectd = %{version}, curl
 %description nginx
 This plugin gets data provided by nginx.
 
+%package rrdcached
+Summary:	rrdcached-plugin for collectd.
+Group:		System Environment/Daemons
+Requires:	collectd = %{version}, rrdtool >= 1.4
+%description rrdcached
+This plugin for collectd provides write plugin for rrdcached.
+
+%package rrdtool
+Summary:	rrdtool-plugin for collectd.
+Group:		System Environment/Daemons
+Requires:	collectd = %{version}, rrdtool
+%description rrdtool
+This plugin for collectd provides write plugin for rrd files.
+
 %package sensors
 Summary:	libsensors-module for collectd.
 Group:		System Environment/Daemons
@@ -92,8 +106,10 @@ make
 %install
 make install DESTDIR=$RPM_BUILD_ROOT
 mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
+mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
 mkdir -p $RPM_BUILD_ROOT/var/www/cgi-bin
 cp contrib/redhat/init.d-collectd $RPM_BUILD_ROOT/etc/rc.d/init.d/collectd
+cp contrib/redhat/sysconfig-collectd $RPM_BUILD_ROOT/etc/sysconfig/collectd
 cp contrib/collection.cgi $RPM_BUILD_ROOT/var/www/cgi-bin
 mkdir -p $RPM_BUILD_ROOT/etc/collectd.d
 mkdir -p $RPM_BUILD_ROOT/var/lib/collectd
@@ -116,11 +132,16 @@ cp contrib/redhat/email.conf $RPM_BUILD_ROOT/etc/collectd.d/email.conf
 cp contrib/redhat/sensors.conf $RPM_BUILD_ROOT/etc/collectd.d/sensors.conf
 cp contrib/redhat/mysql.conf $RPM_BUILD_ROOT/etc/collectd.d/mysql.conf
 cp contrib/redhat/nginx.conf $RPM_BUILD_ROOT/etc/collectd.d/nginx.conf
+cp contrib/redhat/rrdcached.conf $RPM_BUILD_ROOT/etc/collectd.d/rrdcached.conf
+cp contrib/redhat/rrdtool.conf $RPM_BUILD_ROOT/etc/collectd.d/rrdtool.conf
 cp contrib/redhat/snmp.conf $RPM_BUILD_ROOT/etc/collectd.d/snmp.conf
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+%pre
+/usr/sbin/useradd -d /dev/null -r -s /sbin/nologin collectd >/dev/null 2>&1 || :
+
 %post
 /sbin/chkconfig --add collectd
 /sbin/chkconfig collectd on
@@ -143,6 +164,7 @@ exit 0
 %defattr(-,root,root)
 %doc AUTHORS COPYING ChangeLog INSTALL NEWS README contrib/
 %config %attr(0644,root,root) /etc/collectd.conf
+%config %attr(0644,root,root) /etc/sysconfig/collectd
 %attr(0755,root,root) /etc/rc.d/init.d/collectd
 %attr(0755,root,root) /var/www/cgi-bin/collection.cgi
 %attr(0755,root,root) %{_sbindir}/collectd
@@ -175,6 +197,7 @@ exit 0
 %plugin_macro cpu
 %plugin_macro csv
 %plugin_macro curl
+%plugin_macro curl_json
 %plugin_macro curl_xml
 %plugin_macro dbi
 %plugin_macro df
@@ -217,8 +240,6 @@ exit 0
 %plugin_macro processes
 %plugin_macro protocols
 %plugin_macro python
-%plugin_macro rrdtool
-%plugin_macro rrdcached
 %plugin_macro serial
 %plugin_macro sensors
 %plugin_macro swap
@@ -284,6 +305,14 @@ exit 0
 %config %attr(0644,root,root) /etc/collectd.d/nginx.conf
 %plugin_macro nginx
 
+%files rrdcached
+%config %attr(0644,root,root) /etc/collectd.d/rrdcached.conf
+%plugin_macro rrdcached
+
+%files rrdtool
+%config %attr(0644,root,root) /etc/collectd.d/rrdtool.conf
+%plugin_macro rrdtool
+
 %files sensors
 %attr(0644,root,root) %{_libdir}/%{name}/sensors.so*
 %attr(0644,root,root) %{_libdir}/%{name}/sensors.la
@@ -294,6 +323,12 @@ exit 0
 %plugin_macro snmp
 
 %changelog
+* Mon Sep 05 2011 faxm0dem <faxm0dem at cpan.org> 5.0.0
+- New upstream version
+- Added /etc/sysconfig/collectd
+- Added collectd user the daemon shall start as
+- Moved rrdtool/rrdcached plugins to separate package
+
 * Tue Jan 04 2010 Rackspace <stu.hood at rackspace.com> 4.9.0
 - New upstream version
 - Changes to support 4.9.0
diff --git a/contrib/redhat/init.d-collectd b/contrib/redhat/init.d-collectd
index a60acb3..d18b794 100644
--- a/contrib/redhat/init.d-collectd
+++ b/contrib/redhat/init.d-collectd
@@ -18,17 +18,24 @@ prog="collectdmon"
 service="collectd"
 CONFIG=/etc/collectd.conf
 COLLECTD=/usr/sbin/collectd
-COLLECTDMONPID=/var/run/collectdmon.pid
+COLLECTDMONPIDIR="/var/run"
+COLLECTDMONPID="$COLLECTDMONPIDIR/collectdmon.pid"
+RUNAS=collectd
 
-if [ -r /etc/default/$prog ]; then
-	. /etc/default/$prog
+if [ -r /etc/sysconfig/$service ]; then
+	. /etc/sysconfig/$service
 fi
 
+if [ ! -d $COLLECTDMONPIDIR ]; then
+	mkdir $COLLECTDMONPIDIR
+fi
+chown $RUNAS: $COLLECTDMONPIDIR
+
 start () {
 	echo -n $"Starting collectd: "
 	if [ -r "$CONFIG" ]
 	then
-		daemon $prog -P $COLLECTDMONPID -c $COLLECTD -- -C "$CONFIG"
+		daemon --user "${RUNAS-root}" $prog -P $COLLECTDMONPID -c $COLLECTD -- -C "$CONFIG"
 		RETVAL=$?
 		echo
 		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$service
diff --git a/contrib/redhat/rrdcached.conf b/contrib/redhat/rrdcached.conf
new file mode 100644
index 0000000..4e51931
--- /dev/null
+++ b/contrib/redhat/rrdcached.conf
@@ -0,0 +1,9 @@
+LoadPlugin rrdcached
+
+#<Plugin rrdcached>
+#       DaemonAddress "unix:/tmp/rrdcached.sock"
+#       DataDir "/usr/var/lib/collectd/rrd"
+#       CreateFiles true
+#       CollectStatistics true
+#</Plugin>
+
diff --git a/contrib/redhat/rrdtool.conf b/contrib/redhat/rrdtool.conf
new file mode 100644
index 0000000..2f65c1f
--- /dev/null
+++ b/contrib/redhat/rrdtool.conf
@@ -0,0 +1,8 @@
+LoadPlugin rrdtool
+
+#<Plugin rrdtool>
+#       DataDir "/usr/var/lib/collectd/rrd"
+#       CacheTimeout 120
+#       CacheFlush   900
+#</Plugin>
+
diff --git a/contrib/redhat/sysconfig-collectd b/contrib/redhat/sysconfig-collectd
new file mode 100644
index 0000000..209cd08
--- /dev/null
+++ b/contrib/redhat/sysconfig-collectd
@@ -0,0 +1,6 @@
+# These values override defaults in collectd startup script
+# CONFIG=/etc/collectd.conf
+# COLLECTD=/usr/sbin/collectd
+# COLLECTDMONPID=/var/run/collectdmon.pid
+# RUNAS=collectd
+
-- 
1.7.5.4




More information about the collectd mailing list