From 76a8993d2f0cb5a56c0b3f2ef04c4642ebd44793 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Thu, 6 Jul 2006 00:13:36 +0000 Subject: [PATCH] Initial commit. Added collectd-3.9.2-1. --- debian/README.Debian | 44 ++++++++++++ debian/changelog | 10 +++ debian/collectd.init.d | 115 +++++++++++++++++++++++++++++++ debian/collectd.postrm | 43 ++++++++++++ debian/compat | 1 + debian/control | 106 ++++++++++++++++++++++++++++ debian/copyright | 27 ++++++++ debian/examples/myplugin.c | 107 ++++++++++++++++++++++++++++ debian/patches/00list | 1 + debian/patches/getifaddrs.dpatch | 96 ++++++++++++++++++++++++++ debian/rules | 114 ++++++++++++++++++++++++++++++ 11 files changed, 664 insertions(+) create mode 100644 debian/README.Debian create mode 100644 debian/changelog create mode 100755 debian/collectd.init.d create mode 100755 debian/collectd.postrm create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/examples/myplugin.c create mode 100644 debian/patches/00list create mode 100755 debian/patches/getifaddrs.dpatch create mode 100755 debian/rules diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..fc9ffa9 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,44 @@ +collectd on Debian +================== + +General notes: +-------------- + +- This package is split up into several packages to prevent you from having to + install dependencies (or recommended packages) that you don't actually need. + Any plugin that has dependencies other than libc gets its own package. + +Configuring collectd: +--------------------- + +- collectd uses a similar configuration layout as openvpn does. That is to + say that one daemon process is started for each configuration file found in + /etc/collectd/. + +- See collectd.conf(5) for details about configuring collectd. + +- You can use /usr/share/doc/collectd/examples/collectd.conf as a starting + point for writing your own configuration file(s). + +Building your own plugins: +-------------------------- + +- If you want to contribute plugins to the official distribution you should + read http://collectd.org/dev-info.shtml. + +- If you want to build plugins for your personal use only simply install the + collectd-dev package and use /usr/share/doc/collectd-dev/examples/myplugin.c + as a starting point (Note: This is already a working example, though it does + not collect any useful data). + + The resulting file can be compiled as follows: + + gcc -shared -o myplugin.so myplugin.c + + Copy myplugin.so to /usr/lib/collectd and add the following line to your + collectd config file: + + LoadPlugin myplugin + + Restart collectd and you're done. + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..e2e21a6 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,10 @@ +collectd (3.9.2-1) unstable; urgency=low + + * Initial Release. + * Removed upstream's debian/ directory from .orig.tar.gz. + * getifaddrs.dpatch: Patching src/traffic.c to read data from /proc instead + of using getifaddrs(). getifaddrs() does not seem to work correctly on + AMD64. + + -- Sebastian Harl Fri, 2 Jun 2006 15:58:51 +0200 + diff --git a/debian/collectd.init.d b/debian/collectd.init.d new file mode 100755 index 0000000..d88fa14 --- /dev/null +++ b/debian/collectd.init.d @@ -0,0 +1,115 @@ +#!/bin/bash +# +# collectd Initscript for collectd +# http://collectd.org/ +# Authors: Florian Forster +# Sebastian Harl +# + +set -e + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DESC="Statistics collection daemon" +NAME=collectd +DAEMON=/usr/sbin/$NAME +SCRIPTNAME=/etc/init.d/$NAME +ARGS="" + +CONFIGDIR=/etc/collectd +# for backward compatibility +FALLBACKCONF=/etc/collectd.conf + +# Gracefully exit if the package has been removed. +test -x $DAEMON || exit 0 + +if [ -r /etc/default/$NAME ] +then + . /etc/default/$NAME +fi + +# +# Function that starts the daemon/service. +# +d_start() { + i=0 + + if [ ! -d "$CONFIGDIR" ] + then + if [ -e "$FALLBACKCONF" ] + then + $DAEMON -C "$FALLBACKCONF" 2> /dev/null + else + echo "" + echo "This package is not configured yet. Please refer" + echo "to /usr/share/doc/collectd/README.Debian for" + echo "details." + echo "" + exit 0 + fi + else + for FILE in `ls $CONFIGDIR/*.conf 2>/dev/null` + do + NAME=`basename "$FILE" .conf` + + if [ $i == 0 ] + then + echo -n " (" + else + echo -n ", " + fi + + $DAEMON -C "$FILE" 2> /dev/null + if [ $? == 0 ] + then + echo -n "$NAME" + else + echo -n "$NAME failed" + fi + + i=$(($i+1)) + done + + if [ $i == 0 ] + then + echo -n "[no config found]" + exit 1 + else + echo -n ")" + fi + fi +} + +# +# Function that stops the daemon/service. +# +d_stop() { + start-stop-daemon --stop --quiet --exec $DAEMON +} + +case "$1" in + start) + echo -n "Starting $DESC: $NAME" + d_start + echo "." + ;; + stop) + echo -n "Stopping $DESC: $NAME" + d_stop + echo "." + ;; + restart|force-reload) + echo -n "Restarting $DESC: $NAME" + d_stop + sleep 1 + d_start + echo "." + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 + +# vim: syntax=sh noexpandtab sw=8 ts=8 : diff --git a/debian/collectd.postrm b/debian/collectd.postrm new file mode 100755 index 0000000..84b8386 --- /dev/null +++ b/debian/collectd.postrm @@ -0,0 +1,43 @@ +#!/bin/bash +# postrm script for collectd +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' overwrit>r> +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge) + rm -rf /var/lib/collectd + rm -rf /etc/collectd + ;; + + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; + +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +4 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..eee805a --- /dev/null +++ b/debian/control @@ -0,0 +1,106 @@ +Source: collectd +Section: utils +Priority: optional +Maintainer: Sebastian Harl +Build-Depends: debhelper (>= 4.0.0), dpatch, autotools-dev, libcurl3-dev, + libmysqlclient14-dev | libmysqlclient15-dev, librrd0-dev | librrd2-dev, + libsensors-dev +Standards-Version: 3.6.1 + +Package: collectd +Architecture: any +Depends: ${shlibs:Depends} +Suggests: collectd-apache, collectd-mysql, collectd-sensors, collectd-dev, + librrds-perl +Description: statistics collection daemon + collectd is a small daemon written in C for performance. It reads various + system statistics and updates RRD files, creating them if necessary. Since + the daemon doesn't need to startup every time it wants to update the files + it's very fast and easy on the system. Also, the statistics are very fine + grained since the files are updated every 10 seconds. + . + This package contains the main program file and the following plugins: + * Apple computer's sensors information: apple_sensors (server mode only) + * battery status: battery + * CPU utilization: cpu + * CPU frequency: cpufreq + * disk space usage: df + * disk and partition throughput: disk + * system load averages: load + * memory usage: memory + * NFS utilization: nfs + * network latency: ping + * number of processes: processes + * serial port traffic: serial + * swap usage: swap + * tape drive usage: tape (server mode only) + * network traffic: traffic + * number of users logged into the system: users + * system ressources used by Linux-VServers: vserver + * wireless network stats: wireless + +Package: collectd-apache +Architecture: any +Depends: collectd (= ${Source-Version}), ${shlibs:Depends} +Description: statistics collection daemon (Apache plugin) + collectd is a small daemon written in C for performance. It reads various + system statistics and updates RRD files, creating them if necessary. Since + the daemon doesn't need to startup every time it wants to update the files + it's very fast and easy on the system. Also, the statistics are very fine + grained since the files are updated every 10 seconds. + . + This package contains the Apache plugin which collects Apache statistics + provided by Apache's mod_status. + +Package: collectd-hddtemp +Architecture: any +Depends: collectd (= ${Source-Version}), ${shlibs:Depends} +Recommends: hddtemp +Description: statistics collection daemon (hddtemp plugin) + collectd is a small daemon written in C for performance. It reads various + system statistics and updates RRD files, creating them if necessary. Since + the daemon doesn't need to startup every time it wants to update the files + it's very fast and easy on the system. Also, the statistics are very fine + grained since the files are updated every 10 seconds. + . + This package contains the hddtemp plugin which collects harddisk temperatures. + +Package: collectd-mysql +Architecture: any +Depends: collectd (= ${Source-Version}), ${shlibs:Depends} +Description: statistics collection daemon (MySQL plugin) + collectd is a small daemon written in C for performance. It reads various + system statistics and updates RRD files, creating them if necessary. Since + the daemon doesn't need to startup every time it wants to update the files + it's very fast and easy on the system. Also, the statistics are very fine + grained since the files are updated every 10 seconds. + . + This package contains the MySQL plugin which collects MySQL statistics + provided by MySQL's "show status" command. + +Package: collectd-sensors +Architecture: any +Depends: collectd (= ${Source-Version}), ${shlibs:Depends} +Description: statistics collection daemon (sensors plugin) + collectd is a small daemon written in C for performance. It reads various + system statistics and updates RRD files, creating them if necessary. Since + the daemon doesn't need to startup every time it wants to update the files + it's very fast and easy on the system. Also, the statistics are very fine + grained since the files are updated every 10 seconds. + . + This package contains the sensors plugin which collects lm_sensors + information (e.g. CPU temperature, fan speeds). + +Package: collectd-dev +Architecture: all +Depends: collectd (= ${Source-Version}) +Description: statistics collection daemon (development files) + collectd is a small daemon written in C for performance. It reads various + system statistics and updates RRD files, creating them if necessary. Since + the daemon doesn't need to startup every time it wants to update the files + it's very fast and easy on the system. Also, the statistics are very fine + grained since the files are updated every 10 seconds. + . + This package contains the development files needed to create your own + plugins. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..970c7f4 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,27 @@ +This package was debianized by Sebastian Harl on +Wed, 10 May 2006 09:20:39 +0200. + +It was downloaded from http://collectd.org/files/. + +Copyright Holder: Florian Forster + +License: + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, + USA. + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + diff --git a/debian/examples/myplugin.c b/debian/examples/myplugin.c new file mode 100644 index 0000000..1bd8e42 --- /dev/null +++ b/debian/examples/myplugin.c @@ -0,0 +1,107 @@ +/* + * /usr/share/doc/collectd/examples/sample_plugin.c + * + * A sample plugin for collectd. + * + * Written by Sebastian Harl + * + * This is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include /* rrd_update_file */ +#include /* plugin_* */ + +#include +#include + +/* Optional config file support */ +/* #include */ + +/* Optional debugging support + * (only available if collectd was compiled with debugging support) */ +/* #include */ + +#define MODULE_NAME "myplugin" + +/* Name of the rrd file under DataDir (/var/lib/collectd by default) + * + * The name may contain slashes to create subdirectories. */ +static char *my_rrd = "myplugin.rrd"; + +/* DS definitions for the rrd file + * + * See the rrdcreate(1) manpage for details. The heartbeat is configurable in + * collectd. It defaults to 25. */ +static char *ds_def[] = +{ + "DS:my_ds:GAUGE:25:0:U", + NULL +}; + +/* DS count */ +static int ds_num = 1; + +/* Time at which the read function is called */ +extern time_t curtime; + +/* Initialize the plugin + * + * This function is called to set up a plugin before using it. */ +static void my_init(void) +{ + /* we have nothing to do here :-) */ + return; +} + +/* Get the data + * + * This function implements the magic used to get the desired values that + * should be stored in the rrd file. It uses plugin_submit to transfer the + * data to whatever place is configured in the config file. If there are more + * than one instances you should pass a uniq identifier as seconds argument to + * the plugin_submit function. */ +#define BUFSIZE 256 +static void my_read(void) +{ + long int data = 0; + char buf[BUFSIZE] = ""; + + /* magic ;-) */ + data = random(); + + if (snprintf(buf, BUFSIZE, "%u:%li", + (unsigned int)curtime, data) >= BUFSIZE) + return; + + plugin_submit(MODULE_NAME, NULL, buf); + return; +} +#undef BUFSIZE + +/* Save the data + * + * This function saves the data to the appropriate location by calling + * rrd_update_file. It is used to "calculate" the filename and DS definition + * appropriate for the given instance. */ +static void my_write(host, inst, val) + char *host; + char *inst; + char *val; +{ + rrd_update_file(host, my_rrd, val, ds_def, ds_num); + return; +} + +/* Register the plugin + * + * This function registers the plugin with collectd. It has to be named + * "module_register". */ +void module_register(void) +{ + plugin_register(MODULE_NAME, my_init, my_read, my_write); + return; +} + diff --git a/debian/patches/00list b/debian/patches/00list new file mode 100644 index 0000000..21a5503 --- /dev/null +++ b/debian/patches/00list @@ -0,0 +1 @@ +getifaddrs.dpatch diff --git a/debian/patches/getifaddrs.dpatch b/debian/patches/getifaddrs.dpatch new file mode 100755 index 0000000..675caec --- /dev/null +++ b/debian/patches/getifaddrs.dpatch @@ -0,0 +1,96 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## getifaddrs.dpatch by Sebastian Harl +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Read traffic information from /proc by default instead of using +## DP: getifaddrs(). getifaddrs() does not seem to work correctly on AMD64. + +@DPATCH@ + +diff -urN collectd-3.9.2/src/traffic.c collectd-3.9.2.patched/src/traffic.c +--- collectd-3.9.2/src/traffic.c 2006-05-09 11:10:34.000000000 +0200 ++++ collectd-3.9.2.patched/src/traffic.c 2006-06-02 16:12:28.000000000 +0200 +@@ -143,41 +143,7 @@ + + static void traffic_read (void) + { +-#if HAVE_GETIFADDRS +- struct ifaddrs *if_list; +- struct ifaddrs *if_ptr; +- +-#if HAVE_STRUCT_IF_DATA +-# define IFA_DATA if_data +-# define IFA_INCOMING ifi_ibytes +-# define IFA_OUTGOING ifi_obytes +-#elif HAVE_STRUCT_NET_DEVICE_STATS +-# define IFA_DATA net_device_stats +-# define IFA_INCOMING rx_bytes +-# define IFA_OUTGOING tx_bytes +-#else +-# error "No suitable type for `struct ifaddrs->ifa_data' found." +-#endif +- +- struct IFA_DATA *if_data; +- +- if (getifaddrs (&if_list) != 0) +- return; +- +- for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next) +- { +- if ((if_data = (struct IFA_DATA *) if_ptr->ifa_data) == NULL) +- continue; +- +- traffic_submit (if_ptr->ifa_name, +- if_data->IFA_INCOMING, +- if_data->IFA_OUTGOING); +- } +- +- freeifaddrs (if_list); +-/* #endif HAVE_GETIFADDRS */ +- +-#elif KERNEL_LINUX ++#if KERNEL_LINUX + FILE *fh; + char buffer[1024]; + unsigned long long incoming, outgoing; +@@ -221,6 +187,40 @@ + fclose (fh); + /* #endif KERNEL_LINUX */ + ++#elif HAVE_GETIFADDRS ++ struct ifaddrs *if_list; ++ struct ifaddrs *if_ptr; ++ ++#if HAVE_STRUCT_IF_DATA ++# define IFA_DATA if_data ++# define IFA_INCOMING ifi_ibytes ++# define IFA_OUTGOING ifi_obytes ++#elif HAVE_STRUCT_NET_DEVICE_STATS ++# define IFA_DATA net_device_stats ++# define IFA_INCOMING rx_bytes ++# define IFA_OUTGOING tx_bytes ++#else ++# error "No suitable type for `struct ifaddrs->ifa_data' found." ++#endif ++ ++ struct IFA_DATA *if_data; ++ ++ if (getifaddrs (&if_list) != 0) ++ return; ++ ++ for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next) ++ { ++ if ((if_data = (struct IFA_DATA *) if_ptr->ifa_data) == NULL) ++ continue; ++ ++ traffic_submit (if_ptr->ifa_name, ++ if_data->IFA_INCOMING, ++ if_data->IFA_OUTGOING); ++ } ++ ++ freeifaddrs (if_list); ++/* #endif HAVE_GETIFADDRS */ ++ + #elif defined(HAVE_LIBKSTAT) + int i; + unsigned long long incoming, outgoing; diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..d2659c7 --- /dev/null +++ b/debian/rules @@ -0,0 +1,114 @@ +#!/usr/bin/make -f +# debian/rules for collectd +# +# Written by Sebastian Harl . + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +include /usr/share/dpatch/dpatch.make + +config.status: configure + dh_testdir + CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) \ + --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr \ + --mandir=\$${prefix}/share/man \ + --localstatedir=/var --sysconfdir=/etc + +build: build-stamp + +build-stamp: config.status patch + dh_testdir + + $(MAKE) + + touch build-stamp + +clean: clean-patched unpatch + +clean-patched: + dh_testdir + dh_testroot + rm -f build-stamp + + -$(MAKE) distclean + + dh_clean + +install-indep: + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs -i + + include_dir=$(CURDIR)/debian/collectd-dev/usr/include/collectd/ \ + && mkdir -p $$include_dir \ + && cp src/*.h $$include_dir + +install-arch: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs -a + + $(MAKE) install DESTDIR=$(CURDIR)/debian/collectd + + rm -f $(CURDIR)/debian/collectd/usr/lib/collectd/*.la + + doc_dir=$(CURDIR)/debian/collectd/usr/share/doc/collectd/examples \ + && mkdir -p $$doc_dir \ + && cp contrib/collectd.conf $$doc_dir + + for PLUGIN in apache hddtemp mysql sensors; do \ + plugin_dir=$(CURDIR)/debian/collectd-$$PLUGIN/usr/lib/collectd/; \ + mkdir -p $$plugin_dir; \ + mv $(CURDIR)/debian/collectd/usr/lib/collectd/$$PLUGIN.so \ + $$plugin_dir; \ + done + +binary-indep: install-indep + dh_testdir + dh_testroot + dh_installchangelogs -i ChangeLog + dh_installdocs -A -i debian/README.Debian AUTHORS README TODO + dh_installexamples -i debian/examples/myplugin.c + dh_compress -i + dh_fixperms -i + dh_installdeb -i + dh_gencontrol -i + dh_md5sums -i + dh_builddeb -i + +binary-arch: build install-arch + dh_testdir + dh_testroot + dh_installchangelogs -a ChangeLog + dh_installdocs -A -a debian/README.Debian AUTHORS README TODO + dh_installexamples -a contrib/collectd2html.pl contrib/collection.cgi + dh_installinit -a + dh_installman -a src/collectd.1 src/collectd.conf.5 + dh_link -a + dh_strip -a + dh_compress -a + dh_fixperms -a + dh_installdeb -a + dh_shlibdeps -a + dh_gencontrol -a + dh_md5sums -a + dh_builddeb -a + +binary: binary-arch binary-indep +.PHONY: build clean binary-indep binary-arch binary install-indep install-arch -- 2.30.2