From: Florian Forster Date: Wed, 1 Nov 2006 15:19:41 +0000 (+0100) Subject: debian/: Imported the files from Sebastian's Debian package, part 2. X-Git-Tag: collectd-3.10.2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=84c44ebd0b45a9f865a09ac0cdf2bc22d0a7645f;p=collectd.git debian/: Imported the files from Sebastian's Debian package, part 2. --- diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 00000000..b0b701b4 --- /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 new file mode 100644 index 00000000..e9e246dc --- /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 + +# +# URL http://localhost/status?auto +# User www-user +# Password secret +# CACert /etc/ssl/ca.crt +# + +# +# Host localhost +# Port 3551 +# + +# +# Host 127.0.0.1 +# Port 7634 +# + +# +# Host localhost +# Port 123 +# + +# +# Host localhost +# User db_user +# Password secret +# Database db_name +# + +# +# Host host.foo.bar +# Host host.baz.qux +# + +# +# Interface eth0 +# IgnoreSelected false +# + diff --git a/debian/examples/myplugin.c b/debian/examples/myplugin.c new file mode 100644 index 00000000..1bd8e423 --- /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; +} +