summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 56458bc)
raw | patch | inline | side by side (parent: 56458bc)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 1 Nov 2006 15:19:41 +0000 (16:19 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 1 Nov 2006 15:19:41 +0000 (16:19 +0100) |
debian/README.Debian | [new file with mode: 0644] | patch | blob |
debian/collectd.conf | [new file with mode: 0644] | patch | blob |
debian/examples/myplugin.c | [new file with mode: 0644] | patch | blob |
diff --git a/debian/README.Debian b/debian/README.Debian
--- /dev/null
+++ b/debian/README.Debian
@@ -0,0 +1,41 @@
+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.
+
+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/collectd.conf b/debian/collectd.conf
--- /dev/null
+++ b/debian/collectd.conf
@@ -0,0 +1,83 @@
+# Config file for collectd(1).
+#
+# Some plugins need additional configuration and are disabled by default.
+# Please read collectd.conf(5) for details.
+
+Mode Local
+
+# If in "Client" mode you have to specify which server to send datagrams to.
+#Mode Client
+#Server 123.123.123.123 12345
+
+#Mode Server
+
+#Mode Log
+
+#DataDir /var/lib/collectd
+#PIDFILE /var/run/collectd.pid
+#PluginDir /usr/lib/collectd
+
+#LoadPlugin apache
+#LoadPlugin apcups
+#LoadPlugin apple_sensors
+LoadPlugin battery
+LoadPlugin cpu
+#LoadPlugin cpufreq
+LoadPlugin df
+LoadPlugin disk
+#LoadPlugin hddtemp
+LoadPlugin load
+LoadPlugin memory
+#LoadPlugin mysql
+#LoadPlugin nfs
+#LoadPlugin ntpd
+#LoadPlugin ping
+LoadPlugin processes
+#LoadPlugin sensors
+#LoadPlugin serial
+LoadPlugin swap
+#LoadPlugin tape
+LoadPlugin traffic
+LoadPlugin users
+#LoadPlugin vserver
+#LoadPlugin wireless
+
+#<Plugin apache>
+# URL http://localhost/status?auto
+# User www-user
+# Password secret
+# CACert /etc/ssl/ca.crt
+#</Plugin>
+
+#<Plugin apcups>
+# Host localhost
+# Port 3551
+#</Plugin>
+
+#<Plugin hddtemp>
+# Host 127.0.0.1
+# Port 7634
+#</Plugin>
+
+#<Plugin ntpd>
+# Host localhost
+# Port 123
+#</Plugin>
+
+#<Plugin mysql>
+# Host localhost
+# User db_user
+# Password secret
+# Database db_name
+#</Plugin>
+
+#<Plugin ping>
+# Host host.foo.bar
+# Host host.baz.qux
+#</Plugin>
+
+#<Plugin traffic>
+# Interface eth0
+# IgnoreSelected false
+#</Plugin>
+
diff --git a/debian/examples/myplugin.c b/debian/examples/myplugin.c
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * /usr/share/doc/collectd/examples/sample_plugin.c
+ *
+ * A sample plugin for collectd.
+ *
+ * Written by Sebastian Harl <sh@tokkee.org>
+ *
+ * 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 <collectd/common.h> /* rrd_update_file */
+#include <collectd/plugin.h> /* plugin_* */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Optional config file support */
+/* #include <collectd/configfile.h> */
+
+/* Optional debugging support
+ * (only available if collectd was compiled with debugging support) */
+/* #include <collectd/utils_debug.h> */
+
+#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;
+}
+